From: Qian Yingjin Date: Fri, 28 May 2021 03:56:12 +0000 (+0800) Subject: LU-14724 nrs: TBF rule list broken when change rule rank X-Git-Tag: 2.14.55~52 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=e688f29275deeadc0ef4faa01f166986bade301f LU-14724 nrs: TBF rule list broken when change rule rank When change rank of two adjacent rules in the TBF rule list in @nrs_tbf_rule_change_rank(): list_move(&rule->tr_linkage, next_rule->tr_linkage.prev); The previous pointer of @next_rule is @rule, using list_move directly will break the rule list. In this patch, it use list_del + list_add to repace list_move to avoid TBF rule broken. And also add a test case sanityn test_77o for this bug. Fixes: aa14b0b9a152 ("LU-8006 ptlrpc: specify ordering of TBF policy rules") Change-Id: Ica30d3329f07914657ac2c4089d66f934021b763 Signed-off-by: Qian Yingjin Reviewed-on: https://review.whamcloud.com/43925 Reviewed-by: Andreas Dilger Tested-by: jenkins Reviewed-by: Neil Brown Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lustre/ptlrpc/nrs_tbf.c b/lustre/ptlrpc/nrs_tbf.c index 32adf79..653b55e 100644 --- a/lustre/ptlrpc/nrs_tbf.c +++ b/lustre/ptlrpc/nrs_tbf.c @@ -390,7 +390,8 @@ nrs_tbf_rule_change_rank(struct ptlrpc_nrs_policy *policy, if (!next_rule) GOTO(out_put, rc = -ENOENT); - list_move(&rule->tr_linkage, next_rule->tr_linkage.prev); + /* rules may be adjacent in same list, so list_move() isn't safe here */ + list_move_tail(&rule->tr_linkage, &next_rule->tr_linkage); nrs_tbf_rule_put(next_rule); out_put: nrs_tbf_rule_put(rule); diff --git a/lustre/tests/sanityn.sh b/lustre/tests/sanityn.sh index 636ef021..91f9f9a 100755 --- a/lustre/tests/sanityn.sh +++ b/lustre/tests/sanityn.sh @@ -4416,6 +4416,19 @@ test_77n() { #LU-10802 } run_test 77n "check wildcard support for TBF JobID NRS policy" +test_77o() { + (( $OST1_VERSION > $(version_code 2.14.54) )) || + skip "need OST > 2.14.54" + + do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="tbf\ nid" + do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ name\ nid={192.168.*.*@tcp}\ rate=10000" + do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="start\ name1\ nid={192.168.*.*@tcp}\ rate=10000" + do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="change\ name1\ rank=name" + do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_tbf_rule="stop\ name" + do_facet mds1 $LCTL set_param mds.MDS.mdt.nrs_policies="fifo" +} +run_test 77o "Changing rank should not panic" + test_78() { #LU-6673 local rc