diff options
author | kib <kib@FreeBSD.org> | 2016-11-27 09:14:52 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2016-11-27 09:14:52 +0000 |
commit | 71a901ee9bad50192b202147a1ed409725ab7df7 (patch) | |
tree | b8f0d605b98cde3a1be96e020d3711d8e946f528 | |
parent | 9c1c45d77b36f110a2f0c90830637a98ff40c5dd (diff) | |
download | FreeBSD-src-71a901ee9bad50192b202147a1ed409725ab7df7.zip FreeBSD-src-71a901ee9bad50192b202147a1ed409725ab7df7.tar.gz |
MFC r308618:
Provide simple mutual exclusion between mount point update and unmount.
In the update path in ffs_mount(), drop vfs_busy() reference around namei().
-rw-r--r-- | sys/kern/vfs_mount.c | 6 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_vfsops.c | 20 |
2 files changed, 24 insertions, 2 deletions
diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 496b852..577c3fd 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -934,6 +934,11 @@ vfs_domount_update( VOP_UNLOCK(vp, 0); MNT_ILOCK(mp); + if ((mp->mnt_kern_flag & MNTK_UNMOUNT) != 0) { + MNT_IUNLOCK(mp); + error = EBUSY; + goto end; + } mp->mnt_flag &= ~MNT_UPDATEMASK; mp->mnt_flag |= fsflags & (MNT_RELOAD | MNT_FORCE | MNT_UPDATE | MNT_SNAPSHOT | MNT_ROOTFS | MNT_UPDATEMASK | MNT_RDONLY); @@ -1252,6 +1257,7 @@ dounmount(struct mount *mp, int flags, struct thread *td) vn_start_write(NULL, &mp, V_WAIT | V_MNTREF); MNT_ILOCK(mp); if ((mp->mnt_kern_flag & MNTK_UNMOUNT) != 0 || + (mp->mnt_flag & MNT_UPDATE) != 0 || !TAILQ_EMPTY(&mp->mnt_uppers)) { MNT_IUNLOCK(mp); if (coveredvp != NULL) { diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 7fe33f3..f9af4e1 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -147,7 +147,7 @@ ffs_mount(struct mount *mp) struct ufsmount *ump = NULL; struct fs *fs; pid_t fsckpid = 0; - int error, flags; + int error, error1, flags; uint64_t mntorflags; accmode_t accmode; struct nameidata ndp; @@ -461,6 +461,11 @@ ffs_mount(struct mount *mp) */ if (mp->mnt_flag & MNT_SNAPSHOT) return (ffs_snapshot(mp, fspec)); + + /* + * Must not call namei() while owning busy ref. + */ + vfs_unbusy(mp); } /* @@ -468,7 +473,18 @@ ffs_mount(struct mount *mp) * and verify that it refers to a sensible disk device. */ NDINIT(&ndp, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, fspec, td); - if ((error = namei(&ndp)) != 0) + error = namei(&ndp); + if ((mp->mnt_flag & MNT_UPDATE) != 0) { + /* + * Unmount does not start if MNT_UPDATE is set. Mount + * update busies mp before setting MNT_UPDATE. We + * must be able to retain our busy ref succesfully, + * without sleep. + */ + error1 = vfs_busy(mp, MBF_NOWAIT); + MPASS(error1 == 0); + } + if (error != 0) return (error); NDFREE(&ndp, NDF_ONLY_PNBUF); devvp = ndp.ni_vp; |