From 6929549acde2357339aec7bcaac6ec301150e96e Mon Sep 17 00:00:00 2001 From: Johann Lombardi Date: Wed, 24 Oct 2012 20:51:36 +0200 Subject: [PATCH] LU-2211 quota: cache return code of acq for 1s 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 Change-Id: I3c212055b1ed6cd3671e69a0cff079dae831af61 Reviewed-on: http://review.whamcloud.com/4380 Tested-by: Hudson Reviewed-by: Fan Yong Tested-by: Maloo Reviewed-by: Niu Yawei Reviewed-by: Oleg Drokin --- lustre/quota/lquota_internal.h | 8 ++++++++ lustre/quota/qsd_handler.c | 23 ++++++++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/lustre/quota/lquota_internal.h b/lustre/quota/lquota_internal.h index 552993b..990b45b 100644 --- a/lustre/quota/lquota_internal.h +++ b/lustre/quota/lquota_internal.h @@ -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 diff --git a/lustre/quota/qsd_handler.c b/lustre/quota/qsd_handler.c index 68803d0..01b3e54 100644 --- a/lustre/quota/qsd_handler.c +++ b/lustre/quota/qsd_handler.c @@ -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); } -- 1.8.3.1