Whamcloud - gitweb
New tag 2.15.63
[fs/lustre-release.git] / lustre / mdt / mdt_restripe.c
index 794ca4e..e09645e 100644 (file)
@@ -244,6 +244,8 @@ int mdt_restripe_internal(struct mdt_thread_info *info,
 
                lmv->lmv_hash_type |= cpu_to_le32(LMV_HASH_FLAG_MERGE |
                                                  LMV_HASH_FLAG_MIGRATION);
+               lmv->lmv_hash_type |= lum->lum_hash_type &
+                                     cpu_to_le32(LMV_HASH_FLAG_FIXED);
                lmv->lmv_merge_offset = lum->lum_stripe_count;
                lmv->lmv_merge_hash = lum->lum_hash_type;
                lmv->lmv_layout_version = cpu_to_le32(++version);
@@ -276,7 +278,7 @@ static int mdt_auto_split(struct mdt_thread_info *info)
        struct mdt_object *parent = NULL;
        struct mdt_object *child = NULL;
        struct mdt_object *stripe = NULL;
-       struct ldlm_enqueue_info *einfo = &info->mti_einfo[0];
+       struct ldlm_enqueue_info *einfo = &info->mti_einfo;
        struct mdt_lock_handle *lhp;
        struct mdt_lock_handle *lhc;
        u32 lmv_stripe_count = 0;
@@ -387,36 +389,22 @@ static int mdt_auto_split(struct mdt_thread_info *info)
                GOTO(restriping_clear, rc);
 
        lhp = &info->mti_lh[MDT_LH_PARENT];
-       mdt_lock_pdo_init(lhp, LCK_PW, lname);
-       rc = mdt_reint_object_lock(info, parent, lhp, MDS_INODELOCK_UPDATE,
-                                  true);
+       rc = mdt_parent_lock(info, parent, lhp, lname, LCK_PW);
        if (rc)
                GOTO(restriping_clear, rc);
 
        lhc = &info->mti_lh[MDT_LH_CHILD];
-       mdt_lock_reg_init(lhc, LCK_EX);
-       if (mdt_object_remote(parent)) {
-               /* enqueue object remote LOOKUP lock */
-               rc = mdt_remote_object_lock(info, parent, mdt_object_fid(child),
-                                           &lhc->mlh_rreg_lh,
-                                           lhc->mlh_rreg_mode,
-                                           MDS_INODELOCK_LOOKUP, false);
-               if (rc != ELDLM_OK)
-                       GOTO(unlock_parent, rc);
-       }
-
-       rc = mdt_reint_striped_lock(info, child, lhc, MDS_INODELOCK_FULL, einfo,
-                                   true);
+       rc = mdt_object_stripes_lock(info, parent, child, lhc, einfo,
+                                    MDS_INODELOCK_FULL, LCK_EX);
        if (rc)
-               GOTO(unlock_child, rc);
+               GOTO(unlock_parent, rc);
 
        mdt_auto_split_prep(info, spec, ma, lum_stripe_count);
 
        rc = mdt_restripe_internal(info, parent, child, lname, fid, spec, ma);
        EXIT;
 
-unlock_child:
-       mdt_reint_striped_unlock(info, child, lhc, einfo, rc);
+       mdt_object_stripes_unlock(info, child, lhc, einfo, rc);
 unlock_parent:
        mdt_object_unlock(info, parent, lhp, rc);
 restriping_clear:
@@ -470,9 +458,7 @@ static int mdt_restripe_migrate_finish(struct mdt_thread_info *info,
        buf.lb_len = sizeof(*lmv);
 
        lh = &info->mti_lh[MDT_LH_PARENT];
-       mdt_lock_reg_init(lh, LCK_EX);
-       rc = mdt_reint_object_lock(info, stripe, lh, MDS_INODELOCK_XATTR,
-                                  false);
+       rc = mdt_object_lock(info, stripe, lh, MDS_INODELOCK_XATTR, LCK_EX);
        if (!rc)
                rc = mo_xattr_set(info->mti_env, mdt_object_child(stripe), &buf,
                                  XATTR_NAME_LMV, LU_XATTR_REPLACE);
@@ -605,11 +591,14 @@ static int mdt_restripe_migrate(struct mdt_thread_info *info)
        if ((lmv_is_splitting(lmv) &&
             idx >= le32_to_cpu(lmv->lmv_split_offset)) ||
            (lmv_is_merging(lmv) &&
-            le32_to_cpu(lmv->lmv_hash_type) == LMV_HASH_TYPE_CRUSH &&
+            ((le32_to_cpu(lmv->lmv_hash_type) & LMV_HASH_TYPE_MASK) ==
+                                                LMV_HASH_TYPE_CRUSH ||
+             (le32_to_cpu(lmv->lmv_hash_type) & LMV_HASH_TYPE_MASK) ==
+                                                LMV_HASH_TYPE_CRUSH2) &&
             idx < le32_to_cpu(lmv->lmv_merge_offset))) {
                /* new stripes doesn't need to migrate sub files in dir
                 * split, neither for target stripes in dir merge if hash type
-                * is CRUSH.
+                * is CRUSH or CRUSH2.
                 */
                rc = mdt_restripe_migrate_finish(info, stripe, lmv);
                RETURN(rc);
@@ -881,7 +870,6 @@ static int mdt_restriper_main(void *arg)
 int mdt_restriper_start(struct mdt_device *mdt)
 {
        struct mdt_dir_restriper *restriper = &mdt->mdt_restriper;
-       kernel_cap_t kcap = cap_combine(CAP_FS_SET, CAP_NFSD_SET);
        struct task_struct *task;
        struct mdt_thread_info *info;
        struct lu_ucred *uc;
@@ -929,10 +917,17 @@ int mdt_restriper_start(struct mdt_device *mdt)
        uc->uc_fsgid = 0;
        uc->uc_suppgids[0] = -1;
        uc->uc_suppgids[1] = -1;
-       uc->uc_cap = kcap.cap[0];
+       uc->uc_cap = cap_combine(CAP_FS_SET, CAP_NFSD_SET);
        uc->uc_umask = 0644;
        uc->uc_ginfo = NULL;
        uc->uc_identity = NULL;
+       /* do not let rbac interfere with restriper internal processing */
+       uc->uc_rbac_file_perms = 1;
+       uc->uc_rbac_dne_ops = 1;
+       uc->uc_rbac_quota_ops = 1;
+       uc->uc_rbac_byfid_ops = 1;
+       uc->uc_rbac_chlg_ops = 1;
+       uc->uc_rbac_fscrypt_admin = 1;
 
        task = kthread_create(mdt_restriper_main, info, "mdt_restriper_%03d",
                              mdt_seq_site(mdt)->ss_node_id);