1 ext4: don't use MAXQUOTAS value
3 From: Jan Kara <jack@suse.cz>
5 MAXQUOTAS value defines maximum number of quota types VFS supports.
6 This isn't necessarily the number of types ext4 supports. Although
7 ext4 will support project quotas, use ext4 private definition for
8 consistency with other filesystems.
10 Signed-off-by: Jan Kara <jack@suse.cz>
11 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
13 fs/ext4/ext4.h | 5 ++++-
14 fs/ext4/ext4_jbd2.h | 6 +++---
15 fs/ext4/super.c | 22 +++++++++++-----------
16 3 files changed, 18 insertions(+), 15 deletions(-)
18 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
19 index b0c225cdb52c..1da22717ecdb 100644
22 @@ -1174,6 +1174,9 @@ struct ext4_super_block {
23 #define EXT4_MF_MNTDIR_SAMPLED 0x0001
24 #define EXT4_MF_FS_ABORTED 0x0002 /* Fatal error detected */
26 +/* Number of quota types we support */
27 +#define EXT4_MAXQUOTAS 2
30 * fourth extended-fs super-block data in memory
32 @@ -1237,7 +1240,7 @@ struct ext4_sb_info {
34 struct block_device *journal_bdev;
36 - char *s_qf_names[MAXQUOTAS]; /* Names of quota files with journalled quota */
37 + char *s_qf_names[EXT4_MAXQUOTAS]; /* Names of quota files with journalled quota */
38 int s_jquota_fmt; /* Format of quota to use */
40 unsigned int s_want_extra_isize; /* New inodes should reserve # bytes */
41 diff --git a/fs/ext4/ext4_jbd2.h b/fs/ext4/ext4_jbd2.h
42 index 17c00ff202f2..9c5b49fb281e 100644
43 --- a/fs/ext4/ext4_jbd2.h
44 +++ b/fs/ext4/ext4_jbd2.h
46 #define EXT4_QUOTA_INIT_BLOCKS(sb) 0
47 #define EXT4_QUOTA_DEL_BLOCKS(sb) 0
49 -#define EXT4_MAXQUOTAS_TRANS_BLOCKS(sb) (MAXQUOTAS*EXT4_QUOTA_TRANS_BLOCKS(sb))
50 -#define EXT4_MAXQUOTAS_INIT_BLOCKS(sb) (MAXQUOTAS*EXT4_QUOTA_INIT_BLOCKS(sb))
51 -#define EXT4_MAXQUOTAS_DEL_BLOCKS(sb) (MAXQUOTAS*EXT4_QUOTA_DEL_BLOCKS(sb))
52 +#define EXT4_MAXQUOTAS_TRANS_BLOCKS(sb) (EXT4_MAXQUOTAS*EXT4_QUOTA_TRANS_BLOCKS(sb))
53 +#define EXT4_MAXQUOTAS_INIT_BLOCKS(sb) (EXT4_MAXQUOTAS*EXT4_QUOTA_INIT_BLOCKS(sb))
54 +#define EXT4_MAXQUOTAS_DEL_BLOCKS(sb) (EXT4_MAXQUOTAS*EXT4_QUOTA_DEL_BLOCKS(sb))
56 static inline int ext4_jbd2_credits_xattr(struct inode *inode)
58 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
59 index 0b28b36e7915..baa73b798f8b 100644
62 @@ -823,7 +823,7 @@ static void ext4_put_super(struct super_block *sb)
63 percpu_counter_destroy(&sbi->s_extent_cache_cnt);
66 - for (i = 0; i < MAXQUOTAS; i++)
67 + for (i = 0; i < EXT4_MAXQUOTAS; i++)
68 kfree(sbi->s_qf_names[i]);
71 @@ -2207,7 +2207,7 @@ static void ext4_orphan_cleanup(struct super_block *sb,
72 /* Needed for iput() to work correctly and not trash data */
73 sb->s_flags |= MS_ACTIVE;
74 /* Turn on quotas so that they are updated correctly */
75 - for (i = 0; i < MAXQUOTAS; i++) {
76 + for (i = 0; i < EXT4_MAXQUOTAS; i++) {
77 if (EXT4_SB(sb)->s_qf_names[i]) {
78 int ret = ext4_quota_on_mount(sb, i);
80 @@ -2263,7 +2263,7 @@ static void ext4_orphan_cleanup(struct super_block *sb,
81 PLURAL(nr_truncates));
84 - for (i = 0; i < MAXQUOTAS; i++) {
85 + for (i = 0; i < EXT4_MAXQUOTAS; i++) {
86 if (sb_dqopt(sb)->files[i])
87 dquot_quota_off(sb, i);
89 @@ -4243,7 +4243,7 @@ failed_mount:
90 remove_proc_entry(sb->s_id, ext4_proc_root);
93 - for (i = 0; i < MAXQUOTAS; i++)
94 + for (i = 0; i < EXT4_MAXQUOTAS; i++)
95 kfree(sbi->s_qf_names[i]);
97 ext4_blkdev_remove(sbi);
98 @@ -4770,7 +4770,7 @@ struct ext4_mount_options {
99 u32 s_min_batch_time, s_max_batch_time;
102 - char *s_qf_names[MAXQUOTAS];
103 + char *s_qf_names[EXT4_MAXQUOTAS];
107 @@ -4800,7 +4800,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
108 old_opts.s_max_batch_time = sbi->s_max_batch_time;
110 old_opts.s_jquota_fmt = sbi->s_jquota_fmt;
111 - for (i = 0; i < MAXQUOTAS; i++)
112 + for (i = 0; i < EXT4_MAXQUOTAS; i++)
113 if (sbi->s_qf_names[i]) {
114 old_opts.s_qf_names[i] = kstrdup(sbi->s_qf_names[i],
116 @@ -4961,7 +4961,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
119 /* Release old quota file names */
120 - for (i = 0; i < MAXQUOTAS; i++)
121 + for (i = 0; i < EXT4_MAXQUOTAS; i++)
122 kfree(old_opts.s_qf_names[i]);
124 if (sb_any_quota_suspended(sb))
125 @@ -4990,7 +4990,7 @@ restore_opts:
126 sbi->s_max_batch_time = old_opts.s_max_batch_time;
128 sbi->s_jquota_fmt = old_opts.s_jquota_fmt;
129 - for (i = 0; i < MAXQUOTAS; i++) {
130 + for (i = 0; i < EXT4_MAXQUOTAS; i++) {
131 kfree(sbi->s_qf_names[i]);
132 sbi->s_qf_names[i] = old_opts.s_qf_names[i];
134 @@ -5193,7 +5193,7 @@ static int ext4_quota_enable(struct super_block *sb, int type, int format_id,
137 struct inode *qf_inode;
138 - unsigned long qf_inums[MAXQUOTAS] = {
139 + unsigned long qf_inums[EXT4_MAXQUOTAS] = {
140 le32_to_cpu(EXT4_SB(sb)->s_es->s_usr_quota_inum),
141 le32_to_cpu(EXT4_SB(sb)->s_es->s_grp_quota_inum)
143 @@ -5221,13 +5221,13 @@ static int ext4_quota_enable(struct super_block *sb, int type, int format_id,
144 static int ext4_enable_quotas(struct super_block *sb)
147 - unsigned long qf_inums[MAXQUOTAS] = {
148 + unsigned long qf_inums[EXT4_MAXQUOTAS] = {
149 le32_to_cpu(EXT4_SB(sb)->s_es->s_usr_quota_inum),
150 le32_to_cpu(EXT4_SB(sb)->s_es->s_grp_quota_inum)
153 sb_dqopt(sb)->flags |= DQUOT_QUOTA_SYS_FILE;
154 - for (type = 0; type < MAXQUOTAS; type++) {
155 + for (type = 0; type < EXT4_MAXQUOTAS; type++) {
156 if (qf_inums[type]) {
157 err = ext4_quota_enable(sb, type, QFMT_VFS_V1,
158 DQUOT_USAGE_ENABLED);