Whamcloud - gitweb
LU-10629 lod: Clear OST pool with setstripe 42/33742/2
authorBen Evans <bevans@cray.com>
Wed, 28 Nov 2018 17:51:17 +0000 (09:51 -0800)
committerOleg Drokin <green@whamcloud.com>
Wed, 16 Jan 2019 07:31:11 +0000 (07:31 +0000)
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.

This patch is back-ported from the following one:
Lustre-commit: 37f6357a5c9f4ad0e2269529e7001f5ab63689a5
Lustre-change: https://review.whamcloud.com/31364

Signed-off-by: Ben Evans <bevans@cray.com>
Cray-bug-id: LUS-5696
Change-Id: I50426ce79ab153a715d29cc5d54b0ce70726da41
Reviewed-on: https://review.whamcloud.com/33742
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/lod/lod_object.c
lustre/tests/sanity.sh
lustre/tests/test-framework.sh

index ba82ca6..97ae961 100644 (file)
@@ -3394,6 +3394,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);
@@ -3406,8 +3407,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;
 
index 47cf6a1..66a32d0 100755 (executable)
@@ -2190,6 +2190,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
index eaf963e..3d4f3fa 100755 (executable)
@@ -6769,7 +6769,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