svn commit: r362951 - head/sys/kern
Mateusz Guzik
mjg at FreeBSD.org
Mon Jul 6 02:00:36 UTC 2020
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)
More information about the svn-src-head
mailing list