summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2017-07-17 03:45:35 -0400
committerDavid Howells <dhowells@redhat.com>2017-07-17 03:45:35 -0400
commite462ec50cb5fad19f6003a3d8087f4a0945dd2b1 (patch)
tree7e56b715ce6b1c4ad13a4c3cfbce9462efe875bc
parentbc98a42c1f7d0f886c0c1b75a92a004976a46d9f (diff)
VFS: Differentiate mount flags (MS_*) from internal superblock flags
Differentiate the MS_* flags passed to mount(2) from the internal flags set in the super_block's s_flags. s_flags are now called SB_*, with the names and the values for the moment mirroring the MS_* flags that they're equivalent to. In this patch, just the headers are altered and some kernel code where blind automated conversion isn't necessarily correct. Note that this shows up some interesting issues: (1) Some MS_* flags get translated to MNT_* flags (such as MS_NODEV -> MNT_NODEV) without passing this on to the filesystem, but some filesystems set such flags anyway. (2) The ->remount_fs() methods of some filesystems adjust the *flags argument by setting MS_* flags in it, such as MS_NOATIME - but these flags are then scrubbed by do_remount_sb() (only the occupants of MS_RMT_MASK are permitted: MS_RDONLY, MS_SYNCHRONOUS, MS_MANDLOCK, MS_I_VERSION and MS_LAZYTIME) I'm not sure what's the best way to solve all these cases. Suggested-by: Al Viro <viro@ZenIV.linux.org.uk> Signed-off-by: David Howells <dhowells@redhat.com>
-rw-r--r--Documentation/filesystems/porting2
-rw-r--r--fs/namespace.c56
-rw-r--r--fs/super.c68
-rw-r--r--include/linux/fs.h45
-rw-r--r--init/do_mounts.c4
5 files changed, 104 insertions, 71 deletions
diff --git a/Documentation/filesystems/porting b/Documentation/filesystems/porting
index 5fb17f49f7a2..93e0a2404532 100644
--- a/Documentation/filesystems/porting
+++ b/Documentation/filesystems/porting
@@ -228,7 +228,7 @@ anything from oops to silent memory corruption.
228--- 228---
229[mandatory] 229[mandatory]
230 230
231 FS_NOMOUNT is gone. If you use it - just set MS_NOUSER in flags 231 FS_NOMOUNT is gone. If you use it - just set SB_NOUSER in flags
232(see rootfs for one kind of solution and bdev/socket/pipe for another). 232(see rootfs for one kind of solution and bdev/socket/pipe for another).
233 233
234--- 234---
diff --git a/fs/namespace.c b/fs/namespace.c
index e42c9abfeaa8..c26a82cfe4fc 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -971,7 +971,7 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void
971 if (!mnt) 971 if (!mnt)
972 return ERR_PTR(-ENOMEM); 972 return ERR_PTR(-ENOMEM);
973 973
974 if (flags & MS_KERNMOUNT) 974 if (flags & SB_KERNMOUNT)
975 mnt->mnt.mnt_flags = MNT_INTERNAL; 975 mnt->mnt.mnt_flags = MNT_INTERNAL;
976 976
977 root = mount_fs(type, flags, name, data); 977 root = mount_fs(type, flags, name, data);
@@ -1003,7 +1003,7 @@ vfs_submount(const struct dentry *mountpoint, struct file_system_type *type,
1003 if (mountpoint->d_sb->s_user_ns != &init_user_ns) 1003 if (mountpoint->d_sb->s_user_ns != &init_user_ns)
1004 return ERR_PTR(-EPERM); 1004 return ERR_PTR(-EPERM);
1005 1005
1006 return vfs_kern_mount(type, MS_SUBMOUNT, name, data); 1006 return vfs_kern_mount(type, SB_SUBMOUNT, name, data);
1007} 1007}
1008EXPORT_SYMBOL_GPL(vfs_submount); 1008EXPORT_SYMBOL_GPL(vfs_submount);
1009 1009
@@ -1535,7 +1535,7 @@ static int do_umount(struct mount *mnt, int flags)
1535 return -EPERM; 1535 return -EPERM;
1536 down_write(&sb->s_umount); 1536 down_write(&sb->s_umount);
1537 if (!sb_rdonly(sb)) 1537 if (!sb_rdonly(sb))
1538 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0); 1538 retval = do_remount_sb(sb, SB_RDONLY, NULL, 0);
1539 up_write(&sb->s_umount); 1539 up_write(&sb->s_umount);
1540 return retval; 1540 return retval;
1541 } 1541 }
@@ -2059,7 +2059,7 @@ static void unlock_mount(struct mountpoint *where)
2059 2059
2060static int graft_tree(struct mount *mnt, struct mount *p, struct mountpoint *mp) 2060static int graft_tree(struct mount *mnt, struct mount *p, struct mountpoint *mp)
2061{ 2061{
2062 if (mnt->mnt.mnt_sb->s_flags & MS_NOUSER) 2062 if (mnt->mnt.mnt_sb->s_flags & SB_NOUSER)
2063 return -EINVAL; 2063 return -EINVAL;
2064 2064
2065 if (d_is_dir(mp->m_dentry) != 2065 if (d_is_dir(mp->m_dentry) !=
@@ -2073,9 +2073,9 @@ static int graft_tree(struct mount *mnt, struct mount *p, struct mountpoint *mp)
2073 * Sanity check the flags to change_mnt_propagation. 2073 * Sanity check the flags to change_mnt_propagation.
2074 */ 2074 */
2075 2075
2076static int flags_to_propagation_type(int flags) 2076static int flags_to_propagation_type(int ms_flags)
2077{ 2077{
2078 int type = flags & ~(MS_REC | MS_SILENT); 2078 int type = ms_flags & ~(MS_REC | MS_SILENT);
2079 2079
2080 /* Fail if any non-propagation flags are set */ 2080 /* Fail if any non-propagation flags are set */
2081 if (type & ~(MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE)) 2081 if (type & ~(MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
@@ -2089,18 +2089,18 @@ static int flags_to_propagation_type(int flags)
2089/* 2089/*
2090 * recursively change the type of the mountpoint. 2090 * recursively change the type of the mountpoint.
2091 */ 2091 */
2092static int do_change_type(struct path *path, int flag) 2092static int do_change_type(struct path *path, int ms_flags)
2093{ 2093{
2094 struct mount *m; 2094 struct mount *m;
2095 struct mount *mnt = real_mount(path->mnt); 2095 struct mount *mnt = real_mount(path->mnt);
2096 int recurse = flag & MS_REC; 2096 int recurse = ms_flags & MS_REC;
2097 int type; 2097 int type;
2098 int err = 0; 2098 int err = 0;
2099 2099
2100 if (path->dentry != path->mnt->mnt_root) 2100 if (path->dentry != path->mnt->mnt_root)
2101 return -EINVAL; 2101 return -EINVAL;
2102 2102
2103 type = flags_to_propagation_type(flag); 2103 type = flags_to_propagation_type(ms_flags);
2104 if (!type) 2104 if (!type)
2105 return -EINVAL; 2105 return -EINVAL;
2106 2106
@@ -2222,8 +2222,8 @@ static int change_mount_flags(struct vfsmount *mnt, int ms_flags)
2222 * If you've mounted a non-root directory somewhere and want to do remount 2222 * If you've mounted a non-root directory somewhere and want to do remount
2223 * on it - tough luck. 2223 * on it - tough luck.
2224 */ 2224 */
2225static int do_remount(struct path *path, int flags, int mnt_flags, 2225static int do_remount(struct path *path, int ms_flags, int sb_flags,
2226 void *data) 2226 int mnt_flags, void *data)
2227{ 2227{
2228 int err; 2228 int err;
2229 struct super_block *sb = path->mnt->mnt_sb; 2229 struct super_block *sb = path->mnt->mnt_sb;
@@ -2267,12 +2267,12 @@ static int do_remount(struct path *path, int flags, int mnt_flags,
2267 return err; 2267 return err;
2268 2268
2269 down_write(&sb->s_umount); 2269 down_write(&sb->s_umount);
2270 if (flags & MS_BIND) 2270 if (ms_flags & MS_BIND)
2271 err = change_mount_flags(path->mnt, flags); 2271 err = change_mount_flags(path->mnt, ms_flags);
2272 else if (!capable(CAP_SYS_ADMIN)) 2272 else if (!capable(CAP_SYS_ADMIN))
2273 err = -EPERM; 2273 err = -EPERM;
2274 else 2274 else
2275 err = do_remount_sb(sb, flags, data, 0); 2275 err = do_remount_sb(sb, sb_flags, data, 0);
2276 if (!err) { 2276 if (!err) {
2277 lock_mount_hash(); 2277 lock_mount_hash();
2278 mnt_flags |= mnt->mnt.mnt_flags & ~MNT_USER_SETTABLE_MASK; 2278 mnt_flags |= mnt->mnt.mnt_flags & ~MNT_USER_SETTABLE_MASK;
@@ -2437,7 +2437,7 @@ static bool mount_too_revealing(struct vfsmount *mnt, int *new_mnt_flags);
2437 * create a new mount for userspace and request it to be added into the 2437 * create a new mount for userspace and request it to be added into the
2438 * namespace's tree 2438 * namespace's tree
2439 */ 2439 */
2440static int do_new_mount(struct path *path, const char *fstype, int flags, 2440static int do_new_mount(struct path *path, const char *fstype, int sb_flags,
2441 int mnt_flags, const char *name, void *data) 2441 int mnt_flags, const char *name, void *data)
2442{ 2442{
2443 struct file_system_type *type; 2443 struct file_system_type *type;
@@ -2451,7 +2451,7 @@ static int do_new_mount(struct path *path, const char *fstype, int flags,
2451 if (!type) 2451 if (!type)
2452 return -ENODEV; 2452 return -ENODEV;
2453 2453
2454 mnt = vfs_kern_mount(type, flags, name, data); 2454 mnt = vfs_kern_mount(type, sb_flags, name, data);
2455 if (!IS_ERR(mnt) && (type->fs_flags & FS_HAS_SUBTYPE) && 2455 if (!IS_ERR(mnt) && (type->fs_flags & FS_HAS_SUBTYPE) &&
2456 !mnt->mnt_sb->s_subtype) 2456 !mnt->mnt_sb->s_subtype)
2457 mnt = fs_set_subtype(mnt, fstype); 2457 mnt = fs_set_subtype(mnt, fstype);
@@ -2706,8 +2706,8 @@ long do_mount(const char *dev_name, const char __user *dir_name,
2706 const char *type_page, unsigned long flags, void *data_page) 2706 const char *type_page, unsigned long flags, void *data_page)
2707{ 2707{
2708 struct path path; 2708 struct path path;
2709 unsigned int mnt_flags = 0, sb_flags;
2709 int retval = 0; 2710 int retval = 0;
2710 int mnt_flags = 0;
2711 2711
2712 /* Discard magic */ 2712 /* Discard magic */
2713 if ((flags & MS_MGC_MSK) == MS_MGC_VAL) 2713 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
@@ -2717,6 +2717,9 @@ long do_mount(const char *dev_name, const char __user *dir_name,
2717 if (data_page) 2717 if (data_page)
2718 ((char *)data_page)[PAGE_SIZE - 1] = 0; 2718 ((char *)data_page)[PAGE_SIZE - 1] = 0;
2719 2719
2720 if (flags & MS_NOUSER)
2721 return -EINVAL;
2722
2720 /* ... and get the mountpoint */ 2723 /* ... and get the mountpoint */
2721 retval = user_path(dir_name, &path); 2724 retval = user_path(dir_name, &path);
2722 if (retval) 2725 if (retval)
@@ -2726,7 +2729,7 @@ long do_mount(const char *dev_name, const char __user *dir_name,
2726 type_page, flags, data_page); 2729 type_page, flags, data_page);
2727 if (!retval && !may_mount()) 2730 if (!retval && !may_mount())
2728 retval = -EPERM; 2731 retval = -EPERM;
2729 if (!retval && (flags & MS_MANDLOCK) && !may_mandlock()) 2732 if (!retval && (flags & SB_MANDLOCK) && !may_mandlock())
2730 retval = -EPERM; 2733 retval = -EPERM;
2731 if (retval) 2734 if (retval)
2732 goto dput_out; 2735 goto dput_out;
@@ -2748,7 +2751,7 @@ long do_mount(const char *dev_name, const char __user *dir_name,
2748 mnt_flags |= MNT_NODIRATIME; 2751 mnt_flags |= MNT_NODIRATIME;
2749 if (flags & MS_STRICTATIME) 2752 if (flags & MS_STRICTATIME)
2750 mnt_flags &= ~(MNT_RELATIME | MNT_NOATIME); 2753 mnt_flags &= ~(MNT_RELATIME | MNT_NOATIME);
2751 if (flags & MS_RDONLY) 2754 if (flags & SB_RDONLY)
2752 mnt_flags |= MNT_READONLY; 2755 mnt_flags |= MNT_READONLY;
2753 2756
2754 /* The default atime for remount is preservation */ 2757 /* The default atime for remount is preservation */
@@ -2759,12 +2762,15 @@ long do_mount(const char *dev_name, const char __user *dir_name,
2759 mnt_flags |= path.mnt->mnt_flags & MNT_ATIME_MASK; 2762 mnt_flags |= path.mnt->mnt_flags & MNT_ATIME_MASK;
2760 } 2763 }
2761 2764
2762 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE | MS_BORN | 2765 sb_flags = flags & (SB_RDONLY |
2763 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT | 2766 SB_SYNCHRONOUS |
2764 MS_STRICTATIME | MS_NOREMOTELOCK | MS_SUBMOUNT); 2767 SB_MANDLOCK |
2768 SB_DIRSYNC |
2769 SB_SILENT |
2770 SB_POSIXACL);
2765 2771
2766 if (flags & MS_REMOUNT) 2772 if (flags & MS_REMOUNT)
2767 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags, 2773 retval = do_remount(&path, flags, sb_flags, mnt_flags,
2768 data_page); 2774 data_page);
2769 else if (flags & MS_BIND) 2775 else if (flags & MS_BIND)
2770 retval = do_loopback(&path, dev_name, flags & MS_REC); 2776 retval = do_loopback(&path, dev_name, flags & MS_REC);
@@ -2773,7 +2779,7 @@ long do_mount(const char *dev_name, const char __user *dir_name,
2773 else if (flags & MS_MOVE) 2779 else if (flags & MS_MOVE)
2774 retval = do_move_mount(&path, dev_name); 2780 retval = do_move_mount(&path, dev_name);
2775 else 2781 else
2776 retval = do_new_mount(&path, type_page, flags, mnt_flags, 2782 retval = do_new_mount(&path, type_page, sb_flags, mnt_flags,
2777 dev_name, data_page); 2783 dev_name, data_page);
2778dput_out: 2784dput_out:
2779 path_put(&path); 2785 path_put(&path);
@@ -3223,7 +3229,7 @@ void put_mnt_ns(struct mnt_namespace *ns)
3223struct vfsmount *kern_mount_data(struct file_system_type *type, void *data) 3229struct vfsmount *kern_mount_data(struct file_system_type *type, void *data)
3224{ 3230{
3225 struct vfsmount *mnt; 3231 struct vfsmount *mnt;
3226 mnt = vfs_kern_mount(type, MS_KERNMOUNT, type->name, data); 3232 mnt = vfs_kern_mount(type, SB_KERNMOUNT, type->name, data);
3227 if (!IS_ERR(mnt)) { 3233 if (!IS_ERR(mnt)) {
3228 /* 3234 /*
3229 * it is a longterm mount, don't release mnt until 3235 * it is a longterm mount, don't release mnt until
diff --git a/fs/super.c b/fs/super.c
index 7321958d81d8..d956e62e5866 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -360,7 +360,7 @@ static int grab_super(struct super_block *s) __releases(sb_lock)
360 s->s_count++; 360 s->s_count++;
361 spin_unlock(&sb_lock); 361 spin_unlock(&sb_lock);
362 down_write(&s->s_umount); 362 down_write(&s->s_umount);
363 if ((s->s_flags & MS_BORN) && atomic_inc_not_zero(&s->s_active)) { 363 if ((s->s_flags & SB_BORN) && atomic_inc_not_zero(&s->s_active)) {
364 put_super(s); 364 put_super(s);
365 return 1; 365 return 1;
366 } 366 }
@@ -390,7 +390,7 @@ bool trylock_super(struct super_block *sb)
390{ 390{
391 if (down_read_trylock(&sb->s_umount)) { 391 if (down_read_trylock(&sb->s_umount)) {
392 if (!hlist_unhashed(&sb->s_instances) && 392 if (!hlist_unhashed(&sb->s_instances) &&
393 sb->s_root && (sb->s_flags & MS_BORN)) 393 sb->s_root && (sb->s_flags & SB_BORN))
394 return true; 394 return true;
395 up_read(&sb->s_umount); 395 up_read(&sb->s_umount);
396 } 396 }
@@ -419,7 +419,7 @@ void generic_shutdown_super(struct super_block *sb)
419 if (sb->s_root) { 419 if (sb->s_root) {
420 shrink_dcache_for_umount(sb); 420 shrink_dcache_for_umount(sb);
421 sync_filesystem(sb); 421 sync_filesystem(sb);
422 sb->s_flags &= ~MS_ACTIVE; 422 sb->s_flags &= ~SB_ACTIVE;
423 423
424 fsnotify_unmount_inodes(sb); 424 fsnotify_unmount_inodes(sb);
425 cgroup_writeback_umount(); 425 cgroup_writeback_umount();
@@ -472,7 +472,7 @@ struct super_block *sget_userns(struct file_system_type *type,
472 struct super_block *old; 472 struct super_block *old;
473 int err; 473 int err;
474 474
475 if (!(flags & (MS_KERNMOUNT|MS_SUBMOUNT)) && 475 if (!(flags & (SB_KERNMOUNT|SB_SUBMOUNT)) &&
476 !(type->fs_flags & FS_USERNS_MOUNT) && 476 !(type->fs_flags & FS_USERNS_MOUNT) &&
477 !capable(CAP_SYS_ADMIN)) 477 !capable(CAP_SYS_ADMIN))
478 return ERR_PTR(-EPERM); 478 return ERR_PTR(-EPERM);
@@ -502,7 +502,7 @@ retry:
502 } 502 }
503 if (!s) { 503 if (!s) {
504 spin_unlock(&sb_lock); 504 spin_unlock(&sb_lock);
505 s = alloc_super(type, (flags & ~MS_SUBMOUNT), user_ns); 505 s = alloc_super(type, (flags & ~SB_SUBMOUNT), user_ns);
506 if (!s) 506 if (!s)
507 return ERR_PTR(-ENOMEM); 507 return ERR_PTR(-ENOMEM);
508 goto retry; 508 goto retry;
@@ -547,11 +547,11 @@ struct super_block *sget(struct file_system_type *type,
547 * mount through to here so always use &init_user_ns 547 * mount through to here so always use &init_user_ns
548 * until that changes. 548 * until that changes.
549 */ 549 */
550 if (flags & MS_SUBMOUNT) 550 if (flags & SB_SUBMOUNT)
551 user_ns = &init_user_ns; 551 user_ns = &init_user_ns;
552 552
553 /* Ensure the requestor has permissions over the target filesystem */ 553 /* Ensure the requestor has permissions over the target filesystem */
554 if (!(flags & (MS_KERNMOUNT|MS_SUBMOUNT)) && !ns_capable(user_ns, CAP_SYS_ADMIN)) 554 if (!(flags & (SB_KERNMOUNT|SB_SUBMOUNT)) && !ns_capable(user_ns, CAP_SYS_ADMIN))
555 return ERR_PTR(-EPERM); 555 return ERR_PTR(-EPERM);
556 556
557 return sget_userns(type, test, set, flags, user_ns, data); 557 return sget_userns(type, test, set, flags, user_ns, data);
@@ -594,7 +594,7 @@ void iterate_supers(void (*f)(struct super_block *, void *), void *arg)
594 spin_unlock(&sb_lock); 594 spin_unlock(&sb_lock);
595 595
596 down_read(&sb->s_umount); 596 down_read(&sb->s_umount);
597 if (sb->s_root && (sb->s_flags & MS_BORN)) 597 if (sb->s_root && (sb->s_flags & SB_BORN))
598 f(sb, arg); 598 f(sb, arg);
599 up_read(&sb->s_umount); 599 up_read(&sb->s_umount);
600 600
@@ -628,7 +628,7 @@ void iterate_supers_type(struct file_system_type *type,
628 spin_unlock(&sb_lock); 628 spin_unlock(&sb_lock);
629 629
630 down_read(&sb->s_umount); 630 down_read(&sb->s_umount);
631 if (sb->s_root && (sb->s_flags & MS_BORN)) 631 if (sb->s_root && (sb->s_flags & SB_BORN))
632 f(sb, arg); 632 f(sb, arg);
633 up_read(&sb->s_umount); 633 up_read(&sb->s_umount);
634 634
@@ -664,7 +664,7 @@ rescan:
664 else 664 else
665 down_write(&sb->s_umount); 665 down_write(&sb->s_umount);
666 /* still alive? */ 666 /* still alive? */
667 if (sb->s_root && (sb->s_flags & MS_BORN)) 667 if (sb->s_root && (sb->s_flags & SB_BORN))
668 return sb; 668 return sb;
669 if (!excl) 669 if (!excl)
670 up_read(&sb->s_umount); 670 up_read(&sb->s_umount);
@@ -785,7 +785,7 @@ rescan:
785 spin_unlock(&sb_lock); 785 spin_unlock(&sb_lock);
786 down_read(&sb->s_umount); 786 down_read(&sb->s_umount);
787 /* still alive? */ 787 /* still alive? */
788 if (sb->s_root && (sb->s_flags & MS_BORN)) 788 if (sb->s_root && (sb->s_flags & SB_BORN))
789 return sb; 789 return sb;
790 up_read(&sb->s_umount); 790 up_read(&sb->s_umount);
791 /* nope, got unmounted */ 791 /* nope, got unmounted */
@@ -801,13 +801,13 @@ rescan:
801/** 801/**
802 * do_remount_sb - asks filesystem to change mount options. 802 * do_remount_sb - asks filesystem to change mount options.
803 * @sb: superblock in question 803 * @sb: superblock in question
804 * @flags: numeric part of options 804 * @sb_flags: revised superblock flags
805 * @data: the rest of options 805 * @data: the rest of options
806 * @force: whether or not to force the change 806 * @force: whether or not to force the change
807 * 807 *
808 * Alters the mount options of a mounted file system. 808 * Alters the mount options of a mounted file system.
809 */ 809 */
810int do_remount_sb(struct super_block *sb, int flags, void *data, int force) 810int do_remount_sb(struct super_block *sb, int sb_flags, void *data, int force)
811{ 811{
812 int retval; 812 int retval;
813 int remount_ro; 813 int remount_ro;
@@ -816,11 +816,11 @@ int do_remount_sb(struct super_block *sb, int flags, void *data, int force)
816 return -EBUSY; 816 return -EBUSY;
817 817
818#ifdef CONFIG_BLOCK 818#ifdef CONFIG_BLOCK
819 if (!(flags & MS_RDONLY) && bdev_read_only(sb->s_bdev)) 819 if (!(sb_flags & SB_RDONLY) && bdev_read_only(sb->s_bdev))
820 return -EACCES; 820 return -EACCES;
821#endif 821#endif
822 822
823 remount_ro = (flags & MS_RDONLY) && !sb_rdonly(sb); 823 remount_ro = (sb_flags & SB_RDONLY) && !sb_rdonly(sb);
824 824
825 if (remount_ro) { 825 if (remount_ro) {
826 if (!hlist_empty(&sb->s_pins)) { 826 if (!hlist_empty(&sb->s_pins)) {
@@ -831,7 +831,7 @@ int do_remount_sb(struct super_block *sb, int flags, void *data, int force)
831 return 0; 831 return 0;
832 if (sb->s_writers.frozen != SB_UNFROZEN) 832 if (sb->s_writers.frozen != SB_UNFROZEN)
833 return -EBUSY; 833 return -EBUSY;
834 remount_ro = (flags & MS_RDONLY) && !sb_rdonly(sb); 834 remount_ro = (sb_flags & SB_RDONLY) && !sb_rdonly(sb);
835 } 835 }
836 } 836 }
837 shrink_dcache_sb(sb); 837 shrink_dcache_sb(sb);
@@ -850,7 +850,7 @@ int do_remount_sb(struct super_block *sb, int flags, void *data, int force)
850 } 850 }
851 851
852 if (sb->s_op->remount_fs) { 852 if (sb->s_op->remount_fs) {
853 retval = sb->s_op->remount_fs(sb, &flags, data); 853 retval = sb->s_op->remount_fs(sb, &sb_flags, data);
854 if (retval) { 854 if (retval) {
855 if (!force) 855 if (!force)
856 goto cancel_readonly; 856 goto cancel_readonly;
@@ -859,7 +859,7 @@ int do_remount_sb(struct super_block *sb, int flags, void *data, int force)
859 sb->s_type->name, retval); 859 sb->s_type->name, retval);
860 } 860 }
861 } 861 }
862 sb->s_flags = (sb->s_flags & ~MS_RMT_MASK) | (flags & MS_RMT_MASK); 862 sb->s_flags = (sb->s_flags & ~MS_RMT_MASK) | (sb_flags & MS_RMT_MASK);
863 /* Needs to be ordered wrt mnt_is_readonly() */ 863 /* Needs to be ordered wrt mnt_is_readonly() */
864 smp_wmb(); 864 smp_wmb();
865 sb->s_readonly_remount = 0; 865 sb->s_readonly_remount = 0;
@@ -892,12 +892,12 @@ static void do_emergency_remount(struct work_struct *work)
892 sb->s_count++; 892 sb->s_count++;
893 spin_unlock(&sb_lock); 893 spin_unlock(&sb_lock);
894 down_write(&sb->s_umount); 894 down_write(&sb->s_umount);
895 if (sb->s_root && sb->s_bdev && (sb->s_flags & MS_BORN) && 895 if (sb->s_root && sb->s_bdev && (sb->s_flags & SB_BORN) &&
896 !sb_rdonly(sb)) { 896 !sb_rdonly(sb)) {
897 /* 897 /*
898 * What lock protects sb->s_flags?? 898 * What lock protects sb->s_flags??
899 */ 899 */
900 do_remount_sb(sb, MS_RDONLY, NULL, 1); 900 do_remount_sb(sb, SB_RDONLY, NULL, 1);
901 } 901 }
902 up_write(&sb->s_umount); 902 up_write(&sb->s_umount);
903 spin_lock(&sb_lock); 903 spin_lock(&sb_lock);
@@ -1023,7 +1023,7 @@ struct dentry *mount_ns(struct file_system_type *fs_type,
1023 /* Don't allow mounting unless the caller has CAP_SYS_ADMIN 1023 /* Don't allow mounting unless the caller has CAP_SYS_ADMIN
1024 * over the namespace. 1024 * over the namespace.
1025 */ 1025 */
1026 if (!(flags & MS_KERNMOUNT) && !ns_capable(user_ns, CAP_SYS_ADMIN)) 1026 if (!(flags & SB_KERNMOUNT) && !ns_capable(user_ns, CAP_SYS_ADMIN))
1027 return ERR_PTR(-EPERM); 1027 return ERR_PTR(-EPERM);
1028 1028
1029 sb = sget_userns(fs_type, ns_test_super, ns_set_super, flags, 1029 sb = sget_userns(fs_type, ns_test_super, ns_set_super, flags,
@@ -1033,13 +1033,13 @@ struct dentry *mount_ns(struct file_system_type *fs_type,
1033 1033
1034 if (!sb->s_root) { 1034 if (!sb->s_root) {
1035 int err; 1035 int err;
1036 err = fill_super(sb, data, flags & MS_SILENT ? 1 : 0); 1036 err = fill_super(sb, data, flags & SB_SILENT ? 1 : 0);
1037 if (err) { 1037 if (err) {
1038 deactivate_locked_super(sb); 1038 deactivate_locked_super(sb);
1039 return ERR_PTR(err); 1039 return ERR_PTR(err);
1040 } 1040 }
1041 1041
1042 sb->s_flags |= MS_ACTIVE; 1042 sb->s_flags |= SB_ACTIVE;
1043 } 1043 }
1044 1044
1045 return dget(sb->s_root); 1045 return dget(sb->s_root);
@@ -1071,7 +1071,7 @@ struct dentry *mount_bdev(struct file_system_type *fs_type,
1071 fmode_t mode = FMODE_READ | FMODE_EXCL; 1071 fmode_t mode = FMODE_READ | FMODE_EXCL;
1072 int error = 0; 1072 int error = 0;
1073 1073
1074 if (!(flags & MS_RDONLY)) 1074 if (!(flags & SB_RDONLY))
1075 mode |= FMODE_WRITE; 1075 mode |= FMODE_WRITE;
1076 1076
1077 bdev = blkdev_get_by_path(dev_name, mode, fs_type); 1077 bdev = blkdev_get_by_path(dev_name, mode, fs_type);
@@ -1089,14 +1089,14 @@ struct dentry *mount_bdev(struct file_system_type *fs_type,
1089 error = -EBUSY; 1089 error = -EBUSY;
1090 goto error_bdev; 1090 goto error_bdev;
1091 } 1091 }
1092 s = sget(fs_type, test_bdev_super, set_bdev_super, flags | MS_NOSEC, 1092 s = sget(fs_type, test_bdev_super, set_bdev_super, flags | SB_NOSEC,
1093 bdev); 1093 bdev);
1094 mutex_unlock(&bdev->bd_fsfreeze_mutex); 1094 mutex_unlock(&bdev->bd_fsfreeze_mutex);
1095 if (IS_ERR(s)) 1095 if (IS_ERR(s))
1096 goto error_s; 1096 goto error_s;
1097 1097
1098 if (s->s_root) { 1098 if (s->s_root) {
1099 if ((flags ^ s->s_flags) & MS_RDONLY) { 1099 if ((flags ^ s->s_flags) & SB_RDONLY) {
1100 deactivate_locked_super(s); 1100 deactivate_locked_super(s);
1101 error = -EBUSY; 1101 error = -EBUSY;
1102 goto error_bdev; 1102 goto error_bdev;
@@ -1116,13 +1116,13 @@ struct dentry *mount_bdev(struct file_system_type *fs_type,
1116 s->s_mode = mode; 1116 s->s_mode = mode;
1117 snprintf(s->s_id, sizeof(s->s_id), "%pg", bdev); 1117 snprintf(s->s_id, sizeof(s->s_id), "%pg", bdev);
1118 sb_set_blocksize(s, block_size(bdev)); 1118 sb_set_blocksize(s, block_size(bdev));
1119 error = fill_super(s, data, flags & MS_SILENT ? 1 : 0); 1119 error = fill_super(s, data, flags & SB_SILENT ? 1 : 0);
1120 if (error) { 1120 if (error) {
1121 deactivate_locked_super(s); 1121 deactivate_locked_super(s);
1122 goto error; 1122 goto error;
1123 } 1123 }
1124 1124
1125 s->s_flags |= MS_ACTIVE; 1125 s->s_flags |= SB_ACTIVE;
1126 bdev->bd_super = s; 1126 bdev->bd_super = s;
1127 } 1127 }
1128 1128
@@ -1162,12 +1162,12 @@ struct dentry *mount_nodev(struct file_system_type *fs_type,
1162 if (IS_ERR(s)) 1162 if (IS_ERR(s))
1163 return ERR_CAST(s); 1163 return ERR_CAST(s);
1164 1164
1165 error = fill_super(s, data, flags & MS_SILENT ? 1 : 0); 1165 error = fill_super(s, data, flags & SB_SILENT ? 1 : 0);
1166 if (error) { 1166 if (error) {
1167 deactivate_locked_super(s); 1167 deactivate_locked_super(s);
1168 return ERR_PTR(error); 1168 return ERR_PTR(error);
1169 } 1169 }
1170 s->s_flags |= MS_ACTIVE; 1170 s->s_flags |= SB_ACTIVE;
1171 return dget(s->s_root); 1171 return dget(s->s_root);
1172} 1172}
1173EXPORT_SYMBOL(mount_nodev); 1173EXPORT_SYMBOL(mount_nodev);
@@ -1188,12 +1188,12 @@ struct dentry *mount_single(struct file_system_type *fs_type,
1188 if (IS_ERR(s)) 1188 if (IS_ERR(s))
1189 return ERR_CAST(s); 1189 return ERR_CAST(s);
1190 if (!s->s_root) { 1190 if (!s->s_root) {
1191 error = fill_super(s, data, flags & MS_SILENT ? 1 : 0); 1191 error = fill_super(s, data, flags & SB_SILENT ? 1 : 0);
1192 if (error) { 1192 if (error) {
1193 deactivate_locked_super(s); 1193 deactivate_locked_super(s);
1194 return ERR_PTR(error); 1194 return ERR_PTR(error);
1195 } 1195 }
1196 s->s_flags |= MS_ACTIVE; 1196 s->s_flags |= SB_ACTIVE;
1197 } else { 1197 } else {
1198 do_remount_sb(s, flags, data, 0); 1198 do_remount_sb(s, flags, data, 0);
1199 } 1199 }
@@ -1227,7 +1227,7 @@ mount_fs(struct file_system_type *type, int flags, const char *name, void *data)
1227 sb = root->d_sb; 1227 sb = root->d_sb;
1228 BUG_ON(!sb); 1228 BUG_ON(!sb);
1229 WARN_ON(!sb->s_bdi); 1229 WARN_ON(!sb->s_bdi);
1230 sb->s_flags |= MS_BORN; 1230 sb->s_flags |= SB_BORN;
1231 1231
1232 error = security_sb_kern_mount(sb, flags, secdata); 1232 error = security_sb_kern_mount(sb, flags, secdata);
1233 if (error) 1233 if (error)
@@ -1434,7 +1434,7 @@ int freeze_super(struct super_block *sb)
1434 return -EBUSY; 1434 return -EBUSY;
1435 } 1435 }
1436 1436
1437 if (!(sb->s_flags & MS_BORN)) { 1437 if (!(sb->s_flags & SB_BORN)) {
1438 up_write(&sb->s_umount); 1438 up_write(&sb->s_umount);
1439 return 0; /* sic - it's "nothing to do" */ 1439 return 0; /* sic - it's "nothing to do" */
1440 } 1440 }
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 6ae137c1bdf6..3d6ee0c0ebb0 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1270,6 +1270,33 @@ extern int send_sigurg(struct fown_struct *fown);
1270struct mm_struct; 1270struct mm_struct;
1271 1271
1272/* 1272/*
1273 * sb->s_flags. Note that these mirror the equivalent MS_* flags where
1274 * represented in both.
1275 */
1276#define SB_RDONLY 1 /* Mount read-only */
1277#define SB_NOSUID 2 /* Ignore suid and sgid bits */
1278#define SB_NODEV 4 /* Disallow access to device special files */
1279#define SB_NOEXEC 8 /* Disallow program execution */
1280#define SB_SYNCHRONOUS 16 /* Writes are synced at once */
1281#define SB_MANDLOCK 64 /* Allow mandatory locks on an FS */
1282#define SB_DIRSYNC 128 /* Directory modifications are synchronous */
1283#define SB_NOATIME 1024 /* Do not update access times. */
1284#define SB_NODIRATIME 2048 /* Do not update directory access times */
1285#define SB_SILENT 32768
1286#define SB_POSIXACL (1<<16) /* VFS does not apply the umask */
1287#define SB_KERNMOUNT (1<<22) /* this is a kern_mount call */
1288#define SB_I_VERSION (1<<23) /* Update inode I_version field */
1289#define SB_LAZYTIME (1<<25) /* Update the on-disk [acm]times lazily */
1290
1291/* These sb flags are internal to the kernel */
1292#define SB_SUBMOUNT (1<<26)
1293#define SB_NOREMOTELOCK (1<<27)
1294#define SB_NOSEC (1<<28)
1295#define SB_BORN (1<<29)
1296#define SB_ACTIVE (1<<30)
1297#define SB_NOUSER (1<<31)
1298
1299/*
1273 * Umount options 1300 * Umount options
1274 */ 1301 */
1275 1302
@@ -1835,7 +1862,7 @@ struct super_operations {
1835 * possible to override it selectively if you really wanted to with some 1862 * possible to override it selectively if you really wanted to with some
1836 * ioctl() that is not currently implemented. 1863 * ioctl() that is not currently implemented.
1837 * 1864 *
1838 * Exception: MS_RDONLY is always applied to the entire file system. 1865 * Exception: SB_RDONLY is always applied to the entire file system.
1839 * 1866 *
1840 * Unfortunately, it is possible to change a filesystems flags with it mounted 1867 * Unfortunately, it is possible to change a filesystems flags with it mounted
1841 * with files in use. This means that all of the inodes will not have their 1868 * with files in use. This means that all of the inodes will not have their
@@ -1846,18 +1873,18 @@ struct super_operations {
1846 1873
1847static inline bool sb_rdonly(const struct super_block *sb) { return sb->s_flags & MS_RDONLY; } 1874static inline bool sb_rdonly(const struct super_block *sb) { return sb->s_flags & MS_RDONLY; }
1848#define IS_RDONLY(inode) sb_rdonly((inode)->i_sb) 1875#define IS_RDONLY(inode) sb_rdonly((inode)->i_sb)
1849#define IS_SYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS) || \ 1876#define IS_SYNC(inode) (__IS_FLG(inode, SB_SYNCHRONOUS) || \
1850 ((inode)->i_flags & S_SYNC)) 1877 ((inode)->i_flags & S_SYNC))
1851#define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \ 1878#define IS_DIRSYNC(inode) (__IS_FLG(inode, SB_SYNCHRONOUS|SB_DIRSYNC) || \
1852 ((inode)->i_flags & (S_SYNC|S_DIRSYNC))) 1879 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
1853#define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK) 1880#define IS_MANDLOCK(inode) __IS_FLG(inode, SB_MANDLOCK)
1854#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME) 1881#define IS_NOATIME(inode) __IS_FLG(inode, SB_RDONLY|SB_NOATIME)
1855#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION) 1882#define IS_I_VERSION(inode) __IS_FLG(inode, SB_I_VERSION)
1856 1883
1857#define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA) 1884#define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
1858#define IS_APPEND(inode) ((inode)->i_flags & S_APPEND) 1885#define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
1859#define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE) 1886#define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
1860#define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL) 1887#define IS_POSIXACL(inode) __IS_FLG(inode, SB_POSIXACL)
1861 1888
1862#define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD) 1889#define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
1863#define IS_NOCMTIME(inode) ((inode)->i_flags & S_NOCMTIME) 1890#define IS_NOCMTIME(inode) ((inode)->i_flags & S_NOCMTIME)
@@ -2178,7 +2205,7 @@ static inline int __mandatory_lock(struct inode *ino)
2178} 2205}
2179 2206
2180/* 2207/*
2181 * ... and these candidates should be on MS_MANDLOCK mounted fs, 2208 * ... and these candidates should be on SB_MANDLOCK mounted fs,
2182 * otherwise these will be advisory locks 2209 * otherwise these will be advisory locks
2183 */ 2210 */
2184 2211
@@ -3274,7 +3301,7 @@ static inline int check_sticky(struct inode *dir, struct inode *inode)
3274 3301
3275static inline void inode_has_no_xattr(struct inode *inode) 3302static inline void inode_has_no_xattr(struct inode *inode)
3276{ 3303{
3277 if (!is_sxid(inode->i_mode) && (inode->i_sb->s_flags & MS_NOSEC)) 3304 if (!is_sxid(inode->i_mode) && (inode->i_sb->s_flags & SB_NOSEC))
3278 inode->i_flags |= S_NOSEC; 3305 inode->i_flags |= S_NOSEC;
3279} 3306}
3280 3307
diff --git a/init/do_mounts.c b/init/do_mounts.c
index bf7ea36ca286..f6d4dd764a52 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -420,8 +420,8 @@ retry:
420#endif 420#endif
421 panic("VFS: Unable to mount root fs on %s", b); 421 panic("VFS: Unable to mount root fs on %s", b);
422 } 422 }
423 if (!(flags & MS_RDONLY)) { 423 if (!(flags & SB_RDONLY)) {
424 flags |= MS_RDONLY; 424 flags |= SB_RDONLY;
425 goto retry; 425 goto retry;
426 } 426 }
427 427