Whamcloud - gitweb
LU-7004 mgs: remove using obdname2fsname() from mgs layer. 84/32784/21
authorJames Simmons <uja.ornl@yahoo.com>
Wed, 21 Nov 2018 22:53:10 +0000 (17:53 -0500)
committerOleg Drokin <green@whamcloud.com>
Fri, 4 Jan 2019 04:44:56 +0000 (04:44 +0000)
Further testing shows that with the complex of obd device names
as well as wild card handling makes covering every case in
obdname2fsname() very difficult. Instead of mining the file
system name out of obd device name take advantage of the fact
the MGS device will know all the file system names and test if
the file system name is present in the lctl set_param -P
cmd.

Fix up the PERM_CMD test in the test suite which was wrong.
Make config-sanity test 29 wait until the tunables are set
after mounting the client.

Test-Parameters: envdefinitions="PERM_CMD=$LCTL set_param -P"

Change-Id: Ie3f5c8e1e1ff5ec309a31ba598f7cdf2f19c791f
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/32784
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Ben Evans <bevans@cray.com>
Reviewed-by: Vladimir Saveliev <c17830@cray.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mgs/mgs_llog.c
lustre/tests/conf-sanity.sh
lustre/tests/ost-pools.sh
lustre/tests/sanity-quota.sh
lustre/tests/sanity.sh
lustre/tests/test-framework.sh

index 24ecfc5..ffb1e70 100644 (file)
@@ -5236,6 +5236,7 @@ static int mgs_set_param2(const struct lu_env *env, struct mgs_device *mgs,
        /* obdname2fsname reports devname as an obd device */
        len = strcspn(param, ".=");
        if (len && param[len] != '=') {
+               struct list_head *tmp;
                char *ptr;
 
                param += len + 1;
@@ -5250,8 +5251,30 @@ static int mgs_set_param2(const struct lu_env *env, struct mgs_device *mgs,
                snprintf(mti->mti_svname, sizeof(mti->mti_svname), "%.*s",
                        (int)len, param);
 
-               obdname2fsname(mti->mti_svname, mti->mti_fsname,
-                              sizeof(mti->mti_fsname));
+               mutex_lock(&mgs->mgs_mutex);
+               if (unlikely(list_empty(&mgs->mgs_fs_db_list))) {
+                       mutex_unlock(&mgs->mgs_mutex);
+                       GOTO(out, rc = -ENODEV);
+               }
+
+               list_for_each(tmp, &mgs->mgs_fs_db_list) {
+                       fsdb = list_entry(tmp, struct fs_db, fsdb_list);
+                       if (fsdb->fsdb_has_lproc_entry &&
+                           strcmp(fsdb->fsdb_name, "params") != 0 &&
+                           strstr(param, fsdb->fsdb_name)) {
+                               snprintf(mti->mti_svname,
+                                        sizeof(mti->mti_svname), "%s",
+                                        fsdb->fsdb_name);
+                               break;
+                       }
+                       fsdb = NULL;
+               }
+
+               if (!fsdb) {
+                       snprintf(mti->mti_svname, sizeof(mti->mti_svname),
+                                "general");
+               }
+               mutex_unlock(&mgs->mgs_mutex);
        } else {
                snprintf(mti->mti_svname, sizeof(mti->mti_svname), "general");
        }
index ff6151e..59b68f7 100644 (file)
@@ -1139,7 +1139,7 @@ test_29() {
 
        local PARAM="$FSNAME-OST0001.osc.active"
        # With lctl set_param -P the value $PROC_ACT will be sent to
-       # all nodes. The [^M] filter out the ability to set active
+       # all nodes. The [!M] filter out the ability to set active
        # on the MDS servers which is tested with wait_osp_* below.
        # For ost_server_uuid that only exist on client so filtering
        # is safe.
@@ -1164,12 +1164,15 @@ test_29() {
        # test new client starts deactivated
        umount_client $MOUNT || error "umount_client $MOUNT failed"
        mount_client $MOUNT || error "mount_client $MOUNT failed"
-       RESULT=$($LCTL get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
-       if [ -z "$RESULT" ]; then
-               error "New client start active: $(lctl get_param -n $PROC_UUID)"
-       else
-               echo "New client success: got $RESULT"
-       fi
+
+       # the 2nd and 3rd field of ost_server_uuid do not update at the same
+       # time when using lctl set_param -P
+       wait_update_facet client                                        \
+               "$LCTL get_param -n $PROC_UUID | awk '{print \\\$3 }'"  \
+               "DEACTIVATED" ||
+               error "New client start active: $($LCTL get_param -n $PROC_UUID)"
+
+       echo "New client success: got '$($LCTL get_param -n $PROC_UUID)'"
 
        # make sure it reactivates
        set_persistent_param_and_check client $PROC_ACT $PARAM $ACTV
@@ -1201,7 +1204,7 @@ test_30a() {
        pass
 
        echo Erase parameter setting
-       if [[ $PERM_CMD = *"set_param -P"* ]]; then
+       if [[ $PERM_CMD == *"set_param -P"* ]]; then
                do_facet mgs "$PERM_CMD -d $TEST" ||
                        error "Erase param $TEST failed"
        else
@@ -1240,7 +1243,7 @@ test_30b() {
 
        local TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
                grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
-       if [[ $PERM_CMD = *"set_param -P"* ]]; then
+       if [[ $PERM_CMD == *"set_param -P"* ]]; then
                PARAM="osc.$FSNAME-OST0000-osc-[^M]*.import"
                echo "Setting $PARAM from $TEST to $NEW"
                do_facet mgs "$PERM_CMD $PARAM='connection=$NEW'" ||
@@ -1262,7 +1265,7 @@ test_30b() {
        [ $NIDCOUNT -eq $((orignidcount + 1)) ] ||
                error "Failover nid not added"
 
-       if [[ $PERM_CMD = *"set_param -P"* ]]; then
+       if [[ $PERM_CMD == *"set_param -P"* ]]; then
                do_facet mgs "$PERM_CMD -d osc.$FSNAME-OST0000-osc-*.import"
        else
                do_facet mgs "$PERM_CMD -d $FSNAME-OST0000.failover.node" ||
@@ -1901,7 +1904,7 @@ t32_test() {
                return 1
        fi
 
-       if [[ $PERM_CMD = *"set_param -P"* ]]; then
+       if [[ $PERM_CMD == *"set_param -P"* ]]; then
                $r $PERM_CMD osc.$fsname-OST0000*.import=connection=$nid || {
                        error_noexit "Setting OST \"failover.node\""
                        return 1
@@ -1985,7 +1988,7 @@ t32_test() {
        fi
 
        if [ "$dne_upgrade" != "no" ]; then
-               if [[ $PERM_CMD = *"set_param -P"* ]]; then
+               if [[ $PERM_CMD == *"set_param -P"* ]]; then
                        $r $PERM_CMD mdc.$fsname-MDT0001*.import=connection=$nid || {
                                error_noexit "Setting MDT1 \"failover.node\""
                                return 1
@@ -2477,7 +2480,7 @@ test_33a() { # bug 12333, was test_33
        start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
        start fs2ost $fs2ostdev $OST_MOUNT_OPTS
 
-       if [[ $PERM_CMD = *"set_param -P"* ]]; then
+       if [[ $PERM_CMD == *"set_param -P"* ]]; then
                do_facet mgs "$PERM_CMD timeout=200" ||
                        error "$PERM_CMD timeout=200 failed"
        else
@@ -2558,7 +2561,7 @@ test_35a() { # bug 12459
        local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
                awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
 
-       if [[ $PERM_CMD = *"set_param -P"* ]]; then
+       if [[ $PERM_CMD == *"set_param -P"* ]]; then
                do_facet mgs "$PERM_CMD \
                              mdc.*${device}*.import=connection=$(h2nettype $FAKENID)" ||
                        error "Setting mdc.*${device}*.import=connection=\
@@ -2623,7 +2626,7 @@ test_35b() { # bug 18674
        local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
                awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
 
-       if [[ $PERM_CMD = *"set_param -P"* ]]; then
+       if [[ $PERM_CMD == *"set_param -P"* ]]; then
                do_facet mgs "$PERM_CMD \
                              mdc.*${device}*.import=connection=$(h2nettype $FAKENID)" ||
                        error "Set mdc.*${device}*.import=connection=\
@@ -3130,7 +3133,7 @@ test_42() { #bug 14693
        setup
        check_mount || error "client was not mounted"
 
-       if [[ $PERM_CMD = *"set_param -P"* ]]; then
+       if [[ $PERM_CMD == *"set_param -P"* ]]; then
                PARAM="llite.$FSNAME-*.some_wrong_param"
        else
                PARAM="$FSNAME.llite.some_wrong_param"
@@ -3781,7 +3784,7 @@ test_50g() {
         wait_osc_import_state mds ost2 FULL
        wait_osc_import_ready client ost2
 
-       if [[ $PERM_CMD = *"set_param -P"* ]]; then
+       if [[ $PERM_CMD == *"set_param -P"* ]]; then
                local PARAM="osc.${FSNAME}-OST0001*.active"
        else
                local PARAM="${FSNAME}-OST0001.osc.active"
@@ -3859,7 +3862,7 @@ test_50i() {
 
        mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
 
-       if [[ $PERM_CMD = *"set_param -P"* ]]; then
+       if [[ $PERM_CMD == *"set_param -P"* ]]; then
                $PERM_CMD mdc.${FSNAME}-MDT0001-mdc-*.active=0 &&
                        error "deactive MDC0 succeeds"
        else
@@ -7649,7 +7652,7 @@ test_107() {
        start_ost || error "unable to start OST"
 
        # add unknown configuration parameter.
-       if [[ $PERM_CMD = *"set_param -P"* ]]; then
+       if [[ $PERM_CMD == *"set_param -P"* ]]; then
                cmd="$PERM_CMD ost.$FSNAME-OST0000*.unknown_param"
        else
                cmd="$PERM_CMD $FSNAME-OST0000*.ost.unknown_param"
index 4457c92..d66b967 100755 (executable)
@@ -1254,7 +1254,7 @@ test_23a() {
                $LFS quotaoff -ug $MOUNT
                $LFS quotacheck -ug $MOUNT
        else
-               if [[ $PERM_CMD = *"set_param -P"* ]]; then
+               if [[ $PERM_CMD == *"set_param -P"* ]]; then
                        do_facet mgs $PERM_CMD \
                                osd-*.$FSNAME-OST*.quota_slave.enable=ug
                else
@@ -1329,7 +1329,7 @@ test_23b() {
        if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ]; then
                $LFS quotaoff -ug $MOUNT
        else
-               if [[ $PERM_CMD = *"set_param -P"* ]]; then
+               if [[ $PERM_CMD == *"set_param -P"* ]]; then
                        do_facet mgs $PERM_CMD \
                                osd-*.$FSNAME-OST*.quota_slave.enable=none
                else
index 86c54fe..95a9113 100755 (executable)
@@ -231,7 +231,7 @@ set_mdt_qtype() {
        [[ "$qtype" =~ "p" ]] && ! is_project_quota_supported &&
                qtype=$(tr -d 'p' <<<$qtype)
 
-       if [[ $PERM_CMD = *"set_param -P"* ]]; then
+       if [[ $PERM_CMD == *"set_param -P"* ]]; then
                do_facet mgs $PERM_CMD \
                        osd-*.$FSNAME-MDT*.quota_slave.enable=$qtype
        else
@@ -261,7 +261,7 @@ set_ost_qtype() {
        [[ "$qtype" =~ "p" ]] && ! is_project_quota_supported &&
                qtype=$(tr -d 'p' <<<$qtype)
 
-       if [[ $PERM_CMD = *"set_param -P"* ]]; then
+       if [[ $PERM_CMD == *"set_param -P"* ]]; then
                do_facet mgs $PERM_CMD \
                        osd-*.$FSNAME-OST*.quota_slave.enable=$qtype
        else
index 8b1bc51..28e7c33 100755 (executable)
@@ -13991,7 +13991,7 @@ test_205() { # Job stats
        local old_jobenv=$($LCTL get_param -n jobid_var)
        [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
 
-       if [[ $PERM_CMD = *"set_param -P"* ]]; then
+       if [[ $PERM_CMD == *"set_param -P"* ]]; then
                stack_trap "do_facet mgs $PERM_CMD jobid_var=$old_jobenv" EXIT
        else
                stack_trap "do_facet mgs $PERM_CMD \
index b42bc9c..b344a3b 100755 (executable)
@@ -2059,7 +2059,7 @@ ost_quota_type() {
 # restore old quota type settings
 restore_quota() {
        if [ "$old_MDT_QUOTA_TYPE" ]; then
-               if [[ $PERM_CMD = *"set_param -P"* ]]; then
+               if [[ $PERM_CMD == *"set_param -P"* ]]; then
                        do_facet mgs $PERM_CMD \
                                osd-*.$FSNAME-MDT*.quota_slave.enable = \
                                $old_MDT_QUOTA_TYPE
@@ -2069,7 +2069,7 @@ restore_quota() {
                fi
        fi
        if [ "$old_OST_QUOTA_TYPE" ]; then
-               if [[ $PERM_CMD = *"set_param -P"* ]]; then
+               if [[ $PERM_CMD == *"set_param -P"* ]]; then
                        do_facet mgs $PERM_CMD \
                                osd-*.$FSNAME-OST*.quota_slave.enable = \
                                $old_OST_QUOTA_TYPE
@@ -2129,7 +2129,7 @@ setup_quota(){
        export old_MDT_QUOTA_TYPE=$mdt_qtype
        export old_OST_QUOTA_TYPE=$ost_qtype
 
-       if [[ $PERM_CMD = *"set_param -P"* ]]; then
+       if [[ $PERM_CMD == *"set_param -P"* ]]; then
                do_facet mgs $PERM_CMD \
                        osd-*.$FSNAME-MDT*.quota_slave.enable=$QUOTA_TYPE
                do_facet mgs $PERM_CMD \
@@ -4813,7 +4813,7 @@ set_persistent_param() {
                final=$((orig + 5))
        fi
 
-       if [[ $PERM_CMD = *"set_param -P"* ]]; then
+       if [[ $PERM_CMD == *"set_param -P"* ]]; then
                echo "Setting $test_param from $orig to $final"
                do_facet mgs "$PERM_CMD $test_param='$final'" ||
                        error "$PERM_CMD $test_param failed"
@@ -7198,7 +7198,7 @@ wait_osp_active() {
 
                        [ ${PIPESTATUS[0]} = 0 ] || error "Can't read $mproc"
                        if [ $result -eq $expected ]; then
-                               echo -n "target updated after"
+                               echo -n "target updated after "
                                echo "$wait sec (got $result)"
                                break
                        fi