Whamcloud - gitweb
LU-10070 ldlm: layout lock fixes 32/35232/7
authorVitaly Fertman <c17818@cray.com>
Tue, 11 Jun 2019 23:18:45 +0000 (02:18 +0300)
committerOleg Drokin <green@whamcloud.com>
Tue, 25 Jun 2019 01:54:01 +0000 (01:54 +0000)
as the intent_layout operation becomes more frequent with SEL,
cancel existent layout locks in advance and reuse ELC to deliver
cancels to MDS

as clients are given LCK_EX layout locks, take into account this
mode as well in ldlm_lock_match

Cray-bug-id: LUS-2528
Signed-off-by: Vitaly Fertman <c17818@cray.com>
Change-Id: I1525153b3a07385fc17ef5416ded7b6d4378b2ec
Reviewed-on: https://review.whamcloud.com/35232
Reviewed-by: Patrick Farrell <pfarrell@whamcloud.com>
Reviewed-by: Mike Pershin <mpershin@whamcloud.com>
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/llite/file.c
lustre/mdc/mdc_locks.c

index c45090e..1d37ff5 100644 (file)
@@ -5360,7 +5360,8 @@ int ll_layout_refresh(struct inode *inode, __u32 *gen)
                /* mostly layout lock is caching on the local side, so try to
                 * match it before grabbing layout lock mutex. */
                mode = ll_take_md_lock(inode, MDS_INODELOCK_LAYOUT, &lockh, 0,
-                                      LCK_CR | LCK_CW | LCK_PR | LCK_PW);
+                                      LCK_CR | LCK_CW | LCK_PR |
+                                      LCK_PW | LCK_EX);
                if (mode != 0) { /* hit cached lock */
                        rc = ll_layout_lock_set(&lockh, mode, inode);
                        if (rc == -EAGAIN)
index c946fa2..661cb7f 100644 (file)
@@ -588,10 +588,11 @@ static struct ptlrpc_request *mdc_intent_layout_pack(struct obd_export *exp,
                                                     struct md_op_data *op_data)
 {
        struct obd_device     *obd = class_exp2obd(exp);
+       struct list_head cancels = LIST_HEAD_INIT(cancels);
        struct ptlrpc_request *req;
        struct ldlm_intent    *lit;
        struct layout_intent  *layout;
-       int rc;
+       int count = 0, rc;
        ENTRY;
 
        req = ptlrpc_request_alloc(class_exp2cliimp(exp),
@@ -599,8 +600,15 @@ static struct ptlrpc_request *mdc_intent_layout_pack(struct obd_export *exp,
        if (req == NULL)
                RETURN(ERR_PTR(-ENOMEM));
 
+       if (fid_is_sane(&op_data->op_fid2) && (it->it_op & IT_LAYOUT) &&
+           (it->it_flags & FMODE_WRITE)) {
+               count = mdc_resource_get_unused(exp, &op_data->op_fid2,
+                                               &cancels, LCK_EX,
+                                               MDS_INODELOCK_LAYOUT);
+       }
+
        req_capsule_set_size(&req->rq_pill, &RMF_EADATA, RCL_CLIENT, 0);
-       rc = ldlm_prep_enqueue_req(exp, req, NULL, 0);
+       rc = ldlm_prep_enqueue_req(exp, req, &cancels, count);
        if (rc) {
                ptlrpc_request_free(req);
                RETURN(ERR_PTR(rc));