The current implementation of vn_lock() is racy.  Modification of
the vnode oprations vector for active vnodes is unsafe because it
is not known whether deadfs or the original file system will be
called.

- Pass down LK_RETRY to the lock operation (hint for deadfs only).

- Split deadfs lock operations from genfs_XXXlock and change
  deadfs lock operation to return ENOENT if LK_RETRY is unset.

- Change all other lock operations to check for dead vnode once
  the vnode is locked and unlock and return ENOENT in this case.

- Add flag LK_INTERLOCK (requiring LK_NOWAIT) to make it possible
  for vrelel() to try a lock with v_interlock held.

With these changes in place vnode lock operations will never succeed
after vclean() has marked the vnode as VI_XLOCK and before vclean()
has changed the operations vector.

Diff available at http://www.netbsd.org/~hannken/vnode-pass3-1.diff

Comments or objections anyone?

--
J. Hannken-Illjes - hann...@eis.cs.tu-bs.de - TU Braunschweig (Germany)

Reply via email to