Whamcloud - gitweb
LU-14693 mdt: skip DLM when opening volatile files 42/43742/2
authorJohn L. Hammond <jhammond@whamcloud.com>
Wed, 28 Apr 2021 18:43:51 +0000 (13:43 -0500)
committerOleg Drokin <green@whamcloud.com>
Wed, 2 Jun 2021 17:49:33 +0000 (17:49 +0000)
In mdt_reint_open(), when opening a volatile file skip taking a
MDS_INODELOCK_UPDATE lock on the parent directory.

Signed-off-by: John L. Hammond <jhammond@whamcloud.com>
Change-Id: I8ee89710f52e8097e1412897de91159702560e4a
Reviewed-on: https://review.whamcloud.com/43742
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Lai Siyao <lai.siyao@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/md_object.h
lustre/mdt/mdt_open.c
lustre/mdt/mdt_reint.c

index 2d762b8..abab785 100644 (file)
@@ -173,8 +173,6 @@ struct md_op_spec {
                     sp_permitted:1, /* do not check permission */
                     sp_migrate_close:1, /* close the file during migrate */
                     sp_migrate_nsonly:1; /* migrate dirent only */
                     sp_permitted:1, /* do not check permission */
                     sp_migrate_close:1, /* close the file during migrate */
                     sp_migrate_nsonly:1; /* migrate dirent only */
-       /** Current lock mode for parent dir where create is performing. */
-       mdl_mode_t sp_cr_mode;
 
        /** to create directory */
        const struct dt_index_features *sp_feat;
 
        /** to create directory */
        const struct dt_index_features *sp_feat;
index 6361301..d1392e5 100644 (file)
@@ -1301,7 +1301,7 @@ int mdt_reint_open(struct mdt_thread_info *info, struct mdt_lock_handle *lhc)
        struct ptlrpc_request *req = mdt_info_req(info);
        struct mdt_object *parent;
        struct mdt_object *child;
        struct ptlrpc_request *req = mdt_info_req(info);
        struct mdt_object *parent;
        struct mdt_object *child;
-       struct mdt_lock_handle *lh;
+       struct mdt_lock_handle *lh = NULL;
        struct ldlm_reply *ldlm_rep;
        struct mdt_body *repbody;
        struct lu_fid *child_fid = &info->mti_tmp_fid1;
        struct ldlm_reply *ldlm_rep;
        struct mdt_body *repbody;
        struct lu_fid *child_fid = &info->mti_tmp_fid1;
@@ -1403,20 +1403,23 @@ int mdt_reint_open(struct mdt_thread_info *info, struct mdt_lock_handle *lhc)
 
        OBD_RACE(OBD_FAIL_MDS_REINT_OPEN);
 again_pw:
 
        OBD_RACE(OBD_FAIL_MDS_REINT_OPEN);
 again_pw:
-       lh = &info->mti_lh[MDT_LH_PARENT];
-       mdt_lock_pdo_init(lh, lock_mode, &rr->rr_name);
-
-       result = mdt_object_lock(info, parent, lh, MDS_INODELOCK_UPDATE);
-       if (result != 0) {
-               mdt_object_put(info->mti_env, parent);
-               GOTO(out, result);
-       }
        fid_zero(child_fid);
 
        fid_zero(child_fid);
 
-       result = -ENOENT;
-       if ((open_flags & MDS_OPEN_VOLATILE) == 0)
+       if (open_flags & MDS_OPEN_VOLATILE) {
+               lh = NULL;
+               result = -ENOENT;
+       } else {
+               lh = &info->mti_lh[MDT_LH_PARENT];
+               mdt_lock_pdo_init(lh, lock_mode, &rr->rr_name);
+               result = mdt_object_lock(info, parent, lh, MDS_INODELOCK_UPDATE);
+               if (result != 0) {
+                       mdt_object_put(info->mti_env, parent);
+                       GOTO(out, result);
+               }
+
                result = mdo_lookup(info->mti_env, mdt_object_child(parent),
                                    &rr->rr_name, child_fid, &info->mti_spec);
                result = mdo_lookup(info->mti_env, mdt_object_child(parent),
                                    &rr->rr_name, child_fid, &info->mti_spec);
+       }
 
        LASSERTF(ergo(result == 0, fid_is_sane(child_fid)),
                 "looking for "DFID"/"DNAME", found FID = "DFID"\n",
 
        LASSERTF(ergo(result == 0, fid_is_sane(child_fid)),
                 "looking for "DFID"/"DNAME", found FID = "DFID"\n",
@@ -1435,7 +1438,9 @@ again_pw:
                if (mdt_rdonly(req->rq_export))
                        GOTO(out_parent, result = -EROFS);
 
                if (mdt_rdonly(req->rq_export))
                        GOTO(out_parent, result = -EROFS);
 
-               if (lock_mode == LCK_PR) {
+               LASSERT(equi(lh == NULL, open_flags & MDS_OPEN_VOLATILE));
+
+               if (lh != NULL && lock_mode == LCK_PR) {
                        /* first pass: get write lock and restart */
                        mdt_object_unlock(info, parent, lh, 1);
                        mdt_clear_disposition(info, ldlm_rep, DISP_LOOKUP_NEG);
                        /* first pass: get write lock and restart */
                        mdt_object_unlock(info, parent, lh, 1);
                        mdt_clear_disposition(info, ldlm_rep, DISP_LOOKUP_NEG);
@@ -1483,10 +1488,6 @@ again_pw:
                /* Not found and with MDS_OPEN_CREAT: let's create it. */
                mdt_set_disposition(info, ldlm_rep, DISP_OPEN_CREATE);
 
                /* Not found and with MDS_OPEN_CREAT: let's create it. */
                mdt_set_disposition(info, ldlm_rep, DISP_OPEN_CREATE);
 
-               /* Let lower layers know what is lock mode on directory. */
-               info->mti_spec.sp_cr_mode =
-                       mdt_dlm_mode2mdl_mode(lh->mlh_pdo_mode);
-
                /* Don't do lookup sanity check. We know name doesn't exist. */
                info->mti_spec.sp_cr_lookup = 0;
                info->mti_spec.sp_feat = &dt_directory_features;
                /* Don't do lookup sanity check. We know name doesn't exist. */
                info->mti_spec.sp_cr_lookup = 0;
                info->mti_spec.sp_feat = &dt_directory_features;
@@ -1639,7 +1640,10 @@ out_child:
        if (result == 0)
                mdt_pack_size2body(info, child_fid, &lhc->mlh_reg_lh);
 out_parent:
        if (result == 0)
                mdt_pack_size2body(info, child_fid, &lhc->mlh_reg_lh);
 out_parent:
-       mdt_object_unlock_put(info, parent, lh, result || !created);
+       if (lh != NULL)
+               mdt_object_unlock(info, parent, lh, result || !created);
+
+       mdt_object_put(info->mti_env, parent);
 out:
        if (result)
                lustre_msg_set_transno(req->rq_repmsg, 0);
 out:
        if (result)
                lustre_msg_set_transno(req->rq_repmsg, 0);
@@ -1682,7 +1686,6 @@ static struct mdt_object *mdt_orphan_open(struct mdt_thread_info *info,
 
        spec->sp_cr_lookup = 0;
        spec->sp_feat = &dt_directory_features;
 
        spec->sp_cr_lookup = 0;
        spec->sp_feat = &dt_directory_features;
-       spec->sp_cr_mode = MDL_MINMODE; /* no lock */
        spec->sp_cr_flags = MDS_OPEN_VOLATILE | fmode;
        if (attr->ma_valid & MA_LOV) {
                spec->u.sp_ea.eadata = attr->ma_lmm;
        spec->sp_cr_flags = MDS_OPEN_VOLATILE | fmode;
        if (attr->ma_valid & MA_LOV) {
                spec->u.sp_ea.eadata = attr->ma_lmm;
index adf02cc..f2952d2 100644 (file)
@@ -599,9 +599,6 @@ static int mdt_create(struct mdt_thread_info *info)
        if (rc)
                GOTO(put_child, rc);
 
        if (rc)
                GOTO(put_child, rc);
 
-       /* Let lower layer know current lock mode. */
-       info->mti_spec.sp_cr_mode = mdt_dlm_mode2mdl_mode(lh->mlh_pdo_mode);
-
        /*
         * Do not perform lookup sanity check. We know that name does
         * not exist.
        /*
         * Do not perform lookup sanity check. We know that name does
         * not exist.