Commit a2d4a646 authored by Jan Kara's avatar Jan Kara Committed by Theodore Ts'o

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: default avatarJan Kara <jack@suse.cz>
Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent a49058fa
...@@ -1175,6 +1175,9 @@ struct ext4_super_block { ...@@ -1175,6 +1175,9 @@ struct ext4_super_block {
#define EXT4_MF_MNTDIR_SAMPLED 0x0001 #define EXT4_MF_MNTDIR_SAMPLED 0x0001
#define EXT4_MF_FS_ABORTED 0x0002 /* Fatal error detected */ #define EXT4_MF_FS_ABORTED 0x0002 /* Fatal error detected */
/* Number of quota types we support */
#define EXT4_MAXQUOTAS 2
/* /*
* fourth extended-fs super-block data in memory * fourth extended-fs super-block data in memory
*/ */
...@@ -1238,7 +1241,7 @@ struct ext4_sb_info { ...@@ -1238,7 +1241,7 @@ struct ext4_sb_info {
u32 s_min_batch_time; u32 s_min_batch_time;
struct block_device *journal_bdev; struct block_device *journal_bdev;
#ifdef CONFIG_QUOTA #ifdef CONFIG_QUOTA
char *s_qf_names[MAXQUOTAS]; /* Names of quota files with journalled quota */ char *s_qf_names[EXT4_MAXQUOTAS]; /* Names of quota files with journalled quota */
int s_jquota_fmt; /* Format of quota to use */ int s_jquota_fmt; /* Format of quota to use */
#endif #endif
unsigned int s_want_extra_isize; /* New inodes should reserve # bytes */ unsigned int s_want_extra_isize; /* New inodes should reserve # bytes */
......
...@@ -102,9 +102,9 @@ ...@@ -102,9 +102,9 @@
#define EXT4_QUOTA_INIT_BLOCKS(sb) 0 #define EXT4_QUOTA_INIT_BLOCKS(sb) 0
#define EXT4_QUOTA_DEL_BLOCKS(sb) 0 #define EXT4_QUOTA_DEL_BLOCKS(sb) 0
#endif #endif
#define EXT4_MAXQUOTAS_TRANS_BLOCKS(sb) (MAXQUOTAS*EXT4_QUOTA_TRANS_BLOCKS(sb)) #define EXT4_MAXQUOTAS_TRANS_BLOCKS(sb) (EXT4_MAXQUOTAS*EXT4_QUOTA_TRANS_BLOCKS(sb))
#define EXT4_MAXQUOTAS_INIT_BLOCKS(sb) (MAXQUOTAS*EXT4_QUOTA_INIT_BLOCKS(sb)) #define EXT4_MAXQUOTAS_INIT_BLOCKS(sb) (EXT4_MAXQUOTAS*EXT4_QUOTA_INIT_BLOCKS(sb))
#define EXT4_MAXQUOTAS_DEL_BLOCKS(sb) (MAXQUOTAS*EXT4_QUOTA_DEL_BLOCKS(sb)) #define EXT4_MAXQUOTAS_DEL_BLOCKS(sb) (EXT4_MAXQUOTAS*EXT4_QUOTA_DEL_BLOCKS(sb))
static inline int ext4_jbd2_credits_xattr(struct inode *inode) static inline int ext4_jbd2_credits_xattr(struct inode *inode)
{ {
......
...@@ -822,7 +822,7 @@ static void ext4_put_super(struct super_block *sb) ...@@ -822,7 +822,7 @@ static void ext4_put_super(struct super_block *sb)
percpu_counter_destroy(&sbi->s_dirtyclusters_counter); percpu_counter_destroy(&sbi->s_dirtyclusters_counter);
brelse(sbi->s_sbh); brelse(sbi->s_sbh);
#ifdef CONFIG_QUOTA #ifdef CONFIG_QUOTA
for (i = 0; i < MAXQUOTAS; i++) for (i = 0; i < EXT4_MAXQUOTAS; i++)
kfree(sbi->s_qf_names[i]); kfree(sbi->s_qf_names[i]);
#endif #endif
...@@ -2207,7 +2207,7 @@ static void ext4_orphan_cleanup(struct super_block *sb, ...@@ -2207,7 +2207,7 @@ static void ext4_orphan_cleanup(struct super_block *sb,
/* Needed for iput() to work correctly and not trash data */ /* Needed for iput() to work correctly and not trash data */
sb->s_flags |= MS_ACTIVE; sb->s_flags |= MS_ACTIVE;
/* Turn on quotas so that they are updated correctly */ /* Turn on quotas so that they are updated correctly */
for (i = 0; i < MAXQUOTAS; i++) { for (i = 0; i < EXT4_MAXQUOTAS; i++) {
if (EXT4_SB(sb)->s_qf_names[i]) { if (EXT4_SB(sb)->s_qf_names[i]) {
int ret = ext4_quota_on_mount(sb, i); int ret = ext4_quota_on_mount(sb, i);
if (ret < 0) if (ret < 0)
...@@ -2263,7 +2263,7 @@ static void ext4_orphan_cleanup(struct super_block *sb, ...@@ -2263,7 +2263,7 @@ static void ext4_orphan_cleanup(struct super_block *sb,
PLURAL(nr_truncates)); PLURAL(nr_truncates));
#ifdef CONFIG_QUOTA #ifdef CONFIG_QUOTA
/* Turn quotas off */ /* Turn quotas off */
for (i = 0; i < MAXQUOTAS; i++) { for (i = 0; i < EXT4_MAXQUOTAS; i++) {
if (sb_dqopt(sb)->files[i]) if (sb_dqopt(sb)->files[i])
dquot_quota_off(sb, i); dquot_quota_off(sb, i);
} }
...@@ -4238,7 +4238,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) ...@@ -4238,7 +4238,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
remove_proc_entry(sb->s_id, ext4_proc_root); remove_proc_entry(sb->s_id, ext4_proc_root);
} }
#ifdef CONFIG_QUOTA #ifdef CONFIG_QUOTA
for (i = 0; i < MAXQUOTAS; i++) for (i = 0; i < EXT4_MAXQUOTAS; i++)
kfree(sbi->s_qf_names[i]); kfree(sbi->s_qf_names[i]);
#endif #endif
ext4_blkdev_remove(sbi); ext4_blkdev_remove(sbi);
...@@ -4765,7 +4765,7 @@ struct ext4_mount_options { ...@@ -4765,7 +4765,7 @@ struct ext4_mount_options {
u32 s_min_batch_time, s_max_batch_time; u32 s_min_batch_time, s_max_batch_time;
#ifdef CONFIG_QUOTA #ifdef CONFIG_QUOTA
int s_jquota_fmt; int s_jquota_fmt;
char *s_qf_names[MAXQUOTAS]; char *s_qf_names[EXT4_MAXQUOTAS];
#endif #endif
}; };
...@@ -4795,7 +4795,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) ...@@ -4795,7 +4795,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
old_opts.s_max_batch_time = sbi->s_max_batch_time; old_opts.s_max_batch_time = sbi->s_max_batch_time;
#ifdef CONFIG_QUOTA #ifdef CONFIG_QUOTA
old_opts.s_jquota_fmt = sbi->s_jquota_fmt; old_opts.s_jquota_fmt = sbi->s_jquota_fmt;
for (i = 0; i < MAXQUOTAS; i++) for (i = 0; i < EXT4_MAXQUOTAS; i++)
if (sbi->s_qf_names[i]) { if (sbi->s_qf_names[i]) {
old_opts.s_qf_names[i] = kstrdup(sbi->s_qf_names[i], old_opts.s_qf_names[i] = kstrdup(sbi->s_qf_names[i],
GFP_KERNEL); GFP_KERNEL);
...@@ -4956,7 +4956,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) ...@@ -4956,7 +4956,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
#ifdef CONFIG_QUOTA #ifdef CONFIG_QUOTA
/* Release old quota file names */ /* Release old quota file names */
for (i = 0; i < MAXQUOTAS; i++) for (i = 0; i < EXT4_MAXQUOTAS; i++)
kfree(old_opts.s_qf_names[i]); kfree(old_opts.s_qf_names[i]);
if (enable_quota) { if (enable_quota) {
if (sb_any_quota_suspended(sb)) if (sb_any_quota_suspended(sb))
...@@ -4985,7 +4985,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) ...@@ -4985,7 +4985,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
sbi->s_max_batch_time = old_opts.s_max_batch_time; sbi->s_max_batch_time = old_opts.s_max_batch_time;
#ifdef CONFIG_QUOTA #ifdef CONFIG_QUOTA
sbi->s_jquota_fmt = old_opts.s_jquota_fmt; sbi->s_jquota_fmt = old_opts.s_jquota_fmt;
for (i = 0; i < MAXQUOTAS; i++) { for (i = 0; i < EXT4_MAXQUOTAS; i++) {
kfree(sbi->s_qf_names[i]); kfree(sbi->s_qf_names[i]);
sbi->s_qf_names[i] = old_opts.s_qf_names[i]; sbi->s_qf_names[i] = old_opts.s_qf_names[i];
} }
...@@ -5188,7 +5188,7 @@ static int ext4_quota_enable(struct super_block *sb, int type, int format_id, ...@@ -5188,7 +5188,7 @@ static int ext4_quota_enable(struct super_block *sb, int type, int format_id,
{ {
int err; int err;
struct inode *qf_inode; struct inode *qf_inode;
unsigned long qf_inums[MAXQUOTAS] = { unsigned long qf_inums[EXT4_MAXQUOTAS] = {
le32_to_cpu(EXT4_SB(sb)->s_es->s_usr_quota_inum), le32_to_cpu(EXT4_SB(sb)->s_es->s_usr_quota_inum),
le32_to_cpu(EXT4_SB(sb)->s_es->s_grp_quota_inum) le32_to_cpu(EXT4_SB(sb)->s_es->s_grp_quota_inum)
}; };
...@@ -5216,13 +5216,13 @@ static int ext4_quota_enable(struct super_block *sb, int type, int format_id, ...@@ -5216,13 +5216,13 @@ static int ext4_quota_enable(struct super_block *sb, int type, int format_id,
static int ext4_enable_quotas(struct super_block *sb) static int ext4_enable_quotas(struct super_block *sb)
{ {
int type, err = 0; int type, err = 0;
unsigned long qf_inums[MAXQUOTAS] = { unsigned long qf_inums[EXT4_MAXQUOTAS] = {
le32_to_cpu(EXT4_SB(sb)->s_es->s_usr_quota_inum), le32_to_cpu(EXT4_SB(sb)->s_es->s_usr_quota_inum),
le32_to_cpu(EXT4_SB(sb)->s_es->s_grp_quota_inum) le32_to_cpu(EXT4_SB(sb)->s_es->s_grp_quota_inum)
}; };
sb_dqopt(sb)->flags |= DQUOT_QUOTA_SYS_FILE; sb_dqopt(sb)->flags |= DQUOT_QUOTA_SYS_FILE;
for (type = 0; type < MAXQUOTAS; type++) { for (type = 0; type < EXT4_MAXQUOTAS; type++) {
if (qf_inums[type]) { if (qf_inums[type]) {
err = ext4_quota_enable(sb, type, QFMT_VFS_V1, err = ext4_quota_enable(sb, type, QFMT_VFS_V1,
DQUOT_USAGE_ENABLED); DQUOT_USAGE_ENABLED);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment