Whamcloud - gitweb
LU-4684 lmv: support accessing migrating directory 04/31504/31
authorLai Siyao <lai.siyao@intel.com>
Thu, 1 Mar 2018 02:34:19 +0000 (10:34 +0800)
committerOleg Drokin <green@whamcloud.com>
Mon, 1 Oct 2018 14:00:14 +0000 (14:00 +0000)
Migrating directory contains stripes of both old and new layout, and
its sub files may be located on either one. To avoid race between
access and new creations, there are 4 rules to access migrating
directory:
1. always create new file under new layout.
2. any operation that tries to create new file under old layout will
   be rejected, e.g., 'mv a <migrating_dir>/b', if b exists and is
   under old layout, this rename should fail with -EBUSY.
3. operations that access file by name should try old layout first,
   if file doesn't exist, then it will retry new layout, such
   operations include: lookup, getattr_name, unlink, open-by-name,
   link, rename.
4. according to rule 1, open(O_CREAT | O_EXCL) and create() will
   create new file under new layout, but they should check existing
   file in one transaction, however this can't be done for old
   layout, so check existing file under old layout on client side,
   then issue the open/create request to new layout.

Disable sanity 230d for ZFS backend because it will trigger lots of
sync, which may cause system hung.

Signed-off-by: Lai Siyao <lai.siyao@whamcloud.com>
Change-Id: Icd587eb17f4c6dc2234dcc3c7ba40759bc3e8d31
Reviewed-on: https://review.whamcloud.com/31504
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/lustre_lmv.h
lustre/include/obd.h
lustre/lmv/lmv_intent.c
lustre/lmv/lmv_internal.h
lustre/lmv/lmv_obd.c
lustre/tests/conf-sanity.sh
lustre/tests/recovery-small.sh
lustre/tests/sanity-hsm.sh
lustre/tests/sanity-lfsck.sh
lustre/tests/sanity.sh
lustre/tests/sanityn.sh

index e797e77..ff91ff1 100644 (file)
@@ -86,10 +86,6 @@ union lmv_mds_md;
 
 void lmv_free_memmd(struct lmv_stripe_md *lsm);
 
-int lmvea_load_shards(const struct lu_env *env, struct dt_object *obj,
-                     struct lu_dirent *ent, struct lu_buf *buf,
-                     bool resize);
-
 static inline void lmv1_le_to_cpu(struct lmv_mds_md_v1 *lmv_dst,
                                  const struct lmv_mds_md_v1 *lmv_src)
 {
index f792347..6fe934f 100644 (file)
@@ -876,6 +876,18 @@ struct md_op_data {
        unsigned int            op_max_pages;
 
        __u16                   op_mirror_id;
+
+       /*
+        * used to access migrating dir: if it's set, assume migration is
+        * finished, use the new layout to access dir, otherwise use old layout.
+        * By default it's not set, because new files are created under new
+        * layout, if we can't find file with name under both old and new
+        * layout, we are sure file with name doesn't exist, but in reverse
+        * order there may be a race with creation by others.
+        */
+       bool                    op_post_migrate;
+       /* used to access dir with bash hash */
+       __u32                   op_stripe_index;
 };
 
 struct md_callback {
index 8fc27d6..cc902bd 100644 (file)
@@ -193,7 +193,7 @@ int lmv_revalidate_slaves(struct obd_export *exp,
                op_data->op_fid1 = fid;
                op_data->op_fid2 = fid;
 
-               tgt = lmv_locate_mds(lmv, op_data, &fid);
+               tgt = lmv_get_target(lmv, lsm->lsm_md_oinfo[i].lmo_mds, NULL);
                if (IS_ERR(tgt))
                        GOTO(cleanup, rc = PTR_ERR(tgt));
 
@@ -263,13 +263,58 @@ static int lmv_intent_open(struct obd_export *exp, struct md_op_data *op_data,
                           ldlm_blocking_callback cb_blocking,
                           __u64 extra_lock_flags)
 {
-       struct obd_device       *obd = exp->exp_obd;
-       struct lmv_obd          *lmv = &obd->u.lmv;
-       struct lmv_tgt_desc     *tgt;
-       struct mdt_body         *body;
-       int                     rc;
+       struct obd_device *obd = exp->exp_obd;
+       struct lmv_obd *lmv = &obd->u.lmv;
+       struct lmv_tgt_desc *tgt;
+       struct mdt_body *body;
+       __u64 flags = it->it_flags;
+       int rc;
+
        ENTRY;
 
+       if ((it->it_op & IT_CREAT) && !(flags & MDS_OPEN_BY_FID)) {
+               /* don't allow create under dir with bad hash */
+               if (lmv_is_dir_bad_hash(op_data->op_mea1))
+                       RETURN(-EBADF);
+
+               if (lmv_is_dir_migrating(op_data->op_mea1)) {
+                       if (flags & O_EXCL) {
+                               /*
+                                * open(O_CREAT | O_EXCL) needs to check
+                                * existing name, which should be done on both
+                                * old and new layout, to avoid creating new
+                                * file under old layout, check old layout on
+                                * client side.
+                                */
+                               tgt = lmv_locate_tgt(lmv, op_data,
+                                                    &op_data->op_fid1);
+                               if (IS_ERR(tgt))
+                                       RETURN(PTR_ERR(tgt));
+
+                               rc = md_getattr_name(tgt->ltd_exp, op_data,
+                                                    reqp);
+                               if (!rc) {
+                                       ptlrpc_req_finished(*reqp);
+                                       *reqp = NULL;
+                                       RETURN(-EEXIST);
+                               }
+
+                               if (rc != -ENOENT)
+                                       RETURN(rc);
+
+                               op_data->op_post_migrate = true;
+                       } else {
+                               /*
+                                * open(O_CREAT) will be sent to MDT in old
+                                * layout first, to avoid creating new file
+                                * under old layout, clear O_CREAT.
+                                */
+                               it->it_flags &= ~O_CREAT;
+                       }
+               }
+       }
+
+retry:
        if (it->it_flags & MDS_OPEN_BY_FID) {
                LASSERT(fid_is_sane(&op_data->op_fid2));
 
@@ -289,7 +334,7 @@ static int lmv_intent_open(struct obd_export *exp, struct md_op_data *op_data,
                LASSERT(fid_is_zero(&op_data->op_fid2));
                LASSERT(op_data->op_name != NULL);
 
-               tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
+               tgt = lmv_locate_tgt(lmv, op_data, &op_data->op_fid1);
                if (IS_ERR(tgt))
                        RETURN(PTR_ERR(tgt));
        }
@@ -320,8 +365,21 @@ static int lmv_intent_open(struct obd_export *exp, struct md_op_data *op_data,
         */
        if ((it->it_disposition & DISP_LOOKUP_NEG) &&
            !(it->it_disposition & DISP_OPEN_CREATE) &&
-           !(it->it_disposition & DISP_OPEN_OPEN))
+           !(it->it_disposition & DISP_OPEN_OPEN)) {
+               if (!(it->it_flags & MDS_OPEN_BY_FID) &&
+                   lmv_dir_retry_check_update(op_data)) {
+                       ptlrpc_req_finished(*reqp);
+                       it->it_request = NULL;
+                       it->it_disposition = 0;
+                       *reqp = NULL;
+
+                       it->it_flags = flags;
+                       fid_zero(&op_data->op_fid2);
+                       goto retry;
+               }
+
                RETURN(rc);
+       }
 
        body = req_capsule_server_get(&(*reqp)->rq_pill, &RMF_MDT_BODY);
        if (body == NULL)
@@ -351,42 +409,26 @@ lmv_intent_lookup(struct obd_export *exp, struct md_op_data *op_data,
                  ldlm_blocking_callback cb_blocking,
                  __u64 extra_lock_flags)
 {
-       struct obd_device       *obd = exp->exp_obd;
-       struct lmv_obd          *lmv = &obd->u.lmv;
-       struct lmv_tgt_desc     *tgt = NULL;
-       struct mdt_body         *body;
-       struct lmv_stripe_md    *lsm = op_data->op_mea1;
-       int                     rc = 0;
+       struct obd_device *obd = exp->exp_obd;
+       struct lmv_obd *lmv = &obd->u.lmv;
+       struct lmv_tgt_desc *tgt = NULL;
+       struct mdt_body *body;
+       int rc;
        ENTRY;
 
-       /* If it returns ERR_PTR(-EBADFD) then it is an unknown hash type
-        * it will try all stripes to locate the object */
-       tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
-       if (IS_ERR(tgt) && (PTR_ERR(tgt) != -EBADFD))
+retry:
+       tgt = lmv_locate_tgt(lmv, op_data, &op_data->op_fid1);
+       if (IS_ERR(tgt))
                RETURN(PTR_ERR(tgt));
 
-       /* Both migrating dir and unknown hash dir need to try
-        * all of sub-stripes */
-       if (lsm != NULL && !lmv_is_known_hash_type(lsm->lsm_md_hash_type)) {
-               struct lmv_oinfo *oinfo;
-
-               oinfo = &lsm->lsm_md_oinfo[0];
-
-               op_data->op_fid1 = oinfo->lmo_fid;
-               op_data->op_mds = oinfo->lmo_mds;
-               tgt = lmv_get_target(lmv, oinfo->lmo_mds, NULL);
-               if (IS_ERR(tgt))
-                       RETURN(PTR_ERR(tgt));
-       }
-
        if (!fid_is_sane(&op_data->op_fid2))
                fid_zero(&op_data->op_fid2);
 
        CDEBUG(D_INODE, "LOOKUP_INTENT with fid1="DFID", fid2="DFID
-              ", name='%s' -> mds #%u lsm=%p lsm_magic=%x\n",
+              ", name='%s' -> mds #%u\n",
               PFID(&op_data->op_fid1), PFID(&op_data->op_fid2),
               op_data->op_name ? op_data->op_name : "<NULL>",
-              tgt->ltd_idx, lsm, lsm == NULL ? -1 : lsm->lsm_md_magic);
+              tgt->ltd_idx);
 
        op_data->op_bias &= ~MDS_CROSS_REF;
 
@@ -406,37 +448,14 @@ lmv_intent_lookup(struct obd_export *exp, struct md_op_data *op_data,
                                RETURN(rc);
                }
                RETURN(rc);
-       } else if (it_disposition(it, DISP_LOOKUP_NEG) && lsm != NULL &&
-                  lmv_need_try_all_stripes(lsm)) {
-               /* For migrating and unknown hash type directory, it will
-                * try to target the entry on other stripes */
-               int stripe_index;
-
-               for (stripe_index = 1;
-                    stripe_index < lsm->lsm_md_stripe_count &&
-                    it_disposition(it, DISP_LOOKUP_NEG); stripe_index++) {
-                       struct lmv_oinfo *oinfo;
-
-                       /* release the previous request */
-                       ptlrpc_req_finished(*reqp);
-                       it->it_request = NULL;
-                       *reqp = NULL;
-
-                       oinfo = &lsm->lsm_md_oinfo[stripe_index];
-                       tgt = lmv_find_target(lmv, &oinfo->lmo_fid);
-                       if (IS_ERR(tgt))
-                               RETURN(PTR_ERR(tgt));
-
-                       CDEBUG(D_INODE, "Try other stripes " DFID"\n",
-                              PFID(&oinfo->lmo_fid));
+       } else if (it_disposition(it, DISP_LOOKUP_NEG) &&
+                  lmv_dir_retry_check_update(op_data)) {
+               ptlrpc_req_finished(*reqp);
+               it->it_request = NULL;
+               it->it_disposition = 0;
+               *reqp = NULL;
 
-                       op_data->op_fid1 = oinfo->lmo_fid;
-                       it->it_disposition &= ~DISP_ENQ_COMPLETE;
-                       rc = md_intent_lock(tgt->ltd_exp, op_data, it, reqp,
-                                           cb_blocking, extra_lock_flags);
-                       if (rc != 0)
-                               RETURN(rc);
-               }
+               goto retry;
        }
 
        if (!it_has_reply_body(it))
index 899007a..0ad7432 100644 (file)
@@ -58,6 +58,9 @@ int lmv_revalidate_slaves(struct obd_export *exp,
                          ldlm_blocking_callback cb_blocking,
                          int extra_lock_flags);
 
+int lmv_getattr_name(struct obd_export *exp, struct md_op_data *op_data,
+                    struct ptlrpc_request **preq);
+
 static inline struct obd_device *lmv2obd_dev(struct lmv_obd *lmv)
 {
        return container_of0(lmv, struct obd_device, u.lmv);
@@ -125,15 +128,20 @@ static inline int lmv_stripe_md_size(int stripe_count)
 /* for file under migrating directory, return the target stripe info */
 static inline const struct lmv_oinfo *
 lsm_name_to_stripe_info(const struct lmv_stripe_md *lsm, const char *name,
-                       int namelen)
+                       int namelen, bool post_migrate)
 {
        __u32 hash_type = lsm->lsm_md_hash_type;
        __u32 stripe_count = lsm->lsm_md_stripe_count;
        int stripe_index;
 
        if (hash_type & LMV_HASH_FLAG_MIGRATION) {
-               hash_type &= ~LMV_HASH_FLAG_MIGRATION;
-               stripe_count = lsm->lsm_md_migrate_offset;
+               if (post_migrate) {
+                       hash_type &= ~LMV_HASH_FLAG_MIGRATION;
+                       stripe_count = lsm->lsm_md_migrate_offset;
+               } else {
+                       hash_type = lsm->lsm_md_migrate_hash;
+                       stripe_count -= lsm->lsm_md_migrate_offset;
+               }
        }
 
        stripe_index = lmv_name_to_stripe_index(hash_type, stripe_count,
@@ -141,23 +149,65 @@ lsm_name_to_stripe_info(const struct lmv_stripe_md *lsm, const char *name,
        if (stripe_index < 0)
                return ERR_PTR(stripe_index);
 
-       LASSERTF(stripe_index < lsm->lsm_md_stripe_count,
-                "stripe_index = %d, stripe_count = %d hash_type = %x"
-                "name = %.*s\n", stripe_index, lsm->lsm_md_stripe_count,
-                lsm->lsm_md_hash_type, namelen, name);
+       if ((lsm->lsm_md_hash_type & LMV_HASH_FLAG_MIGRATION) && !post_migrate)
+               stripe_index += lsm->lsm_md_migrate_offset;
+
+       if (stripe_index >= lsm->lsm_md_stripe_count) {
+               CERROR("stripe_index %d stripe_count %d hash_type %#x "
+                       "migrate_offset %d migrate_hash %#x name %.*s\n",
+                       stripe_index, lsm->lsm_md_stripe_count,
+                       lsm->lsm_md_hash_type, lsm->lsm_md_migrate_offset,
+                       lsm->lsm_md_migrate_hash, namelen, name);
+               return ERR_PTR(-EBADF);
+       }
 
        return &lsm->lsm_md_oinfo[stripe_index];
 }
 
-static inline bool lmv_need_try_all_stripes(const struct lmv_stripe_md *lsm)
+static inline bool lmv_is_dir_migrating(const struct lmv_stripe_md *lsm)
+{
+       return lsm ? lsm->lsm_md_hash_type & LMV_HASH_FLAG_MIGRATION : false;
+}
+
+static inline bool lmv_is_dir_bad_hash(const struct lmv_stripe_md *lsm)
+{
+       if (!lsm)
+               return false;
+
+       if (lmv_is_dir_migrating(lsm)) {
+               if (lsm->lsm_md_stripe_count - lsm->lsm_md_migrate_offset > 1)
+                       return !lmv_is_known_hash_type(
+                                       lsm->lsm_md_migrate_hash);
+               return false;
+       }
+
+       return !lmv_is_known_hash_type(lsm->lsm_md_hash_type);
+}
+
+static inline bool lmv_dir_retry_check_update(struct md_op_data *op_data)
 {
-       return !lmv_is_known_hash_type(lsm->lsm_md_hash_type) ||
-              lsm->lsm_md_hash_type & LMV_HASH_FLAG_MIGRATION;
+       const struct lmv_stripe_md *lsm = op_data->op_mea1;
+
+       if (!lsm)
+               return false;
+
+       if (lmv_is_dir_migrating(lsm) && !op_data->op_post_migrate) {
+               op_data->op_post_migrate = true;
+               return true;
+       }
+
+       if (lmv_is_dir_bad_hash(lsm) &&
+           op_data->op_stripe_index < lsm->lsm_md_stripe_count - 1) {
+               op_data->op_stripe_index++;
+               return true;
+       }
+
+       return false;
 }
 
-struct lmv_tgt_desc
-*lmv_locate_mds(struct lmv_obd *lmv, struct md_op_data *op_data,
-               struct lu_fid *fid);
+struct lmv_tgt_desc *lmv_locate_tgt(struct lmv_obd *lmv,
+                                   struct md_op_data *op_data,
+                                   struct lu_fid *fid);
 /* lproc_lmv.c */
 int lmv_tunables_init(struct obd_device *obd);
 
index 29e1e76..63f617c 100644 (file)
@@ -1154,7 +1154,7 @@ static int lmv_placement_policy(struct obd_device *obd,
         * 1. See if the stripe offset is specified by lum.
         * 2. Then check if there is default stripe offset.
         * 3. Finally choose MDS by name hash if the parent
-        *    is striped directory. (see lmv_locate_mds()). */
+        *    is striped directory. (see lmv_locate_tgt()). */
        if (op_data->op_cli_flags & CLI_SET_MEA && lum != NULL &&
            le32_to_cpu(lum->lum_stripe_offset) != (__u32)-1) {
                *mds = le32_to_cpu(lum->lum_stripe_offset);
@@ -1539,28 +1539,33 @@ static int lmv_close(struct obd_export *exp, struct md_op_data *op_data,
         RETURN(rc);
 }
 
-/**
- * Choosing the MDT by name or FID in @op_data.
- * For non-striped directory, it will locate MDT by fid.
- * For striped-directory, it will locate MDT by name. And also
- * it will reset op_fid1 with the FID of the choosen stripe.
- **/
-struct lmv_tgt_desc *
-lmv_locate_target_for_name(struct lmv_obd *lmv, struct lmv_stripe_md *lsm,
-                          const char *name, int namelen, struct lu_fid *fid,
-                          u32 *mds)
+struct lmv_tgt_desc*
+__lmv_locate_tgt(struct lmv_obd *lmv, struct lmv_stripe_md *lsm,
+                const char *name, int namelen, struct lu_fid *fid, u32 *mds,
+                bool post_migrate)
 {
-       struct lmv_tgt_desc     *tgt;
-       const struct lmv_oinfo  *oinfo;
+       struct lmv_tgt_desc *tgt;
+       const struct lmv_oinfo *oinfo;
+
+       if (lsm == NULL || namelen == 0) {
+               tgt = lmv_find_target(lmv, fid);
+               if (IS_ERR(tgt))
+                       return tgt;
+
+               LASSERT(mds);
+               *mds = tgt->ltd_idx;
+               return tgt;
+       }
 
        if (OBD_FAIL_CHECK(OBD_FAIL_LFSCK_BAD_NAME_HASH)) {
                if (cfs_fail_val >= lsm->lsm_md_stripe_count)
-                       RETURN(ERR_PTR(-EBADF));
+                       return ERR_PTR(-EBADF);
                oinfo = &lsm->lsm_md_oinfo[cfs_fail_val];
        } else {
-               oinfo = lsm_name_to_stripe_info(lsm, name, namelen);
+               oinfo = lsm_name_to_stripe_info(lsm, name, namelen,
+                                               post_migrate);
                if (IS_ERR(oinfo))
-                       RETURN(ERR_CAST(oinfo));
+                       return ERR_CAST(oinfo);
        }
 
        if (fid != NULL)
@@ -1572,18 +1577,21 @@ lmv_locate_target_for_name(struct lmv_obd *lmv, struct lmv_stripe_md *lsm,
 
        CDEBUG(D_INFO, "locate on mds %u "DFID"\n", oinfo->lmo_mds,
               PFID(&oinfo->lmo_fid));
+
        return tgt;
 }
 
+
 /**
- * Locate mds by fid or name
+ * Locate mdt by fid or name
  *
- * For striped directory (lsm != NULL), it will locate the stripe
- * by name hash (see lsm_name_to_stripe_info()). Note: if the hash_type
- * is unknown, it will return -EBADFD, and lmv_intent_lookup might need
- * walk through all of stripes to locate the entry.
+ * For striped directory, it will locate the stripe by name hash, if hash_type
+ * is unknown, it will return the stripe specified by 'op_data->op_stripe_index'
+ * which is set outside, and if dir is migrating, 'op_data->op_post_migrate'
+ * indicates whether old or new layout is used to locate.
  *
  * For normal direcotry, it will locate MDS by FID directly.
+ *
  * \param[in] lmv      LMV device
  * \param[in] op_data  client MD stack parameters, name, namelen
  *                      mds_num etc.
@@ -1593,27 +1601,27 @@ lmv_locate_target_for_name(struct lmv_obd *lmv, struct lmv_stripe_md *lsm,
  *                      ERR_PTR(errno) if failed.
  */
 struct lmv_tgt_desc*
-lmv_locate_mds(struct lmv_obd *lmv, struct md_op_data *op_data,
+lmv_locate_tgt(struct lmv_obd *lmv, struct md_op_data *op_data,
               struct lu_fid *fid)
 {
-       struct lmv_stripe_md    *lsm = op_data->op_mea1;
-       struct lmv_tgt_desc     *tgt;
+       struct lmv_stripe_md *lsm = op_data->op_mea1;
+       struct lmv_oinfo *oinfo;
+       struct lmv_tgt_desc *tgt;
 
        /* During creating VOLATILE file, it should honor the mdt
         * index if the file under striped dir is being restored, see
         * ct_restore(). */
        if (op_data->op_bias & MDS_CREATE_VOLATILE &&
            (int)op_data->op_mds != -1) {
-               int i;
                tgt = lmv_get_target(lmv, op_data->op_mds, NULL);
                if (IS_ERR(tgt))
                        return tgt;
 
-               if (lsm != NULL) {
+               if (lsm) {
+                       int i;
+
                        /* refill the right parent fid */
                        for (i = 0; i < lsm->lsm_md_stripe_count; i++) {
-                               struct lmv_oinfo *oinfo;
-
                                oinfo = &lsm->lsm_md_oinfo[i];
                                if (oinfo->lmo_mds == op_data->op_mds) {
                                        *fid = oinfo->lmo_fid;
@@ -1624,22 +1632,21 @@ lmv_locate_mds(struct lmv_obd *lmv, struct md_op_data *op_data,
                        if (i == lsm->lsm_md_stripe_count)
                                *fid = lsm->lsm_md_oinfo[0].lmo_fid;
                }
+       } else if (lmv_is_dir_bad_hash(lsm)) {
+               LASSERT(op_data->op_stripe_index < lsm->lsm_md_stripe_count);
+               oinfo = &lsm->lsm_md_oinfo[op_data->op_stripe_index];
 
-               return tgt;
-       }
-
-       if (lsm == NULL || op_data->op_namelen == 0) {
-               tgt = lmv_find_target(lmv, fid);
-               if (IS_ERR(tgt))
-                       return tgt;
-
-               op_data->op_mds = tgt->ltd_idx;
-               return tgt;
+               *fid = oinfo->lmo_fid;
+               op_data->op_mds = oinfo->lmo_mds;
+               tgt = lmv_get_target(lmv, oinfo->lmo_mds, NULL);
+       } else {
+               tgt = __lmv_locate_tgt(lmv, lsm, op_data->op_name,
+                                      op_data->op_namelen, fid,
+                                      &op_data->op_mds,
+                                      op_data->op_post_migrate);
        }
 
-       return lmv_locate_target_for_name(lmv, lsm, op_data->op_name,
-                                         op_data->op_namelen, fid,
-                                         &op_data->op_mds);
+       return tgt;
 }
 
 int lmv_create(struct obd_export *exp, struct md_op_data *op_data,
@@ -1656,7 +1663,33 @@ int lmv_create(struct obd_export *exp, struct md_op_data *op_data,
        if (!lmv->desc.ld_active_tgt_count)
                RETURN(-EIO);
 
-       tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
+       if (lmv_is_dir_bad_hash(op_data->op_mea1))
+               RETURN(-EBADF);
+
+       if (lmv_is_dir_migrating(op_data->op_mea1)) {
+               /*
+                * if parent is migrating, create() needs to lookup existing
+                * name, to avoid creating new file under old layout of
+                * migrating directory, check old layout here.
+                */
+               tgt = lmv_locate_tgt(lmv, op_data, &op_data->op_fid1);
+               if (IS_ERR(tgt))
+                       RETURN(PTR_ERR(tgt));
+
+               rc = md_getattr_name(tgt->ltd_exp, op_data, request);
+               if (!rc) {
+                       ptlrpc_req_finished(*request);
+                       *request = NULL;
+                       RETURN(-EEXIST);
+               }
+
+               if (rc != -ENOENT)
+                       RETURN(rc);
+
+               op_data->op_post_migrate = true;
+       }
+
+       tgt = lmv_locate_tgt(lmv, op_data, &op_data->op_fid1);
        if (IS_ERR(tgt))
                RETURN(PTR_ERR(tgt));
 
@@ -1667,6 +1700,7 @@ int lmv_create(struct obd_export *exp, struct md_op_data *op_data,
        rc = lmv_fid_alloc(NULL, exp, &op_data->op_fid2, op_data);
        if (rc)
                RETURN(rc);
+
        if (exp_connect_flags(exp) & OBD_CONNECT_DIR_STRIPE) {
                /* Send the create request to the MDT where the object
                 * will be located */
@@ -1706,7 +1740,7 @@ lmv_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
 
        CDEBUG(D_INODE, "ENQUEUE on "DFID"\n", PFID(&op_data->op_fid1));
 
-       tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
+       tgt = lmv_find_target(lmv, &op_data->op_fid1);
        if (IS_ERR(tgt))
                RETURN(PTR_ERR(tgt));
 
@@ -1719,19 +1753,20 @@ lmv_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
        RETURN(rc);
 }
 
-static int
+int
 lmv_getattr_name(struct obd_export *exp,struct md_op_data *op_data,
                 struct ptlrpc_request **preq)
 {
-       struct ptlrpc_request   *req = NULL;
-       struct obd_device       *obd = exp->exp_obd;
-       struct lmv_obd          *lmv = &obd->u.lmv;
-       struct lmv_tgt_desc     *tgt;
-       struct mdt_body         *body;
-       int                      rc;
+       struct obd_device *obd = exp->exp_obd;
+       struct lmv_obd *lmv = &obd->u.lmv;
+       struct lmv_tgt_desc *tgt;
+       struct mdt_body *body;
+       int rc;
+
        ENTRY;
 
-       tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
+retry:
+       tgt = lmv_locate_tgt(lmv, op_data, &op_data->op_fid1);
        if (IS_ERR(tgt))
                RETURN(PTR_ERR(tgt));
 
@@ -1740,31 +1775,28 @@ lmv_getattr_name(struct obd_export *exp,struct md_op_data *op_data,
                PFID(&op_data->op_fid1), tgt->ltd_idx);
 
        rc = md_getattr_name(tgt->ltd_exp, op_data, preq);
-       if (rc != 0)
+       if (rc == -ENOENT && lmv_dir_retry_check_update(op_data)) {
+               ptlrpc_req_finished(*preq);
+               *preq = NULL;
+               goto retry;
+       }
+
+       if (rc)
                RETURN(rc);
 
        body = req_capsule_server_get(&(*preq)->rq_pill, &RMF_MDT_BODY);
        LASSERT(body != NULL);
 
        if (body->mbo_valid & OBD_MD_MDS) {
-               struct lu_fid rid = body->mbo_fid1;
-               CDEBUG(D_INODE, "Request attrs for "DFID"\n",
-                      PFID(&rid));
-
-               tgt = lmv_find_target(lmv, &rid);
-               if (IS_ERR(tgt)) {
-                       ptlrpc_req_finished(*preq);
-                       preq = NULL;
-                       RETURN(PTR_ERR(tgt));
-               }
-
-               op_data->op_fid1 = rid;
+               op_data->op_fid1 = body->mbo_fid1;
                op_data->op_valid |= OBD_MD_FLCROSSREF;
                op_data->op_namelen = 0;
                op_data->op_name = NULL;
-               rc = md_getattr_name(tgt->ltd_exp, op_data, &req);
+
                ptlrpc_req_finished(*preq);
-               *preq = req;
+               *preq = NULL;
+
+               goto retry;
        }
 
        RETURN(rc);
@@ -1834,19 +1866,40 @@ static int lmv_link(struct obd_export *exp, struct md_op_data *op_data,
        op_data->op_fsuid = from_kuid(&init_user_ns, current_fsuid());
        op_data->op_fsgid = from_kgid(&init_user_ns, current_fsgid());
        op_data->op_cap = cfs_curproc_cap_pack();
-       if (op_data->op_mea2 != NULL) {
-               struct lmv_stripe_md    *lsm = op_data->op_mea2;
-               const struct lmv_oinfo  *oinfo;
 
-               oinfo = lsm_name_to_stripe_info(lsm, op_data->op_name,
-                                               op_data->op_namelen);
-               if (IS_ERR(oinfo))
-                       RETURN(PTR_ERR(oinfo));
+       if (lmv_is_dir_migrating(op_data->op_mea2)) {
+               struct lu_fid fid1 = op_data->op_fid1;
+               struct lmv_stripe_md *lsm1 = op_data->op_mea1;
 
-               op_data->op_fid2 = oinfo->lmo_fid;
+               /*
+                * avoid creating new file under old layout of migrating
+                * directory, check it here.
+                */
+               tgt = __lmv_locate_tgt(lmv, op_data->op_mea2, op_data->op_name,
+                                      op_data->op_namelen, &op_data->op_fid2,
+                                      &op_data->op_mds, false);
+               tgt = lmv_locate_tgt(lmv, op_data, &op_data->op_fid1);
+               if (IS_ERR(tgt))
+                       RETURN(PTR_ERR(tgt));
+
+               op_data->op_fid1 = op_data->op_fid2;
+               op_data->op_mea1 = op_data->op_mea2;
+               rc = md_getattr_name(tgt->ltd_exp, op_data, request);
+               op_data->op_fid1 = fid1;
+               op_data->op_mea1 = lsm1;
+               if (!rc) {
+                       ptlrpc_req_finished(*request);
+                       *request = NULL;
+                       RETURN(-EEXIST);
+               }
+
+               if (rc != -ENOENT)
+                       RETURN(rc);
        }
 
-       tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid2);
+       tgt = __lmv_locate_tgt(lmv, op_data->op_mea2, op_data->op_name,
+                              op_data->op_namelen, &op_data->op_fid2,
+                              &op_data->op_mds, true);
        if (IS_ERR(tgt))
                RETURN(PTR_ERR(tgt));
 
@@ -2034,9 +2087,9 @@ static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data,
 {
        struct obd_device *obd = exp->exp_obd;
        struct lmv_obd *lmv = &obd->u.lmv;
-       struct lmv_stripe_md *lsm = op_data->op_mea1;
        struct lmv_tgt_desc *sp_tgt;
        struct lmv_tgt_desc *tp_tgt = NULL;
+       struct lmv_tgt_desc *src_tgt = NULL;
        struct lmv_tgt_desc *tgt;
        struct mdt_body *body;
        int rc;
@@ -2054,26 +2107,44 @@ static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data,
        op_data->op_fsgid = from_kgid(&init_user_ns, current_fsgid());
        op_data->op_cap = cfs_curproc_cap_pack();
 
-       CDEBUG(D_INODE, "RENAME "DFID"/%.*s to "DFID"/%.*s\n",
-               PFID(&op_data->op_fid1), (int)oldlen, old,
-               PFID(&op_data->op_fid2), (int)newlen, new);
+       if (lmv_is_dir_migrating(op_data->op_mea2)) {
+               struct lu_fid fid1 = op_data->op_fid1;
+               struct lmv_stripe_md *lsm1 = op_data->op_mea1;
 
-       if (lsm)
-               sp_tgt = lmv_locate_target_for_name(lmv, lsm, old, oldlen,
-                                                   &op_data->op_fid1,
-                                                   &op_data->op_mds);
-       else
-               sp_tgt = lmv_find_target(lmv, &op_data->op_fid1);
-       if (IS_ERR(sp_tgt))
-               RETURN(PTR_ERR(sp_tgt));
+               /*
+                * we avoid creating new file under old layout of migrating
+                * directory, if there is an existing file with new name under
+                * old layout, we can't unlink file in old layout and rename to
+                * new layout in one transaction, so return -EBUSY here.`
+                */
+               tgt = __lmv_locate_tgt(lmv, op_data->op_mea2, new, newlen,
+                                      &op_data->op_fid2, &op_data->op_mds,
+                                      false);
+               if (IS_ERR(tgt))
+                       RETURN(PTR_ERR(tgt));
 
-       lsm = op_data->op_mea2;
-       if (lsm)
-               tp_tgt = lmv_locate_target_for_name(lmv, lsm, new, newlen,
-                                                   &op_data->op_fid2,
-                                                   &op_data->op_mds);
-       else
-               tp_tgt = lmv_find_target(lmv, &op_data->op_fid2);
+               op_data->op_fid1 = op_data->op_fid2;
+               op_data->op_mea1 = op_data->op_mea2;
+               op_data->op_name = new;
+               op_data->op_namelen = newlen;
+               rc = md_getattr_name(tgt->ltd_exp, op_data, request);
+               op_data->op_fid1 = fid1;
+               op_data->op_mea1 = lsm1;
+               op_data->op_name = NULL;
+               op_data->op_namelen = 0;
+               if (!rc) {
+                       ptlrpc_req_finished(*request);
+                       *request = NULL;
+                       RETURN(-EBUSY);
+               }
+
+               if (rc != -ENOENT)
+                       RETURN(rc);
+       }
+
+       /* rename to new layout for migrating directory */
+       tp_tgt = __lmv_locate_tgt(lmv, op_data->op_mea2, new, newlen,
+                                 &op_data->op_fid2, &op_data->op_mds, true);
        if (IS_ERR(tp_tgt))
                RETURN(PTR_ERR(tp_tgt));
 
@@ -2092,34 +2163,28 @@ static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data,
 
        op_data->op_flags |= MF_MDC_CANCEL_FID4;
 
-       /* cancel UPDATE locks of source parent */
-       rc = lmv_early_cancel(exp, sp_tgt, op_data, tgt->ltd_idx, LCK_EX,
-                             MDS_INODELOCK_UPDATE, MF_MDC_CANCEL_FID1);
-       if (rc != 0)
-               RETURN(rc);
-
        /* cancel UPDATE locks of target parent */
        rc = lmv_early_cancel(exp, tp_tgt, op_data, tgt->ltd_idx, LCK_EX,
                              MDS_INODELOCK_UPDATE, MF_MDC_CANCEL_FID2);
        if (rc != 0)
                RETURN(rc);
 
-       if (fid_is_sane(&op_data->op_fid3)) {
-               struct lmv_tgt_desc *src_tgt;
-
-               src_tgt = lmv_find_target(lmv, &op_data->op_fid3);
-               if (IS_ERR(src_tgt))
-                       RETURN(PTR_ERR(src_tgt));
-
-               /* cancel LOOKUP lock of source on source parent */
-               if (src_tgt != sp_tgt) {
-                       rc = lmv_early_cancel(exp, sp_tgt, op_data,
+       if (fid_is_sane(&op_data->op_fid4)) {
+               /* cancel LOOKUP lock of target on target parent */
+               if (tgt != tp_tgt) {
+                       rc = lmv_early_cancel(exp, tp_tgt, op_data,
                                              tgt->ltd_idx, LCK_EX,
                                              MDS_INODELOCK_LOOKUP,
-                                             MF_MDC_CANCEL_FID3);
+                                             MF_MDC_CANCEL_FID4);
                        if (rc != 0)
                                RETURN(rc);
                }
+       }
+
+       if (fid_is_sane(&op_data->op_fid3)) {
+               src_tgt = lmv_find_target(lmv, &op_data->op_fid3);
+               if (IS_ERR(src_tgt))
+                       RETURN(PTR_ERR(src_tgt));
 
                /* cancel ELC locks of source */
                rc = lmv_early_cancel(exp, src_tgt, op_data, tgt->ltd_idx,
@@ -2129,23 +2194,45 @@ static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data,
                        RETURN(rc);
        }
 
-retry_rename:
-       if (fid_is_sane(&op_data->op_fid4)) {
-               /* cancel LOOKUP lock of target on target parent */
-               if (tgt != tp_tgt) {
-                       rc = lmv_early_cancel(exp, tp_tgt, op_data,
+retry:
+       sp_tgt = __lmv_locate_tgt(lmv, op_data->op_mea1, old, oldlen,
+                                 &op_data->op_fid1, &op_data->op_mds,
+                                 op_data->op_post_migrate);
+       if (IS_ERR(sp_tgt))
+               RETURN(PTR_ERR(sp_tgt));
+
+       /* cancel UPDATE locks of source parent */
+       rc = lmv_early_cancel(exp, sp_tgt, op_data, tgt->ltd_idx, LCK_EX,
+                             MDS_INODELOCK_UPDATE, MF_MDC_CANCEL_FID1);
+       if (rc != 0)
+               RETURN(rc);
+
+       if (fid_is_sane(&op_data->op_fid3)) {
+               /* cancel LOOKUP lock of source on source parent */
+               if (src_tgt != sp_tgt) {
+                       rc = lmv_early_cancel(exp, sp_tgt, op_data,
                                              tgt->ltd_idx, LCK_EX,
                                              MDS_INODELOCK_LOOKUP,
-                                             MF_MDC_CANCEL_FID4);
+                                             MF_MDC_CANCEL_FID3);
                        if (rc != 0)
                                RETURN(rc);
                }
        }
 
+rename:
+       CDEBUG(D_INODE, "RENAME "DFID"/%.*s to "DFID"/%.*s\n",
+               PFID(&op_data->op_fid1), (int)oldlen, old,
+               PFID(&op_data->op_fid2), (int)newlen, new);
+
        rc = md_rename(tgt->ltd_exp, op_data, old, oldlen, new, newlen,
                        request);
+       if (rc == -ENOENT && lmv_dir_retry_check_update(op_data)) {
+               ptlrpc_req_finished(*request);
+               *request = NULL;
+               goto retry;
+       }
 
-       if (rc != 0 && rc != -EXDEV)
+       if (rc && rc != -EXDEV)
                RETURN(rc);
 
        body = req_capsule_server_get(&(*request)->rq_pill, &RMF_MDT_BODY);
@@ -2156,10 +2243,8 @@ retry_rename:
        if (likely(!(body->mbo_valid & OBD_MD_MDS)))
                RETURN(rc);
 
-       CDEBUG(D_INODE, "%s: try rename to another MDT for "DFID"\n",
-              exp->exp_obd->obd_name, PFID(&body->mbo_fid1));
-
        op_data->op_fid4 = body->mbo_fid1;
+
        ptlrpc_req_finished(*request);
        *request = NULL;
 
@@ -2167,7 +2252,19 @@ retry_rename:
        if (IS_ERR(tgt))
                RETURN(PTR_ERR(tgt));
 
-       goto retry_rename;
+       if (fid_is_sane(&op_data->op_fid4)) {
+               /* cancel LOOKUP lock of target on target parent */
+               if (tgt != tp_tgt) {
+                       rc = lmv_early_cancel(exp, tp_tgt, op_data,
+                                             tgt->ltd_idx, LCK_EX,
+                                             MDS_INODELOCK_LOOKUP,
+                                             MF_MDC_CANCEL_FID4);
+                       if (rc != 0)
+                               RETURN(rc);
+               }
+       }
+
+       goto rename;
 }
 
 static int lmv_setattr(struct obd_export *exp, struct md_op_data *op_data,
@@ -2610,68 +2707,34 @@ int lmv_read_page(struct obd_export *exp, struct md_op_data *op_data,
  *                      negative errno if failed.
  */
 static int lmv_unlink(struct obd_export *exp, struct md_op_data *op_data,
-                      struct ptlrpc_request **request)
+                     struct ptlrpc_request **request)
 {
-       struct obd_device       *obd = exp->exp_obd;
-       struct lmv_obd          *lmv = &obd->u.lmv;
-       struct lmv_tgt_desc     *tgt = NULL;
-       struct lmv_tgt_desc     *parent_tgt = NULL;
-       struct mdt_body         *body;
-       int                     rc;
-       int                     stripe_index = 0;
-       struct lmv_stripe_md    *lsm = op_data->op_mea1;
-       ENTRY;
-
-retry_unlink:
-       /* For striped dir, we need to locate the parent as well */
-       if (lsm != NULL) {
-               struct lmv_tgt_desc *tmp;
-
-               LASSERT(op_data->op_name != NULL &&
-                       op_data->op_namelen != 0);
-
-               tmp = lmv_locate_target_for_name(lmv, lsm,
-                                                op_data->op_name,
-                                                op_data->op_namelen,
-                                                &op_data->op_fid1,
-                                                &op_data->op_mds);
-
-               /* return -EBADFD means unknown hash type, might
-                * need try all sub-stripe here */
-               if (IS_ERR(tmp) && PTR_ERR(tmp) != -EBADFD)
-                       RETURN(PTR_ERR(tmp));
-
-               /* Note: both migrating dir and unknown hash dir need to
-                * try all of sub-stripes, so we need start search the
-                * name from stripe 0, but migrating dir is already handled
-                * inside lmv_locate_target_for_name(), so we only check
-                * unknown hash type directory here */
-               if (!lmv_is_known_hash_type(lsm->lsm_md_hash_type)) {
-                       struct lmv_oinfo *oinfo;
-
-                       oinfo = &lsm->lsm_md_oinfo[stripe_index];
-
-                       op_data->op_fid1 = oinfo->lmo_fid;
-                       op_data->op_mds = oinfo->lmo_mds;
-               }
-       }
-
-try_next_stripe:
-       /* Send unlink requests to the MDT where the child is located */
-       if (likely(!fid_is_zero(&op_data->op_fid2)))
-               tgt = lmv_find_target(lmv, &op_data->op_fid2);
-       else if (lsm != NULL)
-               tgt = lmv_get_target(lmv, op_data->op_mds, NULL);
-       else
-               tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
+       struct obd_device *obd = exp->exp_obd;
+       struct lmv_obd *lmv = &obd->u.lmv;
+       struct lmv_tgt_desc *tgt;
+       struct lmv_tgt_desc *parent_tgt;
+       struct mdt_body *body;
+       int rc;
 
-       if (IS_ERR(tgt))
-               RETURN(PTR_ERR(tgt));
+       ENTRY;
 
        op_data->op_fsuid = from_kuid(&init_user_ns, current_fsuid());
        op_data->op_fsgid = from_kgid(&init_user_ns, current_fsgid());
        op_data->op_cap = cfs_curproc_cap_pack();
 
+retry:
+       parent_tgt = lmv_locate_tgt(lmv, op_data, &op_data->op_fid1);
+       if (IS_ERR(parent_tgt))
+               RETURN(PTR_ERR(parent_tgt));
+
+       if (likely(!fid_is_zero(&op_data->op_fid2))) {
+               tgt = lmv_find_target(lmv, &op_data->op_fid2);
+               if (IS_ERR(tgt))
+                       RETURN(PTR_ERR(tgt));
+       } else {
+               tgt = parent_tgt;
+       }
+
        /*
         * If child's fid is given, cancel unused locks for it if it is from
         * another export than parent.
@@ -2681,50 +2744,29 @@ try_next_stripe:
         */
        op_data->op_flags |= MF_MDC_CANCEL_FID1 | MF_MDC_CANCEL_FID3;
 
-       /*
-        * Cancel FULL locks on child (fid3).
-        */
-       parent_tgt = lmv_find_target(lmv, &op_data->op_fid1);
-       if (IS_ERR(parent_tgt))
-               RETURN(PTR_ERR(parent_tgt));
-
-       if (parent_tgt != tgt) {
+       if (parent_tgt != tgt)
                rc = lmv_early_cancel(exp, parent_tgt, op_data, tgt->ltd_idx,
                                      LCK_EX, MDS_INODELOCK_LOOKUP,
                                      MF_MDC_CANCEL_FID3);
-       }
 
        rc = lmv_early_cancel(exp, NULL, op_data, tgt->ltd_idx, LCK_EX,
                              MDS_INODELOCK_ELC, MF_MDC_CANCEL_FID3);
-       if (rc != 0)
+       if (rc)
                RETURN(rc);
 
        CDEBUG(D_INODE, "unlink with fid="DFID"/"DFID" -> mds #%u\n",
               PFID(&op_data->op_fid1), PFID(&op_data->op_fid2), tgt->ltd_idx);
 
        rc = md_unlink(tgt->ltd_exp, op_data, request);
-       if (rc != 0 && rc != -EREMOTE && rc != -ENOENT)
-               RETURN(rc);
-
-       /* Try next stripe if it is needed. */
-       if (rc == -ENOENT && lsm != NULL && lmv_need_try_all_stripes(lsm)) {
-               struct lmv_oinfo *oinfo;
-
-               stripe_index++;
-               if (stripe_index >= lsm->lsm_md_stripe_count)
-                       RETURN(rc);
-
-               oinfo = &lsm->lsm_md_oinfo[stripe_index];
-
-               op_data->op_fid1 = oinfo->lmo_fid;
-               op_data->op_mds = oinfo->lmo_mds;
-
+       if (rc == -ENOENT && lmv_dir_retry_check_update(op_data)) {
                ptlrpc_req_finished(*request);
                *request = NULL;
-
-               goto try_next_stripe;
+               goto retry;
        }
 
+       if (rc != -EREMOTE)
+               RETURN(rc);
+
        body = req_capsule_server_get(&(*request)->rq_pill, &RMF_MDT_BODY);
        if (body == NULL)
                RETURN(-EPROTO);
@@ -2733,33 +2775,16 @@ try_next_stripe:
        if (likely(!(body->mbo_valid & OBD_MD_MDS)))
                RETURN(rc);
 
-       CDEBUG(D_INODE, "%s: try unlink to another MDT for "DFID"\n",
-              exp->exp_obd->obd_name, PFID(&body->mbo_fid1));
-
-       /* This is a remote object, try remote MDT, Note: it may
-        * try more than 1 time here, Considering following case
-        * /mnt/lustre is root on MDT0, remote1 is on MDT1
-        * 1. Initially A does not know where remote1 is, it send
-        *    unlink RPC to MDT0, MDT0 return -EREMOTE, it will
-        *    resend unlink RPC to MDT1 (retry 1st time).
-        *
-        * 2. During the unlink RPC in flight,
-        *    client B mv /mnt/lustre/remote1 /mnt/lustre/remote2
-        *    and create new remote1, but on MDT0
-        *
-        * 3. MDT1 get unlink RPC(from A), then do remote lock on
-        *    /mnt/lustre, then lookup get fid of remote1, and find
-        *    it is remote dir again, and replay -EREMOTE again.
-        *
-        * 4. Then A will resend unlink RPC to MDT0. (retry 2nd times).
-        *
-        * In theory, it might try unlimited time here, but it should
-        * be very rare case.  */
+       /* This is a remote object, try remote MDT. */
        op_data->op_fid2 = body->mbo_fid1;
        ptlrpc_req_finished(*request);
        *request = NULL;
 
-       goto retry_unlink;
+       tgt = lmv_find_target(lmv, &op_data->op_fid2);
+       if (IS_ERR(tgt))
+               RETURN(PTR_ERR(tgt));
+
+       goto retry;
 }
 
 static int lmv_precleanup(struct obd_device *obd)
@@ -3181,7 +3206,7 @@ int lmv_intent_getattr_async(struct obd_export *exp,
        if (!fid_is_sane(&op_data->op_fid2))
                RETURN(-EINVAL);
 
-       tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
+       tgt = lmv_find_target(lmv, &op_data->op_fid1);
        if (IS_ERR(tgt))
                RETURN(PTR_ERR(tgt));
 
@@ -3222,7 +3247,7 @@ int lmv_get_fid_from_lsm(struct obd_export *exp,
        const struct lmv_oinfo *oinfo;
 
        LASSERT(lsm != NULL);
-       oinfo = lsm_name_to_stripe_info(lsm, name, namelen);
+       oinfo = lsm_name_to_stripe_info(lsm, name, namelen, false);
        if (IS_ERR(oinfo))
                return PTR_ERR(oinfo);
 
index b5ef8a6..ff62ecb 100644 (file)
@@ -2192,7 +2192,7 @@ t32_test() {
 
                # migrate files/dirs to remote MDT, then move them back
                if [ $(lustre_version_code mds1) -ge $(version_code 2.7.50) -a \
-                    $dne_upgrade != "no" -a 1 -eq 0 ]; then
+                    $dne_upgrade != "no" ]; then
                        $r $LCTL set_param -n   \
                                mdt.${fsname}*.enable_remote_dir=1 2>/dev/null
 
index 90edbf2..84e1a44 100755 (executable)
@@ -2,8 +2,8 @@
 
 set -e
 
-#         bug  5493  LU2034    LU-4684
-ALWAYS_EXCEPT="52              110g    $RECOVERY_SMALL_EXCEPT"
+#         bug  5493  LU2034
+ALWAYS_EXCEPT="52 $RECOVERY_SMALL_EXCEPT"
 
 export MULTIOP=${MULTIOP:-multiop}
 PTLDEBUG=${PTLDEBUG:--1}
index 38e235b..3f684e0 100755 (executable)
@@ -12,8 +12,7 @@ export PATH=$PWD/$SRCDIR:$SRCDIR:$PWD/$SRCDIR/utils:$PATH:/sbin:/usr/sbin
 
 ONLY=${ONLY:-"$*"}
 # bug number for skipped test:
-#             LU-4684
-ALWAYS_EXCEPT="406     $SANITY_HSM_EXCEPT"
+ALWAYS_EXCEPT="$SANITY_HSM_EXCEPT"
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
 
 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
index 4025f38..2edd765 100644 (file)
@@ -8,8 +8,8 @@ set -e
 
 ONLY=${ONLY:-"$*"}
 
-#Bug number for excepting test      LU-4684 LU-10406
-ALWAYS_EXCEPT="$SANITY_LFSCK_EXCEPT 15c 29c 31c"
+#Bug number for excepting test      LU-10406
+ALWAYS_EXCEPT="$SANITY_LFSCK_EXCEPT 31c"
 
 [ "$SLOW" = "no" ] && EXCEPT_SLOW=""
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
index 3005fea..51206c2 100755 (executable)
@@ -14,8 +14,6 @@ ALWAYS_EXCEPT="$SANITY_EXCEPT  42a     42b     42c     77k"
 
 # skipped tests: LU-8411 LU-9096 LU-9054 ..
 ALWAYS_EXCEPT="  407     253     312     $ALWAYS_EXCEPT"
-# skipped tests: LU-4684
-ALWAYS_EXCEPT="  17n 160d 230 316      $ALWAYS_EXCEPT"
 
 # Check Grants after these tests
 GRANT_CHECK_LIST="$GRANT_CHECK_LIST 42a 42b 42c 42d 42e 63a 63b 64a 64b 64c"
@@ -15086,6 +15084,7 @@ test_230c() {
                skip "Need MDS version at least 2.11.52"
 
        local MDTIDX=1
+       local total=3
        local mdt_index
        local file
        local migrate_dir=$DIR/$tdir/migrate_dir
@@ -15094,37 +15093,47 @@ test_230c() {
        #the directory is still accessiable.
        test_mkdir $DIR/$tdir
        test_mkdir -i0 -c1 $migrate_dir
+       test_mkdir -i1 -c1 $DIR/$tdir/remote_dir
        stat $migrate_dir
-       createmany -o $migrate_dir/f 10 ||
+       createmany -o $migrate_dir/f $total ||
                error "create files under ${migrate_dir} failed"
 
-       # fail after migrating top dir, and this will fail only once, so one
-       # sub file migration will fail, others succeed.
+       # fail after migrating top dir, and this will fail only once, so the
+       # first sub file migration will fail (currently f3), others succeed.
        #OBD_FAIL_MIGRATE_ENTRIES       0x1801
        do_facet mds1 lctl set_param fail_loc=0x1801
        local t=$(ls $migrate_dir | wc -l)
        $LFS migrate --mdt-index $MDTIDX $migrate_dir &&
                error "migrate should fail"
+       local u=$(ls $migrate_dir | wc -l)
+       [ "$u" == "$t" ] || error "$u != $t during migration"
 
        # add new dir/file should succeed
        mkdir $migrate_dir/dir ||
                error "mkdir failed under migrating directory"
        touch $migrate_dir/file ||
-               error "touch file failed under migrating directory"
-       # add file with existing name should fail
-       $OPENFILE -f O_CREAT:O_EXCL $migrate_dir/f1 &&
-               error "open(O_CREAT|O_EXCL) f1 should fail"
-       $MULTIOP $migrate_dir/f1 m &&
-               error "create f1 should fail"
-       $MULTIOP $migrate_dir/f3 m &&
-               error "create f3 should fail"
-
-       local u=$(ls $migrate_dir | wc -l)
-       u=$((u - 2))
-       [ "$u" == "$t" ] || error "$u != $t during migration"
+               error "create file failed under migrating directory"
 
-       for file in $(find $migrate_dir); do
-               stat $file || error "stat $file failed"
+       # add file with existing name should fail
+       for file in $migrate_dir/f*; do
+               stat $file > /dev/null || error "stat $file failed"
+               $OPENFILE -f O_CREAT:O_EXCL $file &&
+                       error "open(O_CREAT|O_EXCL) $file should fail"
+               $MULTIOP $file m && error "create $file should fail"
+               touch $DIR/$tdir/remote_dir/$tfile ||
+                       error "touch $tfile failed"
+               ln $DIR/$tdir/remote_dir/$tfile $file &&
+                       error "link $file should fail"
+               mdt_index=$($LFS getstripe -m $file)
+               if [ $mdt_index == 0 ]; then
+                       # file failed to migrate is not allowed to rename to
+                       mv $DIR/$tdir/remote_dir/$tfile $file &&
+                               error "rename to $file should fail"
+               else
+                       mv $DIR/$tdir/remote_dir/$tfile $file ||
+                               error "rename to $file failed"
+               fi
+               echo hello >> $file || error "write $file failed"
        done
 
        # resume migration with different options should fail
@@ -15154,6 +15163,8 @@ test_230d() {
        [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.52) ] &&
                skip "Need MDS version at least 2.11.52"
+       # LU-11235
+       [ "$(facet_fstype mds1)" == "zfs" ] && skip "skip ZFS backend"
 
        local migrate_dir=$DIR/$tdir/migrate_dir
        local old_index
index b1b96de..9fa5ddc 100755 (executable)
@@ -4,8 +4,8 @@ set -e
 
 ONLY=${ONLY:-"$*"}
 # bug number for skipped test: 9977/LU-7105
-#              LU-7105 LU-4684
-ALWAYS_EXCEPT=" 28     33d 80a $SANITYN_EXCEPT"
+#              LU-7105
+ALWAYS_EXCEPT=" 28     $SANITYN_EXCEPT"
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
 
 SRCDIR=$(dirname $0)