Commit 9249e17fe094d853d1ef7475dd559a2cc7e23d42
Committed by
Al Viro
1 parent
f015f1267b
Exists in
master
and in
20 other branches
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>
Showing 20 changed files with 40 additions and 50 deletions Side-by-side Diff
- drivers/mtd/mtdsuper.c
- fs/9p/vfs_super.c
- fs/afs/super.c
- fs/btrfs/super.c
- fs/ceph/super.c
- fs/cifs/cifsfs.c
- fs/devpts/inode.c
- fs/ecryptfs/main.c
- fs/gfs2/ops_fstype.c
- fs/libfs.c
- fs/logfs/super.c
- fs/nfs/super.c
- fs/nilfs2/super.c
- fs/proc/root.c
- fs/reiserfs/procfs.c
- fs/super.c
- fs/sysfs/mount.c
- fs/ubifs/super.c
- include/linux/fs.h
- kernel/cgroup.c
drivers/mtd/mtdsuper.c
... | ... | @@ -63,7 +63,7 @@ |
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,8 +73,6 @@ |
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) { |
fs/9p/vfs_super.c
... | ... | @@ -89,7 +89,7 @@ |
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,7 +137,7 @@ |
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; |
fs/afs/super.c
... | ... | @@ -395,7 +395,7 @@ |
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,7 +406,6 @@ |
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, ¶ms); |
411 | 410 | if (ret < 0) { |
412 | 411 | deactivate_locked_super(sb); |
fs/btrfs/super.c
... | ... | @@ -1068,7 +1068,8 @@ |
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; |
... | ... | @@ -1082,7 +1083,6 @@ |
1082 | 1083 | } else { |
1083 | 1084 | char b[BDEVNAME_SIZE]; |
1084 | 1085 | |
1085 | - s->s_flags = flags | MS_NOSEC; | |
1086 | 1086 | strlcpy(s->s_id, bdevname(bdev, b), sizeof(s->s_id)); |
1087 | 1087 | btrfs_sb(s)->bdev_holder = fs_type; |
1088 | 1088 | error = btrfs_fill_super(s, fs_devices, data, |
fs/ceph/super.c
... | ... | @@ -871,7 +871,7 @@ |
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; |
fs/cifs/cifsfs.c
... | ... | @@ -637,7 +637,10 @@ |
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); |
... | ... | @@ -648,10 +651,6 @@ |
648 | 651 | cFYI(1, "Use existing superblock"); |
649 | 652 | cifs_umount(cifs_sb); |
650 | 653 | } else { |
651 | - sb->s_flags = flags; | |
652 | - /* BB should we make this contingent on mount parm? */ | |
653 | - sb->s_flags |= MS_NODIRATIME | MS_NOATIME; | |
654 | - | |
655 | 654 | rc = cifs_read_super(sb); |
656 | 655 | if (rc) { |
657 | 656 | root = ERR_PTR(rc); |
fs/devpts/inode.c
... | ... | @@ -439,15 +439,15 @@ |
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; |
fs/ecryptfs/main.c
... | ... | @@ -499,13 +499,12 @@ |
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; |
fs/gfs2/ops_fstype.c
... | ... | @@ -1286,7 +1286,7 @@ |
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,7 +1316,6 @@ |
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)); |
... | ... | @@ -1360,7 +1359,7 @@ |
1360 | 1359 | dev_name, error); |
1361 | 1360 | return ERR_PTR(error); |
1362 | 1361 | } |
1363 | - s = sget(&gfs2_fs_type, test_gfs2_super, set_meta_super, | |
1362 | + s = sget(&gfs2_fs_type, test_gfs2_super, set_meta_super, flags, | |
1364 | 1363 | path.dentry->d_inode->i_sb->s_bdev); |
1365 | 1364 | path_put(&path); |
1366 | 1365 | if (IS_ERR(s)) { |
fs/libfs.c
... | ... | @@ -222,15 +222,15 @@ |
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; |
fs/logfs/super.c
... | ... | @@ -519,7 +519,7 @@ |
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,7 +542,6 @@ |
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) |
fs/nfs/super.c
... | ... | @@ -2419,7 +2419,7 @@ |
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; |
fs/nilfs2/super.c
... | ... | @@ -1288,7 +1288,8 @@ |
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); |
... | ... | @@ -1301,7 +1302,6 @@ |
1301 | 1302 | s_new = true; |
1302 | 1303 | |
1303 | 1304 | /* New superblock instance created */ |
1304 | - s->s_flags = flags; | |
1305 | 1305 | s->s_mode = mode; |
1306 | 1306 | strlcpy(s->s_id, bdevname(sd.bdev, b), sizeof(s->s_id)); |
1307 | 1307 | sb_set_blocksize(s, block_size(sd.bdev)); |
fs/proc/root.c
... | ... | @@ -111,7 +111,7 @@ |
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,7 +121,6 @@ |
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); |
fs/reiserfs/procfs.c
fs/super.c
... | ... | @@ -105,11 +105,12 @@ |
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; |
... | ... | @@ -136,6 +137,7 @@ |
136 | 137 | #else |
137 | 138 | INIT_LIST_HEAD(&s->s_files); |
138 | 139 | #endif |
140 | + s->s_flags = flags; | |
139 | 141 | s->s_bdi = &default_backing_dev_info; |
140 | 142 | INIT_HLIST_NODE(&s->s_instances); |
141 | 143 | INIT_HLIST_BL_HEAD(&s->s_anon); |
142 | 144 | |
... | ... | @@ -415,11 +417,13 @@ |
415 | 417 | * @type: filesystem type superblock should belong to |
416 | 418 | * @test: comparison callback |
417 | 419 | * @set: setup callback |
420 | + * @flags: mount flags | |
418 | 421 | * @data: argument to each of them |
419 | 422 | */ |
420 | 423 | struct super_block *sget(struct file_system_type *type, |
421 | 424 | int (*test)(struct super_block *,void *), |
422 | 425 | int (*set)(struct super_block *,void *), |
426 | + int flags, | |
423 | 427 | void *data) |
424 | 428 | { |
425 | 429 | struct super_block *s = NULL; |
... | ... | @@ -450,7 +454,7 @@ |
450 | 454 | } |
451 | 455 | if (!s) { |
452 | 456 | spin_unlock(&sb_lock); |
453 | - s = alloc_super(type); | |
457 | + s = alloc_super(type, flags); | |
454 | 458 | if (!s) |
455 | 459 | return ERR_PTR(-ENOMEM); |
456 | 460 | goto retry; |
457 | 461 | |
... | ... | @@ -925,13 +929,12 @@ |
925 | 929 | { |
926 | 930 | struct super_block *sb; |
927 | 931 | |
928 | - sb = sget(fs_type, ns_test_super, ns_set_super, data); | |
932 | + sb = sget(fs_type, ns_test_super, ns_set_super, flags, data); | |
929 | 933 | if (IS_ERR(sb)) |
930 | 934 | return ERR_CAST(sb); |
931 | 935 | |
932 | 936 | if (!sb->s_root) { |
933 | 937 | int err; |
934 | - sb->s_flags = flags; | |
935 | 938 | err = fill_super(sb, data, flags & MS_SILENT ? 1 : 0); |
936 | 939 | if (err) { |
937 | 940 | deactivate_locked_super(sb); |
... | ... | @@ -992,7 +995,8 @@ |
992 | 995 | error = -EBUSY; |
993 | 996 | goto error_bdev; |
994 | 997 | } |
995 | - s = sget(fs_type, test_bdev_super, set_bdev_super, bdev); | |
998 | + s = sget(fs_type, test_bdev_super, set_bdev_super, flags | MS_NOSEC, | |
999 | + bdev); | |
996 | 1000 | mutex_unlock(&bdev->bd_fsfreeze_mutex); |
997 | 1001 | if (IS_ERR(s)) |
998 | 1002 | goto error_s; |
... | ... | @@ -1017,7 +1021,6 @@ |
1017 | 1021 | } else { |
1018 | 1022 | char b[BDEVNAME_SIZE]; |
1019 | 1023 | |
1020 | - s->s_flags = flags | MS_NOSEC; | |
1021 | 1024 | s->s_mode = mode; |
1022 | 1025 | strlcpy(s->s_id, bdevname(bdev, b), sizeof(s->s_id)); |
1023 | 1026 | sb_set_blocksize(s, block_size(bdev)); |
1024 | 1027 | |
... | ... | @@ -1062,13 +1065,11 @@ |
1062 | 1065 | int (*fill_super)(struct super_block *, void *, int)) |
1063 | 1066 | { |
1064 | 1067 | int error; |
1065 | - struct super_block *s = sget(fs_type, NULL, set_anon_super, NULL); | |
1068 | + struct super_block *s = sget(fs_type, NULL, set_anon_super, flags, NULL); | |
1066 | 1069 | |
1067 | 1070 | if (IS_ERR(s)) |
1068 | 1071 | return ERR_CAST(s); |
1069 | 1072 | |
1070 | - s->s_flags = flags; | |
1071 | - | |
1072 | 1073 | error = fill_super(s, data, flags & MS_SILENT ? 1 : 0); |
1073 | 1074 | if (error) { |
1074 | 1075 | deactivate_locked_super(s); |
1075 | 1076 | |
... | ... | @@ -1091,11 +1092,10 @@ |
1091 | 1092 | struct super_block *s; |
1092 | 1093 | int error; |
1093 | 1094 | |
1094 | - s = sget(fs_type, compare_single, set_anon_super, NULL); | |
1095 | + s = sget(fs_type, compare_single, set_anon_super, flags, NULL); | |
1095 | 1096 | if (IS_ERR(s)) |
1096 | 1097 | return ERR_CAST(s); |
1097 | 1098 | if (!s->s_root) { |
1098 | - s->s_flags = flags; | |
1099 | 1099 | error = fill_super(s, data, flags & MS_SILENT ? 1 : 0); |
1100 | 1100 | if (error) { |
1101 | 1101 | deactivate_locked_super(s); |
fs/sysfs/mount.c
... | ... | @@ -118,13 +118,12 @@ |
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); |
fs/ubifs/super.c
... | ... | @@ -2136,7 +2136,7 @@ |
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,7 +2153,6 @@ |
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; |
include/linux/fs.h
... | ... | @@ -1914,7 +1914,7 @@ |
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, |
kernel/cgroup.c
... | ... | @@ -1587,7 +1587,7 @@ |
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); |