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) _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"