From 345f0d8e56c464a7b4e222430b0f4728c1d13ec7 Mon Sep 17 00:00:00 2001 From: Qian Yingjin Date: Fri, 28 May 2021 11:56:12 +0800 Subject: [PATCH] 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. Lustre-change: https://review.whamcloud.com/43925 Lustre-commit: e688f29275deeadc0ef4faa01f166986bade301f Fixes: aa14b0b9a152 ("LU-8006 ptlrpc: specify ordering of TBF policy rules") Change-Id: Ica30d3329f07914657ac2c4089d66f934021b763 Signed-off-by: Qian Yingjin Reviewed-by: Andreas Dilger Reviewed-on: https://review.whamcloud.com/46017 Tested-by: jenkins Tested-by: Maloo --- lustre/ptlrpc/nrs_tbf.c | 4 +++- lustre/tests/sanityn.sh | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lustre/ptlrpc/nrs_tbf.c b/lustre/ptlrpc/nrs_tbf.c index 9521d69..09d0321 100644 --- a/lustre/ptlrpc/nrs_tbf.c +++ b/lustre/ptlrpc/nrs_tbf.c @@ -392,7 +392,9 @@ 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() is not safe */ + list_del(&rule->tr_linkage); + list_add(&rule->tr_linkage, next_rule->tr_linkage.prev); 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 a70f6ad..3a85cca 100755 --- a/lustre/tests/sanityn.sh +++ b/lustre/tests/sanityn.sh @@ -4408,6 +4408,18 @@ test_77n() { #LU-10802 } run_test 77n "check wildcard support for TBF JobID NRS policy" +test_77o() { + (( $OST1_VERSION > $(version_code 2.12.6) )) || skip "need OST > 2.12.6" + + 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 -- 1.8.3.1