Whamcloud - gitweb
LU-14669 tests: reduce time spent in sanity-sec
[fs/lustre-release.git] / lustre / quota / qsd_handler.c
index f8011eb..d40251d 100644 (file)
@@ -65,7 +65,7 @@ static inline void qsd_request_exit(struct lquota_entry *lqe)
        }
        lqe->lqe_pending_req--;
        lqe->lqe_pending_rel = 0;
-       wake_up_all(&lqe->lqe_waiters);
+       wake_up(&lqe->lqe_waiters);
 }
 
 /**
@@ -631,11 +631,14 @@ static bool qsd_acquire(const struct lu_env *env, struct lquota_entry *lqe,
                        long long space, int *ret)
 {
        int rc = 0, count;
+       int wait_pending = 0;
+       struct qsd_qtype_info *qqi = lqe2qqi(lqe);
+
        ENTRY;
 
        for (count = 0; rc == 0; count++) {
                LQUOTA_DEBUG(lqe, "acquiring:%lld count=%d", space, count);
-
+again:
                if (lqe2qqi(lqe)->qqi_qsd->qsd_stopping) {
                        rc = -EINPROGRESS;
                        break;
@@ -652,6 +655,16 @@ static bool qsd_acquire(const struct lu_env *env, struct lquota_entry *lqe,
                        /* rc == 0, Wouhou! enough local quota space
                         * rc < 0, something bad happened */
                         break;
+               /*
+                * There might be a window that commit transaction
+                * have updated usage but pending write doesn't change
+                * wait for it before acquiring remotely.
+                */
+               if (lqe->lqe_pending_write >= space && !wait_pending) {
+                       wait_pending = 1;
+                       dt_sync(env, qqi->qqi_qsd->qsd_dev);
+                       goto again;
+               }
 
                /* if we have gotten some quota and stil wait more quota,
                 * it's better to give QMT some time to reclaim from clients */
@@ -786,8 +799,11 @@ out_flags:
                        lqe_read_lock(lqe);
                        usage = lqe->lqe_pending_write;
                        usage += lqe->lqe_waiting_write;
-                       if (lqe->lqe_qunit != 0 && (usage % lqe->lqe_qunit >
-                           qqi->qqi_qsd->qsd_sync_threshold))
+                       /* There is a chance to successfully grant more quota
+                        * but get edquot flag through glimpse. */
+                       if (lqe->lqe_edquot || (lqe->lqe_qunit != 0 &&
+                          (usage % lqe->lqe_qunit >
+                           qqi->qqi_qsd->qsd_sync_threshold)))
                                usage += qqi->qqi_qsd->qsd_sync_threshold;
 
                        usage += lqe->lqe_usage;