Whamcloud - gitweb
LU-14459 mdt: support fixed directory layout
[fs/lustre-release.git] / lustre / mdt / mdt_restripe.c
index cddf47c..e62f070 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);
@@ -317,6 +319,10 @@ static int mdt_auto_split(struct mdt_thread_info *info)
                if (le32_to_cpu(lmv->lmv_magic) != LMV_MAGIC_STRIPE)
                        GOTO(out, rc = -EINVAL);
 
+               /* race with migrate? */
+               if (lmv_hash_is_migrating(cpu_to_le32(lmv->lmv_hash_type)))
+                       GOTO(out, rc = -EBUSY);
+
                lmv_stripe_count = le32_to_cpu(lmv->lmv_stripe_count);
 
                /* save stripe to clear 'restriping' flag in the end to avoid
@@ -601,7 +607,8 @@ 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 &&
             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
@@ -877,6 +884,7 @@ 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;
@@ -924,7 +932,7 @@ 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 = CFS_CAP_FS_MASK;
+       uc->uc_cap = kcap.cap[0];
        uc->uc_umask = 0644;
        uc->uc_ginfo = NULL;
        uc->uc_identity = NULL;