diff options
author | David Howells <dhowells@redhat.com> | 2012-06-25 07:55:37 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-07-14 08:38:34 -0400 |
commit | 9249e17fe094d853d1ef7475dd559a2cc7e23d42 (patch) | |
tree | fa80a6044c14b38994d232c0e05cb7365800adf2 /fs/super.c | |
parent | f015f1267b23d3530d3f874243fb83cb5f443005 (diff) |
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>
Diffstat (limited to 'fs/super.c')
-rw-r--r-- | fs/super.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/fs/super.c b/fs/super.c index cf001775617f..c743fb3be4b8 100644 --- a/fs/super.c +++ b/fs/super.c | |||
@@ -105,11 +105,12 @@ static int prune_super(struct shrinker *shrink, struct shrink_control *sc) | |||
105 | /** | 105 | /** |
106 | * alloc_super - create new superblock | 106 | * alloc_super - create new superblock |
107 | * @type: filesystem type superblock should belong to | 107 | * @type: filesystem type superblock should belong to |
108 | * @flags: the mount flags | ||
108 | * | 109 | * |
109 | * Allocates and initializes a new &struct super_block. alloc_super() | 110 | * Allocates and initializes a new &struct super_block. alloc_super() |
110 | * returns a pointer new superblock or %NULL if allocation had failed. | 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 | struct super_block *s = kzalloc(sizeof(struct super_block), GFP_USER); | 115 | struct super_block *s = kzalloc(sizeof(struct super_block), GFP_USER); |
115 | static const struct super_operations default_op; | 116 | static const struct super_operations default_op; |
@@ -136,6 +137,7 @@ static struct super_block *alloc_super(struct file_system_type *type) | |||
136 | #else | 137 | #else |
137 | INIT_LIST_HEAD(&s->s_files); | 138 | INIT_LIST_HEAD(&s->s_files); |
138 | #endif | 139 | #endif |
140 | s->s_flags = flags; | ||
139 | s->s_bdi = &default_backing_dev_info; | 141 | s->s_bdi = &default_backing_dev_info; |
140 | INIT_HLIST_NODE(&s->s_instances); | 142 | INIT_HLIST_NODE(&s->s_instances); |
141 | INIT_HLIST_BL_HEAD(&s->s_anon); | 143 | INIT_HLIST_BL_HEAD(&s->s_anon); |
@@ -415,11 +417,13 @@ EXPORT_SYMBOL(generic_shutdown_super); | |||
415 | * @type: filesystem type superblock should belong to | 417 | * @type: filesystem type superblock should belong to |
416 | * @test: comparison callback | 418 | * @test: comparison callback |
417 | * @set: setup callback | 419 | * @set: setup callback |
420 | * @flags: mount flags | ||
418 | * @data: argument to each of them | 421 | * @data: argument to each of them |
419 | */ | 422 | */ |
420 | struct super_block *sget(struct file_system_type *type, | 423 | struct super_block *sget(struct file_system_type *type, |
421 | int (*test)(struct super_block *,void *), | 424 | int (*test)(struct super_block *,void *), |
422 | int (*set)(struct super_block *,void *), | 425 | int (*set)(struct super_block *,void *), |
426 | int flags, | ||
423 | void *data) | 427 | void *data) |
424 | { | 428 | { |
425 | struct super_block *s = NULL; | 429 | struct super_block *s = NULL; |
@@ -450,7 +454,7 @@ retry: | |||
450 | } | 454 | } |
451 | if (!s) { | 455 | if (!s) { |
452 | spin_unlock(&sb_lock); | 456 | spin_unlock(&sb_lock); |
453 | s = alloc_super(type); | 457 | s = alloc_super(type, flags); |
454 | if (!s) | 458 | if (!s) |
455 | return ERR_PTR(-ENOMEM); | 459 | return ERR_PTR(-ENOMEM); |
456 | goto retry; | 460 | goto retry; |
@@ -925,13 +929,12 @@ struct dentry *mount_ns(struct file_system_type *fs_type, int flags, | |||
925 | { | 929 | { |
926 | struct super_block *sb; | 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 | if (IS_ERR(sb)) | 933 | if (IS_ERR(sb)) |
930 | return ERR_CAST(sb); | 934 | return ERR_CAST(sb); |
931 | 935 | ||
932 | if (!sb->s_root) { | 936 | if (!sb->s_root) { |
933 | int err; | 937 | int err; |
934 | sb->s_flags = flags; | ||
935 | err = fill_super(sb, data, flags & MS_SILENT ? 1 : 0); | 938 | err = fill_super(sb, data, flags & MS_SILENT ? 1 : 0); |
936 | if (err) { | 939 | if (err) { |
937 | deactivate_locked_super(sb); | 940 | deactivate_locked_super(sb); |
@@ -992,7 +995,8 @@ struct dentry *mount_bdev(struct file_system_type *fs_type, | |||
992 | error = -EBUSY; | 995 | error = -EBUSY; |
993 | goto error_bdev; | 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 | mutex_unlock(&bdev->bd_fsfreeze_mutex); | 1000 | mutex_unlock(&bdev->bd_fsfreeze_mutex); |
997 | if (IS_ERR(s)) | 1001 | if (IS_ERR(s)) |
998 | goto error_s; | 1002 | goto error_s; |
@@ -1017,7 +1021,6 @@ struct dentry *mount_bdev(struct file_system_type *fs_type, | |||
1017 | } else { | 1021 | } else { |
1018 | char b[BDEVNAME_SIZE]; | 1022 | char b[BDEVNAME_SIZE]; |
1019 | 1023 | ||
1020 | s->s_flags = flags | MS_NOSEC; | ||
1021 | s->s_mode = mode; | 1024 | s->s_mode = mode; |
1022 | strlcpy(s->s_id, bdevname(bdev, b), sizeof(s->s_id)); | 1025 | strlcpy(s->s_id, bdevname(bdev, b), sizeof(s->s_id)); |
1023 | sb_set_blocksize(s, block_size(bdev)); | 1026 | sb_set_blocksize(s, block_size(bdev)); |
@@ -1062,13 +1065,11 @@ struct dentry *mount_nodev(struct file_system_type *fs_type, | |||
1062 | int (*fill_super)(struct super_block *, void *, int)) | 1065 | int (*fill_super)(struct super_block *, void *, int)) |
1063 | { | 1066 | { |
1064 | int error; | 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 | if (IS_ERR(s)) | 1070 | if (IS_ERR(s)) |
1068 | return ERR_CAST(s); | 1071 | return ERR_CAST(s); |
1069 | 1072 | ||
1070 | s->s_flags = flags; | ||
1071 | |||
1072 | error = fill_super(s, data, flags & MS_SILENT ? 1 : 0); | 1073 | error = fill_super(s, data, flags & MS_SILENT ? 1 : 0); |
1073 | if (error) { | 1074 | if (error) { |
1074 | deactivate_locked_super(s); | 1075 | deactivate_locked_super(s); |
@@ -1091,11 +1092,10 @@ struct dentry *mount_single(struct file_system_type *fs_type, | |||
1091 | struct super_block *s; | 1092 | struct super_block *s; |
1092 | int error; | 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 | if (IS_ERR(s)) | 1096 | if (IS_ERR(s)) |
1096 | return ERR_CAST(s); | 1097 | return ERR_CAST(s); |
1097 | if (!s->s_root) { | 1098 | if (!s->s_root) { |
1098 | s->s_flags = flags; | ||
1099 | error = fill_super(s, data, flags & MS_SILENT ? 1 : 0); | 1099 | error = fill_super(s, data, flags & MS_SILENT ? 1 : 0); |
1100 | if (error) { | 1100 | if (error) { |
1101 | deactivate_locked_super(s); | 1101 | deactivate_locked_super(s); |