Whamcloud - gitweb
LU-17810 dne: dir restripe without fixed hash flag 17/57117/5
authorAlexander Zarochentsev <alexander.zarochentsev@hpe.com>
Mon, 2 Dec 2024 16:47:57 +0000 (16:47 +0000)
committerOleg Drokin <green@whamcloud.com>
Mon, 16 Dec 2024 08:03:43 +0000 (08:03 +0000)
Add an option to clear LMV_HASH_FIXED_FLAG
in dir re-striping, this restores an ability to convert a
striped dir with only one stripe into a plain dir.

HPE-bug-id: LUS-12321
Fixes: 4c2514f483 ("LU-14459 mdt: support fixed directory layout")
Signed-off-by: Alexander Zarochentsev <alexander.zarochentsev@hpe.com>
Change-Id: I7c119f435b19a446cb960cdc5a8ebec7e00ab0dc
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57117
Reviewed-by: Andrew Perepechko <andrew.perepechko@hpe.com>
Reviewed-by: Lai Siyao <lai.siyao@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/doc/lfs-migrate.1
lustre/mdt/mdt_lib.c
lustre/utils/lfs.c

index 1a7ce54..5fe94d8 100644 (file)
@@ -149,6 +149,10 @@ Only migrate the specified \fIDIRECTORY\fR and the non-directory inodes that are
 directly located within it.
 Similar to '\fBls -d\fR' and '\fBlfs getstripe -d\fR'.
 .TP
+.BR --clear-fixed
+Do not set LMV_HASH_FIXED_FLAG upon migrating the directory. It allows a striped dir
+with only one stripe to be converted to a plain directory.
+.TP
 .BR -H , --mdt-hash=\fIHASH_TYPE\fR
 Use
 .I HASH_TYPE
index 3817441..9091197 100644 (file)
@@ -1720,8 +1720,6 @@ static int mdt_migrate_unpack(struct mdt_thread_info *info)
                                struct lmv_user_md_v1 *lmu;
 
                                lmu = req_capsule_client_get(pill, &RMF_EADATA);
-                               lmu->lum_hash_type |=
-                                       cpu_to_le32(LMV_HASH_FLAG_FIXED);
                                rr->rr_eadata = lmu;
                                spec->u.sp_ea.eadatalen = rr->rr_eadatalen;
                                spec->u.sp_ea.eadata = rr->rr_eadata;
index fb9b9c1..7c20f0b 100755 (executable)
@@ -3630,6 +3630,7 @@ enum {
        LFS_LINKS_OPT,
        LFS_ATTRS_OPT,
        LFS_XATTRS_MATCH_OPT,
+       LFS_MIGRATE_NOFIX,
 };
 
 #ifndef LCME_USER_MIRROR_FLAGS
@@ -3681,6 +3682,7 @@ static int lfs_setstripe_internal(int argc, char **argv,
        bool foreign_mode = false;
        char *xattr = NULL;
        bool overstriped = false;
+       bool clear_hash_fixed = false;
        uint32_t type = LU_FOREIGN_TYPE_NONE, flags = 0;
        char *mode_opt = NULL;
        mode_t previous_umask = 0;
@@ -3787,6 +3789,7 @@ static int lfs_setstripe_internal(int argc, char **argv,
        { .val = 'y',   .name = "yaml",         .has_arg = required_argument },
        { .val = 'z',   .name = "ext-size",     .has_arg = required_argument},
        { .val = 'z',   .name = "extension-size", .has_arg = required_argument},
+       { .val = LFS_MIGRATE_NOFIX, .name = "clear-fixed", .has_arg = no_argument},
        { .name = NULL } };
 
        setstripe_args_init(&lsa);
@@ -3952,6 +3955,15 @@ static int lfs_setstripe_internal(int argc, char **argv,
                                goto usage_error;
                        }
                        break;
+               case LFS_MIGRATE_NOFIX:
+                       if (!migrate_mode) {
+                               fprintf(stderr,
+                                       "%s %s: --clear-fixed valid only for migrate command\n",
+                                       progname, argv[0]);
+                               goto usage_error;
+                       }
+                       clear_hash_fixed = true;
+                       break;
                case 'b':
                        if (!migrate_mode) {
                                fprintf(stderr,
@@ -4559,6 +4571,9 @@ create_mirror:
                if (overstriped)
                        lmu->lum_hash_type |= LMV_HASH_FLAG_OVERSTRIPED;
 
+               if (!clear_hash_fixed)
+                       lmu->lum_hash_type |= LMV_HASH_FLAG_FIXED;
+
                if (lsa.lsa_pool_name)
                        snprintf(lmu->lum_pool_name, sizeof(lmu->lum_pool_name),
                                 "%s", lsa.lsa_pool_name);