vfs: release the interlock after failing to set VHOLD_NO_SMR

While here add more comments.

Diagnosed by:	markj
Reported by:	pho
Fixes:	r362827 ("vfs: protect vnodes with smr")
This commit is contained in:
Mateusz Guzik 2020-08-07 19:36:08 +00:00
parent 21673cf0bd
commit 1ff80a3400

View File

@ -3683,19 +3683,24 @@ vdropl(struct vnode *vp)
} }
if (!VN_IS_DOOMED(vp)) { if (!VN_IS_DOOMED(vp)) {
vdrop_deactivate(vp); vdrop_deactivate(vp);
/*
* Also unlocks the interlock. We can't assert on it as we
* released our hold and by now the vnode might have been
* freed.
*/
return; return;
} }
/* /*
* We may be racing against vhold_smr. * Set the VHOLD_NO_SMR flag.
* *
* If they win we can just pretend we never got this far, they will * We may be racing against vhold_smr. If they win we can just pretend
* vdrop later. * we never got this far, they will vdrop later.
*/ */
if (!atomic_cmpset_int(&vp->v_holdcnt, 0, VHOLD_NO_SMR)) { if (!atomic_cmpset_int(&vp->v_holdcnt, 0, VHOLD_NO_SMR)) {
VI_UNLOCK(vp);
/* /*
* We lost the aforementioned race. Note that any subsequent * We lost the aforementioned race. Any subsequent access is
* access is invalid as they might have managed to vdropl on * invalid as they might have managed to vdropl on their own.
* their own.
*/ */
return; return;
} }