From 392f558f405238d1b455256650a6aaa26fa7ab6e Mon Sep 17 00:00:00 2001 From: Alexander Zarochentsev Date: Mon, 2 Dec 2024 16:47:57 +0000 Subject: [PATCH] LU-17810 dne: dir restripe without fixed hash flag 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 Change-Id: I7c119f435b19a446cb960cdc5a8ebec7e00ab0dc Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57117 Reviewed-by: Andrew Perepechko Reviewed-by: Lai Siyao Reviewed-by: Oleg Drokin Tested-by: jenkins Tested-by: Maloo --- lustre/doc/lfs-migrate.1 | 4 ++++ lustre/mdt/mdt_lib.c | 2 -- lustre/utils/lfs.c | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lustre/doc/lfs-migrate.1 b/lustre/doc/lfs-migrate.1 index 1a7ce54..5fe94d8 100644 --- a/lustre/doc/lfs-migrate.1 +++ b/lustre/doc/lfs-migrate.1 @@ -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 diff --git a/lustre/mdt/mdt_lib.c b/lustre/mdt/mdt_lib.c index 3817441c..9091197 100644 --- a/lustre/mdt/mdt_lib.c +++ b/lustre/mdt/mdt_lib.c @@ -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; diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index fb9b9c1..7c20f0b 100755 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -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); -- 1.8.3.1