Whamcloud - gitweb
LU-6245 server: remove types abstraction from quota/target/nodemap code
[fs/lustre-release.git] / lustre / quota / qmt_entry.c
index 47a1ccf..d0374cf 100644 (file)
@@ -112,9 +112,9 @@ static void qmt_lqe_debug(struct lquota_entry *lqe, void *arg,
        struct qmt_pool_info    *pool = (struct qmt_pool_info *)arg;
 
        libcfs_debug_vmsg2(msgdata, fmt, args,
        struct qmt_pool_info    *pool = (struct qmt_pool_info *)arg;
 
        libcfs_debug_vmsg2(msgdata, fmt, args,
-                          "qmt:%s pool:%d-%s id:"LPU64" enforced:%d hard:"LPU64
-                          " soft:"LPU64" granted:"LPU64" time:"LPU64" qunit:"
-                          LPU64" edquot:%d may_rel:"LPU64" revoke:"LPU64"\n",
+                          "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:%llu\n",
                           pool->qpi_qmt->qmt_svname,
                           pool->qpi_key & 0x0000ffff,
                           RES_NAME(pool->qpi_key >> 16),
                           pool->qpi_qmt->qmt_svname,
                           pool->qpi_key & 0x0000ffff,
                           RES_NAME(pool->qpi_key >> 16),
@@ -327,7 +327,7 @@ int qmt_slv_read(const struct lu_env *env, struct lquota_entry *lqe,
                RETURN(rc);
        }
 
                RETURN(rc);
        }
 
-       LQUOTA_DEBUG(lqe, "successful slv read "LPU64, *granted);
+       LQUOTA_DEBUG(lqe, "successful slv read %llu", *granted);
 
        RETURN(0);
 }
 
        RETURN(0);
 }
@@ -360,7 +360,7 @@ int qmt_slv_write(const struct lu_env *env, struct thandle *th,
        LASSERT(lqe_is_master(lqe));
        LASSERT(lqe_is_locked(lqe));
 
        LASSERT(lqe_is_master(lqe));
        LASSERT(lqe_is_locked(lqe));
 
-       LQUOTA_DEBUG(lqe, "write slv "DFID" granted:"LPU64,
+       LQUOTA_DEBUG(lqe, "write slv "DFID" granted:%llu",
                     PFID(lu_object_fid(&slv_obj->do_lu)), granted);
 
        /* never delete the entry, otherwise, it'll not be transferred
                     PFID(lu_object_fid(&slv_obj->do_lu)), granted);
 
        /* never delete the entry, otherwise, it'll not be transferred
@@ -375,7 +375,7 @@ int qmt_slv_write(const struct lu_env *env, struct thandle *th,
                               (struct dt_rec *)rec, flags, ver);
        if (rc) {
                LQUOTA_ERROR(lqe, "failed to update slave index "DFID" granted:"
                               (struct dt_rec *)rec, flags, ver);
        if (rc) {
                LQUOTA_ERROR(lqe, "failed to update slave index "DFID" granted:"
-                            LPU64, PFID(lu_object_fid(&slv_obj->do_lu)),
+                            "%llu", PFID(lu_object_fid(&slv_obj->do_lu)),
                             granted);
                RETURN(rc);
        }
                             granted);
                RETURN(rc);
        }
@@ -425,7 +425,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_MD) {
+                   pool->qpi_key >> 16 != LQUOTA_RES_DT) {
                        /* we haven't reached the minimal qunit yet so there is
                         * still hope that the rebalancing process might free
                         * up some quota space */
                        /* we haven't reached the minimal qunit yet so there is
                         * still hope that the rebalancing process might free
                         * up some quota space */
@@ -443,9 +443,7 @@ void qmt_adjust_edquot(struct lquota_entry *lqe, __u64 now)
                                               lqe->lqe_revoke_time))
                                RETURN_EXIT;
                } else {
                                               lqe->lqe_revoke_time))
                                RETURN_EXIT;
                } else {
-                       /* When exceeding softlimit, block qunit will be shrunk
-                        * to (4 * least_qunit) finally. */
-                       if (lqe->lqe_qunit > (pool->qpi_least_qunit << 2))
+                       if (lqe->lqe_qunit > pool->qpi_soft_least_qunit)
                                RETURN_EXIT;
                }
 
                                RETURN_EXIT;
                }
 
@@ -487,12 +485,11 @@ 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_MD)
+       if (pool->qpi_key >> 16 != LQUOTA_RES_DT)
                return lqe->lqe_softlimit;
 
                return lqe->lqe_softlimit;
 
-       /* Added (least_qunit * 4) as margin */
        if (lqe->lqe_granted <= lqe->lqe_softlimit +
        if (lqe->lqe_granted <= lqe->lqe_softlimit +
-                               (pool->qpi_least_qunit << 2)) {
+                               pool->qpi_soft_least_qunit) {
                return lqe->lqe_softlimit;
        } else if (lqe->lqe_hardlimit != 0) {
                *oversoft = true;
                return lqe->lqe_softlimit;
        } else if (lqe->lqe_hardlimit != 0) {
                *oversoft = true;
@@ -531,7 +528,7 @@ __u64 qmt_alloc_expand(struct lquota_entry *lqe, __u64 granted, __u64 spare)
                remaining = qmt_calc_softlimit(lqe, &oversoft);
                if (remaining == 0)
                        remaining = lqe->lqe_granted +
                remaining = qmt_calc_softlimit(lqe, &oversoft);
                if (remaining == 0)
                        remaining = lqe->lqe_granted +
-                                   (pool->qpi_least_qunit << 2);
+                                   pool->qpi_soft_least_qunit;
        } else {
                remaining = lqe->lqe_hardlimit;
        }
        } else {
                remaining = lqe->lqe_hardlimit;
        }
@@ -600,10 +597,10 @@ void qmt_adjust_qunit(const struct lu_env *env, struct lquota_entry *lqe)
                bool oversoft;
                /* As a compromise of write performance and the grace time
                 * accuracy, the block qunit size will be shrunk to
                bool oversoft;
                /* As a compromise of write performance and the grace time
                 * accuracy, the block qunit size will be shrunk to
-                * (4 * least_qunit) when over softlimit. LU-4139. */
+                * qpi_soft_least_qunit when over softlimit. LU-4139. */
                limit = qmt_calc_softlimit(lqe, &oversoft);
                if (oversoft)
                limit = qmt_calc_softlimit(lqe, &oversoft);
                if (oversoft)
-                       qunit2 = pool->qpi_least_qunit << 2;
+                       qunit2 = pool->qpi_soft_least_qunit;
                if (limit == 0)
                        GOTO(done, qunit = qunit2);
        } else if (lqe->lqe_hardlimit != 0) {
                if (limit == 0)
                        GOTO(done, qunit = qunit2);
        } else if (lqe->lqe_hardlimit != 0) {
@@ -641,8 +638,14 @@ void qmt_adjust_qunit(const struct lu_env *env, struct lquota_entry *lqe)
                /* current qunit value still fits, let's see if we can afford to
                 * increase qunit now ...
                 * To increase qunit again, we have to be under 25% */
                /* current qunit value still fits, let's see if we can afford to
                 * increase qunit now ...
                 * To increase qunit again, we have to be under 25% */
-               while (limit >= lqe->lqe_granted + 6 * qunit * slv_cnt)
+               while (qunit && limit >= lqe->lqe_granted + 6 * qunit * slv_cnt)
                        qunit <<= 2;
                        qunit <<= 2;
+
+               if (!qunit) {
+                       qunit = limit;
+                       do_div(qunit, 2 * slv_cnt);
+               }
+
        } else {
                /* shrink qunit until we find a suitable value */
                while (qunit > pool->qpi_least_qunit &&
        } else {
                /* shrink qunit until we find a suitable value */
                while (qunit > pool->qpi_least_qunit &&
@@ -657,7 +660,7 @@ done:
                /* keep current qunit */
                RETURN_EXIT;
 
                /* keep current qunit */
                RETURN_EXIT;
 
-       LQUOTA_DEBUG(lqe, "%s qunit to "LPU64,
+       LQUOTA_DEBUG(lqe, "%s qunit to %llu",
                     lqe->lqe_qunit < qunit ? "increasing" : "decreasing",
                     qunit);
 
                     lqe->lqe_qunit < qunit ? "increasing" : "decreasing",
                     qunit);