From: Alexander Zarochentsev Date: Tue, 21 Jan 2025 20:10:22 +0000 (+0000) Subject: LU-18639 dne: a correct check for dir split X-Git-Tag: 2.16.53~78 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=103c1f560c8c8dde601aac1fafed137b19fa3429;p=fs%2Flustre-release.git LU-18639 dne: a correct check for dir split Use the actual dir stripe count while performing a dir split sanity check in lod_dir_declare_dir_split(). Fix lod_object_lock() to work with a striped dir with only one stripe correctly. Improve sanity test_230p by adding a dir split right after the dir merges. Also fix a typo in lustre/doc/lfs-migrate.1 . Fixes: 2e2b16c28b ("LU-11025 dne: support directory restripe") Fixes: 392f558f40 ("LU-17810 dne: dir restripe without fixed hash flag") HPE-bug-id: LUS-12701 Test-Parameters: envdefinitions=ONLY=230p fstype=ldiskfs mdtcount=2 mdscount=2 testlist=sanity Signed-off-by: Alexander Zarochentsev Change-Id: I8d8501fd09f89d03ccb1ea92a8562326110ecc24 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57784 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Lai Siyao Reviewed-by: Oleg Drokin --- diff --git a/lustre/doc/lfs-migrate.1 b/lustre/doc/lfs-migrate.1 index 006e8d6..201cffa 100644 --- a/lustre/doc/lfs-migrate.1 +++ b/lustre/doc/lfs-migrate.1 @@ -155,7 +155,7 @@ and .RB ' "lfs getstripe -d" '. .TP .BR --clear-fixed -Do not set LMV_HASH_FIXED_FLAG upon migrating the directory. It allows a striped dir +Do not set LMV_HASH_FLAG_FIXED 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 diff --git a/lustre/lod/lod_object.c b/lustre/lod/lod_object.c index 031f46c..a2b078c 100644 --- a/lustre/lod/lod_object.c +++ b/lustre/lod/lod_object.c @@ -4297,8 +4297,8 @@ static int lod_xattr_set_lmv(const struct lu_env *env, struct dt_object *dt, struct dt_insert_rec *rec = &info->lti_dt_rec; int i; int rc; - ENTRY; + /* lum is used to know whether it's replay */ LASSERT(lum); if (!S_ISDIR(dt->do_lu.lo_header->loh_attr)) @@ -4451,6 +4451,12 @@ static int lod_xattr_set_lmv(const struct lu_env *env, struct dt_object *dt, rc = lod_sub_insert(env, dt_object_child(dt), (const struct dt_rec *)rec, (const struct dt_key *)stripe_name, th); + if (rc == -EEXIST) { + CDEBUG(D_INFO, DFID": can't insert stripe %i "DFID"\n", + PFID(lod_object_fid(lo)), i, + PFID(lu_object_fid(&dt->do_lu))); + continue; + } if (rc != 0) GOTO(out, rc); @@ -6866,7 +6872,7 @@ static int lod_object_lock(const struct lu_env *env, RETURN(rc); /* No stripes */ - if (lo->ldo_dir_stripe_count <= 1) + if (lo->ldo_dir_stripe_count == 0) RETURN(0); slave_locks_size = offsetof(typeof(*slave_locks), @@ -8969,7 +8975,7 @@ static int lod_dir_declare_layout_split(const struct lu_env *env, LASSERT(le32_to_cpu(lum->lum_magic) == LMV_USER_MAGIC); LASSERT(le32_to_cpu(lum->lum_stripe_offset) == LMV_OFFSET_DEFAULT); - saved_count = lo->ldo_dir_stripes_allocated; + saved_count = lo->ldo_dir_stripe_count; stripe_count = le32_to_cpu(lum->lum_stripe_count); /* if the split target is overstriped, we need to put that flag in the @@ -8999,7 +9005,7 @@ static int lod_dir_declare_layout_split(const struct lu_env *env, if (!stripes) RETURN(-ENOMEM); - for (i = 0; i < lo->ldo_dir_stripes_allocated; i++) + for (i = 0; i < saved_count; i++) stripes[i] = lo->ldo_stripe[i]; lod_qos_statfs_update(env, lod, &lod->lod_mdt_descs); diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index a0818c3..2c5dad6 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -24153,7 +24153,7 @@ test_230p() { createmany -d $DIR/$tdir/d 100 || error "create dirs under remote dir failed" - for c in $(seq $((MDSCOUNT - 1)) -1 1); do + for ((c = $MDSCOUNT - 1; c >= 1; c--)); do local mdt_hash="crush" do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear >/dev/null" @@ -24174,6 +24174,16 @@ test_230p() { (( delta < 200 / c + 4 )) || error "$delta files migrated >= $((200 / c + 4))" done + + # and restripe to -c 2 + echo Splitting the dir back to 2 stripes. + $LFS setdirstripe -c 2 $DIR/$tdir || { + $LFS getdirstripe $DIR/$tdir + error "split $tdir to 2 stripes failed" + } + wait_update $HOSTNAME \ + "$LFS getdirstripe -H $DIR/$tdir" "crush" $timeout || + error "dir split not finished" } run_test 230p "dir merge"