Commit 52362810 authored by Jan Kara's avatar Jan Kara

ocfs2: Don't use MAXQUOTAS value

MAXQUOTAS value defines maximum number of quota types VFS supports.
This isn't necessarily the number of types ocfs2 supports and with
addition of project quotas these two numbers stop matching. So make
ocfs2 use its private definition.

CC: Mark Fasheh <mfasheh@suse.com>
CC: Joel Becker <jlbec@evilplan.org>
CC: ocfs2-devel@oss.oracle.com
Signed-off-by: default avatarJan Kara <jack@suse.cz>
parent aca60617
...@@ -1125,7 +1125,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr) ...@@ -1125,7 +1125,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
struct ocfs2_super *osb = OCFS2_SB(sb); struct ocfs2_super *osb = OCFS2_SB(sb);
struct buffer_head *bh = NULL; struct buffer_head *bh = NULL;
handle_t *handle = NULL; handle_t *handle = NULL;
struct dquot *transfer_to[MAXQUOTAS] = { }; struct dquot *transfer_to[OCFS2_MAXQUOTAS] = { };
int qtype; int qtype;
trace_ocfs2_setattr(inode, dentry, trace_ocfs2_setattr(inode, dentry,
...@@ -1253,7 +1253,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr) ...@@ -1253,7 +1253,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
brelse(bh); brelse(bh);
/* Release quota pointers in case we acquired them */ /* Release quota pointers in case we acquired them */
for (qtype = 0; qtype < MAXQUOTAS; qtype++) for (qtype = 0; qtype < OCFS2_MAXQUOTAS; qtype++)
dqput(transfer_to[qtype]); dqput(transfer_to[qtype]);
if (!status && attr->ia_valid & ATTR_MODE) { if (!status && attr->ia_valid & ATTR_MODE) {
......
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
#include "ocfs2.h" #include "ocfs2.h"
/* Number of quota types we support */
#define OCFS2_MAXQUOTAS 2
/* /*
* In-memory structures * In-memory structures
*/ */
...@@ -39,7 +42,7 @@ struct ocfs2_recovery_chunk { ...@@ -39,7 +42,7 @@ struct ocfs2_recovery_chunk {
}; };
struct ocfs2_quota_recovery { struct ocfs2_quota_recovery {
struct list_head r_list[MAXQUOTAS]; /* List of chunks to recover */ struct list_head r_list[OCFS2_MAXQUOTAS]; /* List of chunks to recover */
}; };
/* In-memory structure with quota header information */ /* In-memory structure with quota header information */
......
...@@ -336,8 +336,8 @@ void ocfs2_unlock_global_qf(struct ocfs2_mem_dqinfo *oinfo, int ex) ...@@ -336,8 +336,8 @@ void ocfs2_unlock_global_qf(struct ocfs2_mem_dqinfo *oinfo, int ex)
int ocfs2_global_read_info(struct super_block *sb, int type) int ocfs2_global_read_info(struct super_block *sb, int type)
{ {
struct inode *gqinode = NULL; struct inode *gqinode = NULL;
unsigned int ino[MAXQUOTAS] = { USER_QUOTA_SYSTEM_INODE, unsigned int ino[OCFS2_MAXQUOTAS] = { USER_QUOTA_SYSTEM_INODE,
GROUP_QUOTA_SYSTEM_INODE }; GROUP_QUOTA_SYSTEM_INODE };
struct ocfs2_global_disk_dqinfo dinfo; struct ocfs2_global_disk_dqinfo dinfo;
struct mem_dqinfo *info = sb_dqinfo(sb, type); struct mem_dqinfo *info = sb_dqinfo(sb, type);
struct ocfs2_mem_dqinfo *oinfo = info->dqi_priv; struct ocfs2_mem_dqinfo *oinfo = info->dqi_priv;
......
...@@ -166,12 +166,12 @@ static int ocfs2_read_quota_block(struct inode *inode, u64 v_block, ...@@ -166,12 +166,12 @@ static int ocfs2_read_quota_block(struct inode *inode, u64 v_block,
/* Check whether we understand format of quota files */ /* Check whether we understand format of quota files */
static int ocfs2_local_check_quota_file(struct super_block *sb, int type) static int ocfs2_local_check_quota_file(struct super_block *sb, int type)
{ {
unsigned int lmagics[MAXQUOTAS] = OCFS2_LOCAL_QMAGICS; unsigned int lmagics[OCFS2_MAXQUOTAS] = OCFS2_LOCAL_QMAGICS;
unsigned int lversions[MAXQUOTAS] = OCFS2_LOCAL_QVERSIONS; unsigned int lversions[OCFS2_MAXQUOTAS] = OCFS2_LOCAL_QVERSIONS;
unsigned int gmagics[MAXQUOTAS] = OCFS2_GLOBAL_QMAGICS; unsigned int gmagics[OCFS2_MAXQUOTAS] = OCFS2_GLOBAL_QMAGICS;
unsigned int gversions[MAXQUOTAS] = OCFS2_GLOBAL_QVERSIONS; unsigned int gversions[OCFS2_MAXQUOTAS] = OCFS2_GLOBAL_QVERSIONS;
unsigned int ino[MAXQUOTAS] = { USER_QUOTA_SYSTEM_INODE, unsigned int ino[OCFS2_MAXQUOTAS] = { USER_QUOTA_SYSTEM_INODE,
GROUP_QUOTA_SYSTEM_INODE }; GROUP_QUOTA_SYSTEM_INODE };
struct buffer_head *bh = NULL; struct buffer_head *bh = NULL;
struct inode *linode = sb_dqopt(sb)->files[type]; struct inode *linode = sb_dqopt(sb)->files[type];
struct inode *ginode = NULL; struct inode *ginode = NULL;
...@@ -336,7 +336,7 @@ void ocfs2_free_quota_recovery(struct ocfs2_quota_recovery *rec) ...@@ -336,7 +336,7 @@ void ocfs2_free_quota_recovery(struct ocfs2_quota_recovery *rec)
{ {
int type; int type;
for (type = 0; type < MAXQUOTAS; type++) for (type = 0; type < OCFS2_MAXQUOTAS; type++)
free_recovery_list(&(rec->r_list[type])); free_recovery_list(&(rec->r_list[type]));
kfree(rec); kfree(rec);
} }
...@@ -382,7 +382,7 @@ static struct ocfs2_quota_recovery *ocfs2_alloc_quota_recovery(void) ...@@ -382,7 +382,7 @@ static struct ocfs2_quota_recovery *ocfs2_alloc_quota_recovery(void)
rec = kmalloc(sizeof(struct ocfs2_quota_recovery), GFP_NOFS); rec = kmalloc(sizeof(struct ocfs2_quota_recovery), GFP_NOFS);
if (!rec) if (!rec)
return NULL; return NULL;
for (type = 0; type < MAXQUOTAS; type++) for (type = 0; type < OCFS2_MAXQUOTAS; type++)
INIT_LIST_HEAD(&(rec->r_list[type])); INIT_LIST_HEAD(&(rec->r_list[type]));
return rec; return rec;
} }
...@@ -392,10 +392,11 @@ struct ocfs2_quota_recovery *ocfs2_begin_quota_recovery( ...@@ -392,10 +392,11 @@ struct ocfs2_quota_recovery *ocfs2_begin_quota_recovery(
struct ocfs2_super *osb, struct ocfs2_super *osb,
int slot_num) int slot_num)
{ {
unsigned int feature[MAXQUOTAS] = { OCFS2_FEATURE_RO_COMPAT_USRQUOTA, unsigned int feature[OCFS2_MAXQUOTAS] = {
OCFS2_FEATURE_RO_COMPAT_GRPQUOTA}; OCFS2_FEATURE_RO_COMPAT_USRQUOTA,
unsigned int ino[MAXQUOTAS] = { LOCAL_USER_QUOTA_SYSTEM_INODE, OCFS2_FEATURE_RO_COMPAT_GRPQUOTA};
LOCAL_GROUP_QUOTA_SYSTEM_INODE }; unsigned int ino[OCFS2_MAXQUOTAS] = { LOCAL_USER_QUOTA_SYSTEM_INODE,
LOCAL_GROUP_QUOTA_SYSTEM_INODE };
struct super_block *sb = osb->sb; struct super_block *sb = osb->sb;
struct ocfs2_local_disk_dqinfo *ldinfo; struct ocfs2_local_disk_dqinfo *ldinfo;
struct inode *lqinode; struct inode *lqinode;
...@@ -412,7 +413,7 @@ struct ocfs2_quota_recovery *ocfs2_begin_quota_recovery( ...@@ -412,7 +413,7 @@ struct ocfs2_quota_recovery *ocfs2_begin_quota_recovery(
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
/* First init... */ /* First init... */
for (type = 0; type < MAXQUOTAS; type++) { for (type = 0; type < OCFS2_MAXQUOTAS; type++) {
if (!OCFS2_HAS_RO_COMPAT_FEATURE(sb, feature[type])) if (!OCFS2_HAS_RO_COMPAT_FEATURE(sb, feature[type]))
continue; continue;
/* At this point, journal of the slot is already replayed so /* At this point, journal of the slot is already replayed so
...@@ -589,8 +590,8 @@ int ocfs2_finish_quota_recovery(struct ocfs2_super *osb, ...@@ -589,8 +590,8 @@ int ocfs2_finish_quota_recovery(struct ocfs2_super *osb,
struct ocfs2_quota_recovery *rec, struct ocfs2_quota_recovery *rec,
int slot_num) int slot_num)
{ {
unsigned int ino[MAXQUOTAS] = { LOCAL_USER_QUOTA_SYSTEM_INODE, unsigned int ino[OCFS2_MAXQUOTAS] = { LOCAL_USER_QUOTA_SYSTEM_INODE,
LOCAL_GROUP_QUOTA_SYSTEM_INODE }; LOCAL_GROUP_QUOTA_SYSTEM_INODE };
struct super_block *sb = osb->sb; struct super_block *sb = osb->sb;
struct ocfs2_local_disk_dqinfo *ldinfo; struct ocfs2_local_disk_dqinfo *ldinfo;
struct buffer_head *bh; struct buffer_head *bh;
...@@ -604,7 +605,7 @@ int ocfs2_finish_quota_recovery(struct ocfs2_super *osb, ...@@ -604,7 +605,7 @@ int ocfs2_finish_quota_recovery(struct ocfs2_super *osb,
"slot %u\n", osb->dev_str, slot_num); "slot %u\n", osb->dev_str, slot_num);
mutex_lock(&sb_dqopt(sb)->dqonoff_mutex); mutex_lock(&sb_dqopt(sb)->dqonoff_mutex);
for (type = 0; type < MAXQUOTAS; type++) { for (type = 0; type < OCFS2_MAXQUOTAS; type++) {
if (list_empty(&(rec->r_list[type]))) if (list_empty(&(rec->r_list[type])))
continue; continue;
trace_ocfs2_finish_quota_recovery(slot_num); trace_ocfs2_finish_quota_recovery(slot_num);
......
...@@ -899,11 +899,12 @@ static int ocfs2_susp_quotas(struct ocfs2_super *osb, int unsuspend) ...@@ -899,11 +899,12 @@ static int ocfs2_susp_quotas(struct ocfs2_super *osb, int unsuspend)
{ {
int type; int type;
struct super_block *sb = osb->sb; struct super_block *sb = osb->sb;
unsigned int feature[MAXQUOTAS] = { OCFS2_FEATURE_RO_COMPAT_USRQUOTA, unsigned int feature[OCFS2_MAXQUOTAS] = {
OCFS2_FEATURE_RO_COMPAT_GRPQUOTA}; OCFS2_FEATURE_RO_COMPAT_USRQUOTA,
OCFS2_FEATURE_RO_COMPAT_GRPQUOTA};
int status = 0; int status = 0;
for (type = 0; type < MAXQUOTAS; type++) { for (type = 0; type < OCFS2_MAXQUOTAS; type++) {
if (!OCFS2_HAS_RO_COMPAT_FEATURE(sb, feature[type])) if (!OCFS2_HAS_RO_COMPAT_FEATURE(sb, feature[type]))
continue; continue;
if (unsuspend) if (unsuspend)
...@@ -927,17 +928,19 @@ static int ocfs2_susp_quotas(struct ocfs2_super *osb, int unsuspend) ...@@ -927,17 +928,19 @@ static int ocfs2_susp_quotas(struct ocfs2_super *osb, int unsuspend)
static int ocfs2_enable_quotas(struct ocfs2_super *osb) static int ocfs2_enable_quotas(struct ocfs2_super *osb)
{ {
struct inode *inode[MAXQUOTAS] = { NULL, NULL }; struct inode *inode[OCFS2_MAXQUOTAS] = { NULL, NULL };
struct super_block *sb = osb->sb; struct super_block *sb = osb->sb;
unsigned int feature[MAXQUOTAS] = { OCFS2_FEATURE_RO_COMPAT_USRQUOTA, unsigned int feature[OCFS2_MAXQUOTAS] = {
OCFS2_FEATURE_RO_COMPAT_GRPQUOTA}; OCFS2_FEATURE_RO_COMPAT_USRQUOTA,
unsigned int ino[MAXQUOTAS] = { LOCAL_USER_QUOTA_SYSTEM_INODE, OCFS2_FEATURE_RO_COMPAT_GRPQUOTA};
unsigned int ino[OCFS2_MAXQUOTAS] = {
LOCAL_USER_QUOTA_SYSTEM_INODE,
LOCAL_GROUP_QUOTA_SYSTEM_INODE }; LOCAL_GROUP_QUOTA_SYSTEM_INODE };
int status; int status;
int type; int type;
sb_dqopt(sb)->flags |= DQUOT_QUOTA_SYS_FILE | DQUOT_NEGATIVE_USAGE; sb_dqopt(sb)->flags |= DQUOT_QUOTA_SYS_FILE | DQUOT_NEGATIVE_USAGE;
for (type = 0; type < MAXQUOTAS; type++) { for (type = 0; type < OCFS2_MAXQUOTAS; type++) {
if (!OCFS2_HAS_RO_COMPAT_FEATURE(sb, feature[type])) if (!OCFS2_HAS_RO_COMPAT_FEATURE(sb, feature[type]))
continue; continue;
inode[type] = ocfs2_get_system_file_inode(osb, ino[type], inode[type] = ocfs2_get_system_file_inode(osb, ino[type],
...@@ -952,12 +955,12 @@ static int ocfs2_enable_quotas(struct ocfs2_super *osb) ...@@ -952,12 +955,12 @@ static int ocfs2_enable_quotas(struct ocfs2_super *osb)
goto out_quota_off; goto out_quota_off;
} }
for (type = 0; type < MAXQUOTAS; type++) for (type = 0; type < OCFS2_MAXQUOTAS; type++)
iput(inode[type]); iput(inode[type]);
return 0; return 0;
out_quota_off: out_quota_off:
ocfs2_disable_quotas(osb); ocfs2_disable_quotas(osb);
for (type = 0; type < MAXQUOTAS; type++) for (type = 0; type < OCFS2_MAXQUOTAS; type++)
iput(inode[type]); iput(inode[type]);
mlog_errno(status); mlog_errno(status);
return status; return status;
...@@ -972,7 +975,7 @@ static void ocfs2_disable_quotas(struct ocfs2_super *osb) ...@@ -972,7 +975,7 @@ static void ocfs2_disable_quotas(struct ocfs2_super *osb)
/* We mostly ignore errors in this function because there's not much /* We mostly ignore errors in this function because there's not much
* we can do when we see them */ * we can do when we see them */
for (type = 0; type < MAXQUOTAS; type++) { for (type = 0; type < OCFS2_MAXQUOTAS; type++) {
if (!sb_has_quota_loaded(sb, type)) if (!sb_has_quota_loaded(sb, type))
continue; continue;
/* Cancel periodic syncing before we grab dqonoff_mutex */ /* Cancel periodic syncing before we grab dqonoff_mutex */
...@@ -993,8 +996,9 @@ static void ocfs2_disable_quotas(struct ocfs2_super *osb) ...@@ -993,8 +996,9 @@ static void ocfs2_disable_quotas(struct ocfs2_super *osb)
/* Handle quota on quotactl */ /* Handle quota on quotactl */
static int ocfs2_quota_on(struct super_block *sb, int type, int format_id) static int ocfs2_quota_on(struct super_block *sb, int type, int format_id)
{ {
unsigned int feature[MAXQUOTAS] = { OCFS2_FEATURE_RO_COMPAT_USRQUOTA, unsigned int feature[OCFS2_MAXQUOTAS] = {
OCFS2_FEATURE_RO_COMPAT_GRPQUOTA}; OCFS2_FEATURE_RO_COMPAT_USRQUOTA,
OCFS2_FEATURE_RO_COMPAT_GRPQUOTA};
if (!OCFS2_HAS_RO_COMPAT_FEATURE(sb, feature[type])) if (!OCFS2_HAS_RO_COMPAT_FEATURE(sb, feature[type]))
return -EINVAL; return -EINVAL;
......
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