Whamcloud - gitweb
LU-14724 nrs: TBF rule list broken when change rule rank 25/43925/6
authorQian Yingjin <qian@ddn.com>
Fri, 28 May 2021 03:56:12 +0000 (11:56 +0800)
committerOleg Drokin <green@whamcloud.com>
Fri, 17 Sep 2021 14:06:28 +0000 (14:06 +0000)
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 <qian@ddn.com>
Reviewed-on: https://review.whamcloud.com/43925
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Neil Brown <neilb@suse.de>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/ptlrpc/nrs_tbf.c
lustre/tests/sanityn.sh

index 32adf79..653b55e 100644 (file)
@@ -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);
index 636ef02..91f9f9a 100755 (executable)
@@ -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