Whamcloud - gitweb
LU-11023 quota: remove quota pool ID 89/34389/6
authorSergey Cheremencev <c17829@cray.com>
Tue, 25 Jun 2019 02:42:38 +0000 (22:42 -0400)
committerOleg Drokin <green@whamcloud.com>
Fri, 9 Aug 2019 04:41:23 +0000 (04:41 +0000)
Remove pool ID support in quotas as it is
totally unused. It is also needed to start
implementation of quota pools that may
include 2 type of slaves - OST's or MDT's.
At the first stage quota pools will be the
mirror of LOD pools. Further when/if MDT pools
will appear, these could be aslo used as quota
pools.
The main part of quota pool's is not
changed because it will be used for new quota
pools. Remove qmt's pool hash as pool's look up
mainly will be performed by OST/MDT index and
all code connected with quota pool ID.

Cray-bug-id: LUS-5801
Change-Id: Icb72b69e1d194f23a58fcfbd2655969ad73be46b
Signed-off-by: Sergey Cheremencev <c17829@cray.com>
Reviewed-on: https://review.whamcloud.com/34389
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Hongchao Zhang <hongchao@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/quota/lproc_quota.c
lustre/quota/lquota_disk.c
lustre/quota/lquota_internal.h
lustre/quota/lquota_lib.c
lustre/quota/qmt_entry.c
lustre/quota/qmt_handler.c
lustre/quota/qmt_internal.h
lustre/quota/qmt_lock.c
lustre/quota/qmt_pool.c
lustre/quota/qsd_internal.h
lustre/quota/qsd_lib.c

index a9a3b0b..cfe7b9b 100644 (file)
@@ -212,13 +212,13 @@ static int lprocfs_quota_seq_show(struct seq_file *p, void *v)
                if (fid_is_acct(fid)) {
                        seq_printf(p, "%s:\n", oid2name(fid_oid(fid)));
                } else if (fid_seq(fid) == FID_SEQ_QUOTA_GLB) {
                if (fid_is_acct(fid)) {
                        seq_printf(p, "%s:\n", oid2name(fid_oid(fid)));
                } else if (fid_seq(fid) == FID_SEQ_QUOTA_GLB) {
-                       int     poolid, rtype, qtype;
+                       int     rtype, qtype;
 
 
-                       rc = lquota_extract_fid(fid, &poolid, &rtype, &qtype);
+                       rc = lquota_extract_fid(fid, &rtype, &qtype);
                        if (rc)
                                return rc;
 
                        if (rc)
                                return rc;
 
-                       seq_printf(p, "global_pool%d_%s_%s\n", poolid,
+                       seq_printf(p, "global_pool%d_%s_%s\n", 0,
                                   RES_NAME(rtype), qtype_name(qtype));
                } else if (fid_seq(fid) == FID_SEQ_LOCAL_NAME) {
                        /* global index copy object */
                                   RES_NAME(rtype), qtype_name(qtype));
                } else if (fid_seq(fid) == FID_SEQ_LOCAL_NAME) {
                        /* global index copy object */
index 77e69c8..98acb04 100644 (file)
@@ -129,7 +129,7 @@ static inline int lquota_disk_slv_filename(const struct lu_fid *glb_fid,
        name++;
 
        /* the filename is composed of the most signicant bits of the global
        name++;
 
        /* the filename is composed of the most signicant bits of the global
-        * FID, that's to say the oid which encodes the pool id, pool type and
+        * FID, that's to say the oid which encodes the pool type and
         * quota type, followed by the export UUID */
        sprintf(filename, "0x%x-%s", glb_fid->f_oid, name);
 
         * quota type, followed by the export UUID */
        sprintf(filename, "0x%x-%s", glb_fid->f_oid, name);
 
@@ -248,8 +248,7 @@ struct dt_object *lquota_disk_glb_find_create(const struct lu_env *env,
        idx_feat = &dt_quota_glb_features;
 
        /* the filename is composed of the most signicant bits of the FID,
        idx_feat = &dt_quota_glb_features;
 
        /* the filename is composed of the most signicant bits of the FID,
-        * that's to say the oid which encodes the pool id, pool type and quota
-        * type */
+        * that's to say the oid which encodes the pool type and quota type */
        sprintf(qti->qti_buf, "0x%x", fid->f_oid);
 
        if (local) {
        sprintf(qti->qti_buf, "0x%x", fid->f_oid);
 
        if (local) {
@@ -407,7 +406,7 @@ struct dt_object *lquota_disk_slv_find_create(const struct lu_env *env,
        if (local) {
                int pool_type, qtype;
 
        if (local) {
                int pool_type, qtype;
 
-               rc = lquota_extract_fid(glb_fid, NULL, &pool_type, &qtype);
+               rc = lquota_extract_fid(glb_fid, &pool_type, &qtype);
                if (rc)
                        RETURN(ERR_PTR(rc));
 
                if (rc)
                        RETURN(ERR_PTR(rc));
 
index 1f7626b..009eb5c 100644 (file)
@@ -394,8 +394,8 @@ void lquota_lqe_debug0(struct lquota_entry *lqe,
 /* lquota_lib.c */
 struct dt_object *acct_obj_lookup(const struct lu_env *, struct dt_device *,
                                  int);
 /* lquota_lib.c */
 struct dt_object *acct_obj_lookup(const struct lu_env *, struct dt_device *,
                                  int);
-void lquota_generate_fid(struct lu_fid *, int, int, int);
-int lquota_extract_fid(const struct lu_fid *, int *, int *, int *);
+void lquota_generate_fid(struct lu_fid *, int, int);
+int lquota_extract_fid(const struct lu_fid *, int *, int *);
 const struct dt_index_features *glb_idx_feature(struct lu_fid *);
 
 /* lquota_entry.c */
 const struct dt_index_features *glb_idx_feature(struct lu_fid *);
 
 /* lquota_entry.c */
index 093dc38..8bbc58b 100644 (file)
@@ -307,24 +307,23 @@ static inline int lqtype2qtype(int lqtype)
 
 /**
  * Helper routine returning the FID associated with the global index storing
 
 /**
  * Helper routine returning the FID associated with the global index storing
- * quota settings for the storage pool \pool_id, resource type \pool_type and
+ * quota settings for default storage pool, resource type \pool_type and
  * the quota type \quota_type.
  */
  * the quota type \quota_type.
  */
-void lquota_generate_fid(struct lu_fid *fid, int pool_id, int pool_type,
-                       int quota_type)
+void lquota_generate_fid(struct lu_fid *fid, int pool_type, int quota_type)
 {
        __u8     lqtype = qtype2lqtype(quota_type);
 
        fid->f_seq = FID_SEQ_QUOTA_GLB;
 {
        __u8     lqtype = qtype2lqtype(quota_type);
 
        fid->f_seq = FID_SEQ_QUOTA_GLB;
-       fid->f_oid = (lqtype << 24) | (pool_type << 16) | (__u16)pool_id;
+       fid->f_oid = (lqtype << 24) | (pool_type << 16);
        fid->f_ver = 0;
 }
 
 /**
        fid->f_ver = 0;
 }
 
 /**
- * Helper routine used to extract pool ID, pool type and quota type from a
+ * Helper routine used to extract pool type and quota type from a
  * given FID.
  */
  * given FID.
  */
-int lquota_extract_fid(const struct lu_fid *fid, int *pool_id, int *pool_type,
+int lquota_extract_fid(const struct lu_fid *fid, int *pool_type,
                       int *quota_type)
 {
        unsigned int lqtype;
                       int *quota_type)
 {
        unsigned int lqtype;
@@ -333,14 +332,6 @@ int lquota_extract_fid(const struct lu_fid *fid, int *pool_id, int *pool_type,
        if (fid->f_seq != FID_SEQ_QUOTA_GLB)
                RETURN(-EINVAL);
 
        if (fid->f_seq != FID_SEQ_QUOTA_GLB)
                RETURN(-EINVAL);
 
-       if (pool_id != NULL) {
-               lqtype = fid->f_oid & 0xffffU;
-               if (lqtype != 0)
-                       /* we only support pool ID 0 for the time being */
-                       RETURN(-ENOTSUPP);
-               *pool_id = lqtype;
-       }
-
        if (pool_type != NULL) {
                lqtype = (fid->f_oid >> 16) & 0xffU;
                if (lqtype >= LQUOTA_LAST_RES)
        if (pool_type != NULL) {
                lqtype = (fid->f_oid >> 16) & 0xffU;
                if (lqtype >= LQUOTA_LAST_RES)
index 1abc6e0..d3ed254 100644 (file)
@@ -165,10 +165,10 @@ static void qmt_lqe_debug(struct lquota_entry *lqe, void *arg,
        struct qmt_pool_info    *pool = (struct qmt_pool_info *)arg;
 
        libcfs_debug_msg(msgdata,
        struct qmt_pool_info    *pool = (struct qmt_pool_info *)arg;
 
        libcfs_debug_msg(msgdata,
-                        "%pV qmt:%s pool:%d-%s id:%llu enforced:%d hard:%llu soft:%llu granted:%llu time:%llu qunit: %llu edquot:%d may_rel:%llu revoke:%lld default:%s\n",
+                        "%pV qmt:%s pool:%s-%s id:%llu enforced:%d hard:%llu soft:%llu granted:%llu time:%llu qunit: %llu edquot:%d may_rel:%llu revoke:%lld default:%s\n",
                         vaf, pool->qpi_qmt->qmt_svname,
                         vaf, pool->qpi_qmt->qmt_svname,
-                        pool->qpi_key & 0x0000ffff,
-                        RES_NAME(pool->qpi_key >> 16),
+                        RES_NAME(pool->qpi_rtype),
+                        pool->qpi_name,
                         lqe->lqe_id.qid_uid, lqe->lqe_enforced,
                         lqe->lqe_hardlimit, lqe->lqe_softlimit,
                         lqe->lqe_granted, lqe->lqe_gracetime,
                         lqe->lqe_id.qid_uid, lqe->lqe_enforced,
                         lqe->lqe_hardlimit, lqe->lqe_softlimit,
                         lqe->lqe_granted, lqe->lqe_gracetime,
@@ -483,7 +483,7 @@ void qmt_adjust_edquot(struct lquota_entry *lqe, __u64 now)
 
                /* See comment in qmt_adjust_qunit(). LU-4139 */
                if (qmt_hard_exhausted(lqe) ||
 
                /* See comment in qmt_adjust_qunit(). LU-4139 */
                if (qmt_hard_exhausted(lqe) ||
-                   pool->qpi_key >> 16 != LQUOTA_RES_DT) {
+                   pool->qpi_rtype != LQUOTA_RES_DT) {
                        time64_t lapse;
 
                        /* we haven't reached the minimal qunit yet so there is
                        time64_t lapse;
 
                        /* we haven't reached the minimal qunit yet so there is
@@ -543,7 +543,7 @@ static __u64 qmt_calc_softlimit(struct lquota_entry *lqe, bool *oversoft)
        LASSERT(lqe->lqe_softlimit != 0);
        *oversoft = false;
        /* No need to do special tweaking for inode limit */
        LASSERT(lqe->lqe_softlimit != 0);
        *oversoft = false;
        /* No need to do special tweaking for inode limit */
-       if (pool->qpi_key >> 16 != LQUOTA_RES_DT)
+       if (pool->qpi_rtype != LQUOTA_RES_DT)
                return lqe->lqe_softlimit;
 
        if (lqe->lqe_granted <= lqe->lqe_softlimit +
                return lqe->lqe_softlimit;
 
        if (lqe->lqe_granted <= lqe->lqe_softlimit +
index 455652c..3e8d7f5 100644 (file)
@@ -38,7 +38,6 @@
  *
  * \param env     - is the environment passed by the caller
  * \param qmt     - is the quota master target
  *
  * \param env     - is the environment passed by the caller
  * \param qmt     - is the quota master target
- * \param pool_id - is the 16-bit pool identifier
  * \param restype - is the pool type, either block (i.e. LQUOTA_RES_DT) or inode
  *                  (i.e. LQUOTA_RES_MD)
  * \param qtype   - is the quota type
  * \param restype - is the pool type, either block (i.e. LQUOTA_RES_DT) or inode
  *                  (i.e. LQUOTA_RES_MD)
  * \param qtype   - is the quota type
@@ -49,7 +48,7 @@
  * \param time    - is the output variable where to copy the grace time
  */
 static int qmt_get(const struct lu_env *env, struct qmt_device *qmt,
  * \param time    - is the output variable where to copy the grace time
  */
 static int qmt_get(const struct lu_env *env, struct qmt_device *qmt,
-                  __u16 pool_id, __u8 restype, __u8 qtype, union lquota_id *id,
+                  __u8 restype, __u8 qtype, union lquota_id *id,
                   __u64 *hard, __u64 *soft, __u64 *time, bool is_default)
 {
        struct lquota_entry     *lqe;
                   __u64 *hard, __u64 *soft, __u64 *time, bool is_default)
 {
        struct lquota_entry     *lqe;
@@ -58,7 +57,7 @@ static int qmt_get(const struct lu_env *env, struct qmt_device *qmt,
        LASSERT(!is_default || id->qid_uid == 0);
 
        /* look-up lqe structure containing quota settings */
        LASSERT(!is_default || id->qid_uid == 0);
 
        /* look-up lqe structure containing quota settings */
-       lqe = qmt_pool_lqe_lookup(env, qmt, pool_id, restype, qtype, id);
+       lqe = qmt_pool_lqe_lookup(env, qmt, restype, qtype, id);
        if (IS_ERR(lqe))
                RETURN(PTR_ERR(lqe));
 
        if (IS_ERR(lqe))
                RETURN(PTR_ERR(lqe));
 
@@ -249,7 +248,6 @@ out_nolock:
  *
  * \param env        - is the environment passed by the caller
  * \param qmt        - is the quota master target
  *
  * \param env        - is the environment passed by the caller
  * \param qmt        - is the quota master target
- * \param pool_id    - is the 16-bit pool identifier
  * \param restype    - is the pool type, either block (i.e. LQUOTA_RES_DT) or
  *                     inode (i.e. LQUOTA_RES_MD)
  * \param qtype      - is the quota type
  * \param restype    - is the pool type, either block (i.e. LQUOTA_RES_DT) or
  *                     inode (i.e. LQUOTA_RES_MD)
  * \param qtype      - is the quota type
@@ -263,16 +261,16 @@ out_nolock:
  * \param is_updated - true if the lqe is updated and no need to write back
  */
 static int qmt_set(const struct lu_env *env, struct qmt_device *qmt,
  * \param is_updated - true if the lqe is updated and no need to write back
  */
 static int qmt_set(const struct lu_env *env, struct qmt_device *qmt,
-                  __u16 pool_id, __u8 restype, __u8 qtype,
-                  union lquota_id *id, __u64 hard, __u64 soft, __u64 time,
-                  __u32 valid, bool is_default, bool is_updated)
+                  __u8 restype, __u8 qtype, union lquota_id *id,
+                  __u64 hard, __u64 soft, __u64 time, __u32 valid,
+                  bool is_default, bool is_updated)
 {
        struct lquota_entry *lqe;
        int rc;
        ENTRY;
 
        /* look-up quota entry associated with this ID */
 {
        struct lquota_entry *lqe;
        int rc;
        ENTRY;
 
        /* look-up quota entry associated with this ID */
-       lqe = qmt_pool_lqe_lookup(env, qmt, pool_id, restype, qtype, id);
+       lqe = qmt_pool_lqe_lookup(env, qmt, restype, qtype, id);
        if (IS_ERR(lqe))
                        RETURN(PTR_ERR(lqe));
 
        if (IS_ERR(lqe))
                        RETURN(PTR_ERR(lqe));
 
@@ -314,13 +312,13 @@ static int qmt_quotactl(const struct lu_env *env, struct lu_device *ld,
                id->qid_uid = 0;
 
                /* read inode grace time */
                id->qid_uid = 0;
 
                /* read inode grace time */
-               rc = qmt_get(env, qmt, 0, LQUOTA_RES_MD, oqctl->qc_type, id,
+               rc = qmt_get(env, qmt, LQUOTA_RES_MD, oqctl->qc_type, id,
                             NULL, NULL, &oqctl->qc_dqinfo.dqi_igrace, false);
                if (rc)
                        break;
 
                /* read block grace time */
                             NULL, NULL, &oqctl->qc_dqinfo.dqi_igrace, false);
                if (rc)
                        break;
 
                /* read block grace time */
-               rc = qmt_get(env, qmt, 0, LQUOTA_RES_DT, oqctl->qc_type, id,
+               rc = qmt_get(env, qmt, LQUOTA_RES_DT, oqctl->qc_type, id,
                             NULL, NULL, &oqctl->qc_dqinfo.dqi_bgrace, false);
                break;
 
                             NULL, NULL, &oqctl->qc_dqinfo.dqi_bgrace, false);
                break;
 
@@ -334,7 +332,7 @@ static int qmt_quotactl(const struct lu_env *env, struct lu_device *ld,
 
                if ((dqb->dqb_valid & QIF_ITIME) != 0) {
                        /* set inode grace time */
 
                if ((dqb->dqb_valid & QIF_ITIME) != 0) {
                        /* set inode grace time */
-                       rc = qmt_set(env, qmt, 0, LQUOTA_RES_MD, oqctl->qc_type,
+                       rc = qmt_set(env, qmt, LQUOTA_RES_MD, oqctl->qc_type,
                                     id, 0, 0, oqctl->qc_dqinfo.dqi_igrace,
                                     QIF_TIMES, false, false);
                        if (rc)
                                     id, 0, 0, oqctl->qc_dqinfo.dqi_igrace,
                                     QIF_TIMES, false, false);
                        if (rc)
@@ -343,7 +341,7 @@ static int qmt_quotactl(const struct lu_env *env, struct lu_device *ld,
 
                if ((dqb->dqb_valid & QIF_BTIME) != 0)
                        /* set block grace time */
 
                if ((dqb->dqb_valid & QIF_BTIME) != 0)
                        /* set block grace time */
-                       rc = qmt_set(env, qmt, 0, LQUOTA_RES_DT, oqctl->qc_type,
+                       rc = qmt_set(env, qmt, LQUOTA_RES_DT, oqctl->qc_type,
                                     id, 0, 0, oqctl->qc_dqinfo.dqi_bgrace,
                                     QIF_TIMES, false, false);
                break;
                                     id, 0, 0, oqctl->qc_dqinfo.dqi_bgrace,
                                     QIF_TIMES, false, false);
                break;
@@ -356,7 +354,7 @@ static int qmt_quotactl(const struct lu_env *env, struct lu_device *ld,
                id->qid_uid = oqctl->qc_id;
 
                /* look-up inode quota settings */
                id->qid_uid = oqctl->qc_id;
 
                /* look-up inode quota settings */
-               rc = qmt_get(env, qmt, 0, LQUOTA_RES_MD, oqctl->qc_type, id,
+               rc = qmt_get(env, qmt, LQUOTA_RES_MD, oqctl->qc_type, id,
                             &dqb->dqb_ihardlimit, &dqb->dqb_isoftlimit,
                             &dqb->dqb_itime, is_default);
                if (rc)
                             &dqb->dqb_ihardlimit, &dqb->dqb_isoftlimit,
                             &dqb->dqb_itime, is_default);
                if (rc)
@@ -367,7 +365,7 @@ static int qmt_quotactl(const struct lu_env *env, struct lu_device *ld,
                dqb->dqb_curinodes = 0;
 
                /* look-up block quota settings */
                dqb->dqb_curinodes = 0;
 
                /* look-up block quota settings */
-               rc = qmt_get(env, qmt, 0, LQUOTA_RES_DT, oqctl->qc_type, id,
+               rc = qmt_get(env, qmt, LQUOTA_RES_DT, oqctl->qc_type, id,
                             &dqb->dqb_bhardlimit, &dqb->dqb_bsoftlimit,
                             &dqb->dqb_btime, is_default);
                if (rc)
                             &dqb->dqb_bhardlimit, &dqb->dqb_bsoftlimit,
                             &dqb->dqb_btime, is_default);
                if (rc)
@@ -387,7 +385,7 @@ static int qmt_quotactl(const struct lu_env *env, struct lu_device *ld,
 
                if ((dqb->dqb_valid & QIF_IFLAGS) != 0) {
                        /* update inode quota settings */
 
                if ((dqb->dqb_valid & QIF_IFLAGS) != 0) {
                        /* update inode quota settings */
-                       rc = qmt_set(env, qmt, 0, LQUOTA_RES_MD, oqctl->qc_type,
+                       rc = qmt_set(env, qmt, LQUOTA_RES_MD, oqctl->qc_type,
                                     id, dqb->dqb_ihardlimit,
                                     dqb->dqb_isoftlimit, dqb->dqb_itime,
                                     dqb->dqb_valid & QIF_IFLAGS, is_default,
                                     id, dqb->dqb_ihardlimit,
                                     dqb->dqb_isoftlimit, dqb->dqb_itime,
                                     dqb->dqb_valid & QIF_IFLAGS, is_default,
@@ -398,7 +396,7 @@ static int qmt_quotactl(const struct lu_env *env, struct lu_device *ld,
 
                if ((dqb->dqb_valid & QIF_BFLAGS) != 0)
                        /* update block quota settings */
 
                if ((dqb->dqb_valid & QIF_BFLAGS) != 0)
                        /* update block quota settings */
-                       rc = qmt_set(env, qmt, 0, LQUOTA_RES_DT, oqctl->qc_type,
+                       rc = qmt_set(env, qmt, LQUOTA_RES_DT, oqctl->qc_type,
                                     id, dqb->dqb_bhardlimit,
                                     dqb->dqb_bsoftlimit, dqb->dqb_btime,
                                     dqb->dqb_valid & QIF_BFLAGS, is_default,
                                     id, dqb->dqb_bhardlimit,
                                     dqb->dqb_bsoftlimit, dqb->dqb_btime,
                                     dqb->dqb_valid & QIF_BFLAGS, is_default,
@@ -678,7 +676,7 @@ static int qmt_dqacq(const struct lu_env *env, struct lu_device *ld,
        struct obd_uuid         *uuid;
        struct ldlm_lock        *lock;
        struct lquota_entry     *lqe;
        struct obd_uuid         *uuid;
        struct ldlm_lock        *lock;
        struct lquota_entry     *lqe;
-       int                      pool_id, pool_type, qtype;
+       int                      pool_type, qtype;
        int                      rc;
        ENTRY;
 
        int                      rc;
        ENTRY;
 
@@ -743,14 +741,14 @@ static int qmt_dqacq(const struct lu_env *env, struct lu_device *ld,
                LDLM_LOCK_PUT(lock);
        }
 
                LDLM_LOCK_PUT(lock);
        }
 
-       /* extract pool & quota information from global index FID packed in the
+       /* extract quota information from global index FID packed in the
         * request */
         * request */
-       rc = lquota_extract_fid(&qbody->qb_fid, &pool_id, &pool_type, &qtype);
+       rc = lquota_extract_fid(&qbody->qb_fid, &pool_type, &qtype);
        if (rc)
                RETURN(-EINVAL);
 
        /* Find the quota entry associated with the quota id */
        if (rc)
                RETURN(-EINVAL);
 
        /* Find the quota entry associated with the quota id */
-       lqe = qmt_pool_lqe_lookup(env, qmt, pool_id, pool_type, qtype,
+       lqe = qmt_pool_lqe_lookup(env, qmt, pool_type, qtype,
                                  &qbody->qb_id);
        if (IS_ERR(lqe))
                RETURN(PTR_ERR(lqe));
                                  &qbody->qb_id);
        if (IS_ERR(lqe))
                RETURN(PTR_ERR(lqe));
index 1ac3367..e88e9b8 100644 (file)
@@ -69,6 +69,8 @@ struct qmt_device {
 
        /* List of pools managed by this master target */
        struct list_head         qmt_pool_list;
 
        /* List of pools managed by this master target */
        struct list_head         qmt_pool_list;
+       /* rw spinlock to protect pool list */
+       rwlock_t                 qmt_pool_lock;
 
        /* procfs root directory for this qmt */
        struct proc_dir_entry   *qmt_proc;
 
        /* procfs root directory for this qmt */
        struct proc_dir_entry   *qmt_proc;
@@ -86,26 +88,21 @@ struct qmt_device {
 
 };
 
 
 };
 
+#define QPI_MAXNAME    (LOV_MAXPOOLNAME + 1)
+
 /*
  * Per-pool quota information.
  * The qmt creates one such structure for each pool
 /*
  * Per-pool quota information.
  * The qmt creates one such structure for each pool
- * with quota enforced. All the structures are kept in a hash which is used to
- * determine whether or not quota is enforced for a given pool.
- * We currently only support the default data pool and default metadata pool
- * with the pool_id 0.
+ * with quota enforced. All the structures are kept in a list.
+ * We currently only support the default data pool and default metadata pool.
  */
 struct qmt_pool_info {
  */
 struct qmt_pool_info {
-       /* link to qmt's pool hash */
-       struct hlist_node        qpi_hash;
-
        /* chained list of all pools managed by the same qmt */
        struct list_head         qpi_linkage;
 
        /* chained list of all pools managed by the same qmt */
        struct list_head         qpi_linkage;
 
-       /* Pool key composed of pool_id | (pool_type << 16)
-        * Only pool ID 0 is supported for now and the pool type is either
-        * QUOTA_RES_MD or QUOTA_RES_DT.
-        * immutable after creation. */
-       __u32                    qpi_key;
+       /* Could be  LQUOTA_RES_MD or LQUOTA_RES_DT */
+       int                      qpi_rtype;
+       char                     qpi_name[QPI_MAXNAME];
 
        /* track users of this pool instance */
        atomic_t                 qpi_ref;
 
        /* track users of this pool instance */
        atomic_t                 qpi_ref;
@@ -311,7 +308,7 @@ int qmt_pool_new_conn(const struct lu_env *, struct qmt_device *,
                      struct lu_fid *, struct lu_fid *, __u64 *,
                      struct obd_uuid *);
 struct lquota_entry *qmt_pool_lqe_lookup(const struct lu_env *,
                      struct lu_fid *, struct lu_fid *, __u64 *,
                      struct obd_uuid *);
 struct lquota_entry *qmt_pool_lqe_lookup(const struct lu_env *,
-                                        struct qmt_device *, int, int, int,
+                                        struct qmt_device *, int, int,
                                         union lquota_id *);
 /* qmt_entry.c */
 extern struct lquota_entry_operations qmt_lqe_ops;
                                         union lquota_id *);
 /* qmt_entry.c */
 extern struct lquota_entry_operations qmt_lqe_ops;
index cca59f6..80fb2f5 100644 (file)
@@ -160,7 +160,7 @@ int qmt_lvbo_init(struct lu_device *ld, struct ldlm_resource *res)
        struct lu_env           *env;
        struct qmt_thread_info  *qti;
        struct qmt_device       *qmt = lu2qmt_dev(ld);
        struct lu_env           *env;
        struct qmt_thread_info  *qti;
        struct qmt_device       *qmt = lu2qmt_dev(ld);
-       int                      pool_id, pool_type, qtype;
+       int                      pool_type, qtype;
        int                      rc;
        ENTRY;
 
        int                      rc;
        ENTRY;
 
@@ -181,9 +181,9 @@ int qmt_lvbo_init(struct lu_device *ld, struct ldlm_resource *res)
        fid_extract_from_quota_res(&qti->qti_fid, &qti->qti_id, &res->lr_name);
 
        /* sanity check the global index FID */
        fid_extract_from_quota_res(&qti->qti_fid, &qti->qti_id, &res->lr_name);
 
        /* sanity check the global index FID */
-       rc = lquota_extract_fid(&qti->qti_fid, &pool_id, &pool_type, &qtype);
+       rc = lquota_extract_fid(&qti->qti_fid, &pool_type, &qtype);
        if (rc) {
        if (rc) {
-               CERROR("can't extract pool information from FID "DFID"\n",
+               CERROR("can't extract glb index information from FID "DFID"\n",
                       PFID(&qti->qti_fid));
                GOTO(out, rc);
        }
                       PFID(&qti->qti_fid));
                GOTO(out, rc);
        }
@@ -194,7 +194,7 @@ int qmt_lvbo_init(struct lu_device *ld, struct ldlm_resource *res)
                struct lquota_entry     *lqe;
 
                /* Find the quota entry associated with the quota id */
                struct lquota_entry     *lqe;
 
                /* Find the quota entry associated with the quota id */
-               lqe = qmt_pool_lqe_lookup(env, qmt, pool_id, pool_type, qtype,
+               lqe = qmt_pool_lqe_lookup(env, qmt, pool_type, qtype,
                                          &qti->qti_id);
                if (IS_ERR(lqe))
                        GOTO(out, rc = PTR_ERR(lqe));
                                          &qti->qti_id);
                if (IS_ERR(lqe))
                        GOTO(out, rc = PTR_ERR(lqe));
@@ -574,8 +574,8 @@ void qmt_glb_lock_notify(const struct lu_env *env, struct lquota_entry *lqe,
        struct ldlm_resource    *res = NULL;
        ENTRY;
 
        struct ldlm_resource    *res = NULL;
        ENTRY;
 
-       lquota_generate_fid(&qti->qti_fid, pool->qpi_key & 0x0000ffff,
-                           pool->qpi_key >> 16, lqe->lqe_site->lqs_qtype);
+       lquota_generate_fid(&qti->qti_fid, pool->qpi_rtype,
+                           lqe->lqe_site->lqs_qtype);
 
        /* send glimpse callback to notify slaves of new quota settings */
        qti->qti_gl_desc.lquota_desc.gl_id        = lqe->lqe_id;
 
        /* send glimpse callback to notify slaves of new quota settings */
        qti->qti_gl_desc.lquota_desc.gl_id        = lqe->lqe_id;
@@ -643,8 +643,8 @@ static void qmt_id_lock_glimpse(const struct lu_env *env,
        if (!lqe->lqe_enforced)
                RETURN_EXIT;
 
        if (!lqe->lqe_enforced)
                RETURN_EXIT;
 
-       lquota_generate_fid(&qti->qti_fid, pool->qpi_key & 0x0000ffff,
-                           pool->qpi_key >> 16, lqe->lqe_site->lqs_qtype);
+       lquota_generate_fid(&qti->qti_fid, pool->qpi_rtype,
+                           lqe->lqe_site->lqs_qtype);
        fid_build_quota_res_name(&qti->qti_fid, &lqe->lqe_id, &qti->qti_resid);
        res = ldlm_resource_get(qmt->qmt_ns, NULL, &qti->qti_resid, LDLM_PLAIN,
                                0);
        fid_build_quota_res_name(&qti->qti_fid, &lqe->lqe_id, &qti->qti_resid);
        res = ldlm_resource_get(qmt->qmt_ns, NULL, &qti->qti_resid, LDLM_PLAIN,
                                0);
index 14ee846..87ce912 100644 (file)
@@ -29,7 +29,7 @@
  */
 
 /*
  */
 
 /*
- * A Quota Master Target has a hash table where it stores qmt_pool_info
+ * A Quota Master Target has a list(qmt_pool_list) where it stores qmt_pool_info
  * structures. There is one such structure for each pool managed by the QMT.
  *
  * Each pool can have different quota types enforced (typically user & group
  * structures. There is one such structure for each pool managed by the QMT.
  *
  * Each pool can have different quota types enforced (typically user & group
@@ -82,65 +82,6 @@ static inline void qpi_putref_locked(struct qmt_pool_info *pool)
        atomic_dec(&pool->qpi_ref);
 }
 
        atomic_dec(&pool->qpi_ref);
 }
 
-/*
- * Hash functions for qmt_pool_info management
- */
-
-static unsigned
-qpi_hash_hash(struct cfs_hash *hs, const void *key, unsigned mask)
-{
-       return cfs_hash_u32_hash(*((__u32 *)key), mask);
-}
-
-static void *qpi_hash_key(struct hlist_node *hnode)
-{
-       struct qmt_pool_info *pool;
-       pool = hlist_entry(hnode, struct qmt_pool_info, qpi_hash);
-       return &pool->qpi_key;
-}
-
-static int qpi_hash_keycmp(const void *key, struct hlist_node *hnode)
-{
-       struct qmt_pool_info *pool;
-       pool = hlist_entry(hnode, struct qmt_pool_info, qpi_hash);
-       return pool->qpi_key == *((__u32 *)key);
-}
-
-static void *qpi_hash_object(struct hlist_node *hnode)
-{
-       return hlist_entry(hnode, struct qmt_pool_info, qpi_hash);
-}
-
-static void qpi_hash_get(struct cfs_hash *hs, struct hlist_node *hnode)
-{
-       struct qmt_pool_info *pool;
-       pool = hlist_entry(hnode, struct qmt_pool_info, qpi_hash);
-       qpi_getref(pool);
-}
-
-static void qpi_hash_put_locked(struct cfs_hash *hs, struct hlist_node *hnode)
-{
-       struct qmt_pool_info *pool;
-       pool = hlist_entry(hnode, struct qmt_pool_info, qpi_hash);
-       qpi_putref_locked(pool);
-}
-
-static void qpi_hash_exit(struct cfs_hash *hs, struct hlist_node *hnode)
-{
-       CERROR("Should not have any item left!\n");
-}
-
-/* vector of hash operations */
-static struct cfs_hash_ops qpi_hash_ops = {
-       .hs_hash        = qpi_hash_hash,
-       .hs_key         = qpi_hash_key,
-       .hs_keycmp      = qpi_hash_keycmp,
-       .hs_object      = qpi_hash_object,
-       .hs_get         = qpi_hash_get,
-       .hs_put_locked  = qpi_hash_put_locked,
-       .hs_exit        = qpi_hash_exit
-};
-
 /* some procfs helpers */
 static int qpi_state_seq_show(struct seq_file *m, void *data)
 {
 /* some procfs helpers */
 static int qpi_state_seq_show(struct seq_file *m, void *data)
 {
@@ -154,8 +95,8 @@ static int qpi_state_seq_show(struct seq_file *m, void *data)
                   "    type: %s\n"
                   "    ref: %d\n"
                   "    least qunit: %lu\n",
                   "    type: %s\n"
                   "    ref: %d\n"
                   "    least qunit: %lu\n",
-                  pool->qpi_key & 0x0000ffff,
-                  RES_NAME(pool->qpi_key >> 16),
+                  0,
+                  RES_NAME(pool->qpi_rtype),
                   atomic_read(&pool->qpi_ref),
                   pool->qpi_least_qunit);
 
                   atomic_read(&pool->qpi_ref),
                   pool->qpi_least_qunit);
 
@@ -192,7 +133,7 @@ qpi_soft_least_qunit_seq_write(struct file *file, const char __user *buffer,
        LASSERT(pool != NULL);
 
        /* Not tuneable for inode limit */
        LASSERT(pool != NULL);
 
        /* Not tuneable for inode limit */
-       if (pool->qpi_key >> 16 != LQUOTA_RES_DT)
+       if (pool->qpi_rtype != LQUOTA_RES_DT)
                return -EINVAL;
 
        rc = kstrtoll_from_user(buffer, count, 0, &least_qunit);
                return -EINVAL;
 
        rc = kstrtoll_from_user(buffer, count, 0, &least_qunit);
@@ -222,19 +163,17 @@ static struct lprocfs_vars lprocfs_quota_qpi_vars[] = {
 };
 
 /*
 };
 
 /*
- * Allocate a new qmt_pool_info structure and add it to the pool hash table
- * of the qmt.
+ * Allocate a new qmt_pool_info structure and add it to qmt_pool_list.
  *
  * \param env       - is the environment passed by the caller
  * \param qmt       - is the quota master target
  *
  * \param env       - is the environment passed by the caller
  * \param qmt       - is the quota master target
- * \param pool_id   - is the 16-bit pool identifier of the new pool to add
  * \param pool_type - is the resource type of this pool instance, either
  *                    LQUOTA_RES_MD or LQUOTA_RES_DT.
  *
  * \retval - 0 on success, appropriate error on failure
  */
 static int qmt_pool_alloc(const struct lu_env *env, struct qmt_device *qmt,
  * \param pool_type - is the resource type of this pool instance, either
  *                    LQUOTA_RES_MD or LQUOTA_RES_DT.
  *
  * \retval - 0 on success, appropriate error on failure
  */
 static int qmt_pool_alloc(const struct lu_env *env, struct qmt_device *qmt,
-                         int pool_id, int pool_type)
+                         char *pool_name, int pool_type)
 {
        struct qmt_thread_info  *qti = qmt_info(env);
        struct qmt_pool_info    *pool;
 {
        struct qmt_thread_info  *qti = qmt_info(env);
        struct qmt_pool_info    *pool;
@@ -246,8 +185,7 @@ static int qmt_pool_alloc(const struct lu_env *env, struct qmt_device *qmt,
                RETURN(-ENOMEM);
        INIT_LIST_HEAD(&pool->qpi_linkage);
 
                RETURN(-ENOMEM);
        INIT_LIST_HEAD(&pool->qpi_linkage);
 
-       /* assign key used by hash functions */
-       pool->qpi_key = pool_id + (pool_type << 16);
+       pool->qpi_rtype = pool_type;
 
        /* initialize refcount to 1, hash table will then grab an additional
         * reference */
 
        /* initialize refcount to 1, hash table will then grab an additional
         * reference */
@@ -260,8 +198,15 @@ static int qmt_pool_alloc(const struct lu_env *env, struct qmt_device *qmt,
        else
                pool->qpi_soft_least_qunit = pool->qpi_least_qunit;
 
        else
                pool->qpi_soft_least_qunit = pool->qpi_least_qunit;
 
+       /* grab reference on master target that this pool belongs to */
+       lu_device_get(qmt2lu_dev(qmt));
+       lu_ref_add(&qmt2lu_dev(qmt)->ld_reference, "pool", pool);
+       pool->qpi_qmt = qmt;
+
        /* create pool proc directory */
        /* create pool proc directory */
-       sprintf(qti->qti_buf, "%s-0x%x", RES_NAME(pool_type), pool_id);
+       snprintf(qti->qti_buf, LQUOTA_NAME_MAX, "%s-%s",
+                RES_NAME(pool_type), pool_name);
+       strncpy(pool->qpi_name, pool_name, QPI_MAXNAME);
        pool->qpi_proc = lprocfs_register(qti->qti_buf, qmt->qmt_proc,
                                          lprocfs_quota_qpi_vars, pool);
        if (IS_ERR(pool->qpi_proc)) {
        pool->qpi_proc = lprocfs_register(qti->qti_buf, qmt->qmt_proc,
                                          lprocfs_quota_qpi_vars, pool);
        if (IS_ERR(pool->qpi_proc)) {
@@ -272,22 +217,10 @@ static int qmt_pool_alloc(const struct lu_env *env, struct qmt_device *qmt,
                GOTO(out, rc);
        }
 
                GOTO(out, rc);
        }
 
-       /* grab reference on master target that this pool belongs to */
-       lu_device_get(qmt2lu_dev(qmt));
-       lu_ref_add(&qmt2lu_dev(qmt)->ld_reference, "pool", pool);
-       pool->qpi_qmt = qmt;
-
-       /* add to qmt hash table */
-       rc = cfs_hash_add_unique(qmt->qmt_pool_hash, &pool->qpi_key,
-                                &pool->qpi_hash);
-       if (rc) {
-               CERROR("%s: failed to add pool %s to qmt hash (%d)\n",
-                      qmt->qmt_svname, qti->qti_buf, rc);
-               GOTO(out, rc);
-       }
-
        /* add to qmt pool list */
        /* add to qmt pool list */
+       write_lock(&qmt->qmt_pool_lock);
        list_add_tail(&pool->qpi_linkage, &qmt->qmt_pool_list);
        list_add_tail(&pool->qpi_linkage, &qmt->qmt_pool_list);
+       write_unlock(&qmt->qmt_pool_lock);
        EXIT;
 out:
        if (rc)
        EXIT;
 out:
        if (rc)
@@ -304,9 +237,18 @@ out:
  */
 static void qmt_pool_free(const struct lu_env *env, struct qmt_pool_info *pool)
 {
  */
 static void qmt_pool_free(const struct lu_env *env, struct qmt_pool_info *pool)
 {
+       struct  qmt_device *qmt = pool->qpi_qmt;
        int     qtype;
        ENTRY;
 
        int     qtype;
        ENTRY;
 
+       /* remove from list */
+       write_lock(&qmt->qmt_pool_lock);
+       list_del_init(&pool->qpi_linkage);
+       write_unlock(&qmt->qmt_pool_lock);
+
+       if (atomic_read(&pool->qpi_ref) > 0)
+               RETURN_EXIT;
+
        /* release proc entry */
        if (pool->qpi_proc) {
                lprocfs_remove(&pool->qpi_proc);
        /* release proc entry */
        if (pool->qpi_proc) {
                lprocfs_remove(&pool->qpi_proc);
@@ -348,34 +290,40 @@ static void qmt_pool_free(const struct lu_env *env, struct qmt_pool_info *pool)
 }
 
 /*
 }
 
 /*
- * Look-up a pool in the hash table based on the pool ID and type.
+ * Look-up a pool in a list based on the type.
  *
  * \param env     - is the environment passed by the caller
  * \param qmt     - is the quota master target
  *
  * \param env     - is the environment passed by the caller
  * \param qmt     - is the quota master target
- * \param pool_id   - is the 16-bit identifier of the pool to look up
  * \param pool_type - is the type of this pool, either LQUOTA_RES_MD or
  *                    LQUOTA_RES_DT.
  */
 static struct qmt_pool_info *qmt_pool_lookup(const struct lu_env *env,
                                             struct qmt_device *qmt,
  * \param pool_type - is the type of this pool, either LQUOTA_RES_MD or
  *                    LQUOTA_RES_DT.
  */
 static struct qmt_pool_info *qmt_pool_lookup(const struct lu_env *env,
                                             struct qmt_device *qmt,
-                                            int pool_id, int pool_type)
+                                            int pool_type)
 {
 {
-       struct qmt_pool_info    *pool;
-       __u32                    key;
+       struct qmt_pool_info    *pos, *pool;
        ENTRY;
 
        ENTRY;
 
-       LASSERT(qmt->qmt_pool_hash != NULL);
-
-       /* look-up pool in hash table */
-       key = pool_id + (pool_type << 16);
-       pool = cfs_hash_lookup(qmt->qmt_pool_hash, (void *)&key);
-       if (pool == NULL) {
-               /* this qmt isn't managing this pool! */
-               CERROR("%s: looking up quota entry for a pool (0x%x/%d) which "
-                      "isn't managed by this quota master target\n",
-                      qmt->qmt_svname, pool_id, pool_type);
+       read_lock(&qmt->qmt_pool_lock);
+       if (list_empty(&qmt->qmt_pool_list)) {
+               read_unlock(&qmt->qmt_pool_lock);
                RETURN(ERR_PTR(-ENOENT));
        }
                RETURN(ERR_PTR(-ENOENT));
        }
+
+       /* Now just find a pool with correct type in a list. Further we need
+        * to go through the list and find a pool that includes requested OST
+        * or MDT. Possibly this would return a list of pools that includes
+        * needed target(OST/MDT). */
+       pool = NULL;
+       list_for_each_entry(pos, &qmt->qmt_pool_list, qpi_linkage) {
+               if (pos->qpi_rtype == pool_type) {
+                       pool = pos;
+                       qpi_getref(pool);
+                       break;
+               }
+       }
+       read_unlock(&qmt->qmt_pool_lock);
+
        RETURN(pool);
 }
 
        RETURN(pool);
 }
 
@@ -384,8 +332,7 @@ static struct qmt_pool_info *qmt_pool_lookup(const struct lu_env *env,
  */
 
 /*
  */
 
 /*
- * Destroy all pools which are still in the hash table and free the pool
- * hash table.
+ * Destroy all pools which are still in the pool list.
  *
  * \param env - is the environment passed by the caller
  * \param qmt - is the quota master target
  *
  * \param env - is the environment passed by the caller
  * \param qmt - is the quota master target
@@ -393,31 +340,16 @@ static struct qmt_pool_info *qmt_pool_lookup(const struct lu_env *env,
  */
 void qmt_pool_fini(const struct lu_env *env, struct qmt_device *qmt)
 {
  */
 void qmt_pool_fini(const struct lu_env *env, struct qmt_device *qmt)
 {
-       struct qmt_pool_info    *pool;
-       struct list_head        *pos, *n;
+       struct qmt_pool_info *pool, *tmp;
        ENTRY;
 
        ENTRY;
 
-       if (qmt->qmt_pool_hash == NULL)
-               RETURN_EXIT;
-
        /* parse list of pool and destroy each element */
        /* parse list of pool and destroy each element */
-       list_for_each_safe(pos, n, &qmt->qmt_pool_list) {
-               pool = list_entry(pos, struct qmt_pool_info,
-                                 qpi_linkage);
-               /* remove from hash */
-               cfs_hash_del(qmt->qmt_pool_hash, &pool->qpi_key,
-                            &pool->qpi_hash);
-
-               /* remove from list */
-               list_del_init(&pool->qpi_linkage);
-
+       list_for_each_entry_safe(pool, tmp, &qmt->qmt_pool_list, qpi_linkage) {
                /* release extra reference taken in qmt_pool_alloc */
                qpi_putref(env, pool);
        }
        LASSERT(list_empty(&qmt->qmt_pool_list));
 
                /* release extra reference taken in qmt_pool_alloc */
                qpi_putref(env, pool);
        }
        LASSERT(list_empty(&qmt->qmt_pool_list));
 
-       cfs_hash_putref(qmt->qmt_pool_hash);
-       qmt->qmt_pool_hash = NULL;
        EXIT;
 }
 
        EXIT;
 }
 
@@ -437,30 +369,14 @@ int qmt_pool_init(const struct lu_env *env, struct qmt_device *qmt)
        int     res, rc = 0;
        ENTRY;
 
        int     res, rc = 0;
        ENTRY;
 
-       /* initialize pool hash table */
-       qmt->qmt_pool_hash = cfs_hash_create("POOL_HASH",
-                                            HASH_POOLS_CUR_BITS,
-                                            HASH_POOLS_MAX_BITS,
-                                            HASH_POOLS_BKT_BITS, 0,
-                                            CFS_HASH_MIN_THETA,
-                                            CFS_HASH_MAX_THETA,
-                                            &qpi_hash_ops,
-                                            CFS_HASH_DEFAULT);
-       if (qmt->qmt_pool_hash == NULL) {
-               CERROR("%s: failed to create pool hash table\n",
-                      qmt->qmt_svname);
-               RETURN(-ENOMEM);
-       }
-
-       /* initialize pool list */
        INIT_LIST_HEAD(&qmt->qmt_pool_list);
        INIT_LIST_HEAD(&qmt->qmt_pool_list);
+       rwlock_init(&qmt->qmt_pool_lock);
 
 
-       /* Instantiate pool master for the default data and metadata pool (both
-        * have pool ID equals to 0).
+       /* Instantiate pool master for the default data and metadata pool.
         * This code will have to be revisited once we support quota on
         * non-default pools */
        for (res = LQUOTA_FIRST_RES; res < LQUOTA_LAST_RES; res++) {
         * This code will have to be revisited once we support quota on
         * non-default pools */
        for (res = LQUOTA_FIRST_RES; res < LQUOTA_LAST_RES; res++) {
-               rc = qmt_pool_alloc(env, qmt, 0, res);
+               rc = qmt_pool_alloc(env, qmt, "0x0", res);
                if (rc)
                        break;
        }
                if (rc)
                        break;
        }
@@ -504,25 +420,25 @@ int qmt_pool_prepare(const struct lu_env *env, struct qmt_device *qmt,
        int                      rc = 0, qtype;
        ENTRY;
 
        int                      rc = 0, qtype;
        ENTRY;
 
-       LASSERT(qmt->qmt_pool_hash != NULL);
-
-       /* iterate over each pool in the hash and allocate a quota site for each
+       /* iterate over each pool in the list and allocate a quota site for each
         * one. This involves creating a global index file on disk */
        list_for_each(pos, &qmt->qmt_pool_list) {
                struct dt_object        *obj;
         * one. This involves creating a global index file on disk */
        list_for_each(pos, &qmt->qmt_pool_list) {
                struct dt_object        *obj;
-               int                      pool_type, pool_id;
                struct lquota_entry     *lqe;
                struct lquota_entry     *lqe;
+               char                    *pool_name;
+               int                      pool_type;
 
                pool = list_entry(pos, struct qmt_pool_info,
                                  qpi_linkage);
 
 
                pool = list_entry(pos, struct qmt_pool_info,
                                  qpi_linkage);
 
-               pool_id   = pool->qpi_key & 0x0000ffff;
-               pool_type = pool->qpi_key >> 16;
+               pool_name = pool->qpi_name;
+               pool_type = pool->qpi_rtype;
                if (dev == NULL)
                        dev = pool->qpi_qmt->qmt_child;
 
                /* allocate directory for this pool */
                if (dev == NULL)
                        dev = pool->qpi_qmt->qmt_child;
 
                /* allocate directory for this pool */
-               sprintf(qti->qti_buf, "%s-0x%x", RES_NAME(pool_type), pool_id);
+               snprintf(qti->qti_buf, LQUOTA_NAME_MAX, "%s-%s",
+                        RES_NAME(pool_type), pool_name);
                obj = lquota_disk_dir_find_create(env, qmt->qmt_child, qmt_root,
                                                  qti->qti_buf);
                if (IS_ERR(obj))
                obj = lquota_disk_dir_find_create(env, qmt->qmt_child, qmt_root,
                                                  qti->qti_buf);
                if (IS_ERR(obj))
@@ -532,8 +448,7 @@ int qmt_pool_prepare(const struct lu_env *env, struct qmt_device *qmt,
                for (qtype = 0; qtype < LL_MAXQUOTAS; qtype++) {
                        /* Generating FID of global index in charge of storing
                         * settings for this quota type */
                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,
-                                           qtype);
+                       lquota_generate_fid(&qti->qti_fid, pool_type, qtype);
 
                        /* open/create the global index file for this quota
                         * type */
 
                        /* open/create the global index file for this quota
                         * type */
@@ -646,17 +561,17 @@ int qmt_pool_new_conn(const struct lu_env *env, struct qmt_device *qmt,
 {
        struct qmt_pool_info    *pool;
        struct dt_object        *slv_obj;
 {
        struct qmt_pool_info    *pool;
        struct dt_object        *slv_obj;
-       int                      pool_id, pool_type, qtype;
+       int                      pool_type, qtype;
        bool                     created = false;
        int                      rc = 0;
 
        /* extract pool info from global index FID */
        bool                     created = false;
        int                      rc = 0;
 
        /* extract pool info from global index FID */
-       rc = lquota_extract_fid(glb_fid, &pool_id, &pool_type, &qtype);
+       rc = lquota_extract_fid(glb_fid, &pool_type, &qtype);
        if (rc)
                RETURN(rc);
 
        /* look-up pool in charge of this global index FID */
        if (rc)
                RETURN(rc);
 
        /* look-up pool in charge of this global index FID */
-       pool = qmt_pool_lookup(env, qmt, pool_id, pool_type);
+       pool = qmt_pool_lookup(env, qmt, pool_type);
        if (IS_ERR(pool))
                RETURN(PTR_ERR(pool));
 
        if (IS_ERR(pool))
                RETURN(PTR_ERR(pool));
 
@@ -694,7 +609,6 @@ out:
  * \param env - is the environment passed by the caller
  * \param qmt - is the quota master target for which we have to initialize the
  *              pool configuration
  * \param env - is the environment passed by the caller
  * \param qmt - is the quota master target for which we have to initialize the
  *              pool configuration
- * \param pool_id   - is the 16-bit identifier of the pool
  * \param pool_type - is the pool type, either LQUOTA_RES_MD or LQUOTA_RES_DT.
  * \param qtype     - is the quota type, either user or group.
  * \param qid       - is the quota ID to look-up
  * \param pool_type - is the pool type, either LQUOTA_RES_MD or LQUOTA_RES_DT.
  * \param qtype     - is the quota type, either user or group.
  * \param qid       - is the quota ID to look-up
@@ -704,15 +618,15 @@ out:
  */
 struct lquota_entry *qmt_pool_lqe_lookup(const struct lu_env *env,
                                         struct qmt_device *qmt,
  */
 struct lquota_entry *qmt_pool_lqe_lookup(const struct lu_env *env,
                                         struct qmt_device *qmt,
-                                        int pool_id, int pool_type,
-                                        int qtype, union lquota_id *qid)
+                                        int pool_type, int qtype,
+                                        union lquota_id *qid)
 {
        struct qmt_pool_info    *pool;
        struct lquota_entry     *lqe;
        ENTRY;
 
        /* look-up pool responsible for this global index FID */
 {
        struct qmt_pool_info    *pool;
        struct lquota_entry     *lqe;
        ENTRY;
 
        /* look-up pool responsible for this global index FID */
-       pool = qmt_pool_lookup(env, qmt, pool_id, pool_type);
+       pool = qmt_pool_lookup(env, qmt, pool_type);
        if (IS_ERR(pool))
                RETURN((void *)pool);
 
        if (IS_ERR(pool))
                RETURN((void *)pool);
 
index a4f6734..bebce66 100644 (file)
@@ -45,9 +45,6 @@ struct qsd_instance {
        /* name of service which created this qsd instance */
        char                     qsd_svname[MAX_OBD_NAME];
 
        /* name of service which created this qsd instance */
        char                     qsd_svname[MAX_OBD_NAME];
 
-       /* pool ID is always 0 for now */
-       int                      qsd_pool_id;
-
        /* dt_device associated with this qsd instance */
        struct dt_device        *qsd_dev;
 
        /* dt_device associated with this qsd instance */
        struct dt_device        *qsd_dev;
 
index 1adc22d..da1c7c8 100644 (file)
@@ -90,12 +90,14 @@ static int qsd_state_seq_show(struct seq_file *m, void *data)
        if (strlen(enabled) == 0)
                strcat(enabled, "none");
 
        if (strlen(enabled) == 0)
                strcat(enabled, "none");
 
+       /* TODO: further pool ID should be removed or
+        * replaced with pool Name */
        seq_printf(m, "target name:    %s\n"
                   "pool ID:        %d\n"
                   "type:           %s\n"
                   "quota enabled:  %s\n"
                   "conn to master: %s\n",
        seq_printf(m, "target name:    %s\n"
                   "pool ID:        %d\n"
                   "type:           %s\n"
                   "quota enabled:  %s\n"
                   "conn to master: %s\n",
-                  qsd->qsd_svname, qsd->qsd_pool_id,
+                  qsd->qsd_svname, 0,
                   qsd->qsd_is_md ? "md" : "dt", enabled,
                   qsd->qsd_exp_valid ? "setup" : "not setup yet");
 
                   qsd->qsd_is_md ? "md" : "dt", enabled,
                   qsd->qsd_exp_valid ? "setup" : "not setup yet");
 
@@ -472,8 +474,7 @@ static int qsd_qtype_init(const struct lu_env *env, struct qsd_instance *qsd,
        thread_set_flags(&qqi->qqi_reint_thread, SVC_STOPPED);
        INIT_LIST_HEAD(&qqi->qqi_deferred_glb);
        INIT_LIST_HEAD(&qqi->qqi_deferred_slv);
        thread_set_flags(&qqi->qqi_reint_thread, SVC_STOPPED);
        INIT_LIST_HEAD(&qqi->qqi_deferred_glb);
        INIT_LIST_HEAD(&qqi->qqi_deferred_slv);
-       lquota_generate_fid(&qqi->qqi_fid, qsd->qsd_pool_id,
-                           QSD_RES_TYPE(qsd), qtype);
+       lquota_generate_fid(&qqi->qqi_fid, QSD_RES_TYPE(qsd), qtype);
 
        /* open accounting object */
        LASSERT(qqi->qqi_acct_obj == NULL);
 
        /* open accounting object */
        LASSERT(qqi->qqi_acct_obj == NULL);
@@ -680,11 +681,6 @@ struct qsd_instance *qsd_init(const struct lu_env *env, char *svname,
        lu_ref_add(&dev->dd_lu_dev.ld_reference, "qsd", qsd);
        qsd->qsd_dev = dev;
 
        lu_ref_add(&dev->dd_lu_dev.ld_reference, "qsd", qsd);
        qsd->qsd_dev = dev;
 
-       /* we only support pool ID 0 (default data or metadata pool) for the
-        * time being. A different pool ID could be assigned to this target via
-        * the configuration log in the future */
-       qsd->qsd_pool_id  = 0;
-
        /* get fsname from svname */
        rc = server_name2fsname(svname, qti->qti_buf, NULL);
        if (rc) {
        /* get fsname from svname */
        rc = server_name2fsname(svname, qti->qti_buf, NULL);
        if (rc) {