From 6ca2425ccf6bf7176a37a4c93a67995479307036 Mon Sep 17 00:00:00 2001 From: Wang Shilong Date: Fri, 28 Sep 2018 13:31:29 -0400 Subject: [PATCH] LU-11198 utils: propagate errors for read_param Steps to reproduce: $ lctl get_param -n ost.OSS.ost_io.nrs_tbf_rule error: get_param: reading 'ost.OSS.ost_io.nrs_tbf_rule': No such device $ echo $? 0 read_param() might return errors, fix to return errors to caller. Change-Id: Id165424342be3109669f173b9b72c16aa8c83425 Signed-off-by: Wang Shilong Reviewed-on: https://review.whamcloud.com/32925 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- lustre/tests/conf-sanity.sh | 9 +++++++++ lustre/tests/sanity-sec.sh | 3 +-- lustre/tests/sanity.sh | 2 +- lustre/utils/lustre_cfg.c | 8 ++++++-- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index ff62ecb..b54a558 100644 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -8075,6 +8075,15 @@ test_116() { } run_test 116 "big size MDT support" +test_117() { + setup + do_facet ost1 "$LCTL set_param ost.OSS.ost_io.nrs_policies=fifo" + do_facet ost1 "$LCTL get_param -n ost.OSS.ost_io.nrs_tbf_rule" && + error "get_param should fail" + cleanup || error "cleanup failed with rc $?" +} +run_test 117 "lctl get_param return errors properly" + test_122() { [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return [[ $(lustre_version_code ost1) -ge $(version_code 2.11.53) ]] || diff --git a/lustre/tests/sanity-sec.sh b/lustre/tests/sanity-sec.sh index dfd07fa..8d77c32 100755 --- a/lustre/tests/sanity-sec.sh +++ b/lustre/tests/sanity-sec.sh @@ -1804,8 +1804,7 @@ test_24() { nodemap_test_setup trap nodemap_test_cleanup EXIT - do_nodes $(comma_list $(all_server_nodes)) $LCTL get_param -R nodemap || - error "proc readable file read failed" + do_nodes $(comma_list $(all_server_nodes)) $LCTL get_param -R nodemap nodemap_test_cleanup } diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 1b0dfab..0166c90 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -11015,7 +11015,7 @@ test_133f() { find $proc_dirs -exec cat '{}' \; &> /dev/null # Second verifying readability. - $LCTL get_param -R '*' &> /dev/null || error "proc file read failed" + $LCTL get_param -R '*' &> /dev/null # Verifing writability with badarea_io. find $proc_dirs \ diff --git a/lustre/utils/lustre_cfg.c b/lustre/utils/lustre_cfg.c index cb60057..9879bf4 100644 --- a/lustre/utils/lustre_cfg.c +++ b/lustre/utils/lustre_cfg.c @@ -1031,8 +1031,12 @@ param_display(struct param_opts *popt, char *pattern, char *value, switch (mode) { case GET_PARAM: /* Read the contents of file to stdout */ - if (S_ISREG(st.st_mode)) - read_param(paths.gl_pathv[i], param_name, popt); + if (S_ISREG(st.st_mode)) { + rc2 = read_param(paths.gl_pathv[i], param_name, + popt); + if (rc2 < 0 && rc == 0) + rc = rc2; + } break; case SET_PARAM: if (S_ISREG(st.st_mode)) { -- 1.8.3.1