Skip to content

Commit a2d4a64

Browse files
jankaratytso
authored andcommitted
ext4: don't use MAXQUOTAS value
MAXQUOTAS value defines maximum number of quota types VFS supports. This isn't necessarily the number of types ext4 supports. Although ext4 will support project quotas, use ext4 private definition for consistency with other filesystems. Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent a49058f commit a2d4a64

3 files changed

Lines changed: 18 additions & 15 deletions

File tree

‎fs/ext4/ext4.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,9 @@ struct ext4_super_block {
11751175
#define EXT4_MF_MNTDIR_SAMPLED 0x0001
11761176
#define EXT4_MF_FS_ABORTED 0x0002 /* Fatal error detected */
11771177

1178+
/* Number of quota types we support */
1179+
#define EXT4_MAXQUOTAS 2
1180+
11781181
/*
11791182
* fourth extended-fs super-block data in memory
11801183
*/
@@ -1238,7 +1241,7 @@ struct ext4_sb_info {
12381241
u32 s_min_batch_time;
12391242
struct block_device *journal_bdev;
12401243
#ifdef CONFIG_QUOTA
1241-
char *s_qf_names[MAXQUOTAS]; /* Names of quota files with journalled quota */
1244+
char *s_qf_names[EXT4_MAXQUOTAS]; /* Names of quota files with journalled quota */
12421245
int s_jquota_fmt; /* Format of quota to use */
12431246
#endif
12441247
unsigned int s_want_extra_isize; /* New inodes should reserve # bytes */

‎fs/ext4/ext4_jbd2.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@
102102
#define EXT4_QUOTA_INIT_BLOCKS(sb) 0
103103
#define EXT4_QUOTA_DEL_BLOCKS(sb) 0
104104
#endif
105-
#define EXT4_MAXQUOTAS_TRANS_BLOCKS(sb) (MAXQUOTAS*EXT4_QUOTA_TRANS_BLOCKS(sb))
106-
#define EXT4_MAXQUOTAS_INIT_BLOCKS(sb) (MAXQUOTAS*EXT4_QUOTA_INIT_BLOCKS(sb))
107-
#define EXT4_MAXQUOTAS_DEL_BLOCKS(sb) (MAXQUOTAS*EXT4_QUOTA_DEL_BLOCKS(sb))
105+
#define EXT4_MAXQUOTAS_TRANS_BLOCKS(sb) (EXT4_MAXQUOTAS*EXT4_QUOTA_TRANS_BLOCKS(sb))
106+
#define EXT4_MAXQUOTAS_INIT_BLOCKS(sb) (EXT4_MAXQUOTAS*EXT4_QUOTA_INIT_BLOCKS(sb))
107+
#define EXT4_MAXQUOTAS_DEL_BLOCKS(sb) (EXT4_MAXQUOTAS*EXT4_QUOTA_DEL_BLOCKS(sb))
108108

109109
static inline int ext4_jbd2_credits_xattr(struct inode *inode)
110110
{

‎fs/ext4/super.c‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ static void ext4_put_super(struct super_block *sb)
822822
percpu_counter_destroy(&sbi->s_dirtyclusters_counter);
823823
brelse(sbi->s_sbh);
824824
#ifdef CONFIG_QUOTA
825-
for (i = 0; i < MAXQUOTAS; i++)
825+
for (i = 0; i < EXT4_MAXQUOTAS; i++)
826826
kfree(sbi->s_qf_names[i]);
827827
#endif
828828

@@ -2207,7 +2207,7 @@ static void ext4_orphan_cleanup(struct super_block *sb,
22072207
/* Needed for iput() to work correctly and not trash data */
22082208
sb->s_flags |= MS_ACTIVE;
22092209
/* Turn on quotas so that they are updated correctly */
2210-
for (i = 0; i < MAXQUOTAS; i++) {
2210+
for (i = 0; i < EXT4_MAXQUOTAS; i++) {
22112211
if (EXT4_SB(sb)->s_qf_names[i]) {
22122212
int ret = ext4_quota_on_mount(sb, i);
22132213
if (ret < 0)
@@ -2263,7 +2263,7 @@ static void ext4_orphan_cleanup(struct super_block *sb,
22632263
PLURAL(nr_truncates));
22642264
#ifdef CONFIG_QUOTA
22652265
/* Turn quotas off */
2266-
for (i = 0; i < MAXQUOTAS; i++) {
2266+
for (i = 0; i < EXT4_MAXQUOTAS; i++) {
22672267
if (sb_dqopt(sb)->files[i])
22682268
dquot_quota_off(sb, i);
22692269
}
@@ -4238,7 +4238,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
42384238
remove_proc_entry(sb->s_id, ext4_proc_root);
42394239
}
42404240
#ifdef CONFIG_QUOTA
4241-
for (i = 0; i < MAXQUOTAS; i++)
4241+
for (i = 0; i < EXT4_MAXQUOTAS; i++)
42424242
kfree(sbi->s_qf_names[i]);
42434243
#endif
42444244
ext4_blkdev_remove(sbi);
@@ -4765,7 +4765,7 @@ struct ext4_mount_options {
47654765
u32 s_min_batch_time, s_max_batch_time;
47664766
#ifdef CONFIG_QUOTA
47674767
int s_jquota_fmt;
4768-
char *s_qf_names[MAXQUOTAS];
4768+
char *s_qf_names[EXT4_MAXQUOTAS];
47694769
#endif
47704770
};
47714771

@@ -4795,7 +4795,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
47954795
old_opts.s_max_batch_time = sbi->s_max_batch_time;
47964796
#ifdef CONFIG_QUOTA
47974797
old_opts.s_jquota_fmt = sbi->s_jquota_fmt;
4798-
for (i = 0; i < MAXQUOTAS; i++)
4798+
for (i = 0; i < EXT4_MAXQUOTAS; i++)
47994799
if (sbi->s_qf_names[i]) {
48004800
old_opts.s_qf_names[i] = kstrdup(sbi->s_qf_names[i],
48014801
GFP_KERNEL);
@@ -4956,7 +4956,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
49564956

49574957
#ifdef CONFIG_QUOTA
49584958
/* Release old quota file names */
4959-
for (i = 0; i < MAXQUOTAS; i++)
4959+
for (i = 0; i < EXT4_MAXQUOTAS; i++)
49604960
kfree(old_opts.s_qf_names[i]);
49614961
if (enable_quota) {
49624962
if (sb_any_quota_suspended(sb))
@@ -4985,7 +4985,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
49854985
sbi->s_max_batch_time = old_opts.s_max_batch_time;
49864986
#ifdef CONFIG_QUOTA
49874987
sbi->s_jquota_fmt = old_opts.s_jquota_fmt;
4988-
for (i = 0; i < MAXQUOTAS; i++) {
4988+
for (i = 0; i < EXT4_MAXQUOTAS; i++) {
49894989
kfree(sbi->s_qf_names[i]);
49904990
sbi->s_qf_names[i] = old_opts.s_qf_names[i];
49914991
}
@@ -5188,7 +5188,7 @@ static int ext4_quota_enable(struct super_block *sb, int type, int format_id,
51885188
{
51895189
int err;
51905190
struct inode *qf_inode;
5191-
unsigned long qf_inums[MAXQUOTAS] = {
5191+
unsigned long qf_inums[EXT4_MAXQUOTAS] = {
51925192
le32_to_cpu(EXT4_SB(sb)->s_es->s_usr_quota_inum),
51935193
le32_to_cpu(EXT4_SB(sb)->s_es->s_grp_quota_inum)
51945194
};
@@ -5216,13 +5216,13 @@ static int ext4_quota_enable(struct super_block *sb, int type, int format_id,
52165216
static int ext4_enable_quotas(struct super_block *sb)
52175217
{
52185218
int type, err = 0;
5219-
unsigned long qf_inums[MAXQUOTAS] = {
5219+
unsigned long qf_inums[EXT4_MAXQUOTAS] = {
52205220
le32_to_cpu(EXT4_SB(sb)->s_es->s_usr_quota_inum),
52215221
le32_to_cpu(EXT4_SB(sb)->s_es->s_grp_quota_inum)
52225222
};
52235223

52245224
sb_dqopt(sb)->flags |= DQUOT_QUOTA_SYS_FILE;
5225-
for (type = 0; type < MAXQUOTAS; type++) {
5225+
for (type = 0; type < EXT4_MAXQUOTAS; type++) {
52265226
if (qf_inums[type]) {
52275227
err = ext4_quota_enable(sb, type, QFMT_VFS_V1,
52285228
DQUOT_USAGE_ENABLED);

0 commit comments

Comments
 (0)