summaryrefslogtreecommitdiffstats
path: root/sys/fs
diff options
context:
space:
mode:
authortegge <tegge@FreeBSD.org>2006-09-26 04:12:49 +0000
committertegge <tegge@FreeBSD.org>2006-09-26 04:12:49 +0000
commit83154f853d9ca39deb1add01e032aff1f0678514 (patch)
treeac46e0b5a80f88127d3d14dc940a5f2746573c00 /sys/fs
parentd7fe3e736512a1dd37a985037184eecf7df1f26d (diff)
downloadFreeBSD-src-83154f853d9ca39deb1add01e032aff1f0678514.zip
FreeBSD-src-83154f853d9ca39deb1add01e032aff1f0678514.tar.gz
Use mount interlock to protect all changes to mnt_flag and mnt_kern_flag.
This eliminates a race where MNT_UPDATE flag could be lost when nmount() raced against sync(), sync_fsync() or quotactl().
Diffstat (limited to 'sys/fs')
-rw-r--r--sys/fs/cd9660/cd9660_vfsops.c6
-rw-r--r--sys/fs/devfs/devfs_vfsops.c2
-rw-r--r--sys/fs/hpfs/hpfs_vfsops.c4
-rw-r--r--sys/fs/msdosfs/msdosfs_vfsops.c4
-rw-r--r--sys/fs/ntfs/ntfs_vfsops.c4
-rw-r--r--sys/fs/nullfs/null_vfsops.c7
-rw-r--r--sys/fs/nwfs/nwfs_vfsops.c2
-rw-r--r--sys/fs/portalfs/portal_vfsops.c2
-rw-r--r--sys/fs/smbfs/smbfs_vfsops.c2
-rw-r--r--sys/fs/udf/udf_vfsops.c6
-rw-r--r--sys/fs/umapfs/umap_vfsops.c5
-rw-r--r--sys/fs/unionfs/union_vfsops.c9
12 files changed, 50 insertions, 3 deletions
diff --git a/sys/fs/cd9660/cd9660_vfsops.c b/sys/fs/cd9660/cd9660_vfsops.c
index 30aba51..9a5e836 100644
--- a/sys/fs/cd9660/cd9660_vfsops.c
+++ b/sys/fs/cd9660/cd9660_vfsops.c
@@ -137,7 +137,9 @@ cd9660_mount(struct mount *mp, struct thread *td)
/*
* Unconditionally mount as read-only.
*/
+ MNT_ILOCK(mp);
mp->mnt_flag |= MNT_RDONLY;
+ MNT_IUNLOCK(mp);
fspec = vfs_getopts(mp->mnt_optnew, "from", &error);
if (error)
@@ -378,7 +380,9 @@ iso_mountfs(devvp, mp, td)
mp->mnt_stat.f_fsid.val[0] = dev2udev(dev);
mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum;
mp->mnt_maxsymlinklen = 0;
+ MNT_ILOCK(mp);
mp->mnt_flag |= MNT_LOCAL;
+ MNT_IUNLOCK(mp);
isomp->im_mountp = mp;
isomp->im_dev = dev;
isomp->im_devvp = devvp;
@@ -528,7 +532,9 @@ cd9660_unmount(mp, mntflags, td)
vrele(isomp->im_devvp);
free((caddr_t)isomp, M_ISOFSMNT);
mp->mnt_data = (qaddr_t)0;
+ MNT_ILOCK(mp);
mp->mnt_flag &= ~MNT_LOCAL;
+ MNT_IUNLOCK(mp);
return (error);
}
diff --git a/sys/fs/devfs/devfs_vfsops.c b/sys/fs/devfs/devfs_vfsops.c
index 8c1069a..f3a364b 100644
--- a/sys/fs/devfs/devfs_vfsops.c
+++ b/sys/fs/devfs/devfs_vfsops.c
@@ -79,11 +79,13 @@ devfs_mount(struct mount *mp, struct thread *td)
sx_init(&fmp->dm_lock, "devfsmount");
fmp->dm_holdcnt = 1;
+ MNT_ILOCK(mp);
mp->mnt_flag |= MNT_LOCAL;
mp->mnt_kern_flag |= MNTK_MPSAFE;
#ifdef MAC
mp->mnt_flag |= MNT_MULTILABEL;
#endif
+ MNT_IUNLOCK(mp);
fmp->dm_mount = mp;
mp->mnt_data = (void *) fmp;
vfs_getnewfsid(mp);
diff --git a/sys/fs/hpfs/hpfs_vfsops.c b/sys/fs/hpfs/hpfs_vfsops.c
index cc43fe6..92735ec 100644
--- a/sys/fs/hpfs/hpfs_vfsops.c
+++ b/sys/fs/hpfs/hpfs_vfsops.c
@@ -315,7 +315,9 @@ hpfs_mountfs(devvp, mp, td)
mp->mnt_stat.f_fsid.val[0] = (long)dev2udev(dev);
mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum;
mp->mnt_maxsymlinklen = 0;
+ MNT_ILOCK(mp);
mp->mnt_flag |= MNT_LOCAL;
+ MNT_IUNLOCK(mp);
return (0);
failed:
@@ -359,7 +361,9 @@ hpfs_unmount(
hpfs_cpdeinit(hpmp);
hpfs_bmdeinit(hpmp);
mp->mnt_data = (qaddr_t)0;
+ MNT_ILOCK(mp);
mp->mnt_flag &= ~MNT_LOCAL;
+ MNT_IUNLOCK(mp);
FREE(hpmp, M_HPFSMNT);
return (0);
diff --git a/sys/fs/msdosfs/msdosfs_vfsops.c b/sys/fs/msdosfs/msdosfs_vfsops.c
index a485632..c0963cb 100644
--- a/sys/fs/msdosfs/msdosfs_vfsops.c
+++ b/sys/fs/msdosfs/msdosfs_vfsops.c
@@ -706,7 +706,9 @@ mountmsdosfs(devvp, mp, td)
mp->mnt_data = (qaddr_t) pmp;
mp->mnt_stat.f_fsid.val[0] = dev2udev(dev);
mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum;
+ MNT_ILOCK(mp);
mp->mnt_flag |= MNT_LOCAL;
+ MNT_IUNLOCK(mp);
#ifdef MSDOSFS_LARGE
msdosfs_fileno_init(mp);
@@ -798,7 +800,9 @@ msdosfs_unmount(mp, mntflags, td)
#endif
free(pmp, M_MSDOSFSMNT);
mp->mnt_data = (qaddr_t)0;
+ MNT_ILOCK(mp);
mp->mnt_flag &= ~MNT_LOCAL;
+ MNT_IUNLOCK(mp);
return (error);
}
diff --git a/sys/fs/ntfs/ntfs_vfsops.c b/sys/fs/ntfs/ntfs_vfsops.c
index 31f1a0b..1f46d01 100644
--- a/sys/fs/ntfs/ntfs_vfsops.c
+++ b/sys/fs/ntfs/ntfs_vfsops.c
@@ -430,7 +430,9 @@ ntfs_mountfs(devvp, mp, td)
mp->mnt_stat.f_fsid.val[0] = dev2udev(dev);
mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum;
mp->mnt_maxsymlinklen = 0;
+ MNT_ILOCK(mp);
mp->mnt_flag |= MNT_LOCAL;
+ MNT_IUNLOCK(mp);
return (0);
out1:
@@ -507,7 +509,9 @@ ntfs_unmount(
ntfs_u28_uninit(ntmp);
ntfs_82u_uninit(ntmp);
mp->mnt_data = (qaddr_t)0;
+ MNT_ILOCK(mp);
mp->mnt_flag &= ~MNT_LOCAL;
+ MNT_IUNLOCK(mp);
FREE(ntmp->ntm_ad, M_NTFSMNT);
FREE(ntmp, M_NTFSMNT);
return (error);
diff --git a/sys/fs/nullfs/null_vfsops.c b/sys/fs/nullfs/null_vfsops.c
index 505576b..125c67a 100644
--- a/sys/fs/nullfs/null_vfsops.c
+++ b/sys/fs/nullfs/null_vfsops.c
@@ -179,9 +179,14 @@ nullfs_mount(struct mount *mp, struct thread *td)
*/
VOP_UNLOCK(vp, 0, td);
- if (NULLVPTOLOWERVP(nullm_rootvp)->v_mount->mnt_flag & MNT_LOCAL)
+ if (NULLVPTOLOWERVP(nullm_rootvp)->v_mount->mnt_flag & MNT_LOCAL) {
+ MNT_ILOCK(mp);
mp->mnt_flag |= MNT_LOCAL;
+ MNT_IUNLOCK(mp);
+ }
+ MNT_ILOCK(mp);
mp->mnt_kern_flag |= lowerrootvp->v_mount->mnt_kern_flag & MNTK_MPSAFE;
+ MNT_IUNLOCK(mp);
mp->mnt_data = (qaddr_t) xmp;
vfs_getnewfsid(mp);
diff --git a/sys/fs/nwfs/nwfs_vfsops.c b/sys/fs/nwfs/nwfs_vfsops.c
index e1e4997..aad0b99 100644
--- a/sys/fs/nwfs/nwfs_vfsops.c
+++ b/sys/fs/nwfs/nwfs_vfsops.c
@@ -267,7 +267,9 @@ nwfs_unmount(struct mount *mp, int mntflags, struct thread *td)
if (nmp->m.flags & NWFS_MOUNT_HAVE_NLS)
free(nmp->m.nls.to_lower, M_NWFSDATA);
free(nmp, M_NWFSDATA);
+ MNT_ILOCK(mp);
mp->mnt_flag &= ~MNT_LOCAL;
+ MNT_IUNLOCK(mp);
return (error);
}
diff --git a/sys/fs/portalfs/portal_vfsops.c b/sys/fs/portalfs/portal_vfsops.c
index ed2022e..db73ef0 100644
--- a/sys/fs/portalfs/portal_vfsops.c
+++ b/sys/fs/portalfs/portal_vfsops.c
@@ -146,7 +146,9 @@ portal_mount(struct mount *mp, struct thread *td)
fhold(fp);
fmp->pm_server = fp;
+ MNT_ILOCK(mp);
mp->mnt_flag |= MNT_LOCAL;
+ MNT_IUNLOCK(mp);
mp->mnt_data = (qaddr_t) fmp;
vfs_getnewfsid(mp);
diff --git a/sys/fs/smbfs/smbfs_vfsops.c b/sys/fs/smbfs/smbfs_vfsops.c
index 904835c..182ba2b 100644
--- a/sys/fs/smbfs/smbfs_vfsops.c
+++ b/sys/fs/smbfs/smbfs_vfsops.c
@@ -318,7 +318,9 @@ smbfs_unmount(struct mount *mp, int mntflags, struct thread *td)
#else
free(smp, M_SMBFSDATA);
#endif
+ MNT_ILOCK(mp);
mp->mnt_flag &= ~MNT_LOCAL;
+ MNT_IUNLOCK(mp);
return error;
}
diff --git a/sys/fs/udf/udf_vfsops.c b/sys/fs/udf/udf_vfsops.c
index 706816e..672bdeb 100644
--- a/sys/fs/udf/udf_vfsops.c
+++ b/sys/fs/udf/udf_vfsops.c
@@ -201,7 +201,9 @@ udf_mount(struct mount *mp, struct thread *td)
/*
* Unconditionally mount as read-only.
*/
+ MNT_ILOCK(mp);
mp->mnt_flag |= MNT_RDONLY;
+ MNT_IUNLOCK(mp);
/*
* No root filesystem support. Probably not a big deal, since the
@@ -341,7 +343,9 @@ udf_mountfs(struct vnode *devvp, struct mount *mp, struct thread *td) {
mp->mnt_data = (qaddr_t)udfmp;
mp->mnt_stat.f_fsid.val[0] = dev2udev(devvp->v_rdev);
mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum;
+ MNT_ILOCK(mp);
mp->mnt_flag |= MNT_LOCAL;
+ MNT_IUNLOCK(mp);
udfmp->im_mountp = mp;
udfmp->im_dev = devvp->v_rdev;
udfmp->im_devvp = devvp;
@@ -532,7 +536,9 @@ udf_unmount(struct mount *mp, int mntflags, struct thread *td)
FREE(udfmp, M_UDFMOUNT);
mp->mnt_data = (qaddr_t)0;
+ MNT_ILOCK(mp);
mp->mnt_flag &= ~MNT_LOCAL;
+ MNT_IUNLOCK(mp);
return (0);
}
diff --git a/sys/fs/umapfs/umap_vfsops.c b/sys/fs/umapfs/umap_vfsops.c
index 7d4d40c..a692998 100644
--- a/sys/fs/umapfs/umap_vfsops.c
+++ b/sys/fs/umapfs/umap_vfsops.c
@@ -216,8 +216,11 @@ umapfs_omount(mp, path, data, ndp, td)
umapm_rootvp = vp;
umapm_rootvp->v_vflag |= VV_ROOT;
amp->umapm_rootvp = umapm_rootvp;
- if (UMAPVPTOLOWERVP(umapm_rootvp)->v_mount->mnt_flag & MNT_LOCAL)
+ if (UMAPVPTOLOWERVP(umapm_rootvp)->v_mount->mnt_flag & MNT_LOCAL) {
+ MNT_ILOCK(mp);
mp->mnt_flag |= MNT_LOCAL;
+ MNT_IUNLOCK(mp);
+ }
mp->mnt_data = (qaddr_t) amp;
vfs_getnewfsid(mp);
diff --git a/sys/fs/unionfs/union_vfsops.c b/sys/fs/unionfs/union_vfsops.c
index 0a65ea7..1d0d58e 100644
--- a/sys/fs/unionfs/union_vfsops.c
+++ b/sys/fs/unionfs/union_vfsops.c
@@ -86,7 +86,9 @@ union_mount(mp, td)
/*
* Disable clustered write, otherwise system becomes unstable.
*/
+ MNT_ILOCK(mp);
mp->mnt_flag |= MNT_NOCLUSTERW;
+ MNT_IUNLOCK(mp);
if (mp->mnt_flag & MNT_ROOTFS)
return (EOPNOTSUPP);
@@ -246,8 +248,11 @@ union_mount(mp, td)
if (um->um_op == UNMNT_ABOVE) {
if (((um->um_lowervp == NULLVP) ||
(um->um_lowervp->v_mount->mnt_flag & MNT_LOCAL)) &&
- (um->um_uppervp->v_mount->mnt_flag & MNT_LOCAL))
+ (um->um_uppervp->v_mount->mnt_flag & MNT_LOCAL)) {
+ MNT_ILOCK(mp);
mp->mnt_flag |= MNT_LOCAL;
+ MNT_IUNLOCK(mp);
+ }
}
/*
@@ -257,7 +262,9 @@ union_mount(mp, td)
* mount of the underlying filesystem to go from rdonly to rdwr
* will leave the unioned view as read-only.
*/
+ MNT_ILOCK(mp);
mp->mnt_flag |= (um->um_uppervp->v_mount->mnt_flag & MNT_RDONLY);
+ MNT_IUNLOCK(mp);
mp->mnt_data = (qaddr_t) um;
vfs_getnewfsid(mp);
OpenPOWER on IntegriCloud