From 5522990660248930108e84c89bc7e5807bda9ea0 Mon Sep 17 00:00:00 2001 From: Wang Shilong Date: Thu, 28 Apr 2016 03:44:36 -0400 Subject: [PATCH] LU-4017 quota: redefine LL_MAXQUOTAS for Lustre Lustre code should similarly be patched to use LL_MAXQUOTAS like EXT4_MAXQUOTAS so that it is independent of the kernel MAXQUOTAS value. Signed-off-by: Wang Shilong Change-Id: I95c894600e6b9fa4932b367a1ef10635a9aa222d Reviewed-on: http://review.whamcloud.com/19843 Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Li Xi Reviewed-by: Niu Yawei --- lustre/include/lustre_quota.h | 4 ++++ lustre/include/obd.h | 3 ++- lustre/osc/osc_cache.c | 2 +- lustre/osc/osc_quota.c | 10 +++++----- lustre/osc/osc_request.c | 3 ++- lustre/osd-zfs/osd_object.c | 2 +- lustre/quota/lquota_entry.c | 3 ++- lustre/quota/qmt_handler.c | 2 +- lustre/quota/qmt_pool.c | 6 +++--- lustre/quota/qsd_config.c | 2 +- lustre/quota/qsd_internal.h | 4 ++-- lustre/quota/qsd_lib.c | 16 ++++++++-------- lustre/quota/qsd_writeback.c | 6 +++--- 13 files changed, 35 insertions(+), 28 deletions(-) diff --git a/lustre/include/lustre_quota.h b/lustre/include/lustre_quota.h index 8f2e417..2bb8c20 100644 --- a/lustre/include/lustre_quota.h +++ b/lustre/include/lustre_quota.h @@ -47,6 +47,10 @@ #define MAX_DQ_TIME 604800 /* (7*24*60*60) 1 week */ #endif +#ifndef LL_MAXQUOTAS +#define LL_MAXQUOTAS 2 +#endif + struct lquota_id_info; struct lquota_trans; diff --git a/lustre/include/obd.h b/lustre/include/obd.h index 331f036..4efe7f1 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -53,6 +53,7 @@ #include #include #include +#include #define MAX_OBD_DEVICES 8192 @@ -327,7 +328,7 @@ struct client_obd { void *cl_writeback_work; void *cl_lru_work; /* hash tables for osc_quota_info */ - struct cfs_hash *cl_quota_hash[MAXQUOTAS]; + struct cfs_hash *cl_quota_hash[LL_MAXQUOTAS]; }; #define obd2cli_tgt(obd) ((char *)(obd)->u.cli.cl_target_uuid.uuid) diff --git a/lustre/osc/osc_cache.c b/lustre/osc/osc_cache.c index 72a3350..664d4ea 100644 --- a/lustre/osc/osc_cache.c +++ b/lustre/osc/osc_cache.c @@ -2332,7 +2332,7 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io, if (!(cmd & OBD_BRW_NOQUOTA)) { struct cl_object *obj; struct cl_attr *attr; - unsigned int qid[MAXQUOTAS]; + unsigned int qid[LL_MAXQUOTAS]; obj = cl_object_top(&osc->oo_cl); attr = &osc_env_info(env)->oti_attr; diff --git a/lustre/osc/osc_quota.c b/lustre/osc/osc_quota.c index eaf5455..f259f49 100644 --- a/lustre/osc/osc_quota.c +++ b/lustre/osc/osc_quota.c @@ -47,7 +47,7 @@ int osc_quota_chkdq(struct client_obd *cli, const unsigned int qid[]) int type; ENTRY; - for (type = 0; type < MAXQUOTAS; type++) { + for (type = 0; type < LL_MAXQUOTAS; type++) { struct osc_quota_info *oqi; oqi = cfs_hash_lookup(cli->cl_quota_hash[type], &qid[type]); @@ -81,7 +81,7 @@ int osc_quota_setdq(struct client_obd *cli, const unsigned int qid[], if ((valid & (OBD_MD_FLUSRQUOTA | OBD_MD_FLGRPQUOTA)) == 0) RETURN(0); - for (type = 0; type < MAXQUOTAS; type++) { + for (type = 0; type < LL_MAXQUOTAS; type++) { struct osc_quota_info *oqi; if ((valid & MD_QUOTA_FLAG(type)) == 0) @@ -210,7 +210,7 @@ int osc_quota_setup(struct obd_device *obd) int i, type; ENTRY; - for (type = 0; type < MAXQUOTAS; type++) { + for (type = 0; type < LL_MAXQUOTAS; type++) { cli->cl_quota_hash[type] = cfs_hash_create("QUOTA_HASH", HASH_QUOTA_CUR_BITS, HASH_QUOTA_MAX_BITS, @@ -224,7 +224,7 @@ int osc_quota_setup(struct obd_device *obd) break; } - if (type == MAXQUOTAS) + if (type == LL_MAXQUOTAS) RETURN(0); for (i = 0; i < type; i++) @@ -239,7 +239,7 @@ int osc_quota_cleanup(struct obd_device *obd) int type; ENTRY; - for (type = 0; type < MAXQUOTAS; type++) + for (type = 0; type < LL_MAXQUOTAS; type++) cfs_hash_putref(cli->cl_quota_hash[type]); RETURN(0); diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index bc2f25c..5161287 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -1391,7 +1391,8 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) /* set/clear over quota flag for a uid/gid */ if (lustre_msg_get_opc(req->rq_reqmsg) == OST_WRITE && body->oa.o_valid & (OBD_MD_FLUSRQUOTA | OBD_MD_FLGRPQUOTA)) { - unsigned int qid[MAXQUOTAS] = { body->oa.o_uid, body->oa.o_gid }; + unsigned int qid[LL_MAXQUOTAS] = + {body->oa.o_uid, body->oa.o_gid}; CDEBUG(D_QUOTA, "setdq for [%u %u] with valid "LPX64", flags %x\n", body->oa.o_uid, body->oa.o_gid, body->oa.o_valid, diff --git a/lustre/osd-zfs/osd_object.c b/lustre/osd-zfs/osd_object.c index 4079eeb..2575ea4 100644 --- a/lustre/osd-zfs/osd_object.c +++ b/lustre/osd-zfs/osd_object.c @@ -798,7 +798,7 @@ static inline int qsd_transfer(const struct lu_env *env, if (unlikely(qsd == NULL)) return 0; - LASSERT(qtype >= 0 && qtype < MAXQUOTAS); + LASSERT(qtype >= 0 && qtype < LL_MAXQUOTAS); qi->lqi_type = qtype; /* inode accounting */ diff --git a/lustre/quota/lquota_entry.c b/lustre/quota/lquota_entry.c index 38324e9..92a9c6e 100644 --- a/lustre/quota/lquota_entry.c +++ b/lustre/quota/lquota_entry.c @@ -203,7 +203,8 @@ struct lquota_site *lquota_site_alloc(const struct lu_env *env, void *parent, char hashname[15]; ENTRY; - LASSERT(qtype < MAXQUOTAS); + if (qtype >= LL_MAXQUOTAS) + RETURN(ERR_PTR(-ENOTSUPP)); OBD_ALLOC_PTR(site); if (site == NULL) diff --git a/lustre/quota/qmt_handler.c b/lustre/quota/qmt_handler.c index a1f0f1b..7ae6a0c 100644 --- a/lustre/quota/qmt_handler.c +++ b/lustre/quota/qmt_handler.c @@ -209,7 +209,7 @@ static int qmt_quotactl(const struct lu_env *env, struct lu_device *ld, LASSERT(qmt != NULL); - if (oqctl->qc_type >= MAXQUOTAS) + if (oqctl->qc_type >= LL_MAXQUOTAS) /* invalid quota type */ RETURN(-EINVAL); diff --git a/lustre/quota/qmt_pool.c b/lustre/quota/qmt_pool.c index 47f5b12..69b209f 100644 --- a/lustre/quota/qmt_pool.c +++ b/lustre/quota/qmt_pool.c @@ -159,7 +159,7 @@ static int qpi_state_seq_show(struct seq_file *m, void *data) atomic_read(&pool->qpi_ref), pool->qpi_least_qunit); - for (type = 0; type < MAXQUOTAS; type++) + for (type = 0; type < LL_MAXQUOTAS; type++) seq_printf(m, " %s:\n" " #slv: %d\n" " #lqe: %d\n", @@ -314,7 +314,7 @@ static void qmt_pool_free(const struct lu_env *env, struct qmt_pool_info *pool) /* release per-quota type site used to manage quota entries as well as * references to global index files */ - for (qtype = 0; qtype < MAXQUOTAS; qtype++) { + for (qtype = 0; qtype < LL_MAXQUOTAS; qtype++) { /* release lqe storing grace time */ if (pool->qpi_grace_lqe[qtype] != NULL) lqe_putref(pool->qpi_grace_lqe[qtype]); @@ -528,7 +528,7 @@ int qmt_pool_prepare(const struct lu_env *env, struct qmt_device *qmt, RETURN(PTR_ERR(obj)); pool->qpi_root = obj; - for (qtype = 0; qtype < MAXQUOTAS; qtype++) { + for (qtype = 0; qtype < LL_MAXQUOTAS; qtype++) { /* Generating FID of global index in charge of storing * settings for this quota type */ lquota_generate_fid(&qti->qti_fid, pool_id, pool_type, diff --git a/lustre/quota/qsd_config.c b/lustre/quota/qsd_config.c index 282526c..06e566e 100644 --- a/lustre/quota/qsd_config.c +++ b/lustre/quota/qsd_config.c @@ -198,7 +198,7 @@ int qsd_process_config(struct lustre_cfg *lcfg) continue; } - for (type = USRQUOTA; type < MAXQUOTAS; type++) { + for (type = USRQUOTA; type < LL_MAXQUOTAS; type++) { qqi = qsd->qsd_type_array[type]; qsd_start_reint_thread(qqi); } diff --git a/lustre/quota/qsd_internal.h b/lustre/quota/qsd_internal.h index 94cb04f..9b1d6b2 100644 --- a/lustre/quota/qsd_internal.h +++ b/lustre/quota/qsd_internal.h @@ -70,7 +70,7 @@ struct qsd_instance { * * This will have to be revisited if new quota types are added in the * future. For the time being, we can just use an array. */ - struct qsd_qtype_info *qsd_type_array[MAXQUOTAS]; + struct qsd_qtype_info *qsd_type_array[LL_MAXQUOTAS]; /* per-filesystem quota information */ struct qsd_fsinfo *qsd_fsinfo; @@ -277,7 +277,7 @@ static inline int qsd_type_enabled(struct qsd_instance *qsd, int type) int enabled, pool; LASSERT(qsd != NULL); - LASSERT(type < MAXQUOTAS); + LASSERT(type < LL_MAXQUOTAS); if (qsd->qsd_fsinfo == NULL) return 0; diff --git a/lustre/quota/qsd_lib.c b/lustre/quota/qsd_lib.c index 1a4b5ad..1e4236c 100644 --- a/lustre/quota/qsd_lib.c +++ b/lustre/quota/qsd_lib.c @@ -160,7 +160,7 @@ lprocfs_force_reint_seq_write(struct file *file, const char __user *buffer, rc = -EAGAIN; } else { /* mark all indexes as stale */ - for (qtype = USRQUOTA; qtype < MAXQUOTAS; qtype++) { + for (qtype = USRQUOTA; qtype < LL_MAXQUOTAS; qtype++) { qsd->qsd_type_array[qtype]->qqi_glb_uptodate = false; qsd->qsd_type_array[qtype]->qqi_slv_uptodate = false; } @@ -171,7 +171,7 @@ lprocfs_force_reint_seq_write(struct file *file, const char __user *buffer, return rc; /* kick off reintegration */ - for (qtype = USRQUOTA; qtype < MAXQUOTAS; qtype++) { + for (qtype = USRQUOTA; qtype < LL_MAXQUOTAS; qtype++) { rc = qsd_start_reint_thread(qsd->qsd_type_array[qtype]); if (rc) break; @@ -252,7 +252,7 @@ static int qsd_conn_callback(void *data) * reintegration procedure (i.e. global lock enqueue and slave * index transfer) since the space usage reconciliation (i.e. * step 3) will have to wait for qsd_start() to be called */ - for (type = USRQUOTA; type < MAXQUOTAS; type++) { + for (type = USRQUOTA; type < LL_MAXQUOTAS; type++) { struct qsd_qtype_info *qqi = qsd->qsd_type_array[type]; wake_up(&qqi->qqi_reint_thread.t_ctl_waitq); } @@ -494,7 +494,7 @@ void qsd_fini(const struct lu_env *env, struct qsd_instance *qsd) qsd_stop_upd_thread(qsd); /* shutdown the reintegration threads */ - for (qtype = USRQUOTA; qtype < MAXQUOTAS; qtype++) { + for (qtype = USRQUOTA; qtype < LL_MAXQUOTAS; qtype++) { if (qsd->qsd_type_array[qtype] == NULL) continue; qsd_stop_reint_thread(qsd->qsd_type_array[qtype]); @@ -505,7 +505,7 @@ void qsd_fini(const struct lu_env *env, struct qsd_instance *qsd) } /* free per-quota type data */ - for (qtype = USRQUOTA; qtype < MAXQUOTAS; qtype++) + for (qtype = USRQUOTA; qtype < LL_MAXQUOTAS; qtype++) qsd_qtype_fini(env, qsd, qtype); /* deregister connection to the quota master */ @@ -692,7 +692,7 @@ int qsd_prepare(const struct lu_env *env, struct qsd_instance *qsd) } /* initialize per-quota type data */ - for (qtype = USRQUOTA; qtype < MAXQUOTAS; qtype++) { + for (qtype = USRQUOTA; qtype < LL_MAXQUOTAS; qtype++) { rc = qsd_qtype_init(env, qsd, qtype); if (rc) RETURN(rc); @@ -704,7 +704,7 @@ int qsd_prepare(const struct lu_env *env, struct qsd_instance *qsd) write_unlock(&qsd->qsd_lock); /* start reintegration thread for each type, if required */ - for (qtype = USRQUOTA; qtype < MAXQUOTAS; qtype++) { + for (qtype = USRQUOTA; qtype < LL_MAXQUOTAS; qtype++) { struct qsd_qtype_info *qqi = qsd->qsd_type_array[qtype]; if (qsd_type_enabled(qsd, qtype) && qsd->qsd_acct_failed) { @@ -792,7 +792,7 @@ int qsd_start(const struct lu_env *env, struct qsd_instance *qsd) /* Trigger the 3rd step of reintegration: If usage > granted, acquire * up to usage; If usage < granted, release down to usage. */ - for (type = USRQUOTA; type < MAXQUOTAS; type++) { + for (type = USRQUOTA; type < LL_MAXQUOTAS; type++) { struct qsd_qtype_info *qqi = qsd->qsd_type_array[type]; wake_up(&qqi->qqi_reint_thread.t_ctl_waitq); } diff --git a/lustre/quota/qsd_writeback.c b/lustre/quota/qsd_writeback.c index 7e82e77..3109ca3 100644 --- a/lustre/quota/qsd_writeback.c +++ b/lustre/quota/qsd_writeback.c @@ -390,7 +390,7 @@ static bool qsd_job_pending(struct qsd_instance *qsd, struct list_head *upd, return job_pending; } - for (qtype = USRQUOTA; qtype < MAXQUOTAS; qtype++) { + for (qtype = USRQUOTA; qtype < LL_MAXQUOTAS; qtype++) { struct qsd_qtype_info *qqi = qsd->qsd_type_array[qtype]; if (!qsd_type_enabled(qsd, qtype)) @@ -480,7 +480,7 @@ static int qsd_upd_thread(void *arg) if (uptodate) continue; - for (qtype = USRQUOTA; qtype < MAXQUOTAS; qtype++) + for (qtype = USRQUOTA; qtype < LL_MAXQUOTAS; qtype++) qsd_start_reint_thread(qsd->qsd_type_array[qtype]); } lu_env_fini(env); @@ -516,7 +516,7 @@ static void qsd_cleanup_deferred(struct qsd_instance *qsd) { int qtype; - for (qtype = USRQUOTA; qtype < MAXQUOTAS; qtype++) { + for (qtype = USRQUOTA; qtype < LL_MAXQUOTAS; qtype++) { struct qsd_upd_rec *upd, *tmp; struct qsd_qtype_info *qqi = qsd->qsd_type_array[qtype]; -- 1.8.3.1