vfs: expand on vhold_smr comment

This commit is contained in:
mjg 2020-07-06 02:00:35 +00:00
parent ef8519822a
commit dfad2c95f9

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)