@@ -307,7 +307,7 @@ static const struct constant_table btrfs_parameter_fragment[] = {
307
307
};
308
308
#endif
309
309
310
- static const struct fs_parameter_spec btrfs_fs_parameters [] __maybe_unused = {
310
+ static const struct fs_parameter_spec btrfs_fs_parameters [] = {
311
311
fsparam_flag_no ("acl" , Opt_acl ),
312
312
fsparam_flag_no ("autodefrag" , Opt_defrag ),
313
313
fsparam_flag_no ("barrier" , Opt_barrier ),
@@ -738,8 +738,8 @@ static bool check_ro_option(struct btrfs_fs_info *fs_info,
738
738
return false;
739
739
}
740
740
741
- static bool check_options (struct btrfs_fs_info * info , unsigned long * mount_opt ,
742
- unsigned long flags )
741
+ bool btrfs_check_options (struct btrfs_fs_info * info , unsigned long * mount_opt ,
742
+ unsigned long flags )
743
743
{
744
744
bool ret = true;
745
745
@@ -788,18 +788,6 @@ static bool check_options(struct btrfs_fs_info *info, unsigned long *mount_opt,
788
788
*/
789
789
void btrfs_set_free_space_cache_settings (struct btrfs_fs_info * fs_info )
790
790
{
791
- if (btrfs_fs_compat_ro (fs_info , FREE_SPACE_TREE ))
792
- btrfs_set_opt (fs_info -> mount_opt , FREE_SPACE_TREE );
793
- else if (btrfs_free_space_cache_v1_active (fs_info )) {
794
- if (btrfs_is_zoned (fs_info )) {
795
- btrfs_info (fs_info ,
796
- "zoned: clearing existing space cache" );
797
- btrfs_set_super_cache_generation (fs_info -> super_copy , 0 );
798
- } else {
799
- btrfs_set_opt (fs_info -> mount_opt , SPACE_CACHE );
800
- }
801
- }
802
-
803
791
if (fs_info -> sectorsize < PAGE_SIZE ) {
804
792
btrfs_clear_opt (fs_info -> mount_opt , SPACE_CACHE );
805
793
if (!btrfs_test_opt (fs_info , FREE_SPACE_TREE )) {
@@ -809,6 +797,35 @@ void btrfs_set_free_space_cache_settings(struct btrfs_fs_info *fs_info)
809
797
btrfs_set_opt (fs_info -> mount_opt , FREE_SPACE_TREE );
810
798
}
811
799
}
800
+
801
+ /*
802
+ * At this point our mount options are populated, so we only mess with
803
+ * these settings if we don't have any settings already.
804
+ */
805
+ if (btrfs_test_opt (fs_info , FREE_SPACE_TREE ))
806
+ return ;
807
+
808
+ if (btrfs_is_zoned (fs_info ) &&
809
+ btrfs_free_space_cache_v1_active (fs_info )) {
810
+ btrfs_info (fs_info , "zoned: clearing existing space cache" );
811
+ btrfs_set_super_cache_generation (fs_info -> super_copy , 0 );
812
+ return ;
813
+ }
814
+
815
+ if (btrfs_test_opt (fs_info , SPACE_CACHE ))
816
+ return ;
817
+
818
+ if (btrfs_test_opt (fs_info , NOSPACECACHE ))
819
+ return ;
820
+
821
+ /*
822
+ * At this point we don't have explicit options set by the user, set
823
+ * them ourselves based on the state of the file system.
824
+ */
825
+ if (btrfs_fs_compat_ro (fs_info , FREE_SPACE_TREE ))
826
+ btrfs_set_opt (fs_info -> mount_opt , FREE_SPACE_TREE );
827
+ else if (btrfs_free_space_cache_v1_active (fs_info ))
828
+ btrfs_set_opt (fs_info -> mount_opt , SPACE_CACHE );
812
829
}
813
830
814
831
static int parse_rescue_options (struct btrfs_fs_info * info , const char * options )
@@ -1345,7 +1362,7 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
1345
1362
}
1346
1363
}
1347
1364
out :
1348
- if (!ret && !check_options (info , & info -> mount_opt , new_flags ))
1365
+ if (!ret && !btrfs_check_options (info , & info -> mount_opt , new_flags ))
1349
1366
ret = - EINVAL ;
1350
1367
return ret ;
1351
1368
}
@@ -1646,10 +1663,6 @@ static int btrfs_fill_super(struct super_block *sb,
1646
1663
#endif
1647
1664
sb -> s_xattr = btrfs_xattr_handlers ;
1648
1665
sb -> s_time_gran = 1 ;
1649
- #ifdef CONFIG_BTRFS_FS_POSIX_ACL
1650
- sb -> s_flags |= SB_POSIXACL ;
1651
- #endif
1652
- sb -> s_flags |= SB_I_VERSION ;
1653
1666
sb -> s_iflags |= SB_I_CGROUPWB ;
1654
1667
1655
1668
err = super_setup_bdi (sb );
@@ -1929,7 +1942,7 @@ static struct dentry *mount_subvol(const char *subvol_name, u64 subvol_objectid,
1929
1942
* Note: This is based on mount_bdev from fs/super.c with a few additions
1930
1943
* for multiple device setup. Make sure to keep it in sync.
1931
1944
*/
1932
- static struct dentry * btrfs_mount_root (struct file_system_type * fs_type ,
1945
+ static __maybe_unused struct dentry * btrfs_mount_root (struct file_system_type * fs_type ,
1933
1946
int flags , const char * device_name , void * data )
1934
1947
{
1935
1948
struct block_device * bdev = NULL ;
@@ -2062,7 +2075,7 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type,
2062
2075
* 3. Call mount_subvol() to get the dentry of subvolume. Since there is
2063
2076
* "btrfs subvolume set-default", mount_subvol() is called always.
2064
2077
*/
2065
- static struct dentry * btrfs_mount (struct file_system_type * fs_type , int flags ,
2078
+ static __maybe_unused struct dentry * btrfs_mount (struct file_system_type * fs_type , int flags ,
2066
2079
const char * device_name , void * data )
2067
2080
{
2068
2081
struct vfsmount * mnt_root ;
@@ -2485,7 +2498,7 @@ static int btrfs_reconfigure(struct fs_context *fc)
2485
2498
set_bit (BTRFS_FS_STATE_REMOUNTING , & fs_info -> fs_state );
2486
2499
2487
2500
if (!mount_reconfigure &&
2488
- !check_options (fs_info , & ctx -> mount_opt , fc -> sb_flags ))
2501
+ !btrfs_check_options (fs_info , & ctx -> mount_opt , fc -> sb_flags ))
2489
2502
return - EINVAL ;
2490
2503
2491
2504
ret = btrfs_check_features (fs_info , !(fc -> sb_flags & SB_RDONLY ));
@@ -3147,7 +3160,7 @@ static const struct fs_context_operations btrfs_fs_context_ops = {
3147
3160
.free = btrfs_free_fs_context ,
3148
3161
};
3149
3162
3150
- static int __maybe_unused btrfs_init_fs_context (struct fs_context * fc )
3163
+ static int btrfs_init_fs_context (struct fs_context * fc )
3151
3164
{
3152
3165
struct btrfs_fs_context * ctx ;
3153
3166
@@ -3168,24 +3181,22 @@ static int __maybe_unused btrfs_init_fs_context(struct fs_context *fc)
3168
3181
ctx -> commit_interval = BTRFS_DEFAULT_COMMIT_INTERVAL ;
3169
3182
}
3170
3183
3184
+ #ifdef CONFIG_BTRFS_FS_POSIX_ACL
3185
+ fc -> sb_flags |= SB_POSIXACL ;
3186
+ #endif
3187
+ fc -> sb_flags |= SB_I_VERSION ;
3188
+
3171
3189
return 0 ;
3172
3190
}
3173
3191
3174
3192
static struct file_system_type btrfs_fs_type = {
3175
- .owner = THIS_MODULE ,
3176
- .name = "btrfs" ,
3177
- .mount = btrfs_mount ,
3178
- .kill_sb = btrfs_kill_super ,
3179
- .fs_flags = FS_REQUIRES_DEV | FS_BINARY_MOUNTDATA ,
3180
- };
3181
-
3182
- static struct file_system_type btrfs_root_fs_type = {
3183
- .owner = THIS_MODULE ,
3184
- .name = "btrfs" ,
3185
- .mount = btrfs_mount_root ,
3186
- .kill_sb = btrfs_kill_super ,
3187
- .fs_flags = FS_REQUIRES_DEV | FS_BINARY_MOUNTDATA | FS_ALLOW_IDMAP ,
3188
- };
3193
+ .owner = THIS_MODULE ,
3194
+ .name = "btrfs" ,
3195
+ .init_fs_context = btrfs_init_fs_context ,
3196
+ .parameters = btrfs_fs_parameters ,
3197
+ .kill_sb = btrfs_kill_super ,
3198
+ .fs_flags = FS_REQUIRES_DEV | FS_BINARY_MOUNTDATA | FS_ALLOW_IDMAP ,
3199
+ };
3189
3200
3190
3201
MODULE_ALIAS_FS ("btrfs" );
3191
3202
@@ -3398,7 +3409,6 @@ static const struct super_operations btrfs_super_ops = {
3398
3409
.destroy_inode = btrfs_destroy_inode ,
3399
3410
.free_inode = btrfs_free_inode ,
3400
3411
.statfs = btrfs_statfs ,
3401
- .remount_fs = btrfs_remount ,
3402
3412
.freeze_fs = btrfs_freeze ,
3403
3413
.unfreeze_fs = btrfs_unfreeze ,
3404
3414
};
0 commit comments