Skip to content

Commit f3c1c42

Browse files
LiBaokun96tytso
authored andcommitted
ext4: refactoring to use the unified helper ext4_quotas_off()
Rename ext4_quota_off_umount() to ext4_quotas_off(), and add type parameter to replace open code in ext4_enable_quotas(). Signed-off-by: Baokun Li <[email protected]> Reviewed-by: Jan Kara <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent d13f996 commit f3c1c42

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

fs/ext4/super.c

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,12 +1165,12 @@ static void dump_orphan_list(struct super_block *sb, struct ext4_sb_info *sbi)
11651165
#ifdef CONFIG_QUOTA
11661166
static int ext4_quota_off(struct super_block *sb, int type);
11671167

1168-
static inline void ext4_quota_off_umount(struct super_block *sb)
1168+
static inline void ext4_quotas_off(struct super_block *sb, int type)
11691169
{
1170-
int type;
1170+
BUG_ON(type > EXT4_MAXQUOTAS);
11711171

11721172
/* Use our quota_off function to clear inode flags etc. */
1173-
for (type = 0; type < EXT4_MAXQUOTAS; type++)
1173+
for (type--; type >= 0; type--)
11741174
ext4_quota_off(sb, type);
11751175
}
11761176

@@ -1186,7 +1186,7 @@ static inline char *get_qf_name(struct super_block *sb,
11861186
lockdep_is_held(&sb->s_umount));
11871187
}
11881188
#else
1189-
static inline void ext4_quota_off_umount(struct super_block *sb)
1189+
static inline void ext4_quotas_off(struct super_block *sb, int type)
11901190
{
11911191
}
11921192
#endif
@@ -1286,7 +1286,7 @@ static void ext4_put_super(struct super_block *sb)
12861286
&sb->s_uuid);
12871287

12881288
ext4_unregister_li_request(sb);
1289-
ext4_quota_off_umount(sb);
1289+
ext4_quotas_off(sb, EXT4_MAXQUOTAS);
12901290

12911291
flush_work(&sbi->s_error_work);
12921292
destroy_workqueue(sbi->rsv_conversion_wq);
@@ -5597,7 +5597,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
55975597
return 0;
55985598

55995599
failed_mount10:
5600-
ext4_quota_off_umount(sb);
5600+
ext4_quotas_off(sb, EXT4_MAXQUOTAS);
56015601
failed_mount9: __maybe_unused
56025602
ext4_release_orphan_info(sb);
56035603
failed_mount8:
@@ -7044,20 +7044,8 @@ int ext4_enable_quotas(struct super_block *sb)
70447044
"(type=%d, err=%d, ino=%lu). "
70457045
"Please run e2fsck to fix.", type,
70467046
err, qf_inums[type]);
7047-
for (type--; type >= 0; type--) {
7048-
struct inode *inode;
7049-
7050-
inode = sb_dqopt(sb)->files[type];
7051-
if (inode)
7052-
inode = igrab(inode);
7053-
dquot_quota_off(sb, type);
7054-
if (inode) {
7055-
lockdep_set_quota_inode(inode,
7056-
I_DATA_SEM_NORMAL);
7057-
iput(inode);
7058-
}
7059-
}
70607047

7048+
ext4_quotas_off(sb, type);
70617049
return err;
70627050
}
70637051
}

0 commit comments

Comments
 (0)