From 37f6357a5c9f4ad0e2269529e7001f5ab63689a5 Mon Sep 17 00:00:00 2001 From: Ben Evans Date: Wed, 21 Feb 2018 13:17:58 -0500 Subject: [PATCH] LU-10629 lod: Clear OST pool with setstripe When setstripe -d is run on a directory, we should clear the OST pool along with all the other settings Currently there is no way to clear an OST pool, only change them. Signed-off-by: Ben Evans Cray-bug-id: LUS-5696 Change-Id: I50426ce79ab153a715d29cc5d54b0ce70726da41 Reviewed-on: https://review.whamcloud.com/31364 Reviewed-by: Jinshan Xiong Tested-by: Jenkins Reviewed-by: Jian Yu Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/lod/lod_object.c | 9 ++++++++- lustre/tests/sanity.sh | 25 +++++++++++++++++++++++++ lustre/tests/test-framework.sh | 2 +- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/lustre/lod/lod_object.c b/lustre/lod/lod_object.c index 8735bee..1fac134 100644 --- a/lustre/lod/lod_object.c +++ b/lustre/lod/lod_object.c @@ -3778,6 +3778,7 @@ static int lod_xattr_set(const struct lu_env *env, struct lod_default_striping *lds = &info->lti_def_striping; struct lov_user_md_v1 *v1 = buf->lb_buf; char pool[LOV_MAXPOOLNAME + 1]; + bool is_del; /* get existing striping config */ rc = lod_get_default_lov_striping(env, lod_dt_obj(dt), lds); @@ -3790,8 +3791,14 @@ static int lod_xattr_set(const struct lu_env *env, lds->lds_def_comp_cnt, pool, sizeof(pool)); + is_del = LOVEA_DELETE_VALUES(v1->lmm_stripe_size, + v1->lmm_stripe_count, + v1->lmm_stripe_offset, + NULL); + /* Retain the pool name if it is not given */ - if (v1->lmm_magic == LOV_USER_MAGIC_V1 && pool[0] != '\0') { + if (v1->lmm_magic == LOV_USER_MAGIC_V1 && pool[0] != '\0' && + !is_del) { struct lod_thread_info *info = lod_env_info(env); struct lov_user_md_v3 *v3 = info->lti_ea_store; diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 76a8e08..efc4b9d 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -2252,6 +2252,31 @@ test_27F() { # LU-5346/LU-7975 } run_test 27F "Client resend delayed layout creation with non-zero size" +test_27G() { #LU-10629 + [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return + remote_mds_nodsh && skip "remote MDS with nodsh" && return + local POOL=${POOL:-testpool} + local ostrange="0 0 1" + + test_mkdir $DIR/$tdir + pool_add $POOL || error "pool_add failed" + pool_add_targets $POOL $ostrange || error "pool_add_targets failed" + $LFS setstripe -p $POOL $DIR/$tdir + + local pool=$($LFS getstripe -p $DIR/$tdir) + + [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'" + + $LFS setstripe -d $DIR/$tdir + + pool=$($LFS getstripe -p $DIR/$tdir) + + rmdir $DIR/$tdir + + [ -z "$pool" ] || error "'$pool' is not empty" +} +run_test 27G "Clear OST pool from stripe" + # createtest also checks that device nodes are created and # then visible correctly (#2091) test_28() { # bug 2091 diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 1630e79..d82f4bd 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -7177,7 +7177,7 @@ create_pool() { local fsname=${1%%.*} local poolname=${1##$fsname.} - trap "destroy_test_pools $fsname" EXIT + stack_trap "destroy_test_pools $fsname" EXIT do_facet mgs lctl pool_new $1 local RC=$? # get param should return err unless pool is created -- 1.8.3.1