From: Ben Evans Date: Fri, 9 Mar 2018 20:51:26 +0000 (-0500) Subject: LU-4939 obdclass: llog_print params file X-Git-Tag: 2.10.7-RC1~35 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=fb77f09ac8907059552eb5d606e9f8bcab580426;p=fs%2Flustre-release.git LU-4939 obdclass: llog_print params file Allow llog_print to handle the params file in yaml Lustre-commit: 320e736191cce766cd0838ebbd5e76f1aefa1a6f Lustre-change: https://review.whamcloud.com/31620 Test-Parameters: trivial testlist=sanity Signed-off-by: Ben Evans Change-Id: Icf286bca7a1466bf3c8d9084971e58d2e8b8a651 Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-on: https://review.whamcloud.com/34250 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lustre/obdclass/obd_config.c b/lustre/obdclass/obd_config.c index 84f6a7a..ade51b3 100644 --- a/lustre/obdclass/obd_config.c +++ b/lustre/obdclass/obd_config.c @@ -1749,7 +1749,7 @@ static struct lcfg_type_data { { LCFG_DEL_CONN, "del_conn", { "1", "2", "3", "4" } }, { LCFG_LOV_ADD_OBD, "add_osc", { "ost", "index", "gen", "UUID" } }, { LCFG_LOV_DEL_OBD, "del_osc", { "1", "2", "3", "4" } }, - { LCFG_PARAM, "set_param", { "parameter", "value", "3", "4" } }, + { LCFG_PARAM, "conf_param", { "parameter", "value", "3", "4" } }, { LCFG_MARKER, "marker", { "1", "2", "3", "4" } }, { LCFG_LOG_START, "log_start", { "1", "2", "3", "4" } }, { LCFG_LOG_END, "log_end", { "1", "2", "3", "4" } }, @@ -1763,6 +1763,7 @@ static struct lcfg_type_data { { LCFG_POOL_DEL, "del_pool", { "fsname", "pool", "3", "4" } }, { LCFG_SET_LDLM_TIMEOUT, "set_ldlm_timeout", { "parameter", "2", "3", "4" } }, + { LCFG_SET_PARAM, "set_param", { "parameter", "value", "3", "4" } }, { 0, NULL, { NULL, NULL, NULL, NULL } } }; @@ -1830,6 +1831,30 @@ int class_config_yaml_output(struct llog_rec_hdr *rec, char *buf, int size) ptr += snprintf(ptr, end - ptr, ", device: %s", lustre_cfg_string(lcfg, 0)); + if (lcfg->lcfg_command == LCFG_SET_PARAM) { + /* + * set_param -P parameters have param=val here, separate + * them through pointer magic and print them out in + * native yamlese + */ + char *cfg_str = lustre_cfg_string(lcfg, 1); + char *tmp = strchr(cfg_str, '='); + size_t len; + + if (tmp == NULL) + return -ENOTTY; + + ptr += snprintf(ptr, end - ptr, ", %s: ", ldata->ltd_bufs[0]); + len = tmp - cfg_str + 1; + snprintf(ptr, len, "%s", cfg_str); + ptr += len - 1; + + ptr += snprintf(ptr, end - ptr, ", %s: ", ldata->ltd_bufs[1]); + ptr += snprintf(ptr, end - ptr, "%s", tmp + 1); + + goto out_done; + } + for (i = 1; i < lcfg->lcfg_bufcount; i++) { if (LUSTRE_CFG_BUFLEN(lcfg, i) > 0) ptr += snprintf(ptr, end - ptr, ", %s: %s", @@ -1837,6 +1862,7 @@ int class_config_yaml_output(struct llog_rec_hdr *rec, char *buf, int size) lustre_cfg_string(lcfg, i)); } +out_done: ptr += snprintf(ptr, end - ptr, " }\n"); /* return consumed bytes */ rc = ptr - buf; diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index bc7c285..bb6f18a 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -5642,6 +5642,26 @@ test_60aa() { } run_test 60aa "llog_print works with FIDs and simple names" +test_60ab() { + # test llog_print with params + local yaml + local orig_val + + orig_val=$(do_facet mgs $LCTL get_param jobid_name) + do_facet mgs $LCTL set_param -P jobid_name="testname" + + yaml=$(do_facet mgs $LCTL --device MGS llog_print params | + grep jobid_name | tail -n 1) + + local param=`awk '{ print $10 }' <<< "$yaml"` + local val=`awk '{ print $12 }' <<< "$yaml"` + #return to the default + do_facet mgs $LCTL set_param -P jobid_name=$orig_val + [ $val = "testname" ] || error "bad value: $val" + [ $param = "jobid_name," ] || error "Bad param: $param" +} +run_test 60ab "llog_print params output values from set_param -P" + test_60b() { # bug 6411 [ $PARALLEL == "yes" ] && skip "skip parallel run" && return dmesg > $DIR/$tfile