From 8a7cd2fdfbde9b79182ab9b5c6efb044d4690d3a Mon Sep 17 00:00:00 2001 From: Jeff Roberson Date: Wed, 22 Feb 2006 06:20:12 +0000 Subject: [PATCH] - 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 --- sys/kern/vfs_subr.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 5017c72ad3d3..7cd93a3d3413 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -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); }