Skip to content

Commit e1f8030

Browse files
johnpgarrykawasaki
authored andcommitted
md/rc: test atomic writes for dm-linear
Introduce testing for dm-linear. We need to use device mapper tools, like vgcreate and lvm. dm-linear does not require any chunk size to be set, so only test once. Signed-off-by: John Garry <[email protected]> Signed-off-by: Shin'ichiro Kawasaki <[email protected]>
1 parent a2badd1 commit e1f8030

2 files changed

Lines changed: 53 additions & 1 deletion

File tree

tests/md/002.out

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,17 @@ TEST 9 raid10 step 4 - perform a pwritev2 with size of sysfs_atomic_unit_max_byt
116116
TEST 10 raid10 step 4 - perform a pwritev2 with size of sysfs_atomic_unit_min_bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
117117
pwrite: Invalid argument
118118
TEST 11 raid10 step 4 - perform a pwritev2 with a size of sysfs_atomic_write_unit_max_bytes - LBS bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
119+
TEST 1 dm-linear step 1 - Verify md sysfs atomic attributes matches - pass
120+
TEST 2 dm-linear step 1 - Verify sysfs atomic attributes - pass
121+
TEST 3 dm-linear step 1 - Verify md sysfs_atomic_write_max is equal to expected_atomic_write_max - pass
122+
TEST 4 dm-linear step 1 - Verify sysfs atomic_write_unit_max_bytes = expected_atomic_write_unit_max - pass
123+
TEST 5 dm-linear step 1 - Verify sysfs atomic_write_unit_boundary_bytes = expected atomic_write_unit_boundary_bytes - pass
124+
TEST 6 dm-linear step 1 - Verify statx stx_atomic_write_unit_min - pass
125+
TEST 7 dm-linear step 1 - Verify statx stx_atomic_write_unit_max - pass
126+
TEST 8 dm-linear step 1 - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
127+
pwrite: Invalid argument
128+
TEST 9 dm-linear step 1 - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes + LBS bytes with RWF_ATOMIC flag - pwritev2 should not be succesful - pass
129+
TEST 10 dm-linear step 1 - perform a pwritev2 with size of sysfs_atomic_unit_min_bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
130+
pwrite: Invalid argument
131+
TEST 11 dm-linear step 1 - perform a pwritev2 with a size of sysfs_atomic_write_unit_max_bytes - LBS bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
119132
Test complete

tests/md/rc

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ _stacked_atomic_test_requires() {
1919
_have_driver raid0
2020
_have_driver raid1
2121
_have_driver raid10
22+
_have_driver dm-mod
23+
_have_program vgcreate
24+
_have_program lvm
2225
}
2326

2427
_max_pow_of_two_factor() {
@@ -85,6 +88,13 @@ _md_atomics_boundaries_max() {
8588

8689
declare -A MD_DEVICES
8790

91+
_get_vgsize() {
92+
local vgsize
93+
94+
vgsize=$(vgdisplay --units b blktests_vg00 | grep 'VG Size' | tr -d -c 0-9)
95+
echo "$vgsize"
96+
}
97+
8898
_md_atomics_test() {
8999
local md_sysfs_max_hw_sectors_kb
90100
local md_sysfs_max_hw
@@ -147,7 +157,7 @@ _md_atomics_test() {
147157
raw_atomic_write_boundary=0;
148158
fi
149159

150-
for personality in raid0 raid1 raid10; do
160+
for personality in raid0 raid1 raid10 dm-linear; do
151161
local step_limit
152162
if [ "$personality" = raid0 ] || [ "$personality" = raid10 ]
153163
then
@@ -215,6 +225,26 @@ _md_atomics_test() {
215225
md_dev=$(readlink /dev/md/blktests_md | sed 's|\.\./||')
216226
fi
217227

228+
if [ "$personality" = dm-linear ]
229+
then
230+
for i in "${MD_DEVICES[@]}"; do
231+
pvremove --force /dev/"$i" 2> /dev/null 1>&2
232+
pvcreate /dev/"$i" 2> /dev/null 1>&2
233+
done
234+
235+
echo y | vgcreate blktests_vg00 /dev/"${dev0}" /dev/"${dev1}" \
236+
/dev/"${dev2}" /dev/"${dev3}" 2> /dev/null 1>&2
237+
fi
238+
239+
if [ "$personality" = dm-linear ]
240+
then
241+
local vgsize
242+
243+
vgsize=$(_get_vgsize)
244+
echo y | lvm lvcreate -v -n blktests_lv -L "${vgsize}"B blktests_vg00 2> /dev/null 1>&2
245+
md_dev=$(readlink /dev/mapper/blktests_vg00-blktests_lv | sed 's|\.\./||')
246+
fi
247+
218248
md_dev_sysfs="/sys/devices/virtual/block/${md_dev}"
219249

220250
sysfs_logical_block_size=$(< "${md_dev_sysfs}"/queue/logical_block_size)
@@ -385,6 +415,15 @@ _md_atomics_test() {
385415
mdadm --zero-superblock /dev/"$i" 2> /dev/null 1>&2
386416
done
387417
fi
418+
419+
if [ "$personality" = dm-linear ]
420+
then
421+
lvremove --force /dev/mapper/blktests_vg00-blktests_lv 2> /dev/null 1>&2
422+
vgremove --force blktests_vg00 2> /dev/null 1>&2
423+
for i in "${MD_DEVICES[@]}"; do
424+
pvremove --force /dev/"$i" 2> /dev/null 1>&2
425+
done
426+
fi
388427
done
389428
done
390429
}

0 commit comments

Comments
 (0)