diff options
author | Sachin Prabhu <sprabhu@redhat.com> | 2011-08-01 07:10:12 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2011-09-13 17:10:15 -0400 |
commit | fb2088ccc139ffbf1cf359216883712dab4ae43d (patch) | |
tree | 88fd8cad42bd9d7518fdc25b519965b37cdcb4a5 /fs | |
parent | f13c3620a4d1123dbf032f93f350b856ef292ced (diff) |
nfs: Do not allow multiple mounts on same mountpoint when using -o noac
Do not allow multiple mounts on same mountpoint when using -o noac
When you normally attempt to mount a share twice on the same mountpoint,
a check in do_add_mount causes it to return an error
# mount localhost:/nfsv3 /mnt
# mount localhost:/nfsv3 /mnt
mount.nfs: /mnt is already mounted or busy
However when using the option 'noac', the user is able to mount the same
share on the same mountpoint multiple times. This happens because a
share mounted with the noac option is automatically assigned the 'sync'
flag MS_SYNCHRONOUS in nfs_initialise_sb(). This flag is set after the
check for already existing superblocks is done in sget(). The check for
the mount flags in nfs_compare_mount_options() does not take into
account the 'sync' flag applied later on in the code path. This means
that when using 'noac', a new superblock structure is assigned for every
new mount of the same share and multiple shares on the same mountpoint
are allowed.
ie.
# mount -onoac localhost:/nfsv3 /mnt
can be run multiple times.
The patch checks for noac and assigns the sync flag before sget() is
called to obtain an already existing superblock structure.
Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>
Reviewed-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfs/super.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/fs/nfs/super.c b/fs/nfs/super.c index b961ceac66b4..9b7dd7013b15 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c | |||
@@ -2035,9 +2035,6 @@ static inline void nfs_initialise_sb(struct super_block *sb) | |||
2035 | sb->s_blocksize = nfs_block_bits(server->wsize, | 2035 | sb->s_blocksize = nfs_block_bits(server->wsize, |
2036 | &sb->s_blocksize_bits); | 2036 | &sb->s_blocksize_bits); |
2037 | 2037 | ||
2038 | if (server->flags & NFS_MOUNT_NOAC) | ||
2039 | sb->s_flags |= MS_SYNCHRONOUS; | ||
2040 | |||
2041 | sb->s_bdi = &server->backing_dev_info; | 2038 | sb->s_bdi = &server->backing_dev_info; |
2042 | 2039 | ||
2043 | nfs_super_set_maxbytes(sb, server->maxfilesize); | 2040 | nfs_super_set_maxbytes(sb, server->maxfilesize); |
@@ -2249,6 +2246,10 @@ static struct dentry *nfs_fs_mount(struct file_system_type *fs_type, | |||
2249 | if (server->flags & NFS_MOUNT_UNSHARED) | 2246 | if (server->flags & NFS_MOUNT_UNSHARED) |
2250 | compare_super = NULL; | 2247 | compare_super = NULL; |
2251 | 2248 | ||
2249 | /* -o noac implies -o sync */ | ||
2250 | if (server->flags & NFS_MOUNT_NOAC) | ||
2251 | sb_mntdata.mntflags |= MS_SYNCHRONOUS; | ||
2252 | |||
2252 | /* Get a superblock - note that we may end up sharing one that already exists */ | 2253 | /* Get a superblock - note that we may end up sharing one that already exists */ |
2253 | s = sget(fs_type, compare_super, nfs_set_super, &sb_mntdata); | 2254 | s = sget(fs_type, compare_super, nfs_set_super, &sb_mntdata); |
2254 | if (IS_ERR(s)) { | 2255 | if (IS_ERR(s)) { |
@@ -2361,6 +2362,10 @@ nfs_xdev_mount(struct file_system_type *fs_type, int flags, | |||
2361 | if (server->flags & NFS_MOUNT_UNSHARED) | 2362 | if (server->flags & NFS_MOUNT_UNSHARED) |
2362 | compare_super = NULL; | 2363 | compare_super = NULL; |
2363 | 2364 | ||
2365 | /* -o noac implies -o sync */ | ||
2366 | if (server->flags & NFS_MOUNT_NOAC) | ||
2367 | sb_mntdata.mntflags |= MS_SYNCHRONOUS; | ||
2368 | |||
2364 | /* Get a superblock - note that we may end up sharing one that already exists */ | 2369 | /* Get a superblock - note that we may end up sharing one that already exists */ |
2365 | s = sget(&nfs_fs_type, compare_super, nfs_set_super, &sb_mntdata); | 2370 | s = sget(&nfs_fs_type, compare_super, nfs_set_super, &sb_mntdata); |
2366 | if (IS_ERR(s)) { | 2371 | if (IS_ERR(s)) { |
@@ -2628,6 +2633,10 @@ nfs4_remote_mount(struct file_system_type *fs_type, int flags, | |||
2628 | if (server->flags & NFS4_MOUNT_UNSHARED) | 2633 | if (server->flags & NFS4_MOUNT_UNSHARED) |
2629 | compare_super = NULL; | 2634 | compare_super = NULL; |
2630 | 2635 | ||
2636 | /* -o noac implies -o sync */ | ||
2637 | if (server->flags & NFS_MOUNT_NOAC) | ||
2638 | sb_mntdata.mntflags |= MS_SYNCHRONOUS; | ||
2639 | |||
2631 | /* Get a superblock - note that we may end up sharing one that already exists */ | 2640 | /* Get a superblock - note that we may end up sharing one that already exists */ |
2632 | s = sget(&nfs4_fs_type, compare_super, nfs_set_super, &sb_mntdata); | 2641 | s = sget(&nfs4_fs_type, compare_super, nfs_set_super, &sb_mntdata); |
2633 | if (IS_ERR(s)) { | 2642 | if (IS_ERR(s)) { |
@@ -2916,6 +2925,10 @@ nfs4_xdev_mount(struct file_system_type *fs_type, int flags, | |||
2916 | if (server->flags & NFS4_MOUNT_UNSHARED) | 2925 | if (server->flags & NFS4_MOUNT_UNSHARED) |
2917 | compare_super = NULL; | 2926 | compare_super = NULL; |
2918 | 2927 | ||
2928 | /* -o noac implies -o sync */ | ||
2929 | if (server->flags & NFS_MOUNT_NOAC) | ||
2930 | sb_mntdata.mntflags |= MS_SYNCHRONOUS; | ||
2931 | |||
2919 | /* Get a superblock - note that we may end up sharing one that already exists */ | 2932 | /* Get a superblock - note that we may end up sharing one that already exists */ |
2920 | s = sget(&nfs4_fs_type, compare_super, nfs_set_super, &sb_mntdata); | 2933 | s = sget(&nfs4_fs_type, compare_super, nfs_set_super, &sb_mntdata); |
2921 | if (IS_ERR(s)) { | 2934 | if (IS_ERR(s)) { |
@@ -3003,6 +3016,10 @@ nfs4_remote_referral_mount(struct file_system_type *fs_type, int flags, | |||
3003 | if (server->flags & NFS4_MOUNT_UNSHARED) | 3016 | if (server->flags & NFS4_MOUNT_UNSHARED) |
3004 | compare_super = NULL; | 3017 | compare_super = NULL; |
3005 | 3018 | ||
3019 | /* -o noac implies -o sync */ | ||
3020 | if (server->flags & NFS_MOUNT_NOAC) | ||
3021 | sb_mntdata.mntflags |= MS_SYNCHRONOUS; | ||
3022 | |||
3006 | /* Get a superblock - note that we may end up sharing one that already exists */ | 3023 | /* Get a superblock - note that we may end up sharing one that already exists */ |
3007 | s = sget(&nfs4_fs_type, compare_super, nfs_set_super, &sb_mntdata); | 3024 | s = sget(&nfs4_fs_type, compare_super, nfs_set_super, &sb_mntdata); |
3008 | if (IS_ERR(s)) { | 3025 | if (IS_ERR(s)) { |