vfs: expand on vhold_smr comment

This commit is contained in:
Mateusz Guzik 2020-07-06 02:00:35 +00:00
parent d363fa4127
commit 9b0c2e5909
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=362951

View File

@ -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)