diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 702efc3..57cb877 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -1222,7 +1222,7 @@ dounmount(mp, flags, td) VOP_UNLOCK(coveredvp, 0, td); return (EBUSY); } - mp->mnt_kern_flag |= MNTK_UNMOUNT; + mp->mnt_kern_flag |= MNTK_UNMOUNT | MNTK_NOINSMNTQ; /* Allow filesystems to detect that a forced unmount is in progress. */ if (flags & MNT_FORCE) mp->mnt_kern_flag |= MNTK_UNMOUNTF; @@ -1230,7 +1230,8 @@ dounmount(mp, flags, td) ((flags & MNT_FORCE) ? 0 : LK_NOWAIT), MNT_MTX(mp), td); if (error) { MNT_ILOCK(mp); - mp->mnt_kern_flag &= ~(MNTK_UNMOUNT | MNTK_UNMOUNTF); + mp->mnt_kern_flag &= ~(MNTK_UNMOUNT | MNTK_NOINSMNTQ | + MNTK_UNMOUNTF); if (mp->mnt_kern_flag & MNTK_MWAIT) wakeup(mp); MNT_IUNLOCK(mp); @@ -1285,9 +1286,13 @@ dounmount(mp, flags, td) } vput(fsrootvp); } - if ((mp->mnt_flag & MNT_RDONLY) == 0 && mp->mnt_syncer == NULL) - (void) vfs_allocate_syncvnode(mp); MNT_ILOCK(mp); + mp->mnt_kern_flag &= ~MNTK_NOINSMNTQ; + if ((mp->mnt_flag & MNT_RDONLY) == 0 && mp->mnt_syncer == NULL) { + MNT_IUNLOCK(mp); + (void) vfs_allocate_syncvnode(mp); + MNT_ILOCK(mp); + } mp->mnt_kern_flag &= ~(MNTK_UNMOUNT | MNTK_UNMOUNTF); mp->mnt_flag |= async_flag; if ((mp->mnt_flag & MNT_ASYNC) != 0 && mp->mnt_noasync == 0) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index ad4ca11..76dad07 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1021,7 +1021,7 @@ insmntque1(struct vnode *vp, struct mount *mp, ("insmntque: vnode already on per mount vnode list")); VNASSERT(mp != NULL, vp, ("Don't call insmntque(foo, NULL)")); MNT_ILOCK(mp); - if ((mp->mnt_kern_flag & MNTK_UNMOUNT) != 0 && + if ((mp->mnt_kern_flag & MNTK_NOINSMNTQ) != 0 && mp->mnt_nvnodelistsize == 0) { MNT_IUNLOCK(mp); if (dtr != NULL) diff --git a/sys/sys/mount.h b/sys/sys/mount.h index ab6f181..66c0a46 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -303,10 +303,15 @@ void __mnt_vnode_markerfree(struct vnode **mvp, struct mount *mp); * dounmount() is still waiting to lock the mountpoint. This allows * the filesystem to cancel operations that might otherwise deadlock * with the unmount attempt (used by NFS). + * + * MNTK_NOINSMNTQ is strict subset of MNTK_UNMOUNT. They are separated + * to allow for failed unmount attempt to restore the syncer vnode for + * the mount. */ #define MNTK_UNMOUNTF 0x00000001 /* forced unmount in progress */ #define MNTK_ASYNC 0x00000002 /* filtered async flag */ #define MNTK_SOFTDEP 0x00000004 /* async disabled by softdep */ +#define MNTK_NOINSMNTQ 0x00000008 /* insmntque is not allowed */ #define MNTK_UNMOUNT 0x01000000 /* unmount in progress */ #define MNTK_MWAIT 0x02000000 /* waiting for unmount to finish */ #define MNTK_SUSPEND 0x08000000 /* request write suspension */