Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

VFS: Pass mount flags to sget()

Pass mount flags to sget() so that it can use them in initialising a new
superblock before the set function is called. They could also be passed to the
compare function.

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

authored by

David Howells and committed by
Al Viro
9249e17f f015f126

+40 -50
+1 -3
drivers/mtd/mtdsuper.c
··· 63 63 struct super_block *sb; 64 64 int ret; 65 65 66 - sb = sget(fs_type, get_sb_mtd_compare, get_sb_mtd_set, mtd); 66 + sb = sget(fs_type, get_sb_mtd_compare, get_sb_mtd_set, flags, mtd); 67 67 if (IS_ERR(sb)) 68 68 goto out_error; 69 69 ··· 73 73 /* fresh new superblock */ 74 74 pr_debug("MTDSB: New superblock for device %d (\"%s\")\n", 75 75 mtd->index, mtd->name); 76 - 77 - sb->s_flags = flags; 78 76 79 77 ret = fill_super(sb, data, flags & MS_SILENT ? 1 : 0); 80 78 if (ret < 0) {
+2 -2
fs/9p/vfs_super.c
··· 89 89 if (v9ses->cache) 90 90 sb->s_bdi->ra_pages = (VM_MAX_READAHEAD * 1024)/PAGE_CACHE_SIZE; 91 91 92 - sb->s_flags = flags | MS_ACTIVE | MS_DIRSYNC | MS_NOATIME; 92 + sb->s_flags |= MS_ACTIVE | MS_DIRSYNC | MS_NOATIME; 93 93 if (!v9ses->cache) 94 94 sb->s_flags |= MS_SYNCHRONOUS; 95 95 ··· 137 137 goto close_session; 138 138 } 139 139 140 - sb = sget(fs_type, NULL, v9fs_set_super, v9ses); 140 + sb = sget(fs_type, NULL, v9fs_set_super, flags, v9ses); 141 141 if (IS_ERR(sb)) { 142 142 retval = PTR_ERR(sb); 143 143 goto clunk_fid;
+1 -2
fs/afs/super.c
··· 395 395 as->volume = vol; 396 396 397 397 /* allocate a deviceless superblock */ 398 - sb = sget(fs_type, afs_test_super, afs_set_super, as); 398 + sb = sget(fs_type, afs_test_super, afs_set_super, flags, as); 399 399 if (IS_ERR(sb)) { 400 400 ret = PTR_ERR(sb); 401 401 afs_put_volume(vol); ··· 406 406 if (!sb->s_root) { 407 407 /* initial superblock/root creation */ 408 408 _debug("create"); 409 - sb->s_flags = flags; 410 409 ret = afs_fill_super(sb, &params); 411 410 if (ret < 0) { 412 411 deactivate_locked_super(sb);
+2 -2
fs/btrfs/super.c
··· 1068 1068 } 1069 1069 1070 1070 bdev = fs_devices->latest_bdev; 1071 - s = sget(fs_type, btrfs_test_super, btrfs_set_super, fs_info); 1071 + s = sget(fs_type, btrfs_test_super, btrfs_set_super, flags | MS_NOSEC, 1072 + fs_info); 1072 1073 if (IS_ERR(s)) { 1073 1074 error = PTR_ERR(s); 1074 1075 goto error_close_devices; ··· 1083 1082 } else { 1084 1083 char b[BDEVNAME_SIZE]; 1085 1084 1086 - s->s_flags = flags | MS_NOSEC; 1087 1085 strlcpy(s->s_id, bdevname(bdev, b), sizeof(s->s_id)); 1088 1086 btrfs_sb(s)->bdev_holder = fs_type; 1089 1087 error = btrfs_fill_super(s, fs_devices, data,
+1 -1
fs/ceph/super.c
··· 871 871 872 872 if (ceph_test_opt(fsc->client, NOSHARE)) 873 873 compare_super = NULL; 874 - sb = sget(fs_type, compare_super, ceph_set_super, fsc); 874 + sb = sget(fs_type, compare_super, ceph_set_super, flags, fsc); 875 875 if (IS_ERR(sb)) { 876 876 res = ERR_CAST(sb); 877 877 goto out;
+4 -5
fs/cifs/cifsfs.c
··· 637 637 mnt_data.cifs_sb = cifs_sb; 638 638 mnt_data.flags = flags; 639 639 640 - sb = sget(fs_type, cifs_match_super, cifs_set_super, &mnt_data); 640 + /* BB should we make this contingent on mount parm? */ 641 + flags |= MS_NODIRATIME | MS_NOATIME; 642 + 643 + sb = sget(fs_type, cifs_match_super, cifs_set_super, flags, &mnt_data); 641 644 if (IS_ERR(sb)) { 642 645 root = ERR_CAST(sb); 643 646 cifs_umount(cifs_sb); ··· 651 648 cFYI(1, "Use existing superblock"); 652 649 cifs_umount(cifs_sb); 653 650 } else { 654 - sb->s_flags = flags; 655 - /* BB should we make this contingent on mount parm? */ 656 - sb->s_flags |= MS_NODIRATIME | MS_NOATIME; 657 - 658 651 rc = cifs_read_super(sb); 659 652 if (rc) { 660 653 root = ERR_PTR(rc);
+3 -3
fs/devpts/inode.c
··· 439 439 return ERR_PTR(error); 440 440 441 441 if (opts.newinstance) 442 - s = sget(fs_type, NULL, set_anon_super, NULL); 442 + s = sget(fs_type, NULL, set_anon_super, flags, NULL); 443 443 else 444 - s = sget(fs_type, compare_init_pts_sb, set_anon_super, NULL); 444 + s = sget(fs_type, compare_init_pts_sb, set_anon_super, flags, 445 + NULL); 445 446 446 447 if (IS_ERR(s)) 447 448 return ERR_CAST(s); 448 449 449 450 if (!s->s_root) { 450 - s->s_flags = flags; 451 451 error = devpts_fill_super(s, data, flags & MS_SILENT ? 1 : 0); 452 452 if (error) 453 453 goto out_undo_sget;
+1 -2
fs/ecryptfs/main.c
··· 499 499 goto out; 500 500 } 501 501 502 - s = sget(fs_type, NULL, set_anon_super, NULL); 502 + s = sget(fs_type, NULL, set_anon_super, flags, NULL); 503 503 if (IS_ERR(s)) { 504 504 rc = PTR_ERR(s); 505 505 goto out; 506 506 } 507 507 508 - s->s_flags = flags; 509 508 rc = bdi_setup_and_register(&sbi->bdi, "ecryptfs", BDI_CAP_MAP_COPY); 510 509 if (rc) 511 510 goto out1;
+2 -3
fs/gfs2/ops_fstype.c
··· 1286 1286 error = -EBUSY; 1287 1287 goto error_bdev; 1288 1288 } 1289 - s = sget(fs_type, test_gfs2_super, set_gfs2_super, bdev); 1289 + s = sget(fs_type, test_gfs2_super, set_gfs2_super, flags, bdev); 1290 1290 mutex_unlock(&bdev->bd_fsfreeze_mutex); 1291 1291 error = PTR_ERR(s); 1292 1292 if (IS_ERR(s)) ··· 1316 1316 } else { 1317 1317 char b[BDEVNAME_SIZE]; 1318 1318 1319 - s->s_flags = flags; 1320 1319 s->s_mode = mode; 1321 1320 strlcpy(s->s_id, bdevname(bdev, b), sizeof(s->s_id)); 1322 1321 sb_set_blocksize(s, block_size(bdev)); ··· 1359 1360 dev_name, error); 1360 1361 return ERR_PTR(error); 1361 1362 } 1362 - s = sget(&gfs2_fs_type, test_gfs2_super, set_meta_super, 1363 + s = sget(&gfs2_fs_type, test_gfs2_super, set_meta_super, flags, 1363 1364 path.dentry->d_inode->i_sb->s_bdev); 1364 1365 path_put(&path); 1365 1366 if (IS_ERR(s)) {
+2 -2
fs/libfs.c
··· 222 222 const struct super_operations *ops, 223 223 const struct dentry_operations *dops, unsigned long magic) 224 224 { 225 - struct super_block *s = sget(fs_type, NULL, set_anon_super, NULL); 225 + struct super_block *s; 226 226 struct dentry *dentry; 227 227 struct inode *root; 228 228 struct qstr d_name = QSTR_INIT(name, strlen(name)); 229 229 230 + s = sget(fs_type, NULL, set_anon_super, MS_NOUSER, NULL); 230 231 if (IS_ERR(s)) 231 232 return ERR_CAST(s); 232 233 233 - s->s_flags = MS_NOUSER; 234 234 s->s_maxbytes = MAX_LFS_FILESIZE; 235 235 s->s_blocksize = PAGE_SIZE; 236 236 s->s_blocksize_bits = PAGE_SHIFT;
+1 -2
fs/logfs/super.c
··· 519 519 log_super("LogFS: Start mount %x\n", mount_count++); 520 520 521 521 err = -EINVAL; 522 - sb = sget(type, logfs_sb_test, logfs_sb_set, super); 522 + sb = sget(type, logfs_sb_test, logfs_sb_set, flags | MS_NOATIME, super); 523 523 if (IS_ERR(sb)) { 524 524 super->s_devops->put_device(super); 525 525 kfree(super); ··· 542 542 sb->s_maxbytes = (1ull << 43) - 1; 543 543 sb->s_max_links = LOGFS_LINK_MAX; 544 544 sb->s_op = &logfs_super_operations; 545 - sb->s_flags = flags | MS_NOATIME; 546 545 547 546 err = logfs_read_sb(sb, sb->s_flags & MS_RDONLY); 548 547 if (err)
+1 -1
fs/nfs/super.c
··· 2419 2419 sb_mntdata.mntflags |= MS_SYNCHRONOUS; 2420 2420 2421 2421 /* Get a superblock - note that we may end up sharing one that already exists */ 2422 - s = sget(fs_type, compare_super, nfs_set_super, &sb_mntdata); 2422 + s = sget(fs_type, compare_super, nfs_set_super, flags, &sb_mntdata); 2423 2423 if (IS_ERR(s)) { 2424 2424 mntroot = ERR_CAST(s); 2425 2425 goto out_err_nosb;
+2 -2
fs/nilfs2/super.c
··· 1288 1288 err = -EBUSY; 1289 1289 goto failed; 1290 1290 } 1291 - s = sget(fs_type, nilfs_test_bdev_super, nilfs_set_bdev_super, sd.bdev); 1291 + s = sget(fs_type, nilfs_test_bdev_super, nilfs_set_bdev_super, flags, 1292 + sd.bdev); 1292 1293 mutex_unlock(&sd.bdev->bd_fsfreeze_mutex); 1293 1294 if (IS_ERR(s)) { 1294 1295 err = PTR_ERR(s); ··· 1302 1301 s_new = true; 1303 1302 1304 1303 /* New superblock instance created */ 1305 - s->s_flags = flags; 1306 1304 s->s_mode = mode; 1307 1305 strlcpy(s->s_id, bdevname(sd.bdev, b), sizeof(s->s_id)); 1308 1306 sb_set_blocksize(s, block_size(sd.bdev));
+1 -2
fs/proc/root.c
··· 111 111 options = data; 112 112 } 113 113 114 - sb = sget(fs_type, proc_test_super, proc_set_super, ns); 114 + sb = sget(fs_type, proc_test_super, proc_set_super, flags, ns); 115 115 if (IS_ERR(sb)) 116 116 return ERR_CAST(sb); 117 117 ··· 121 121 } 122 122 123 123 if (!sb->s_root) { 124 - sb->s_flags = flags; 125 124 err = proc_fill_super(sb); 126 125 if (err) { 127 126 deactivate_locked_super(sb);
+1 -1
fs/reiserfs/procfs.c
··· 403 403 if (l) 404 404 return NULL; 405 405 406 - if (IS_ERR(sget(&reiserfs_fs_type, test_sb, set_sb, s))) 406 + if (IS_ERR(sget(&reiserfs_fs_type, test_sb, set_sb, 0, s))) 407 407 return NULL; 408 408 409 409 up_write(&s->s_umount);
+11 -11
fs/super.c
··· 105 105 /** 106 106 * alloc_super - create new superblock 107 107 * @type: filesystem type superblock should belong to 108 + * @flags: the mount flags 108 109 * 109 110 * Allocates and initializes a new &struct super_block. alloc_super() 110 111 * returns a pointer new superblock or %NULL if allocation had failed. 111 112 */ 112 - static struct super_block *alloc_super(struct file_system_type *type) 113 + static struct super_block *alloc_super(struct file_system_type *type, int flags) 113 114 { 114 115 struct super_block *s = kzalloc(sizeof(struct super_block), GFP_USER); 115 116 static const struct super_operations default_op; ··· 137 136 #else 138 137 INIT_LIST_HEAD(&s->s_files); 139 138 #endif 139 + s->s_flags = flags; 140 140 s->s_bdi = &default_backing_dev_info; 141 141 INIT_HLIST_NODE(&s->s_instances); 142 142 INIT_HLIST_BL_HEAD(&s->s_anon); ··· 417 415 * @type: filesystem type superblock should belong to 418 416 * @test: comparison callback 419 417 * @set: setup callback 418 + * @flags: mount flags 420 419 * @data: argument to each of them 421 420 */ 422 421 struct super_block *sget(struct file_system_type *type, 423 422 int (*test)(struct super_block *,void *), 424 423 int (*set)(struct super_block *,void *), 424 + int flags, 425 425 void *data) 426 426 { 427 427 struct super_block *s = NULL; ··· 454 450 } 455 451 if (!s) { 456 452 spin_unlock(&sb_lock); 457 - s = alloc_super(type); 453 + s = alloc_super(type, flags); 458 454 if (!s) 459 455 return ERR_PTR(-ENOMEM); 460 456 goto retry; ··· 929 925 { 930 926 struct super_block *sb; 931 927 932 - sb = sget(fs_type, ns_test_super, ns_set_super, data); 928 + sb = sget(fs_type, ns_test_super, ns_set_super, flags, data); 933 929 if (IS_ERR(sb)) 934 930 return ERR_CAST(sb); 935 931 936 932 if (!sb->s_root) { 937 933 int err; 938 - sb->s_flags = flags; 939 934 err = fill_super(sb, data, flags & MS_SILENT ? 1 : 0); 940 935 if (err) { 941 936 deactivate_locked_super(sb); ··· 995 992 error = -EBUSY; 996 993 goto error_bdev; 997 994 } 998 - s = sget(fs_type, test_bdev_super, set_bdev_super, bdev); 995 + s = sget(fs_type, test_bdev_super, set_bdev_super, flags | MS_NOSEC, 996 + bdev); 999 997 mutex_unlock(&bdev->bd_fsfreeze_mutex); 1000 998 if (IS_ERR(s)) 1001 999 goto error_s; ··· 1021 1017 } else { 1022 1018 char b[BDEVNAME_SIZE]; 1023 1019 1024 - s->s_flags = flags | MS_NOSEC; 1025 1020 s->s_mode = mode; 1026 1021 strlcpy(s->s_id, bdevname(bdev, b), sizeof(s->s_id)); 1027 1022 sb_set_blocksize(s, block_size(bdev)); ··· 1065 1062 int (*fill_super)(struct super_block *, void *, int)) 1066 1063 { 1067 1064 int error; 1068 - struct super_block *s = sget(fs_type, NULL, set_anon_super, NULL); 1065 + struct super_block *s = sget(fs_type, NULL, set_anon_super, flags, NULL); 1069 1066 1070 1067 if (IS_ERR(s)) 1071 1068 return ERR_CAST(s); 1072 - 1073 - s->s_flags = flags; 1074 1069 1075 1070 error = fill_super(s, data, flags & MS_SILENT ? 1 : 0); 1076 1071 if (error) { ··· 1092 1091 struct super_block *s; 1093 1092 int error; 1094 1093 1095 - s = sget(fs_type, compare_single, set_anon_super, NULL); 1094 + s = sget(fs_type, compare_single, set_anon_super, flags, NULL); 1096 1095 if (IS_ERR(s)) 1097 1096 return ERR_CAST(s); 1098 1097 if (!s->s_root) { 1099 - s->s_flags = flags; 1100 1098 error = fill_super(s, data, flags & MS_SILENT ? 1 : 0); 1101 1099 if (error) { 1102 1100 deactivate_locked_super(s);
+1 -2
fs/sysfs/mount.c
··· 118 118 for (type = KOBJ_NS_TYPE_NONE; type < KOBJ_NS_TYPES; type++) 119 119 info->ns[type] = kobj_ns_grab_current(type); 120 120 121 - sb = sget(fs_type, sysfs_test_super, sysfs_set_super, info); 121 + sb = sget(fs_type, sysfs_test_super, sysfs_set_super, flags, info); 122 122 if (IS_ERR(sb) || sb->s_fs_info != info) 123 123 free_sysfs_super_info(info); 124 124 if (IS_ERR(sb)) 125 125 return ERR_CAST(sb); 126 126 if (!sb->s_root) { 127 - sb->s_flags = flags; 128 127 error = sysfs_fill_super(sb, data, flags & MS_SILENT ? 1 : 0); 129 128 if (error) { 130 129 deactivate_locked_super(sb);
+1 -2
fs/ubifs/super.c
··· 2136 2136 2137 2137 dbg_gen("opened ubi%d_%d", c->vi.ubi_num, c->vi.vol_id); 2138 2138 2139 - sb = sget(fs_type, sb_test, sb_set, c); 2139 + sb = sget(fs_type, sb_test, sb_set, flags, c); 2140 2140 if (IS_ERR(sb)) { 2141 2141 err = PTR_ERR(sb); 2142 2142 kfree(c); ··· 2153 2153 goto out_deact; 2154 2154 } 2155 2155 } else { 2156 - sb->s_flags = flags; 2157 2156 err = ubifs_fill_super(sb, data, flags & MS_SILENT ? 1 : 0); 2158 2157 if (err) 2159 2158 goto out_deact;
+1 -1
include/linux/fs.h
··· 1914 1914 struct super_block *sget(struct file_system_type *type, 1915 1915 int (*test)(struct super_block *,void *), 1916 1916 int (*set)(struct super_block *,void *), 1917 - void *data); 1917 + int flags, void *data); 1918 1918 extern struct dentry *mount_pseudo(struct file_system_type *, char *, 1919 1919 const struct super_operations *ops, 1920 1920 const struct dentry_operations *dops,
+1 -1
kernel/cgroup.c
··· 1587 1587 opts.new_root = new_root; 1588 1588 1589 1589 /* Locate an existing or new sb for this hierarchy */ 1590 - sb = sget(fs_type, cgroup_test_super, cgroup_set_super, &opts); 1590 + sb = sget(fs_type, cgroup_test_super, cgroup_set_super, 0, &opts); 1591 1591 if (IS_ERR(sb)) { 1592 1592 ret = PTR_ERR(sb); 1593 1593 cgroup_drop_root(opts.new_root);