Whamcloud - gitweb
LU-11133 dkms: Add missing ldiskfs module in dkms config
[fs/lustre-release.git] / lustre / quota / qsd_writeback.c
index 8352e59..3c4f0fd 100644 (file)
@@ -21,7 +21,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright (c) 2012, 2014, Intel Corporation.
+ * Copyright (c) 2012, 2017, Intel Corporation.
  * Use is subject to license terms.
  *
  * Author: Johann Lombardi <johann.lombardi@intel.com>
@@ -121,9 +121,14 @@ static void qsd_add_deferred(struct qsd_instance *qsd, struct list_head *list,
                 * updates. We should just delete the legacy record in such
                 * case. */
                if (upd->qur_ver == tmp->qur_ver) {
-                       LASSERT(tmp->qur_lqe);
-                       LQUOTA_ERROR(tmp->qur_lqe, "Found a conflict record "
-                                    "with ver:%llu", tmp->qur_ver);
+                       if (tmp->qur_lqe)
+                               LQUOTA_WARN(tmp->qur_lqe, "Found a conflict "
+                                           "record with ver:%llu",
+                                           tmp->qur_ver);
+                       else
+                               CWARN("%s: Found a conflict record with ver: "
+                                     "%llu\n", qsd->qsd_svname, tmp->qur_ver);
+
                        list_del_init(&tmp->qur_link);
                        qsd_upd_free(tmp);
                } else if (upd->qur_ver < tmp->qur_ver) {
@@ -293,6 +298,11 @@ static int qsd_process_upd(const struct lu_env *env, struct qsd_upd_rec *upd)
                        GOTO(out, rc);
                /* refresh usage */
                qsd_refresh_usage(env, lqe);
+
+               spin_lock(&qqi->qqi_qsd->qsd_adjust_lock);
+               lqe->lqe_adjust_time = 0;
+               spin_unlock(&qqi->qqi_qsd->qsd_adjust_lock);
+
                /* Report usage asynchronously */
                rc = qsd_adjust(env, lqe);
                if (rc)
@@ -302,6 +312,21 @@ static int qsd_process_upd(const struct lu_env *env, struct qsd_upd_rec *upd)
        rc = qsd_update_index(env, qqi, &upd->qur_qid, upd->qur_global,
                              upd->qur_ver, &upd->qur_rec);
 out:
+       if (upd->qur_global && rc == 0 &&
+           upd->qur_rec.lqr_glb_rec.qbr_softlimit == 0 &&
+           upd->qur_rec.lqr_glb_rec.qbr_hardlimit == 0 &&
+           (LQUOTA_FLAG(upd->qur_rec.lqr_glb_rec.qbr_time) &
+                                                       LQUOTA_FLAG_DEFAULT)) {
+               lqe->lqe_is_default = true;
+               if (qqi->qqi_default_softlimit == 0 &&
+                   qqi->qqi_default_hardlimit == 0)
+                       lqe->lqe_enforced = false;
+               else
+                       lqe->lqe_enforced = true;
+
+               LQUOTA_DEBUG(lqe, "update to use default quota");
+       }
+
        if (lqe && !IS_ERR(lqe)) {
                lqe_putref(lqe);
                upd->qur_lqe = NULL;
@@ -333,12 +358,14 @@ void qsd_adjust_schedule(struct lquota_entry *lqe, bool defer, bool cancel)
        }
 
        if (list_empty(&lqe->lqe_link)) {
-               if (cancel)
+               if (!cancel) {
+                       lqe->lqe_adjust_time = ktime_get_seconds();
+                       if (defer)
+                               lqe->lqe_adjust_time += QSD_WB_INTERVAL;
+               } else {
                        lqe->lqe_adjust_time = 0;
-               else
-                       lqe->lqe_adjust_time = defer ?
-                               cfs_time_shift_64(QSD_WB_INTERVAL) :
-                               cfs_time_current_64();
+               }
+
                /* lqe reference transferred to list */
                if (defer)
                        list_add_tail(&lqe->lqe_link,
@@ -371,8 +398,7 @@ static bool qsd_job_pending(struct qsd_instance *qsd, struct list_head *upd,
                struct lquota_entry *lqe;
                lqe = list_entry(qsd->qsd_adjust_list.next,
                                     struct lquota_entry, lqe_link);
-               if (cfs_time_beforeq_64(lqe->lqe_adjust_time,
-                                       cfs_time_current_64()))
+               if (ktime_get_seconds() >= lqe->lqe_adjust_time)
                        job_pending = true;
        }
        spin_unlock(&qsd->qsd_adjust_lock);
@@ -383,16 +409,14 @@ static bool qsd_job_pending(struct qsd_instance *qsd, struct list_head *upd,
                job_pending = true;
        }
 
-       if (qsd->qsd_acct_failed) {
-               /* don't bother kicking off reintegration if space accounting
-                * failed to be enabled */
-               write_unlock(&qsd->qsd_lock);
-               return job_pending;
-       }
-
        for (qtype = USRQUOTA; qtype < LL_MAXQUOTAS; qtype++) {
                struct qsd_qtype_info *qqi = qsd->qsd_type_array[qtype];
 
+               /* don't bother kicking off reintegration if space accounting
+                * failed to be enabled */
+               if (qqi->qqi_acct_failed)
+                       continue;
+
                if (!qsd_type_enabled(qsd, qtype))
                        continue;
 
@@ -418,7 +442,7 @@ static int qsd_upd_thread(void *arg)
        int                      qtype, rc = 0;
        bool                     uptodate;
        struct lquota_entry     *lqe;
-       __u64                    cur_time;
+       time64_t cur_time;
        ENTRY;
 
        OBD_ALLOC_PTR(env);
@@ -449,13 +473,12 @@ static int qsd_upd_thread(void *arg)
                }
 
                spin_lock(&qsd->qsd_adjust_lock);
-               cur_time = cfs_time_current_64();
+               cur_time = ktime_get_seconds();
                while (!list_empty(&qsd->qsd_adjust_list)) {
                        lqe = list_entry(qsd->qsd_adjust_list.next,
                                         struct lquota_entry, lqe_link);
                        /* deferred items are sorted by time */
-                       if (!cfs_time_beforeq_64(lqe->lqe_adjust_time,
-                                                cur_time))
+                       if (lqe->lqe_adjust_time > cur_time)
                                break;
 
                        list_del_init(&lqe->lqe_link);