From owner-svn-src-head@freebsd.org Mon Jul 6 02:00:35 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EB0DD3520E8; Mon, 6 Jul 2020 02:00:35 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4B0TLC5mCZz4Zft; Mon, 6 Jul 2020 02:00:35 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A8B2716D1E; Mon, 6 Jul 2020 02:00:35 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 06620Z16037943; Mon, 6 Jul 2020 02:00:35 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 06620ZZu037942; Mon, 6 Jul 2020 02:00:35 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202007060200.06620ZZu037942@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Mon, 6 Jul 2020 02:00:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r362951 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 362951 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Jul 2020 02:00:36 -0000 Author: mjg Date: Mon Jul 6 02:00:35 2020 New Revision: 362951 URL: https://svnweb.freebsd.org/changeset/base/362951 Log: vfs: expand on vhold_smr comment Modified: head/sys/kern/vfs_subr.c Modified: head/sys/kern/vfs_subr.c ============================================================================== --- head/sys/kern/vfs_subr.c Sun Jul 5 23:07:54 2020 (r362950) +++ head/sys/kern/vfs_subr.c Mon Jul 6 02:00:35 2020 (r362951) @@ -3441,10 +3441,23 @@ vholdnz(struct vnode *vp) } /* - * Grab a hold count as long as the vnode is not getting freed. + * Grab a hold count unless the vnode is freed. * * Only use this routine if vfs smr is the only protection you have against * freeing the vnode. + * + * The code loops trying to add a hold count as long as the VHOLD_NO_SMR flag + * is not set. After the flag is set the vnode becomes immutable to anyone but + * the thread which managed to set the flag. + * + * It may be tempting to replace the loop with: + * count = atomic_fetchadd_int(&vp->v_holdcnt, 1); + * if (count & VHOLD_NO_SMR) { + * backpedal and error out; + * } + * + * However, while this is more performant, it hinders debugging by eliminating + * the previously mentioned invariant. */ bool vhold_smr(struct vnode *vp)