File tree Expand file tree Collapse file tree 3 files changed +87
-0
lines changed Expand file tree Collapse file tree 3 files changed +87
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # SPDX-License-Identifier: GPL-3.0+
3+ # Copyright (C) 2025 Ming Lei
4+ #
5+ # Test prioritized meta IO when IO throttling, regression test for
6+ # commit 29390bb5661d ("blk-throttle: support prioritized processing of metadata")
7+
8+ . tests/throtl/rc
9+
10+ DESCRIPTION=" test if meta IO has higher priority than data IO"
11+ QUICK=1
12+
13+ requires () {
14+ _have_program mkfs.ext4
15+ _have_driver ext4
16+ }
17+
18+ test_meta_io () {
19+ local path=" $1 "
20+ local start_time
21+ local end_time
22+ local elapsed
23+
24+ start_time=$( date +%s.%N)
25+ mkdir " ${path} " /xxx
26+ touch " ${path} " /xxx/1
27+ sync " ${path} " /xxx
28+
29+ end_time=$( date +%s.%N)
30+ elapsed=$( echo " $end_time - $start_time " | bc)
31+ printf " %.0f\n" " $elapsed "
32+ }
33+
34+ test () {
35+ echo " Running ${TEST_NAME} "
36+
37+ if ! _set_up_throtl memory_backed=1; then
38+ return 1;
39+ fi
40+
41+ mkdir --parents " ${TMPDIR} /mnt"
42+ mkfs.ext4 -E lazy_itable_init=0,lazy_journal_init=0 \
43+ -F " /dev/${THROTL_DEV} " >> " $FULL " 2>&1
44+ mount " /dev/${THROTL_DEV} " " ${TMPDIR} /mnt" >> " $FULL " 2>&1
45+
46+ _throtl_set_limits wbps=$(( 1024 * 1024 ))
47+ {
48+ local jbd2_pid
49+
50+ jbd2_pid=$( ps -eo pid,comm | pgrep -f " jbd2/${THROTL_DEV} " | awk ' {print $1}' )
51+ echo " $BASHPID " > " $CGROUP2_DIR /$THROTL_DIR /cgroup.procs"
52+ echo " $jbd2_pid " > " $CGROUP2_DIR /$THROTL_DIR /cgroup.procs"
53+ _throtl_issue_fs_io " ${TMPDIR} /mnt/test.img" write 4M 1 &
54+ sleep 2
55+ test_meta_io " ${TMPDIR} /mnt"
56+ wait
57+ } &
58+ wait $!
59+
60+ umount " ${TMPDIR} /mnt" || return $?
61+ _throtl_remove_limits
62+ _clean_up_throtl
63+ echo " Test complete"
64+ }
Original file line number Diff line number Diff line change 1+ Running throtl/006
2+ 0
3+ 4
4+ Test complete
Original file line number Diff line number Diff line change @@ -75,6 +75,25 @@ _throtl_get_max_io_size() {
7575 cat " /sys/block/$THROTL_DEV /queue/max_sectors_kb"
7676}
7777
78+ _throtl_issue_fs_io () {
79+ local path=$1
80+ local start_time
81+ local end_time
82+ local elapsed
83+
84+ start_time=$( date +%s.%N)
85+
86+ if [ " $2 " == " read" ]; then
87+ dd if=" ${path} " of=/dev/null bs=" $3 " count=" $4 " iflag=direct status=none
88+ elif [ " $2 " == " write" ]; then
89+ dd of=" ${path} " if=/dev/zero bs=" $3 " count=" $4 " oflag=direct conv=fdatasync status=none
90+ fi
91+
92+ end_time=$( date +%s.%N)
93+ elapsed=$( echo " $end_time - $start_time " | bc)
94+ printf " %.0f\n" " $elapsed "
95+ }
96+
7897_throtl_issue_io () {
7998 local start_time
8099 local end_time
You can’t perform that action at this time.
0 commit comments