Whamcloud - gitweb
LU-2211 quota: cache return code of acq for 1s
authorJohann Lombardi <johann.lombardi@intel.com>
Wed, 24 Oct 2012 18:51:36 +0000 (20:51 +0200)
committerOleg Drokin <green@whamcloud.com>
Mon, 12 Nov 2012 16:37:52 +0000 (11:37 -0500)
Cache failed return code of acquire request for 1s to avoid
request flooding with EINPROGRESS and cumulative timeout on
ETIMEOUT when the master isn't responsive.

Signed-off-by: Johann Lombard <johann.lombardi@intel.com>
Change-Id: I3c212055b1ed6cd3671e69a0cff079dae831af61
Reviewed-on: http://review.whamcloud.com/4380
Tested-by: Hudson
Reviewed-by: Fan Yong <yong.fan@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Niu Yawei <niu@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/quota/lquota_internal.h
lustre/quota/qsd_handler.c

index 552993b..990b45b 100644 (file)
@@ -123,6 +123,12 @@ struct lquota_slv_entry {
 
        /* time to trigger quota adjust */
        __u64                   lse_adjust_time;
+
+       /* return code of latest acquire RPC */
+       int                     lse_acq_rc;
+
+       /* when latest acquire RPC completed */
+       __u64                   lse_acq_time;
 };
 
 /* In-memory entry for each enforced quota id
@@ -200,6 +206,8 @@ struct lquota_site {
 #define lqe_usage              u.se.lse_usage
 #define lqe_adjust_time                u.se.lse_adjust_time
 #define lqe_lockh              u.se.lse_lockh
+#define lqe_acq_rc             u.se.lse_acq_rc
+#define lqe_acq_time           u.se.lse_acq_time
 
 #define LQUOTA_BUMP_VER 0x1
 #define LQUOTA_SET_VER  0x2
index 68803d0..01b3e54 100644 (file)
@@ -407,6 +407,10 @@ static void qsd_req_completion(const struct lu_env *env,
                lqe->lqe_nopreacq = true;
 out:
        adjust = qsd_adjust_needed(lqe);
+       if (reqbody && req_is_acq(reqbody->qb_flags) && ret != -EDQUOT) {
+               lqe->lqe_acq_rc = ret;
+               lqe->lqe_acq_time = cfs_time_current_64();
+       }
 out_noadjust:
        qsd_request_exit(lqe);
        lqe_write_unlock(lqe);
@@ -558,6 +562,14 @@ static int qsd_acquire_remote(const struct lu_env *env,
                RETURN(0);
        }
 
+       /* check whether an acquire request completed recently */
+       if (lqe->lqe_acq_rc != 0 &&
+           cfs_time_before_64(cfs_time_shift_64(-1), lqe->lqe_acq_time)) {
+               lqe_write_unlock(lqe);
+               LQUOTA_DEBUG(lqe, "using cached return code %d", lqe->lqe_acq_rc);
+               RETURN(lqe->lqe_acq_rc);
+       }
+
        /* only 1 quota request in flight for a given ID is allowed */
        rc = qsd_request_enter(lqe);
        if (rc) {
@@ -898,8 +910,13 @@ int qsd_adjust(const struct lu_env *env, struct lquota_entry *lqe)
 
        memset(qbody, 0, sizeof(*qbody));
        rc = qsd_ready(lqe, &qbody->qb_glb_lockh);
-       if (rc)
-               RETURN(rc);
+       if (rc) {
+               /* add to adjust list again to trigger adjustment later when
+                * slave is ready */
+               LQUOTA_DEBUG(lqe, "delaying adjustment since qsd isn't ready");
+               qsd_adjust_schedule(lqe, true, false);
+               RETURN(0);
+       }
 
        qqi = lqe2qqi(lqe);
        qsd = qqi->qqi_qsd;
@@ -909,7 +926,7 @@ int qsd_adjust(const struct lu_env *env, struct lquota_entry *lqe)
        /* fill qb_count & qb_flags */
        if (!qsd_calc_adjust(lqe, qbody)) {
                lqe_write_unlock(lqe);
-               LQUOTA_DEBUG(lqe, "No adjust required");
+               LQUOTA_DEBUG(lqe, "no adjustment required");
                RETURN(0);
        }