Whamcloud - gitweb
LU-11025 mdt: don't save remote lock if op not from client 81/37281/8
authorLai Siyao <lai.siyao@whamcloud.com>
Sat, 4 Jan 2020 20:51:32 +0000 (04:51 +0800)
committerOleg Drokin <green@whamcloud.com>
Thu, 7 May 2020 05:41:57 +0000 (05:41 +0000)
Some operation may not be originated from client, e.g., directory
auto split, in this case ptlrpc_request is NULL, therefore we can't
get the transaction number from request and save remote lock. This
means upon remote lock cancel this distributed transaction may not
be committed yet, that is to say, commit-on-sharing won't be triggered
if subsequent operations depend on this operation. However this won't
cause any inconsistency normally, because upon one MDT failure, this
distributed transaction can be replayed from update logs in other
MDT, and as a side effect, it avoids continuous commit in directory
auto split.

Signed-off-by: Lai Siyao <lai.siyao@whamcloud.com>
Change-Id: If7608cab96f36480654d5d7a0f5a0f1c4dfd12b2
Reviewed-on: https://review.whamcloud.com/37281
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Hongchao Zhang <hongchao@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/mdt/mdt_handler.c

index 4deb40e..e5ed97a 100644 (file)
@@ -3525,20 +3525,18 @@ static void mdt_save_remote_lock(struct mdt_thread_info *info,
 
        if (lustre_handle_is_used(h)) {
                struct ldlm_lock *lock = ldlm_handle2lock(h);
+               struct ptlrpc_request *req = mdt_info_req(info);
 
                if (o != NULL &&
                    (lock->l_policy_data.l_inodebits.bits &
                     (MDS_INODELOCK_XATTR | MDS_INODELOCK_UPDATE)))
                        mo_invalidate(info->mti_env, mdt_object_child(o));
 
-               if (decref || !info->mti_has_trans ||
+               if (decref || !info->mti_has_trans || !req ||
                    !(mode & (LCK_PW | LCK_EX))) {
                        ldlm_lock_decref_and_cancel(h, mode);
                        LDLM_LOCK_PUT(lock);
                } else {
-                       struct ptlrpc_request *req = mdt_info_req(info);
-
-                       LASSERT(req != NULL);
                        tgt_save_slc_lock(&info->mti_mdt->mdt_lut, lock,
                                          req->rq_transno);
                        ldlm_lock_decref(h, mode);