diff options
author | tegge <tegge@FreeBSD.org> | 2006-09-26 04:12:49 +0000 |
---|---|---|
committer | tegge <tegge@FreeBSD.org> | 2006-09-26 04:12:49 +0000 |
commit | 83154f853d9ca39deb1add01e032aff1f0678514 (patch) | |
tree | ac46e0b5a80f88127d3d14dc940a5f2746573c00 /sys/nfsclient | |
parent | d7fe3e736512a1dd37a985037184eecf7df1f26d (diff) | |
download | FreeBSD-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/nfsclient')
-rw-r--r-- | sys/nfsclient/nfs_vfsops.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/sys/nfsclient/nfs_vfsops.c b/sys/nfsclient/nfs_vfsops.c index 480a5d6..69476bc 100644 --- a/sys/nfsclient/nfs_vfsops.c +++ b/sys/nfsclient/nfs_vfsops.c @@ -522,8 +522,10 @@ nfs_mountdiskless(char *path, int mountflag, struct sockaddr *nam; int error; + MNT_ILOCK(mp); mp->mnt_kern_flag = 0; mp->mnt_flag = mountflag; + MNT_IUNLOCK(mp); nam = sodupsockaddr((struct sockaddr *)sin, M_WAITOK); if ((error = mountnfs(args, mp, nam, path, vpp, td->td_ucred)) != 0) { @@ -548,10 +550,15 @@ nfs_decode_args(struct mount *mp, struct nfsmount *nmp, struct nfs_args *argp) * flag is already clear, or this is a root mount and it was set * intentionally at some previous point. */ - if (vfs_getopt(mp->mnt_optnew, "ro", NULL, NULL) == 0) + if (vfs_getopt(mp->mnt_optnew, "ro", NULL, NULL) == 0) { + MNT_ILOCK(mp); mp->mnt_flag |= MNT_RDONLY; - else if (mp->mnt_flag & MNT_UPDATE) + MNT_IUNLOCK(mp); + } else if (mp->mnt_flag & MNT_UPDATE) { + MNT_ILOCK(mp); mp->mnt_flag &= ~MNT_RDONLY; + MNT_IUNLOCK(mp); + } /* * Silently clear NFSMNT_NOCONN if it's a TCP mount, it makes @@ -784,8 +791,11 @@ nfs_mount(struct mount *mp, struct thread *td) args.fh = nfh; error = mountnfs(&args, mp, nam, hst, &vp, td->td_ucred); out: - if (!error) + if (!error) { + MNT_ILOCK(mp); mp->mnt_kern_flag |= (MNTK_MPSAFE|MNTK_LOOKUP_SHARED); + MNT_IUNLOCK(mp); + } return (error); } |