+test_id() {
+ local idstr="${1}id"
+ local policy="${idstr}={$2}"
+ local rate="rate=$3"
+
+ do_nodes $(comma_list $(osts_nodes)) \
+ lctl set_param jobid_var=procname_uid \
+ ost.OSS.ost_io.nrs_policies="tbf\ ${idstr}" \
+ ost.OSS.ost_io.nrs_tbf_rule="start\ ost_${idstr}\ ${policy}\ ${rate}"
+ [ $? -ne 0 ] && error "failed to set tbf ${idstr} policy"
+
+ nrs_write_read "runas $4"
+ tbf_verify $3 $3 "runas $4"
+
+ do_nodes $(comma_list $(osts_nodes)) \
+ lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ ost_${idstr}" \
+ ost.OSS.ost_io.nrs_policies="fifo"
+
+ # sleep 3 seconds to wait the tbf policy stop completely,
+ # or the next test case is possible get -eagain when
+ # setting the tbf policy
+ sleep 3
+}
+
+test_77ja(){
+ if [ $(lustre_version_code ost1) -lt $(version_code 2.11.50) ]; then
+ skip "Need OST version at least 2.11.50"
+ return 0
+ fi
+ test_id "u" "500" "5" "-u 500"
+ test_id "g" "500" "5" "-u 500 -g 500"
+}
+run_test 77ja "check TBF-UID/GID NRS policy"
+
+cleanup_77k()
+{
+ local rule_lists=$1
+ local old_nrs=$2
+
+ trap 0
+ for rule in $rule_lists; do
+ do_nodes $(comma_list $(osts_nodes)) \
+ lctl set_param ost.OSS.ost_io.nrs_tbf_rule="stop\ $rule"
+ done
+
+ do_nodes $(comma_list $(osts_nodes)) \
+ lctl set_param ost.OSS.ost_io.nrs_policies="$old_nrs"
+
+ sleep 3
+}
+