Skip to content

Commit 21b514d

Browse files
kawasakiosandov
authored andcommitted
zbd/rc: Support dm-crypt
Linux kernel 5.9 added zoned block device support to dm-crypt. To test dm-crypt devices, modify the function _get_dev_container_and_sector(). To handle device-mapper table format difference between dm-crypt and dm-linear/flakey, add dev_idx and off_idx local variables. Signed-off-by: Shin'ichiro Kawasaki <[email protected]>
1 parent 62ec9d6 commit 21b514d

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

  • tests/zbd

tests/zbd/rc

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ _get_dev_container_and_sector() {
327327
local cont_dev
328328
local -i offset
329329
local -a tbl_line
330+
local -i dev_idx=3 off_idx=4
330331

331332
if _test_dev_is_partition; then
332333
offset=$(<"${TEST_DEV_PART_SYSFS}/start")
@@ -340,13 +341,19 @@ _get_dev_container_and_sector() {
340341
return 1
341342
fi
342343
if ! _test_dev_has_dm_map linear &&
343-
! _test_dev_has_dm_map flakey; then
344-
echo -n "dm mapping test other than linear/flakey is"
344+
! _test_dev_has_dm_map flakey &&
345+
! _test_dev_has_dm_map crypt; then
346+
echo -n "dm mapping test other than linear/flakey/crypt is"
345347
echo "not implemented"
346348
return 1
347349
fi
348350

349-
# Parse dm table lines for dm-linear or dm-flakey target
351+
if _test_dev_has_dm_map crypt; then
352+
dev_idx=6
353+
off_idx=7
354+
fi
355+
356+
# Parse dm table lines for dm-linear, dm-flakey or dm-crypt target
350357
while read -r -a tbl_line; do
351358
local -i map_start=${tbl_line[0]}
352359
local -i map_end=$((tbl_line[0] + tbl_line[1]))
@@ -355,10 +362,11 @@ _get_dev_container_and_sector() {
355362
continue
356363
fi
357364

358-
offset=${tbl_line[4]}
359-
if ! cont_dev=$(_get_dev_path_by_id "${tbl_line[3]}"); then
365+
offset=${tbl_line[off_idx]}
366+
if ! cont_dev=$(_get_dev_path_by_id \
367+
"${tbl_line[dev_idx]}"); then
360368
echo -n "Cannot access to container device: "
361-
echo "${tbl_line[3]}"
369+
echo "${tbl_line[dev_idx]}"
362370
return 1
363371
fi
364372

0 commit comments

Comments
 (0)