@@ -1239,11 +1239,25 @@ static void ext4_group_desc_free(struct ext4_sb_info *sbi)
12391239 rcu_read_unlock ();
12401240}
12411241
1242+ static void ext4_flex_groups_free (struct ext4_sb_info * sbi )
1243+ {
1244+ struct flex_groups * * flex_groups ;
1245+ int i ;
1246+
1247+ rcu_read_lock ();
1248+ flex_groups = rcu_dereference (sbi -> s_flex_groups );
1249+ if (flex_groups ) {
1250+ for (i = 0 ; i < sbi -> s_flex_groups_allocated ; i ++ )
1251+ kvfree (flex_groups [i ]);
1252+ kvfree (flex_groups );
1253+ }
1254+ rcu_read_unlock ();
1255+ }
1256+
12421257static void ext4_put_super (struct super_block * sb )
12431258{
12441259 struct ext4_sb_info * sbi = EXT4_SB (sb );
12451260 struct ext4_super_block * es = sbi -> s_es ;
1246- struct flex_groups * * flex_groups ;
12471261 int aborted = 0 ;
12481262 int i , err ;
12491263
@@ -1294,14 +1308,7 @@ static void ext4_put_super(struct super_block *sb)
12941308 ext4_commit_super (sb );
12951309
12961310 ext4_group_desc_free (sbi );
1297- rcu_read_lock ();
1298- flex_groups = rcu_dereference (sbi -> s_flex_groups );
1299- if (flex_groups ) {
1300- for (i = 0 ; i < sbi -> s_flex_groups_allocated ; i ++ )
1301- kvfree (flex_groups [i ]);
1302- kvfree (flex_groups );
1303- }
1304- rcu_read_unlock ();
1311+ ext4_flex_groups_free (sbi );
13051312 ext4_percpu_param_destroy (sbi );
13061313#ifdef CONFIG_QUOTA
13071314 for (i = 0 ; i < EXT4_MAXQUOTAS ; i ++ )
@@ -5091,7 +5098,6 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
50915098{
50925099 struct ext4_super_block * es = NULL ;
50935100 struct ext4_sb_info * sbi = EXT4_SB (sb );
5094- struct flex_groups * * flex_groups ;
50955101 ext4_fsblk_t logical_sb_block ;
50965102 struct inode * root ;
50975103 int ret = - ENOMEM ;
@@ -5566,14 +5572,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
55665572 ext4_unregister_li_request (sb );
55675573failed_mount6 :
55685574 ext4_mb_release (sb );
5569- rcu_read_lock ();
5570- flex_groups = rcu_dereference (sbi -> s_flex_groups );
5571- if (flex_groups ) {
5572- for (i = 0 ; i < sbi -> s_flex_groups_allocated ; i ++ )
5573- kvfree (flex_groups [i ]);
5574- kvfree (flex_groups );
5575- }
5576- rcu_read_unlock ();
5575+ ext4_flex_groups_free (sbi );
55775576 ext4_percpu_param_destroy (sbi );
55785577failed_mount5 :
55795578 ext4_ext_release (sb );
0 commit comments