Whamcloud - gitweb
LU-8634 quota: fix return code of intent quota lock 51/22751/3
authorNiu Yawei <yawei.niu@intel.com>
Mon, 26 Sep 2016 03:19:11 +0000 (23:19 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 7 Nov 2016 15:45:53 +0000 (15:45 +0000)
Intent quota operation should return error code in lock_policy_res2
like other intent operations, otherwise, it'll be confused with the
error code returned by intent locking.

Signed-off-by: Niu Yawei <yawei.niu@intel.com>
Change-Id: I99fd04f72eeb6d10380ebd30da928b5749e74443
Reviewed-on: http://review.whamcloud.com/22751
Reviewed-by: Fan Yong <fan.yong@intel.com>
Tested-by: Jenkins
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/quota/qmt_lock.c
lustre/quota/qsd_request.c

index b5849aa..be80dce 100644 (file)
@@ -51,6 +51,7 @@ int qmt_intent_policy(const struct lu_env *env, struct lu_device *ld,
        struct obd_uuid         *uuid;
        struct lquota_lvb       *lvb;
        struct ldlm_resource    *res = (*lockp)->l_resource;
+       struct ldlm_reply       *ldlm_rep;
        int                      rc, lvb_len;
        ENTRY;
 
@@ -78,6 +79,10 @@ int qmt_intent_policy(const struct lu_env *env, struct lu_device *ld,
        if (repbody == NULL)
                RETURN(err_serious(-EFAULT));
 
+       ldlm_rep = req_capsule_server_get(&req->rq_pill, &RMF_DLM_REP);
+       if (ldlm_rep == NULL)
+               RETURN(err_serious(-EFAULT));
+
        uuid = &(*lockp)->l_export->exp_client_uuid;
        switch (it->opc) {
 
@@ -129,7 +134,7 @@ int qmt_intent_policy(const struct lu_env *env, struct lu_device *ld,
        default:
                CERROR("%s: invalid intent opcode: %llu\n", qmt->qmt_svname,
                       it->opc);
-               GOTO(out, rc = err_serious(-EINVAL));
+               GOTO(out, rc = -EINVAL);
        }
 
        /* on success, pack lvb in reply */
@@ -140,9 +145,10 @@ int qmt_intent_policy(const struct lu_env *env, struct lu_device *ld,
                GOTO(out, rc = lvb_len);
 
        req_capsule_shrink(&req->rq_pill, &RMF_DLM_LVB, lvb_len, RCL_SERVER);
-       EXIT;
 out:
-       return rc;
+       ldlm_rep->lock_policy_res2 = clear_serious(rc);
+       EXIT;
+       return ELDLM_OK;
 }
 
 /*
index 1eb59b2..1259071 100644 (file)
@@ -159,6 +159,7 @@ static int qsd_intent_interpret(const struct lu_env *env,
        struct lustre_handle     *lockh;
        struct quota_body        *rep_qbody = NULL, *req_qbody;
        struct qsd_async_args    *aa = (struct qsd_async_args *)arg;
+       struct ldlm_reply        *lockrep;
        __u64                     flags = LDLM_FL_HAS_INTENT;
        ENTRY;
 
@@ -170,14 +171,28 @@ static int qsd_intent_interpret(const struct lu_env *env,
        rc = ldlm_cli_enqueue_fini(aa->aa_exp, req, LDLM_PLAIN, 0, LCK_CR,
                                   &flags, (void *)aa->aa_lvb,
                                   sizeof(struct lquota_lvb), lockh, rc);
-       if (rc < 0)
+       if (rc < 0) {
                /* the lock has been destroyed, forget about the lock handle */
                memset(lockh, 0, sizeof(*lockh));
+               /*
+                * To avoid the server being fullfilled by LDLM locks, server
+                * may reject the locking request by returning -EINPROGRESS,
+                * this is different from the -EINPROGRESS returned by quota
+                * code.
+                */
+               if (rc == -EINPROGRESS)
+                       rc = -EAGAIN;
+               GOTO(out, rc);
+       }
+
+       lockrep = req_capsule_server_get(&req->rq_pill, &RMF_DLM_REP);
+       LASSERT(lockrep != NULL);
+       rc = ptlrpc_status_ntoh(lockrep->lock_policy_res2);
 
        if (rc == 0 || rc == -EDQUOT || rc == -EINPROGRESS)
                rep_qbody = req_capsule_server_get(&req->rq_pill,
                                                   &RMF_QUOTA_BODY);
-
+out:
        aa->aa_completion(env, aa->aa_qqi, req_qbody, rep_qbody, lockh,
                          aa->aa_lvb, aa->aa_arg, rc);
        RETURN(rc);