@@ -532,6 +532,14 @@ static int f2fs_unnote_qf_name(struct fs_context *fc, int qtype)
532
532
ctx -> qname_mask |= 1 << qtype ;
533
533
return 0 ;
534
534
}
535
+
536
+ static void f2fs_unnote_qf_name_all (struct fs_context * fc )
537
+ {
538
+ int i ;
539
+
540
+ for (i = 0 ; i < MAXQUOTAS ; i ++ )
541
+ f2fs_unnote_qf_name (fc , i );
542
+ }
535
543
#endif
536
544
537
545
static int f2fs_parse_test_dummy_encryption (const struct fs_parameter * param ,
@@ -1139,47 +1147,6 @@ static int f2fs_parse_param(struct fs_context *fc, struct fs_parameter *param)
1139
1147
return 0 ;
1140
1148
}
1141
1149
1142
- static int parse_options (struct fs_context * fc , char * options )
1143
- {
1144
- struct fs_parameter param ;
1145
- char * key ;
1146
- int ret ;
1147
-
1148
- if (!options )
1149
- return 0 ;
1150
-
1151
- while ((key = strsep (& options , "," )) != NULL ) {
1152
- if (* key ) {
1153
- size_t v_len = 0 ;
1154
- char * value = strchr (key , '=' );
1155
-
1156
- param .type = fs_value_is_flag ;
1157
- param .string = NULL ;
1158
-
1159
- if (value ) {
1160
- if (value == key )
1161
- continue ;
1162
-
1163
- * value ++ = 0 ;
1164
- v_len = strlen (value );
1165
- param .string = kmemdup_nul (value , v_len , GFP_KERNEL );
1166
- if (!param .string )
1167
- return - ENOMEM ;
1168
- param .type = fs_value_is_string ;
1169
- }
1170
-
1171
- param .key = key ;
1172
- param .size = v_len ;
1173
-
1174
- ret = f2fs_parse_param (fc , & param );
1175
- kfree (param .string );
1176
- if (ret < 0 )
1177
- return ret ;
1178
- }
1179
- }
1180
- return 0 ;
1181
- }
1182
-
1183
1150
/*
1184
1151
* Check quota settings consistency.
1185
1152
*/
@@ -2621,13 +2588,12 @@ static void f2fs_enable_checkpoint(struct f2fs_sb_info *sbi)
2621
2588
f2fs_flush_ckpt_thread (sbi );
2622
2589
}
2623
2590
2624
- static int f2fs_remount (struct super_block * sb , int * flags , char * data )
2591
+ static int __f2fs_remount (struct fs_context * fc , struct super_block * sb )
2625
2592
{
2626
2593
struct f2fs_sb_info * sbi = F2FS_SB (sb );
2627
2594
struct f2fs_mount_info org_mount_opt ;
2628
- struct f2fs_fs_context ctx ;
2629
- struct fs_context fc ;
2630
2595
unsigned long old_sb_flags ;
2596
+ unsigned int flags = fc -> sb_flags ;
2631
2597
int err ;
2632
2598
bool need_restart_gc = false, need_stop_gc = false;
2633
2599
bool need_restart_flush = false, need_stop_flush = false;
@@ -2673,7 +2639,7 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
2673
2639
#endif
2674
2640
2675
2641
/* recover superblocks we couldn't write due to previous RO mount */
2676
- if (!(* flags & SB_RDONLY ) && is_sbi_flag_set (sbi , SBI_NEED_SB_WRITE )) {
2642
+ if (!(flags & SB_RDONLY ) && is_sbi_flag_set (sbi , SBI_NEED_SB_WRITE )) {
2677
2643
err = f2fs_commit_super (sbi , false);
2678
2644
f2fs_info (sbi , "Try to recover all the superblocks, ret: %d" ,
2679
2645
err );
@@ -2683,21 +2649,11 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
2683
2649
2684
2650
default_options (sbi , true);
2685
2651
2686
- memset (& fc , 0 , sizeof (fc ));
2687
- memset (& ctx , 0 , sizeof (ctx ));
2688
- fc .fs_private = & ctx ;
2689
- fc .purpose = FS_CONTEXT_FOR_RECONFIGURE ;
2690
-
2691
- /* parse mount options */
2692
- err = parse_options (& fc , data );
2652
+ err = f2fs_check_opt_consistency (fc , sb );
2693
2653
if (err )
2694
2654
goto restore_opts ;
2695
2655
2696
- err = f2fs_check_opt_consistency (& fc , sb );
2697
- if (err )
2698
- goto restore_opts ;
2699
-
2700
- f2fs_apply_options (& fc , sb );
2656
+ f2fs_apply_options (fc , sb );
2701
2657
2702
2658
err = f2fs_sanity_check_options (sbi , true);
2703
2659
if (err )
@@ -2710,20 +2666,20 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
2710
2666
* Previous and new state of filesystem is RO,
2711
2667
* so skip checking GC and FLUSH_MERGE conditions.
2712
2668
*/
2713
- if (f2fs_readonly (sb ) && (* flags & SB_RDONLY ))
2669
+ if (f2fs_readonly (sb ) && (flags & SB_RDONLY ))
2714
2670
goto skip ;
2715
2671
2716
- if (f2fs_dev_is_readonly (sbi ) && !(* flags & SB_RDONLY )) {
2672
+ if (f2fs_dev_is_readonly (sbi ) && !(flags & SB_RDONLY )) {
2717
2673
err = - EROFS ;
2718
2674
goto restore_opts ;
2719
2675
}
2720
2676
2721
2677
#ifdef CONFIG_QUOTA
2722
- if (!f2fs_readonly (sb ) && (* flags & SB_RDONLY )) {
2678
+ if (!f2fs_readonly (sb ) && (flags & SB_RDONLY )) {
2723
2679
err = dquot_suspend (sb , -1 );
2724
2680
if (err < 0 )
2725
2681
goto restore_opts ;
2726
- } else if (f2fs_readonly (sb ) && !(* flags & SB_RDONLY )) {
2682
+ } else if (f2fs_readonly (sb ) && !(flags & SB_RDONLY )) {
2727
2683
/* dquot_resume needs RW */
2728
2684
sb -> s_flags &= ~SB_RDONLY ;
2729
2685
if (sb_any_quota_suspended (sb )) {
@@ -2773,7 +2729,7 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
2773
2729
goto restore_opts ;
2774
2730
}
2775
2731
2776
- if ((* flags & SB_RDONLY ) && test_opt (sbi , DISABLE_CHECKPOINT )) {
2732
+ if ((flags & SB_RDONLY ) && test_opt (sbi , DISABLE_CHECKPOINT )) {
2777
2733
err = - EINVAL ;
2778
2734
f2fs_warn (sbi , "disabling checkpoint not compatible with read-only" );
2779
2735
goto restore_opts ;
@@ -2784,7 +2740,7 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
2784
2740
* or if background_gc = off is passed in mount
2785
2741
* option. Also sync the filesystem.
2786
2742
*/
2787
- if ((* flags & SB_RDONLY ) ||
2743
+ if ((flags & SB_RDONLY ) ||
2788
2744
(F2FS_OPTION (sbi ).bggc_mode == BGGC_MODE_OFF &&
2789
2745
!test_opt (sbi , GC_MERGE ))) {
2790
2746
if (sbi -> gc_thread ) {
@@ -2798,7 +2754,7 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
2798
2754
need_stop_gc = true;
2799
2755
}
2800
2756
2801
- if (* flags & SB_RDONLY ) {
2757
+ if (flags & SB_RDONLY ) {
2802
2758
sync_inodes_sb (sb );
2803
2759
2804
2760
set_sbi_flag (sbi , SBI_IS_DIRTY );
@@ -2811,7 +2767,7 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
2811
2767
* We stop issue flush thread if FS is mounted as RO
2812
2768
* or if flush_merge is not passed in mount option.
2813
2769
*/
2814
- if ((* flags & SB_RDONLY ) || !test_opt (sbi , FLUSH_MERGE )) {
2770
+ if ((flags & SB_RDONLY ) || !test_opt (sbi , FLUSH_MERGE )) {
2815
2771
clear_opt (sbi , FLUSH_MERGE );
2816
2772
f2fs_destroy_flush_cmd_control (sbi , false);
2817
2773
need_restart_flush = true;
@@ -2853,7 +2809,7 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
2853
2809
* triggered while remount and we need to take care of it before
2854
2810
* returning from remount.
2855
2811
*/
2856
- if ((* flags & SB_RDONLY ) || test_opt (sbi , DISABLE_CHECKPOINT ) ||
2812
+ if ((flags & SB_RDONLY ) || test_opt (sbi , DISABLE_CHECKPOINT ) ||
2857
2813
!test_opt (sbi , MERGE_CHECKPOINT )) {
2858
2814
f2fs_stop_ckpt_thread (sbi );
2859
2815
} else {
@@ -2880,7 +2836,7 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
2880
2836
(test_opt (sbi , POSIX_ACL ) ? SB_POSIXACL : 0 );
2881
2837
2882
2838
limit_reserve_root (sbi );
2883
- * flags = (* flags & ~SB_LAZYTIME ) | (sb -> s_flags & SB_LAZYTIME );
2839
+ fc -> sb_flags = (flags & ~SB_LAZYTIME ) | (sb -> s_flags & SB_LAZYTIME );
2884
2840
2885
2841
sbi -> umount_lock_holder = NULL ;
2886
2842
return 0 ;
@@ -3551,7 +3507,6 @@ static const struct super_operations f2fs_sops = {
3551
3507
.freeze_fs = f2fs_freeze ,
3552
3508
.unfreeze_fs = f2fs_unfreeze ,
3553
3509
.statfs = f2fs_statfs ,
3554
- .remount_fs = f2fs_remount ,
3555
3510
.shutdown = f2fs_shutdown ,
3556
3511
};
3557
3512
@@ -4811,16 +4766,14 @@ static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi)
4811
4766
sbi -> readdir_ra = true;
4812
4767
}
4813
4768
4814
- static int f2fs_fill_super (struct super_block * sb , void * data , int silent )
4769
+ static int f2fs_fill_super (struct super_block * sb , struct fs_context * fc )
4815
4770
{
4771
+ struct f2fs_fs_context * ctx = fc -> fs_private ;
4816
4772
struct f2fs_sb_info * sbi ;
4817
4773
struct f2fs_super_block * raw_super ;
4818
- struct f2fs_fs_context ctx ;
4819
- struct fs_context fc ;
4820
4774
struct inode * root ;
4821
4775
int err ;
4822
4776
bool skip_recovery = false, need_fsck = false;
4823
- char * options = NULL ;
4824
4777
int recovery , i , valid_super_block ;
4825
4778
struct curseg_info * seg_i ;
4826
4779
int retry_cnt = 1 ;
@@ -4833,9 +4786,6 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
4833
4786
raw_super = NULL ;
4834
4787
valid_super_block = -1 ;
4835
4788
recovery = 0 ;
4836
- memset (& fc , 0 , sizeof (fc ));
4837
- memset (& ctx , 0 , sizeof (ctx ));
4838
- fc .fs_private = & ctx ;
4839
4789
4840
4790
/* allocate memory for f2fs-specific super block info */
4841
4791
sbi = kzalloc (sizeof (struct f2fs_sb_info ), GFP_KERNEL );
@@ -4886,22 +4836,12 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
4886
4836
sizeof (raw_super -> uuid ));
4887
4837
4888
4838
default_options (sbi , false);
4889
- /* parse mount options */
4890
- options = kstrdup ((const char * )data , GFP_KERNEL );
4891
- if (data && !options ) {
4892
- err = - ENOMEM ;
4893
- goto free_sb_buf ;
4894
- }
4895
4839
4896
- err = parse_options ( & fc , options );
4840
+ err = f2fs_check_opt_consistency ( fc , sb );
4897
4841
if (err )
4898
- goto free_options ;
4899
-
4900
- err = f2fs_check_opt_consistency (& fc , sb );
4901
- if (err )
4902
- goto free_options ;
4842
+ goto free_sb_buf ;
4903
4843
4904
- f2fs_apply_options (& fc , sb );
4844
+ f2fs_apply_options (fc , sb );
4905
4845
4906
4846
err = f2fs_sanity_check_options (sbi , false);
4907
4847
if (err )
@@ -5234,7 +5174,6 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
5234
5174
if (err )
5235
5175
goto sync_free_meta ;
5236
5176
}
5237
- kfree (options );
5238
5177
5239
5178
/* recover broken superblock */
5240
5179
if (recovery ) {
@@ -5329,8 +5268,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
5329
5268
kfree (F2FS_OPTION (sbi ).s_qf_names [i ]);
5330
5269
#endif
5331
5270
/* no need to free dummy_enc_policy, we just keep it in ctx when failed */
5332
- swap (F2FS_CTX_INFO (& ctx ).dummy_enc_policy , F2FS_OPTION (sbi ).dummy_enc_policy );
5333
- kfree (options );
5271
+ swap (F2FS_CTX_INFO (ctx ).dummy_enc_policy , F2FS_OPTION (sbi ).dummy_enc_policy );
5334
5272
free_sb_buf :
5335
5273
kfree (raw_super );
5336
5274
free_sbi :
@@ -5346,14 +5284,37 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
5346
5284
return err ;
5347
5285
}
5348
5286
5349
- static struct dentry * f2fs_mount (struct file_system_type * fs_type , int flags ,
5350
- const char * dev_name , void * data )
5287
+ static int f2fs_get_tree (struct fs_context * fc )
5288
+ {
5289
+ return get_tree_bdev (fc , f2fs_fill_super );
5290
+ }
5291
+
5292
+ static int f2fs_reconfigure (struct fs_context * fc )
5293
+ {
5294
+ struct super_block * sb = fc -> root -> d_sb ;
5295
+
5296
+ return __f2fs_remount (fc , sb );
5297
+ }
5298
+
5299
+ static void f2fs_fc_free (struct fs_context * fc )
5351
5300
{
5352
- return mount_bdev (fs_type , flags , dev_name , data , f2fs_fill_super );
5301
+ struct f2fs_fs_context * ctx = fc -> fs_private ;
5302
+
5303
+ if (!ctx )
5304
+ return ;
5305
+
5306
+ #ifdef CONFIG_QUOTA
5307
+ f2fs_unnote_qf_name_all (fc );
5308
+ #endif
5309
+ fscrypt_free_dummy_policy (& F2FS_CTX_INFO (ctx ).dummy_enc_policy );
5310
+ kfree (ctx );
5353
5311
}
5354
5312
5355
5313
static const struct fs_context_operations f2fs_context_ops = {
5356
5314
.parse_param = f2fs_parse_param ,
5315
+ .get_tree = f2fs_get_tree ,
5316
+ .reconfigure = f2fs_reconfigure ,
5317
+ .free = f2fs_fc_free ,
5357
5318
};
5358
5319
5359
5320
static void kill_f2fs_super (struct super_block * sb )
@@ -5397,10 +5358,24 @@ static void kill_f2fs_super(struct super_block *sb)
5397
5358
}
5398
5359
}
5399
5360
5361
+ static int f2fs_init_fs_context (struct fs_context * fc )
5362
+ {
5363
+ struct f2fs_fs_context * ctx ;
5364
+
5365
+ ctx = kzalloc (sizeof (struct f2fs_fs_context ), GFP_KERNEL );
5366
+ if (!ctx )
5367
+ return - ENOMEM ;
5368
+
5369
+ fc -> fs_private = ctx ;
5370
+ fc -> ops = & f2fs_context_ops ;
5371
+
5372
+ return 0 ;
5373
+ }
5374
+
5400
5375
static struct file_system_type f2fs_fs_type = {
5401
5376
.owner = THIS_MODULE ,
5402
5377
.name = "f2fs" ,
5403
- .mount = f2fs_mount ,
5378
+ .init_fs_context = f2fs_init_fs_context ,
5404
5379
.kill_sb = kill_f2fs_super ,
5405
5380
.fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP ,
5406
5381
};
0 commit comments