mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	ext4: factor out ext4_flex_groups_free()
Factor out ext4_flex_groups_free() and it can be used both in __ext4_fill_super() and ext4_put_super(). Signed-off-by: Jason Yan <yanaijie@huawei.com> Link: https://lore.kernel.org/r/20230323140517.1070239-5-yanaijie@huawei.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
		
							parent
							
								
									6ef6849888
								
							
						
					
					
						commit
						dcbf87589d
					
				
					 1 changed files with 17 additions and 18 deletions
				
			
		| 
						 | 
				
			
			@ -1239,11 +1239,25 @@ static void ext4_group_desc_free(struct ext4_sb_info *sbi)
 | 
			
		|||
	rcu_read_unlock();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void ext4_flex_groups_free(struct ext4_sb_info *sbi)
 | 
			
		||||
{
 | 
			
		||||
	struct flex_groups **flex_groups;
 | 
			
		||||
	int i;
 | 
			
		||||
 | 
			
		||||
	rcu_read_lock();
 | 
			
		||||
	flex_groups = rcu_dereference(sbi->s_flex_groups);
 | 
			
		||||
	if (flex_groups) {
 | 
			
		||||
		for (i = 0; i < sbi->s_flex_groups_allocated; i++)
 | 
			
		||||
			kvfree(flex_groups[i]);
 | 
			
		||||
		kvfree(flex_groups);
 | 
			
		||||
	}
 | 
			
		||||
	rcu_read_unlock();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void ext4_put_super(struct super_block *sb)
 | 
			
		||||
{
 | 
			
		||||
	struct ext4_sb_info *sbi = EXT4_SB(sb);
 | 
			
		||||
	struct ext4_super_block *es = sbi->s_es;
 | 
			
		||||
	struct flex_groups **flex_groups;
 | 
			
		||||
	int aborted = 0;
 | 
			
		||||
	int i, err;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1294,14 +1308,7 @@ static void ext4_put_super(struct super_block *sb)
 | 
			
		|||
		ext4_commit_super(sb);
 | 
			
		||||
 | 
			
		||||
	ext4_group_desc_free(sbi);
 | 
			
		||||
	rcu_read_lock();
 | 
			
		||||
	flex_groups = rcu_dereference(sbi->s_flex_groups);
 | 
			
		||||
	if (flex_groups) {
 | 
			
		||||
		for (i = 0; i < sbi->s_flex_groups_allocated; i++)
 | 
			
		||||
			kvfree(flex_groups[i]);
 | 
			
		||||
		kvfree(flex_groups);
 | 
			
		||||
	}
 | 
			
		||||
	rcu_read_unlock();
 | 
			
		||||
	ext4_flex_groups_free(sbi);
 | 
			
		||||
	ext4_percpu_param_destroy(sbi);
 | 
			
		||||
#ifdef CONFIG_QUOTA
 | 
			
		||||
	for (i = 0; i < EXT4_MAXQUOTAS; i++)
 | 
			
		||||
| 
						 | 
				
			
			@ -5091,7 +5098,6 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
 | 
			
		|||
{
 | 
			
		||||
	struct ext4_super_block *es = NULL;
 | 
			
		||||
	struct ext4_sb_info *sbi = EXT4_SB(sb);
 | 
			
		||||
	struct flex_groups **flex_groups;
 | 
			
		||||
	ext4_fsblk_t logical_sb_block;
 | 
			
		||||
	struct inode *root;
 | 
			
		||||
	int ret = -ENOMEM;
 | 
			
		||||
| 
						 | 
				
			
			@ -5566,14 +5572,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
 | 
			
		|||
	ext4_unregister_li_request(sb);
 | 
			
		||||
failed_mount6:
 | 
			
		||||
	ext4_mb_release(sb);
 | 
			
		||||
	rcu_read_lock();
 | 
			
		||||
	flex_groups = rcu_dereference(sbi->s_flex_groups);
 | 
			
		||||
	if (flex_groups) {
 | 
			
		||||
		for (i = 0; i < sbi->s_flex_groups_allocated; i++)
 | 
			
		||||
			kvfree(flex_groups[i]);
 | 
			
		||||
		kvfree(flex_groups);
 | 
			
		||||
	}
 | 
			
		||||
	rcu_read_unlock();
 | 
			
		||||
	ext4_flex_groups_free(sbi);
 | 
			
		||||
	ext4_percpu_param_destroy(sbi);
 | 
			
		||||
failed_mount5:
 | 
			
		||||
	ext4_ext_release(sb);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue