- Grab a mnt ref in vfs_busy() before dropping the interlock. This will

prevent the mount point from going away while we're waiting on the lock.
   The ref does not need to persist once we have the lock because the
   lock prevents the mount point from being unmounted.

MFC After:	1 week
This commit is contained in:
Jeff Roberson 2006-02-22 06:20:12 +00:00
parent 05b6a20a66
commit 8a7cd2fdfb

View File

@ -337,8 +337,10 @@ vfs_busy(struct mount *mp, int flags, struct mtx *interlkp,
int lkflags;
MNT_ILOCK(mp);
MNT_REF(mp);
if (mp->mnt_kern_flag & MNTK_UNMOUNT) {
if (flags & LK_NOWAIT) {
MNT_REL(mp);
MNT_IUNLOCK(mp);
return (ENOENT);
}
@ -351,7 +353,9 @@ vfs_busy(struct mount *mp, int flags, struct mtx *interlkp,
* wakeup needs to be done is at the release of the
* exclusive lock at the end of dounmount.
*/
msleep(mp, MNT_MTX(mp), PVFS|PDROP, "vfs_busy", 0);
msleep(mp, MNT_MTX(mp), PVFS, "vfs_busy", 0);
MNT_REL(mp);
MNT_IUNLOCK(mp);
if (interlkp)
mtx_lock(interlkp);
return (ENOENT);
@ -361,6 +365,7 @@ vfs_busy(struct mount *mp, int flags, struct mtx *interlkp,
lkflags = LK_SHARED | LK_INTERLOCK;
if (lockmgr(&mp->mnt_lock, lkflags, MNT_MTX(mp), td))
panic("vfs_busy: unexpected lock failure");
vfs_rel(mp);
return (0);
}