From 83154f853d9ca39deb1add01e032aff1f0678514 Mon Sep 17 00:00:00 2001 From: tegge Date: Tue, 26 Sep 2006 04:12:49 +0000 Subject: 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(). --- sys/nfsclient/nfs_vfsops.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'sys/nfsclient') 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); } -- cgit v1.1