@@ -75,12 +75,9 @@ static int ext4_mark_recovery_complete(struct super_block *sb,
7575static int ext4_clear_journal_err (struct super_block * sb ,
7676 struct ext4_super_block * es );
7777static int ext4_sync_fs (struct super_block * sb , int wait );
78- static int ext4_remount (struct super_block * sb , int * flags , char * data );
7978static int ext4_statfs (struct dentry * dentry , struct kstatfs * buf );
8079static int ext4_unfreeze (struct super_block * sb );
8180static int ext4_freeze (struct super_block * sb );
82- static struct dentry * ext4_mount (struct file_system_type * fs_type , int flags ,
83- const char * dev_name , void * data );
8481static inline int ext2_feature_set_ok (struct super_block * sb );
8582static inline int ext3_feature_set_ok (struct super_block * sb );
8683static void ext4_destroy_lazyinit_thread (void );
@@ -93,6 +90,11 @@ static int ext4_check_opt_consistency(struct fs_context *fc,
9390 struct super_block * sb );
9491static int ext4_apply_options (struct fs_context * fc , struct super_block * sb );
9592static int ext4_parse_param (struct fs_context * fc , struct fs_parameter * param );
93+ static int ext4_get_tree (struct fs_context * fc );
94+ static int ext4_reconfigure (struct fs_context * fc );
95+ static void ext4_fc_free (struct fs_context * fc );
96+ static int ext4_init_fs_context (struct fs_context * fc );
97+ static const struct fs_parameter_spec ext4_param_specs [];
9698
9799/*
98100 * Lock ordering
@@ -122,16 +124,20 @@ static int ext4_parse_param(struct fs_context *fc, struct fs_parameter *param);
122124
123125static const struct fs_context_operations ext4_context_ops = {
124126 .parse_param = ext4_parse_param ,
127+ .get_tree = ext4_get_tree ,
128+ .reconfigure = ext4_reconfigure ,
129+ .free = ext4_fc_free ,
125130};
126131
127132
128133#if !defined(CONFIG_EXT2_FS ) && !defined(CONFIG_EXT2_FS_MODULE ) && defined(CONFIG_EXT4_USE_FOR_EXT2 )
129134static struct file_system_type ext2_fs_type = {
130- .owner = THIS_MODULE ,
131- .name = "ext2" ,
132- .mount = ext4_mount ,
133- .kill_sb = kill_block_super ,
134- .fs_flags = FS_REQUIRES_DEV ,
135+ .owner = THIS_MODULE ,
136+ .name = "ext2" ,
137+ .init_fs_context = ext4_init_fs_context ,
138+ .parameters = ext4_param_specs ,
139+ .kill_sb = kill_block_super ,
140+ .fs_flags = FS_REQUIRES_DEV ,
135141};
136142MODULE_ALIAS_FS ("ext2" );
137143MODULE_ALIAS ("ext2" );
@@ -142,11 +148,12 @@ MODULE_ALIAS("ext2");
142148
143149
144150static struct file_system_type ext3_fs_type = {
145- .owner = THIS_MODULE ,
146- .name = "ext3" ,
147- .mount = ext4_mount ,
148- .kill_sb = kill_block_super ,
149- .fs_flags = FS_REQUIRES_DEV ,
151+ .owner = THIS_MODULE ,
152+ .name = "ext3" ,
153+ .init_fs_context = ext4_init_fs_context ,
154+ .parameters = ext4_param_specs ,
155+ .kill_sb = kill_block_super ,
156+ .fs_flags = FS_REQUIRES_DEV ,
150157};
151158MODULE_ALIAS_FS ("ext3" );
152159MODULE_ALIAS ("ext3" );
@@ -1665,7 +1672,6 @@ static const struct super_operations ext4_sops = {
16651672 .freeze_fs = ext4_freeze ,
16661673 .unfreeze_fs = ext4_unfreeze ,
16671674 .statfs = ext4_statfs ,
1668- .remount_fs = ext4_remount ,
16691675 .show_options = ext4_show_options ,
16701676#ifdef CONFIG_QUOTA
16711677 .quota_read = ext4_quota_read ,
@@ -2203,6 +2209,35 @@ struct ext4_fs_context {
22032209 ext4_fsblk_t s_sb_block ;
22042210};
22052211
2212+ static void ext4_fc_free (struct fs_context * fc )
2213+ {
2214+ struct ext4_fs_context * ctx = fc -> fs_private ;
2215+ int i ;
2216+
2217+ if (!ctx )
2218+ return ;
2219+
2220+ for (i = 0 ; i < EXT4_MAXQUOTAS ; i ++ )
2221+ kfree (ctx -> s_qf_names [i ]);
2222+
2223+ kfree (ctx -> test_dummy_enc_arg );
2224+ kfree (ctx );
2225+ }
2226+
2227+ int ext4_init_fs_context (struct fs_context * fc )
2228+ {
2229+ struct xfs_fs_context * ctx ;
2230+
2231+ ctx = kzalloc (sizeof (struct ext4_fs_context ), GFP_KERNEL );
2232+ if (!ctx )
2233+ return - ENOMEM ;
2234+
2235+ fc -> fs_private = ctx ;
2236+ fc -> ops = & ext4_context_ops ;
2237+
2238+ return 0 ;
2239+ }
2240+
22062241#ifdef CONFIG_QUOTA
22072242/*
22082243 * Note the name of the specified quota file.
@@ -5602,61 +5637,31 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb,
56025637 return err ? err : ret ;
56035638}
56045639
5605- static void cleanup_ctx (struct ext4_fs_context * ctx )
5640+ static int ext4_fill_super (struct super_block * sb , struct fs_context * fc )
56065641{
5607- int i ;
5608-
5609- if (!ctx )
5610- return ;
5611-
5612- for (i = 0 ; i < EXT4_MAXQUOTAS ; i ++ ) {
5613- kfree (ctx -> s_qf_names [i ]);
5614- }
5615-
5616- kfree (ctx -> test_dummy_enc_arg );
5617- }
5618-
5619- static int ext4_fill_super (struct super_block * sb , void * data , int silent )
5620- {
5621- struct ext4_fs_context ctx ;
5642+ struct ext4_fs_context * ctx = fc -> fs_private ;
56225643 struct ext4_sb_info * sbi ;
5623- struct fs_context fc ;
56245644 const char * descr ;
5625- char * orig_data ;
5626- int ret = - ENOMEM ;
5627-
5628- orig_data = kstrdup (data , GFP_KERNEL );
5629- if (data && !orig_data )
5630- return - ENOMEM ;
5631-
5632- /* Cleanup superblock name */
5633- strreplace (sb -> s_id , '/' , '!' );
5634-
5635- memset (& fc , 0 , sizeof (fc ));
5636- memset (& ctx , 0 , sizeof (ctx ));
5637- fc .fs_private = & ctx ;
5638-
5639- ret = parse_options (& fc , (char * ) data );
5640- if (ret < 0 )
5641- goto free_data ;
5645+ int ret ;
56425646
56435647 sbi = ext4_alloc_sbi (sb );
5644- if (!sbi ) {
5648+ if (!sbi )
56455649 ret = - ENOMEM ;
5646- goto free_data ;
5647- }
56485650
5649- fc .s_fs_info = sbi ;
5651+ fc -> s_fs_info = sbi ;
5652+
5653+ /* Cleanup superblock name */
5654+ strreplace (sb -> s_id , '/' , '!' );
56505655
56515656 sbi -> s_sb_block = 1 ; /* Default super block location */
5652- if (ctx . spec & EXT4_SPEC_s_sb_block )
5653- sbi -> s_sb_block = ctx . s_sb_block ;
5657+ if (ctx -> spec & EXT4_SPEC_s_sb_block )
5658+ sbi -> s_sb_block = ctx -> s_sb_block ;
56545659
5655- ret = __ext4_fill_super (& fc , sb , silent );
5660+ ret = __ext4_fill_super (fc , sb , fc -> sb_flags & SB_SILENT );
56565661 if (ret < 0 )
56575662 goto free_sbi ;
56585663
5659- if (EXT4_SB ( sb ) -> s_journal ) {
5664+ if (sbi -> s_journal ) {
56605665 if (test_opt (sb , DATA_FLAGS ) == EXT4_MOUNT_JOURNAL_DATA )
56615666 descr = " journalled data mode" ;
56625667 else if (test_opt (sb , DATA_FLAGS ) == EXT4_MOUNT_ORDERED_DATA )
@@ -5668,23 +5673,21 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
56685673
56695674 if (___ratelimit (& ext4_mount_msg_ratelimit , "EXT4-fs mount" ))
56705675 ext4_msg (sb , KERN_INFO , "mounted filesystem with%s. "
5671- "Opts: %.*s%s%s. Quota mode: %s." , descr ,
5672- (int ) sizeof (sbi -> s_es -> s_mount_opts ),
5673- sbi -> s_es -> s_mount_opts ,
5674- * sbi -> s_es -> s_mount_opts ? "; " : "" , orig_data ,
5675- ext4_quota_mode (sb ));
5676-
5677- kfree (orig_data );
5678- cleanup_ctx (& ctx );
5676+ "Quota mode: %s." , descr , ext4_quota_mode (sb ));
5677+
56795678 return 0 ;
5679+
56805680free_sbi :
56815681 ext4_free_sbi (sbi );
5682- free_data :
5683- kfree (orig_data );
5684- cleanup_ctx (& ctx );
5682+ fc -> s_fs_info = NULL ;
56855683 return ret ;
56865684}
56875685
5686+ static int ext4_get_tree (struct fs_context * fc )
5687+ {
5688+ return get_tree_bdev (fc , ext4_fill_super );
5689+ }
5690+
56885691/*
56895692 * Setup any per-fs journal parameters now. We'll do this both on
56905693 * initial mount, once the journal has been initialised but before we've
@@ -6609,47 +6612,26 @@ static int __ext4_remount(struct fs_context *fc, struct super_block *sb,
66096612 return err ;
66106613}
66116614
6612- static int ext4_remount (struct super_block * sb , int * flags , char * data )
6615+ static int ext4_reconfigure (struct fs_context * fc )
66136616{
6614- struct ext4_sb_info * sbi = EXT4_SB (sb );
6615- struct ext4_fs_context ctx ;
6616- struct fs_context fc ;
6617- char * orig_data ;
6617+ struct super_block * sb = fc -> root -> d_sb ;
6618+ int flags = fc -> sb_flags ;
66186619 int ret ;
66196620
6620- orig_data = kstrdup (data , GFP_KERNEL );
6621- if (data && !orig_data )
6622- return - ENOMEM ;
6623-
6624- memset (& fc , 0 , sizeof (fc ));
6625- memset (& ctx , 0 , sizeof (ctx ));
6621+ fc -> s_fs_info = EXT4_SB (sb );
66266622
6627- fc .fs_private = & ctx ;
6628- fc .purpose = FS_CONTEXT_FOR_RECONFIGURE ;
6629- fc .s_fs_info = sbi ;
6630-
6631- ret = parse_options (& fc , (char * ) data );
6623+ ret = ext4_check_opt_consistency (fc , sb );
66326624 if (ret < 0 )
6633- goto err_out ;
6625+ return ret ;
66346626
6635- ret = ext4_check_opt_consistency ( & fc , sb );
6627+ ret = __ext4_remount ( fc , sb , & flags );
66366628 if (ret < 0 )
6637- goto err_out ;
6629+ return ret ;
66386630
6639- ret = __ext4_remount (& fc , sb , flags );
6640- if (ret < 0 )
6641- goto err_out ;
6631+ ext4_msg (sb , KERN_INFO , "re-mounted. Quota mode: %s." ,
6632+ ext4_quota_mode (sb ));
66426633
6643- ext4_msg (sb , KERN_INFO , "re-mounted. Opts: %s. Quota mode: %s." ,
6644- orig_data , ext4_quota_mode (sb ));
6645- cleanup_ctx (& ctx );
6646- kfree (orig_data );
66476634 return 0 ;
6648-
6649- err_out :
6650- cleanup_ctx (& ctx );
6651- kfree (orig_data );
6652- return ret ;
66536635}
66546636
66556637#ifdef CONFIG_QUOTA
@@ -7134,12 +7116,6 @@ static ssize_t ext4_quota_write(struct super_block *sb, int type,
71347116}
71357117#endif
71367118
7137- static struct dentry * ext4_mount (struct file_system_type * fs_type , int flags ,
7138- const char * dev_name , void * data )
7139- {
7140- return mount_bdev (fs_type , flags , dev_name , data , ext4_fill_super );
7141- }
7142-
71437119#if !defined(CONFIG_EXT2_FS ) && !defined(CONFIG_EXT2_FS_MODULE ) && defined(CONFIG_EXT4_USE_FOR_EXT2 )
71447120static inline void register_as_ext2 (void )
71457121{
@@ -7197,11 +7173,12 @@ static inline int ext3_feature_set_ok(struct super_block *sb)
71977173}
71987174
71997175static struct file_system_type ext4_fs_type = {
7200- .owner = THIS_MODULE ,
7201- .name = "ext4" ,
7202- .mount = ext4_mount ,
7203- .kill_sb = kill_block_super ,
7204- .fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP ,
7176+ .owner = THIS_MODULE ,
7177+ .name = "ext4" ,
7178+ .init_fs_context = ext4_init_fs_context ,
7179+ .parameters = ext4_param_specs ,
7180+ .kill_sb = kill_block_super ,
7181+ .fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP ,
72057182};
72067183MODULE_ALIAS_FS ("ext4" );
72077184
0 commit comments