Linux block layer
 help / color / mirror / Atom feed
* [PATCH blktests v2 0/9] Further stacked device atomic writes testing
@ 2025-09-22 10:24 John Garry
  2025-09-22 10:24 ` [PATCH blktests v2 1/9] common/rc: add _min() John Garry
                   ` (9 more replies)
  0 siblings, 10 replies; 18+ messages in thread
From: John Garry @ 2025-09-22 10:24 UTC (permalink / raw)
  To: linux-block, shinichiro.kawasaki; +Cc: John Garry

The testing of atomic writes support for stacked devices is limited.

We only test scsi_debug and for a limited sets of personalities.

Extend to test NVMe and also extend to the following stacked device
personalities:
- dm-linear
- dm-stripe
- dm-mirror

Also add more strict atomic writes limits testing.

Based on https://lore.kernel.org/linux-block/20250917114920.142996-1-shinichiro.kawasaki@wdc.com/#t

Differences to v1:
(all based on comments from Shin'ichiro)
- Rebase on "support testing with multiple devices" series
- clean up "make check" issues and other coding style issues
- Relocate some NVMe helpers
- Add _stacked_atomic_test_requires helper

John Garry (9):
  common/rc: add _min()
  nvme: relocate _nvme_requires and _require_nvme_test_img_size
  nvme: relocate _require_test_dev_is_nvme
  md/rc: add _md_atomics_test
  md/002: convert to use _md_atomics_test
  md/003: add NVMe atomic write tests for stacked devices
  md/rc: test atomic writes for dm-linear
  md/rc: test atomic writes for dm-stripe
  md/rc: test atomic writes for dm-mirror

 common/nvme      |  80 +++++++++
 common/rc        |  11 ++
 tests/md/002     | 219 +----------------------
 tests/md/002.out | 238 ++++++++++++++++++++-----
 tests/md/003     |  45 +++++
 tests/md/003.out |   1 +
 tests/md/rc      | 446 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/nvme/rc    |  80 ---------
 8 files changed, 784 insertions(+), 336 deletions(-)
 create mode 100755 tests/md/003
 create mode 120000 tests/md/003.out

-- 
2.43.5


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH blktests v2 1/9] common/rc: add _min()
  2025-09-22 10:24 [PATCH blktests v2 0/9] Further stacked device atomic writes testing John Garry
@ 2025-09-22 10:24 ` John Garry
  2025-09-22 10:24 ` [PATCH blktests v2 2/9] nvme: relocate _nvme_requires and _require_nvme_test_img_size John Garry
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 18+ messages in thread
From: John Garry @ 2025-09-22 10:24 UTC (permalink / raw)
  To: linux-block, shinichiro.kawasaki; +Cc: John Garry

Add a helper to find the minimum of two numbers.

A similar helper is being added in xfstests:
https://lore.kernel.org/linux-xfs/cover.1755849134.git.ojaswin@linux.ibm.com/T/#m962683d8115979e57342d2644660230ee978c803

Signed-off-by: John Garry <john.g.garry@oracle.com>
---
 common/rc | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/common/rc b/common/rc
index 946dee1..6406b51 100644
--- a/common/rc
+++ b/common/rc
@@ -700,3 +700,14 @@ _real_dev()
 	fi
 	echo "$dev"
 }
+
+_min() {
+	local ret
+
+	for arg in "$@"; do
+		if [ -z "$ret" ] || (( arg < ret )); then
+			ret="$arg"
+		fi
+	done
+	echo "$ret"
+}
-- 
2.43.5


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH blktests v2 2/9] nvme: relocate _nvme_requires and _require_nvme_test_img_size
  2025-09-22 10:24 [PATCH blktests v2 0/9] Further stacked device atomic writes testing John Garry
  2025-09-22 10:24 ` [PATCH blktests v2 1/9] common/rc: add _min() John Garry
@ 2025-09-22 10:24 ` John Garry
  2025-09-22 10:24 ` [PATCH blktests v2 3/9] nvme: relocate _require_test_dev_is_nvme John Garry
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 18+ messages in thread
From: John Garry @ 2025-09-22 10:24 UTC (permalink / raw)
  To: linux-block, shinichiro.kawasaki; +Cc: John Garry

Helper _nvme_requires will be required for md atomics NVMe testing, so
relocate to a common file.

Helper _require_nvme_test_img_size is referenced by _nvme_requires, so
relocate that as well.

Signed-off-by: John Garry <john.g.garry@oracle.com>
---
 common/nvme   | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/nvme/rc | 72 ---------------------------------------------------
 2 files changed, 72 insertions(+), 72 deletions(-)

diff --git a/common/nvme b/common/nvme
index 8de41fa..26b3b97 100644
--- a/common/nvme
+++ b/common/nvme
@@ -1102,3 +1102,75 @@ _nvmet_target_cleanup() {
 		_cleanup_blkdev
 	fi
 }
+
+_require_nvme_test_img_size() {
+	local require_sz_mb
+	local nvme_img_size_mb
+
+	require_sz_mb="$(convert_to_mb "$1")"
+	nvme_img_size_mb="$(convert_to_mb "${NVME_IMG_SIZE}")"
+
+	if ((nvme_img_size_mb < require_sz_mb)); then
+		SKIP_REASONS+=("NVME_IMG_SIZE must be at least ${require_sz_mb}m")
+		return 1
+	fi
+	return 0
+}
+
+_nvme_requires() {
+	_require_nvme_test_img_size 4m
+	case ${nvme_trtype} in
+	loop)
+		_have_driver nvme-loop
+		_have_configfs
+		;;
+	pci)
+		_have_driver nvme
+		;;
+	tcp)
+		_have_driver nvme-tcp
+		_have_driver nvmet-tcp
+		_have_configfs
+		;;
+	rdma)
+		_have_driver nvme-rdma
+		_have_driver nvmet-rdma
+		_have_configfs
+		_have_program rdma
+		if [ -n "$USE_RXE" ]; then
+			_have_driver rdma_rxe
+		else
+			_have_driver siw
+		fi
+		;;
+	fc)
+		_have_driver nvme-fc
+		_have_driver nvme-fcloop
+		_have_configfs
+		def_adrfam="fc"
+		;;
+	esac
+
+	if [[ -n ${nvme_adrfam} ]]; then
+		case ${nvme_adrfam} in
+		ipv6)
+			def_traddr="::1"
+			def_adrfam="ipv6"
+			;;
+		ipv4)
+			;; # was already set
+		fc)
+			def_adrfam="fc"
+			;;
+		*)
+			# ignore for non ip transports
+			if [[ "${nvme_trtype}" == "tcp" ||
+			      "${nvme_trtype}" == "rdma" ]]; then
+				SKIP_REASONS+=("unsupported nvme_adrfam=${nvme_adrfam}")
+				return 1
+			fi
+		esac
+	fi
+
+	return 0
+}
diff --git a/tests/nvme/rc b/tests/nvme/rc
index 6d86ad4..33055ef 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -54,64 +54,6 @@ _set_nvmet_blkdev_type() {
 	COND_DESC="bd=${nvmet_blkdev_type}"
 }
 
-_nvme_requires() {
-	_require_nvme_test_img_size 4m
-	case ${nvme_trtype} in
-	loop)
-		_have_driver nvme-loop
-		_have_configfs
-		;;
-	pci)
-		_have_driver nvme
-		;;
-	tcp)
-		_have_driver nvme-tcp
-		_have_driver nvmet-tcp
-		_have_configfs
-		;;
-	rdma)
-		_have_driver nvme-rdma
-		_have_driver nvmet-rdma
-		_have_configfs
-		_have_program rdma
-		if [ -n "$USE_RXE" ]; then
-			_have_driver rdma_rxe
-		else
-			_have_driver siw
-		fi
-		;;
-	fc)
-		_have_driver nvme-fc
-		_have_driver nvme-fcloop
-		_have_configfs
-		def_adrfam="fc"
-		;;
-	esac
-
-	if [[ -n ${nvme_adrfam} ]]; then
-		case ${nvme_adrfam} in
-		ipv6)
-			def_traddr="::1"
-			def_adrfam="ipv6"
-			;;
-		ipv4)
-			;; # was already set
-		fc)
-			def_adrfam="fc"
-			;;
-		*)
-			# ignore for non ip transports
-			if [[ "${nvme_trtype}" == "tcp" ||
-			      "${nvme_trtype}" == "rdma" ]]; then
-				SKIP_REASONS+=("unsupported nvme_adrfam=${nvme_adrfam}")
-				return 1
-			fi
-		esac
-	fi
-
-	return 0
-}
-
 group_setup() {
 	if [[ -n "${nvme_target_control}" ]]; then
 		NVMET_TRTYPES="$(${nvme_target_control} config --show-trtype)"
@@ -186,20 +128,6 @@ _test_dev_disables_extended_lba() {
 	return 0
 }
 
-_require_nvme_test_img_size() {
-	local require_sz_mb
-	local nvme_img_size_mb
-
-	require_sz_mb="$(convert_to_mb "$1")"
-	nvme_img_size_mb="$(convert_to_mb "${NVME_IMG_SIZE}")"
-
-	if ((nvme_img_size_mb < require_sz_mb)); then
-		SKIP_REASONS+=("NVME_IMG_SIZE must be at least ${require_sz_mb}m")
-		return 1
-	fi
-	return 0
-}
-
 _require_nvme_cli_auth() {
 	if ! nvme gen-dhchap-key --nqn nvmf-test-subsys > /dev/null 2>&1 ; then
 		SKIP_REASONS+=("nvme gen-dhchap-key command missing")
-- 
2.43.5


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH blktests v2 3/9] nvme: relocate _require_test_dev_is_nvme
  2025-09-22 10:24 [PATCH blktests v2 0/9] Further stacked device atomic writes testing John Garry
  2025-09-22 10:24 ` [PATCH blktests v2 1/9] common/rc: add _min() John Garry
  2025-09-22 10:24 ` [PATCH blktests v2 2/9] nvme: relocate _nvme_requires and _require_nvme_test_img_size John Garry
@ 2025-09-22 10:24 ` John Garry
  2025-09-22 10:24 ` [PATCH blktests v2 4/9] md/rc: add _md_atomics_test John Garry
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 18+ messages in thread
From: John Garry @ 2025-09-22 10:24 UTC (permalink / raw)
  To: linux-block, shinichiro.kawasaki; +Cc: John Garry

Relocate helper _require_test_dev_is_nvme into common/nvme so that it may
be used for md tests.

Signed-off-by: John Garry <john.g.garry@oracle.com>
---
 common/nvme   | 8 ++++++++
 tests/nvme/rc | 8 --------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/common/nvme b/common/nvme
index 26b3b97..c3e0df1 100644
--- a/common/nvme
+++ b/common/nvme
@@ -1174,3 +1174,11 @@ _nvme_requires() {
 
 	return 0
 }
+
+_require_test_dev_is_nvme() {
+	if ! readlink -f "$TEST_DEV_SYSFS/device" | grep -q nvme; then
+		SKIP_REASONS+=("$TEST_DEV is not a NVMe device")
+		return 1
+	fi
+	return 0
+}
diff --git a/tests/nvme/rc b/tests/nvme/rc
index 33055ef..b16418c 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -71,14 +71,6 @@ group_device_requires() {
 	_require_test_dev_is_nvme
 }
 
-_require_test_dev_is_nvme() {
-	if ! readlink -f "$TEST_DEV_SYSFS/device" | grep -q nvme; then
-		SKIP_REASONS+=("$TEST_DEV is not a NVMe device")
-		return 1
-	fi
-	return 0
-}
-
 _require_test_dev_is_nvme_pci() {
 	if [[ ! "$(readlink -f "$TEST_DEV_SYSFS/device")" =~ devices/pci ]]; then
 		SKIP_REASONS+=("$TEST_DEV is not a PCI NVMe device")
-- 
2.43.5


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH blktests v2 4/9] md/rc: add _md_atomics_test
  2025-09-22 10:24 [PATCH blktests v2 0/9] Further stacked device atomic writes testing John Garry
                   ` (2 preceding siblings ...)
  2025-09-22 10:24 ` [PATCH blktests v2 3/9] nvme: relocate _require_test_dev_is_nvme John Garry
@ 2025-09-22 10:24 ` John Garry
  2025-09-22 10:24 ` [PATCH blktests v2 5/9] md/002: convert to use _md_atomics_test John Garry
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 18+ messages in thread
From: John Garry @ 2025-09-22 10:24 UTC (permalink / raw)
  To: linux-block, shinichiro.kawasaki; +Cc: John Garry

The stacked device atomic writes testing is currently limited.

md/002 currently only tests scsi_debug. SCSI does not support atomic
boundaries, so it would be nice to test NVMe (which does support them).

Furthermore, the testing in md/002 for chunk boundaries is very limited,
in that we test once one boundary value. Indeed, for RAID0 and RAID10, a
boundary should always be set for testing.

Finally, md/002 only tests md RAID0/1/10. In future we will also want to
test the following stacked device personalities which support atomic
writes:
- md-linear (being upstreamed)
- dm-linear
- dm-stripe
- dm-mirror

To solve all those problems, add a generic test handler,
_md_atomics_test(). This can be extended for more extensive testing.

This test handler will accept a group of devices and test as follows:
a. calculate expected atomic write limits based on device limits
b. Take results from a., and refine expected limits based on any chunk
   size
c. loop through creating a stacked device for different chunk size. We loop
   once for any personality which does not have a chunk size, e.g. RAID1
d. test sysfs and statx limits vs what is calculated in a. and b.
e. test RWF_ATOMIC is accepted or rejected as expected

Steps c, d, and e are really same as md/002.

Signed-off-by: John Garry <john.g.garry@oracle.com>
---
 tests/md/rc | 377 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 377 insertions(+)

diff --git a/tests/md/rc b/tests/md/rc
index 96bcd97..ee5934c 100644
--- a/tests/md/rc
+++ b/tests/md/rc
@@ -5,9 +5,386 @@
 # Tests for md raid
 
 . common/rc
+. common/xfs
 
 group_requires() {
 	_have_root
 	_have_program mdadm
 	_have_driver md-mod
 }
+
+_stacked_atomic_test_requires() {
+	_have_kver 6 14 0
+	_have_xfs_io_atomic_write
+	_have_driver raid0
+	_have_driver raid1
+	_have_driver raid10
+}
+
+_max_pow_of_two_factor() {
+	local part1=$1
+	local part2=-$1
+	local retval=$((part1 & part2))
+	echo "$retval"
+}
+
+# Find max atomic size given a boundary and chunk size
+# @unit is set if we want atomic write "unit" size, i.e power-of-2
+# @chunk must be > 0
+_md_atomics_boundaries_max() {
+	local boundary=$1
+	local chunk=$2
+	local unit=$3
+	local retval
+
+	if [ "$boundary" -eq 0 ]
+	then
+		if [ "$unit" -eq 1 ]
+		then
+			retval=$(_max_pow_of_two_factor "$chunk")
+			echo "$retval"
+			return
+		fi
+
+		echo "$chunk"
+		return
+	fi
+
+	# boundary is always a power-of-2
+	if [ "$boundary" -eq "$chunk" ]
+	then
+		echo "$boundary"
+		return
+	fi
+
+	if [ "$boundary" -gt "$chunk" ]
+	then
+		if (( boundary % chunk == 0))
+		then
+			if [ "$unit" -eq 1 ]
+			then
+				retval=$(_max_pow_of_two_factor "$chunk")
+				echo "$retval"
+				return
+			fi
+			echo "$chunk"
+			return
+		fi
+		echo "0"
+		return
+	fi
+
+	if (( chunk % boundary == 0))
+	then
+		echo "$boundary"
+		return
+	fi
+
+	echo "0"
+}
+
+declare -A MD_DEVICES
+
+_md_atomics_test() {
+	local md_sysfs_max_hw_sectors_kb
+	local md_sysfs_max_hw
+	local md_chunk_size
+	local sysfs_logical_block_size
+	local sysfs_atomic_write_max
+	local sysfs_atomic_write_unit_min
+	local sysfs_atomic_write_unit_max
+	local bytes_to_write
+	local bytes_written
+	local test_desc
+	local md_dev
+	local md_dev_sysfs
+	local raw_atomic_write_unit_min
+	local raw_atomic_write_unit_max
+	local raw_atomic_write_max
+	local raw_atomic_write_boundary
+	local raw_atomic_write_supported=1
+	local dev0=$1
+	local dev1=$2
+	local dev2=$3
+	local dev3=$4
+
+	unset MD_DEVICES
+	MD_DEVICES=([0]=$dev0 [1]=$dev1 [2]=$dev2 [3]=$dev3);
+
+	# Calculate what we expect the atomic write limits to be
+	# Don't consider any chunk size at this stage
+	# Use the limits from the first device and then loop again to find
+	# lowest common supported
+	raw_atomic_write_unit_min=$(< /sys/block/"$dev0"/queue/atomic_write_unit_min_bytes);
+	raw_atomic_write_unit_max=$(< /sys/block/"$dev0"/queue/atomic_write_unit_max_bytes);
+	raw_atomic_write_max=$(< /sys/block/"$dev0"/queue/atomic_write_max_bytes);
+	raw_atomic_write_boundary=$(< /sys/block/"$dev0"/queue/atomic_write_boundary_bytes);
+
+	for i in "${MD_DEVICES[@]}"; do
+		if [[ $(< /sys/block/"$i"/queue/atomic_write_unit_min_bytes) -gt raw_atomic_write_unit_min ]]; then
+			raw_atomic_write_unit_min=$(< /sys/block/"$i"/queue/atomic_write_unit_min_bytes)
+		fi
+		if [[ $(< /sys/block/"$i"/queue/atomic_write_unit_max_bytes) -lt raw_atomic_write_unit_max ]]; then
+			raw_atomic_write_unit_max=$(< /sys/block/"$i"/queue/atomic_write_unit_max_bytes)
+		fi
+		if [[ $(< /sys/block/"$i"/queue/atomic_write_max_bytes) -lt raw_atomic_write_max ]]; then
+			raw_atomic_write_max=$(< /sys/block/"$i"/queue/atomic_write_max_bytes)
+		fi
+		# The kernel only supports same boundary size for all devices in the array
+		if [[ $(< /sys/block/"$i"/queue/atomic_write_boundary_bytes) -ne raw_atomic_write_boundary ]]; then
+			raw_atomic_write_supported=0;
+		fi
+	done
+
+	# Check if we can support atomic writes for the array of devices given.
+	# If we cannot, then it is still worth trying to test that atomic
+	# writes don't work (as we would expect).
+
+	if [[ raw_atomic_write_supported -eq 0 ]]; then
+		raw_atomic_write_unit_min=0;
+		raw_atomic_write_unit_max=0;
+		raw_atomic_write_max=0;
+		raw_atomic_write_boundary=0;
+	fi
+
+	for personality in raid0 raid1 raid10; do
+		local step_limit
+		if [ "$personality" = raid0 ] || [ "$personality" = raid10 ]
+		then
+			step_limit=4
+		else
+			step_limit=1
+		fi
+		chunk_gran=$(( "$raw_atomic_write_unit_max" / 2))
+		if [ "$chunk_gran" -lt 4096 ]
+		then
+			chunk_gran=4096
+		fi
+
+		local chunk_multiple=1
+		for step in $(seq 1 $step_limit)
+		do
+			local expected_atomic_write_unit_min
+			local expected_atomic_write_unit_max
+			local expected_atomic_write_max
+			local expected_atomic_write_boundary
+			local atomics_boundaries_unit_max
+			local atomics_boundaries_max
+
+			# only raid0 does not require a power-of-2 chunk size
+			if [ "$personality" = raid0 ]
+			then
+				chunk_multiple=$step
+			else
+				chunk_multiple=$(( 2 * "$chunk_multiple"))
+			fi
+			md_chunk_size=$(( "$chunk_gran" * "$chunk_multiple"))
+			md_chunk_size_kb=$(( "$md_chunk_size" / 1024))
+
+			# We may reassign these for RAID0/10
+			expected_atomic_write_unit_min=$raw_atomic_write_unit_min
+			expected_atomic_write_unit_max=$raw_atomic_write_unit_max
+			expected_atomic_write_max=$raw_atomic_write_max
+			expected_atomic_write_boundary=$raw_atomic_write_boundary
+
+			if [ "$personality" = raid0 ] || [ "$personality" = raid10 ]
+			then
+				echo y | mdadm --create /dev/md/blktests_md --level=$personality \
+					 --chunk="${md_chunk_size_kb}"K \
+					--raid-devices=4 --force /dev/"${dev0}" /dev/"${dev1}" \
+					/dev/"${dev2}" /dev/"${dev3}" 2> /dev/null 1>&2
+
+				atomics_boundaries_unit_max=$(_md_atomics_boundaries_max $raw_atomic_write_boundary $md_chunk_size "1")
+				atomics_boundaries_max=$(_md_atomics_boundaries_max "$raw_atomic_write_boundary" "$md_chunk_size" "0")
+				expected_atomic_write_unit_min=$(_min "$expected_atomic_write_unit_min" "$atomics_boundaries_unit_max")
+				expected_atomic_write_unit_max=$(_min "$expected_atomic_write_unit_max" "$atomics_boundaries_unit_max")
+				expected_atomic_write_max=$(_min "$expected_atomic_write_max" "$atomics_boundaries_max")
+				if [ "$atomics_boundaries_max" -eq 0 ]
+				then
+					expected_atomic_write_boundary=0
+				fi
+				md_dev=$(readlink /dev/md/blktests_md | sed 's|\.\./||')
+			fi
+
+			if [ "$personality" = raid1 ]
+			then
+				echo y | mdadm --create /dev/md/blktests_md --level=$personality \
+					--raid-devices=4 --force /dev/"${dev0}" /dev/"${dev1}" \
+					/dev/"${dev2}" /dev/"${dev3}" 2> /dev/null 1>&2
+
+				md_dev=$(readlink /dev/md/blktests_md | sed 's|\.\./||')
+			fi
+
+			md_dev_sysfs="/sys/devices/virtual/block/${md_dev}"
+
+			sysfs_logical_block_size=$(< "${md_dev_sysfs}"/queue/logical_block_size)
+			md_sysfs_max_hw_sectors_kb=$(< "${md_dev_sysfs}"/queue/max_hw_sectors_kb)
+			md_sysfs_max_hw=$(( "$md_sysfs_max_hw_sectors_kb" * 1024 ))
+			sysfs_atomic_write_max=$(< "${md_dev_sysfs}"/queue/atomic_write_max_bytes)
+			sysfs_atomic_write_unit_max=$(< "${md_dev_sysfs}"/queue/atomic_write_unit_max_bytes)
+			sysfs_atomic_write_unit_min=$(< "${md_dev_sysfs}"/queue/atomic_write_unit_min_bytes)
+			sysfs_atomic_write_boundary=$(< "${md_dev_sysfs}"/queue/atomic_write_boundary_bytes)
+
+			test_desc="TEST 1 $personality step $step - Verify md sysfs atomic attributes matches"
+			if [ "$sysfs_atomic_write_unit_min" = "$expected_atomic_write_unit_min" ] &&
+				[ "$sysfs_atomic_write_unit_max" = "$expected_atomic_write_unit_max" ]
+			then
+				echo "$test_desc - pass"
+			else
+				echo "$test_desc - fail sysfs_atomic_write_unit_min=$sysfs_atomic_write_unit_min" \
+					"expected_atomic_write_unit_min=$expected_atomic_write_unit_min" \
+					"sysfs_atomic_write_unit_max=$sysfs_atomic_write_unit_max" \
+					"expected_atomic_write_unit_max=$expected_atomic_write_unit_max" \
+					"md_chunk_size=$md_chunk_size"
+			fi
+
+			test_desc="TEST 2 $personality step $step - Verify sysfs atomic attributes"
+			if [ "$md_sysfs_max_hw" -ge "$sysfs_atomic_write_max" ] &&
+				[ "$sysfs_atomic_write_unit_max" -ge "$sysfs_atomic_write_unit_min" ] &&
+				[ "$sysfs_atomic_write_max" -ge "$sysfs_atomic_write_unit_max" ]
+			then
+				echo "$test_desc - pass"
+			else
+				echo "$test_desc - fail md_sysfs_max_hw=$md_sysfs_max_hw" \
+					"sysfs_atomic_write_max=$sysfs_atomic_write_max" \
+					"sysfs_atomic_write_unit_min=$sysfs_atomic_write_unit_min" \
+					"sysfs_atomic_write_unit_max=$sysfs_atomic_write_unit_max" \
+					"md_chunk_size=$md_chunk_size"
+			fi
+
+			test_desc="TEST 3 $personality step $step - Verify md sysfs_atomic_write_max is equal to "
+			test_desc+="expected_atomic_write_max"
+			if [ "$sysfs_atomic_write_max" -eq "$expected_atomic_write_max" ]
+			then
+				echo "$test_desc - pass"
+			else
+				echo "$test_desc - fail sysfs_atomic_write_max=$sysfs_atomic_write_max" \
+					"expected_atomic_write_max=$expected_atomic_write_max" \
+					"md_chunk_size=$md_chunk_size"
+			fi
+
+			test_desc="TEST 4 $personality step $step - Verify sysfs atomic_write_unit_max_bytes =  expected_atomic_write_unit_max"
+			if [ "$sysfs_atomic_write_unit_max" = "$expected_atomic_write_unit_max" ]
+			then
+				echo "$test_desc - pass"
+			else
+				echo "$test_desc - fail sysfs_atomic_write_unit_max=$sysfs_atomic_write_unit_max" \
+					"expected_atomic_write_unit_max=$expected_atomic_write_unit_max" \
+					"md_chunk_size=$md_chunk_size"
+			fi
+
+			test_desc="TEST 5 $personality step $step - Verify sysfs atomic_write_unit_boundary_bytes = expected atomic_write_unit_boundary_bytes"
+			if [ "$sysfs_atomic_write_boundary" = "$expected_atomic_write_boundary" ]
+			then
+				echo "$test_desc - pass"
+			else
+				echo "$test_desc - fail sysfs_atomic_write_boundary=$sysfs_atomic_write_boundary" \
+					"expected_atomic_write_boundary=$expected_atomic_write_boundary"
+			fi
+
+			test_desc="TEST 6 $personality step $step - Verify statx stx_atomic_write_unit_min"
+			statx_atomic_write_unit_min=$(run_xfs_io_xstat /dev/"$md_dev" "stat.atomic_write_unit_min")
+			if [ "$statx_atomic_write_unit_min" = "$sysfs_atomic_write_unit_min" ]
+			then
+				echo "$test_desc - pass"
+			else
+				echo "$test_desc - fail statx_atomic_write_unit_min=$statx_atomic_write_unit_min" \
+					"sysfs_atomic_write_unit_min=$sysfs_atomic_write_unit_min" \
+					"md_chunk_size=$md_chunk_size"
+			fi
+
+			test_desc="TEST 7 $personality step $step - Verify statx stx_atomic_write_unit_max"
+			statx_atomic_write_unit_max=$(run_xfs_io_xstat /dev/"$md_dev" "stat.atomic_write_unit_max")
+			if [ "$statx_atomic_write_unit_max" = "$sysfs_atomic_write_unit_max" ]
+			then
+				echo "$test_desc - pass"
+			else
+				echo "$test_desc - fail statx_atomic_write_unit_max=$statx_atomic_write_unit_max" \
+					"sysfs_atomic_write_unit_max=$sysfs_atomic_write_unit_max" \
+					"md_chunk_size=$md_chunk_size"
+			fi
+
+			test_desc="TEST 8 $personality step $step - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes with "
+			test_desc+="RWF_ATOMIC flag - pwritev2 should fail"
+			if [ "$sysfs_atomic_write_unit_max" = 0 ]
+			then
+				echo "$test_desc - pass"
+			else
+				bytes_written=$(run_xfs_io_pwritev2_atomic /dev/"$md_dev" "$sysfs_atomic_write_unit_max")
+				if [ "$bytes_written" = "$sysfs_atomic_write_unit_max" ]
+				then
+					echo "$test_desc - pass"
+				else
+					echo "$test_desc - fail bytes_written=$bytes_written" \
+						"sysfs_atomic_write_unit_max=$sysfs_atomic_write_unit_max" \
+						"md_chunk_size=$md_chunk_size"
+				fi
+			fi
+
+			test_desc="TEST 9 $personality step $step - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes + LBS "
+			test_desc+="bytes with RWF_ATOMIC flag - pwritev2 should not be succesful"
+			if [ "$sysfs_atomic_write_unit_max" = 0 ]
+			then
+				echo "pwrite: Invalid argument"
+				echo "$test_desc - pass"
+			else
+				bytes_to_write=$(( "${sysfs_atomic_write_unit_max}" + "${sysfs_logical_block_size}" ))
+				bytes_written=$(run_xfs_io_pwritev2_atomic /dev/"$md_dev" "$bytes_to_write")
+				if [ "$bytes_written" = "" ]
+				then
+					echo "$test_desc - pass"
+				else
+					echo "$test_desc - fail bytes_written=$bytes_written" \
+						"bytes_to_write=$bytes_to_write" \
+						"sysfs_atomic_write_unit_max=$sysfs_atomic_write_unit_max" \
+						"md_chunk_size=$md_chunk_size"
+				fi
+			fi
+
+			test_desc="TEST 10 $personality step $step - perform a pwritev2 with size of sysfs_atomic_unit_min_bytes "
+			test_desc+="with RWF_ATOMIC flag - pwritev2 should fail"
+			if [ "$sysfs_atomic_write_unit_min" = 0 ]
+			then
+				echo "$test_desc - pass"
+			else
+				bytes_written=$(run_xfs_io_pwritev2_atomic /dev/"$md_dev" "$sysfs_atomic_write_unit_min")
+				if [ "$bytes_written" = "$sysfs_atomic_write_unit_min" ]
+				then
+					echo "$test_desc - pass"
+				else
+					echo "$test_desc - fail bytes_written=$bytes_written" \
+						"sysfs_atomic_write_unit_min=$sysfs_atomic_write_unit_min" \
+						"md_chunk_size=$md_chunk_size"
+				fi
+			fi
+
+			test_desc="TEST 11 $personality step $step - perform a pwritev2 with a size of sysfs_atomic_write_unit_max_bytes - LBS "
+			test_desc+="bytes with RWF_ATOMIC flag - pwritev2 should fail"
+			if [ "${sysfs_atomic_write_unit_max}" -le "${sysfs_logical_block_size}" ]
+			then
+				echo "pwrite: Invalid argument"
+				echo "$test_desc - pass"
+			else
+				bytes_to_write=$(( "${sysfs_atomic_write_unit_max}" - "${sysfs_logical_block_size}" ))
+				bytes_written=$(run_xfs_io_pwritev2_atomic /dev/"$md_dev" "$bytes_to_write")
+				if [ "$bytes_written" = "" ]
+				then
+					echo "$test_desc - pass"
+				else
+					echo "$test_desc - fail bytes_written=$bytes_written" \
+						"bytes_to_write=$bytes_to_write" \
+						"md_chunk_size=$md_chunk_size"
+				fi
+			fi
+
+			if [ "$personality" = raid0 ] || [ "$personality" = raid1 ] || [ "$personality" = raid10 ]
+			then
+				mdadm --stop /dev/md/blktests_md  2> /dev/null 1>&2
+
+				for i in "${MD_DEVICES[@]}"; do
+					mdadm --zero-superblock /dev/"$i" 2> /dev/null 1>&2
+				done
+			fi
+		done
+	done
+}
-- 
2.43.5


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH blktests v2 5/9] md/002: convert to use _md_atomics_test
  2025-09-22 10:24 [PATCH blktests v2 0/9] Further stacked device atomic writes testing John Garry
                   ` (3 preceding siblings ...)
  2025-09-22 10:24 ` [PATCH blktests v2 4/9] md/rc: add _md_atomics_test John Garry
@ 2025-09-22 10:24 ` John Garry
  2025-09-22 10:24 ` [PATCH blktests v2 6/9] md/003: add NVMe atomic write tests for stacked devices John Garry
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 18+ messages in thread
From: John Garry @ 2025-09-22 10:24 UTC (permalink / raw)
  To: linux-block, shinichiro.kawasaki; +Cc: John Garry

_md_atomics_test does even more testing than 002 does now.

group_requires() already requires mdadm, so drop that also.

Signed-off-by: John Garry <john.g.garry@oracle.com>
---
 tests/md/002     | 216 +----------------------------------------------
 tests/md/002.out | 158 +++++++++++++++++++++++++---------
 2 files changed, 120 insertions(+), 254 deletions(-)

diff --git a/tests/md/002 b/tests/md/002
index fdf1e23..3e9c1fa 100755
--- a/tests/md/002
+++ b/tests/md/002
@@ -12,41 +12,11 @@ DESCRIPTION="test md atomic writes"
 QUICK=1
 
 requires() {
-	_have_kver 6 14 0
-	_have_program mdadm
 	_have_driver scsi_debug
-	_have_xfs_io_atomic_write
-	_have_driver raid0
-	_have_driver raid1
-	_have_driver raid10
+	_stacked_atomic_test_requires
 }
 
 test() {
-	local scsi_debug_atomic_wr_max_length
-	local scsi_debug_atomic_wr_gran
-	local scsi_sysfs_atomic_max_bytes
-	local scsi_sysfs_atomic_unit_max_bytes
-	local scsi_sysfs_atomic_unit_min_bytes
-	local md_atomic_max_bytes
-	local md_atomic_min_bytes
-	local md_sysfs_max_hw_sectors_kb
-	local md_max_hw_bytes
-	local md_chunk_size
-	local md_chunk_size_bytes
-	local md_sysfs_logical_block_size
-	local md_sysfs_atomic_max_bytes
-	local md_sysfs_atomic_unit_max_bytes
-	local md_sysfs_atomic_unit_min_bytes
-	local bytes_to_write
-	local bytes_written
-	local test_desc
-	local scsi_0
-	local scsi_1
-	local scsi_2
-	local scsi_3
-	local scsi_dev_sysfs
-	local md_dev
-	local md_dev_sysfs
 	local scsi_debug_params=(
 		delay=0
 		atomic_wr=1
@@ -61,188 +31,8 @@ test() {
 		return 1
 	fi
 
-	scsi_0="${SCSI_DEBUG_DEVICES[0]}"
-	scsi_1="${SCSI_DEBUG_DEVICES[1]}"
-	scsi_2="${SCSI_DEBUG_DEVICES[2]}"
-	scsi_3="${SCSI_DEBUG_DEVICES[3]}"
-
-	scsi_dev_sysfs="/sys/block/${scsi_0}"
-	scsi_sysfs_atomic_max_bytes=$(< "${scsi_dev_sysfs}"/queue/atomic_write_max_bytes)
-	scsi_sysfs_atomic_unit_max_bytes=$(< "${scsi_dev_sysfs}"/queue/atomic_write_unit_max_bytes)
-	scsi_sysfs_atomic_unit_min_bytes=$(< "${scsi_dev_sysfs}"/queue/atomic_write_unit_min_bytes)
-	scsi_debug_atomic_wr_max_length=$(< /sys/module/scsi_debug/parameters/atomic_wr_max_length)
-	scsi_debug_atomic_wr_gran=$(< /sys/module/scsi_debug/parameters/atomic_wr_gran)
-
-	for raid_level in 0 1 10; do
-		if [ "$raid_level" = 10 ]
-		then
-			mdadm --create /dev/md/blktests_md --level=$raid_level \
-				--raid-devices=4 --force --run /dev/"${scsi_0}" /dev/"${scsi_1}" \
-				/dev/"${scsi_2}" /dev/"${scsi_3}" 2> /dev/null 1>&2
-		else
-			mdadm --create /dev/md/blktests_md --level=$raid_level \
-				--raid-devices=2 --force --run \
-				/dev/"${scsi_0}" /dev/"${scsi_1}" 2> /dev/null 1>&2
-		fi
-
-		md_dev=$(readlink /dev/md/blktests_md | sed 's|\.\./||')
-		md_dev_sysfs="/sys/devices/virtual/block/${md_dev}"
-
-		md_sysfs_logical_block_size=$(< "${md_dev_sysfs}"/queue/logical_block_size)
-		md_sysfs_max_hw_sectors_kb=$(< "${md_dev_sysfs}"/queue/max_hw_sectors_kb)
-		md_max_hw_bytes=$(( "$md_sysfs_max_hw_sectors_kb" * 1024 ))
-		md_sysfs_atomic_max_bytes=$(< "${md_dev_sysfs}"/queue/atomic_write_max_bytes)
-		md_sysfs_atomic_unit_max_bytes=$(< "${md_dev_sysfs}"/queue/atomic_write_unit_max_bytes)
-		md_sysfs_atomic_unit_min_bytes=$(< "${md_dev_sysfs}"/queue/atomic_write_unit_min_bytes)
-		md_atomic_max_bytes=$(( "$scsi_debug_atomic_wr_max_length" * "$md_sysfs_logical_block_size" ))
-		md_atomic_min_bytes=$(( "$scsi_debug_atomic_wr_gran" * "$md_sysfs_logical_block_size" ))
-
-		test_desc="TEST 1 RAID $raid_level - Verify md sysfs atomic attributes matches scsi"
-		if [ "$md_sysfs_atomic_unit_max_bytes" = "$scsi_sysfs_atomic_unit_max_bytes" ] &&
-			[ "$md_sysfs_atomic_unit_min_bytes" = "$scsi_sysfs_atomic_unit_min_bytes" ]
-		then
-			echo "$test_desc - pass"
-		else
-			echo "$test_desc - fail $md_sysfs_atomic_unit_max_bytes - $scsi_sysfs_atomic_unit_max_bytes -" \
-				"$md_sysfs_atomic_unit_min_bytes - $scsi_sysfs_atomic_unit_min_bytes "
-		fi
-
-		test_desc="TEST 2 RAID $raid_level - Verify sysfs atomic attributes"
-		if [ "$md_max_hw_bytes" -ge "$md_sysfs_atomic_max_bytes" ] &&
-			[ "$md_sysfs_atomic_max_bytes" -ge "$md_sysfs_atomic_unit_max_bytes" ] &&
-			[ "$md_sysfs_atomic_unit_max_bytes" -ge "$md_sysfs_atomic_unit_min_bytes" ]
-		then
-			echo "$test_desc - pass"
-		else
-			echo "$test_desc - fail $md_max_hw_bytes - $md_sysfs_max_hw_sectors_kb -" \
-				"$md_sysfs_atomic_max_bytes - $md_sysfs_atomic_unit_max_bytes -" \
-				"$md_sysfs_atomic_unit_min_bytes"
-		fi
-
-		test_desc="TEST 3 RAID $raid_level - Verify md sysfs_atomic_max_bytes is less than or equal "
-		test_desc+="scsi sysfs_atomic_max_bytes"
-		if [ "$md_sysfs_atomic_max_bytes" -le "$scsi_sysfs_atomic_max_bytes" ]
-		then
-			echo "$test_desc - pass"
-		else
-			echo "$test_desc - fail $md_sysfs_atomic_max_bytes - $scsi_sysfs_atomic_max_bytes"
-		fi
-
-		test_desc="TEST 4 RAID $raid_level - check sysfs atomic_write_unit_max_bytes <= scsi_debug atomic_wr_max_length"
-		if (("$md_sysfs_atomic_unit_max_bytes" <= "$md_atomic_max_bytes"))
-		then
-			echo "$test_desc - pass"
-		else
-			echo "$test_desc - fail $md_sysfs_atomic_unit_max_bytes - $md_atomic_max_bytes"
-		fi
-
-		test_desc="TEST 5 RAID $raid_level - check sysfs atomic_write_unit_min_bytes = scsi_debug atomic_wr_gran"
-		if [ "$md_sysfs_atomic_unit_min_bytes" = "$md_atomic_min_bytes" ]
-		then
-			echo "$test_desc - pass"
-		else
-			echo "$test_desc - fail $md_sysfs_atomic_unit_min_bytes - $md_atomic_min_bytes"
-		fi
-
-		test_desc="TEST 6 RAID $raid_level - check statx stx_atomic_write_unit_min"
-		statx_atomic_min=$(run_xfs_io_xstat /dev/"$md_dev" "stat.atomic_write_unit_min")
-		if [ "$statx_atomic_min" = "$md_atomic_min_bytes" ]
-		then
-			echo "$test_desc - pass"
-		else
-			echo "$test_desc - fail $statx_atomic_min - $md_atomic_min_bytes"
-		fi
-
-		test_desc="TEST 7 RAID $raid_level - check statx stx_atomic_write_unit_max"
-		statx_atomic_max=$(run_xfs_io_xstat /dev/"$md_dev" "stat.atomic_write_unit_max")
-		if [ "$statx_atomic_max" = "$md_sysfs_atomic_unit_max_bytes" ]
-		then
-			echo "$test_desc - pass"
-		else
-			echo "$test_desc - fail $statx_atomic_max - $md_sysfs_atomic_unit_max_bytes"
-		fi
-
-		test_desc="TEST 8 RAID $raid_level - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes with "
-		test_desc+="RWF_ATOMIC flag - pwritev2 should be succesful"
-		bytes_written=$(run_xfs_io_pwritev2_atomic /dev/"$md_dev" "$md_sysfs_atomic_unit_max_bytes")
-		if [ "$bytes_written" = "$md_sysfs_atomic_unit_max_bytes" ]
-		then
-			echo "$test_desc - pass"
-		else
-			echo "$test_desc - fail $bytes_written - $md_sysfs_atomic_unit_max_bytes"
-		fi
-
-		test_desc="TEST 9 RAID $raid_level - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes + 512 "
-		test_desc+="bytes with RWF_ATOMIC flag - pwritev2 should not be succesful"
-		bytes_to_write=$(( "${md_sysfs_atomic_unit_max_bytes}" + 512 ))
-		bytes_written=$(run_xfs_io_pwritev2_atomic /dev/"$md_dev" "$bytes_to_write")
-		if [ "$bytes_written" = "" ]
-		then
-			echo "$test_desc - pass"
-		else
-			echo "$test_desc - fail $bytes_written - $bytes_to_write"
-		fi
-
-		test_desc="TEST 10 RAID $raid_level - perform a pwritev2 with size of sysfs_atomic_unit_min_bytes "
-		test_desc+="with RWF_ATOMIC flag - pwritev2 should be succesful"
-		bytes_written=$(run_xfs_io_pwritev2_atomic /dev/"$md_dev" "$md_sysfs_atomic_unit_min_bytes")
-		if [ "$bytes_written" = "$md_sysfs_atomic_unit_min_bytes" ]
-		then
-			echo "$test_desc - pass"
-		else
-			echo "$test_desc - fail $bytes_written - $md_atomic_min_bytes"
-		fi
-
-		bytes_to_write=$(( "${md_sysfs_atomic_unit_min_bytes}" - "${md_sysfs_logical_block_size}" ))
-		test_desc="TEST 11 RAID $raid_level - perform a pwritev2 with a size of sysfs_atomic_unit_min_bytes - 512 "
-		test_desc+="bytes with RWF_ATOMIC flag - pwritev2 should fail"
-		if [ "$bytes_to_write" = 0 ]
-		then
-			echo "$test_desc - pass"
-		else
-			bytes_written=$(run_xfs_io_pwritev2_atomic /dev/"$md_dev" "$bytes_to_write")
-			if [ "$bytes_written" = "" ]
-			then
-				echo "$test_desc - pass"
-			else
-				echo "$test_desc - fail $bytes_written - $bytes_to_write"
-			fi
-		fi
-
-		mdadm --stop /dev/md/blktests_md  2> /dev/null 1>&2
-
-		if [ "$raid_level" = 0 ] || [ "$raid_level" = 10 ]
-		then
-			md_chunk_size=$(( "$scsi_sysfs_atomic_unit_max_bytes" / 2048))
-
-			if [ "$raid_level" = 0 ]
-			then
-				mdadm --create /dev/md/blktests_md --level=$raid_level \
-					--raid-devices=2 --chunk="${md_chunk_size}"K --force --run \
-					/dev/"${scsi_0}" /dev/"${scsi_1}" 2> /dev/null 1>&2
-			else
-				mdadm --create /dev/md/blktests_md --level=$raid_level \
-					--raid-devices=4 --chunk="${md_chunk_size}"K --force --run \
-					/dev/"${scsi_0}" /dev/"${scsi_1}" \
-					/dev/"${scsi_2}" /dev/"${scsi_3}" 2> /dev/null 1>&2
-			fi
-
-			md_dev=$(readlink /dev/md/blktests_md | sed 's|\.\./||')
-			md_dev_sysfs="/sys/devices/virtual/block/${md_dev}"
-			md_sysfs_atomic_unit_max_bytes=$(< "${md_dev_sysfs}"/queue/atomic_write_unit_max_bytes)
-			md_chunk_size_bytes=$(( "$md_chunk_size" * 1024))
-			test_desc="TEST 12 RAID $raid_level - Verify chunk size "
-			if [ "$md_chunk_size_bytes" -le "$md_sysfs_atomic_unit_max_bytes" ] && \
-				(( md_sysfs_atomic_unit_max_bytes % md_chunk_size_bytes == 0 ))
-			then
-				echo "$test_desc - pass"
-			else
-				echo "$test_desc - fail $md_chunk_size_bytes - $md_sysfs_atomic_unit_max_bytes"
-			fi
-
-			mdadm --quiet --stop /dev/md/blktests_md
-		fi
-	done
+	_md_atomics_test "${SCSI_DEBUG_DEVICES[0]}" "${SCSI_DEBUG_DEVICES[1]}" \
+			"${SCSI_DEBUG_DEVICES[2]}" "${SCSI_DEBUG_DEVICES[3]}"
 
 	_exit_scsi_debug
 
diff --git a/tests/md/002.out b/tests/md/002.out
index 6b0a431..cd34e38 100644
--- a/tests/md/002.out
+++ b/tests/md/002.out
@@ -1,43 +1,119 @@
 Running md/002
-TEST 1 RAID 0 - Verify md sysfs atomic attributes matches scsi - pass
-TEST 2 RAID 0 - Verify sysfs atomic attributes - pass
-TEST 3 RAID 0 - Verify md sysfs_atomic_max_bytes is less than or equal scsi sysfs_atomic_max_bytes - pass
-TEST 4 RAID 0 - check sysfs atomic_write_unit_max_bytes <= scsi_debug atomic_wr_max_length - pass
-TEST 5 RAID 0 - check sysfs atomic_write_unit_min_bytes = scsi_debug atomic_wr_gran - pass
-TEST 6 RAID 0 - check statx stx_atomic_write_unit_min - pass
-TEST 7 RAID 0 - check statx stx_atomic_write_unit_max - pass
-TEST 8 RAID 0 - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes with RWF_ATOMIC flag - pwritev2 should be succesful - pass
-pwrite: Invalid argument
-TEST 9 RAID 0 - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes + 512 bytes with RWF_ATOMIC flag - pwritev2 should not be succesful - pass
-TEST 10 RAID 0 - perform a pwritev2 with size of sysfs_atomic_unit_min_bytes with RWF_ATOMIC flag - pwritev2 should be succesful - pass
-pwrite: Invalid argument
-TEST 11 RAID 0 - perform a pwritev2 with a size of sysfs_atomic_unit_min_bytes - 512 bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
-TEST 12 RAID 0 - Verify chunk size  - pass
-TEST 1 RAID 1 - Verify md sysfs atomic attributes matches scsi - pass
-TEST 2 RAID 1 - Verify sysfs atomic attributes - pass
-TEST 3 RAID 1 - Verify md sysfs_atomic_max_bytes is less than or equal scsi sysfs_atomic_max_bytes - pass
-TEST 4 RAID 1 - check sysfs atomic_write_unit_max_bytes <= scsi_debug atomic_wr_max_length - pass
-TEST 5 RAID 1 - check sysfs atomic_write_unit_min_bytes = scsi_debug atomic_wr_gran - pass
-TEST 6 RAID 1 - check statx stx_atomic_write_unit_min - pass
-TEST 7 RAID 1 - check statx stx_atomic_write_unit_max - pass
-TEST 8 RAID 1 - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes with RWF_ATOMIC flag - pwritev2 should be succesful - pass
-pwrite: Invalid argument
-TEST 9 RAID 1 - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes + 512 bytes with RWF_ATOMIC flag - pwritev2 should not be succesful - pass
-TEST 10 RAID 1 - perform a pwritev2 with size of sysfs_atomic_unit_min_bytes with RWF_ATOMIC flag - pwritev2 should be succesful - pass
-pwrite: Invalid argument
-TEST 11 RAID 1 - perform a pwritev2 with a size of sysfs_atomic_unit_min_bytes - 512 bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
-TEST 1 RAID 10 - Verify md sysfs atomic attributes matches scsi - pass
-TEST 2 RAID 10 - Verify sysfs atomic attributes - pass
-TEST 3 RAID 10 - Verify md sysfs_atomic_max_bytes is less than or equal scsi sysfs_atomic_max_bytes - pass
-TEST 4 RAID 10 - check sysfs atomic_write_unit_max_bytes <= scsi_debug atomic_wr_max_length - pass
-TEST 5 RAID 10 - check sysfs atomic_write_unit_min_bytes = scsi_debug atomic_wr_gran - pass
-TEST 6 RAID 10 - check statx stx_atomic_write_unit_min - pass
-TEST 7 RAID 10 - check statx stx_atomic_write_unit_max - pass
-TEST 8 RAID 10 - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes with RWF_ATOMIC flag - pwritev2 should be succesful - pass
-pwrite: Invalid argument
-TEST 9 RAID 10 - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes + 512 bytes with RWF_ATOMIC flag - pwritev2 should not be succesful - pass
-TEST 10 RAID 10 - perform a pwritev2 with size of sysfs_atomic_unit_min_bytes with RWF_ATOMIC flag - pwritev2 should be succesful - pass
-pwrite: Invalid argument
-TEST 11 RAID 10 - perform a pwritev2 with a size of sysfs_atomic_unit_min_bytes - 512 bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
-TEST 12 RAID 10 - Verify chunk size  - pass
+TEST 1 raid0 step 1 - Verify md sysfs atomic attributes matches - pass
+TEST 2 raid0 step 1 - Verify sysfs atomic attributes - pass
+TEST 3 raid0 step 1 - Verify md sysfs_atomic_write_max is equal to expected_atomic_write_max - pass
+TEST 4 raid0 step 1 - Verify sysfs atomic_write_unit_max_bytes =  expected_atomic_write_unit_max - pass
+TEST 5 raid0 step 1 - Verify sysfs atomic_write_unit_boundary_bytes = expected atomic_write_unit_boundary_bytes - pass
+TEST 6 raid0 step 1 - Verify statx stx_atomic_write_unit_min - pass
+TEST 7 raid0 step 1 - Verify statx stx_atomic_write_unit_max - pass
+TEST 8 raid0 step 1 - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+pwrite: Invalid argument
+TEST 9 raid0 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
+TEST 10 raid0 step 1 - perform a pwritev2 with size of sysfs_atomic_unit_min_bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+pwrite: Invalid argument
+TEST 11 raid0 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
+TEST 1 raid0 step 2 - Verify md sysfs atomic attributes matches - pass
+TEST 2 raid0 step 2 - Verify sysfs atomic attributes - pass
+TEST 3 raid0 step 2 - Verify md sysfs_atomic_write_max is equal to expected_atomic_write_max - pass
+TEST 4 raid0 step 2 - Verify sysfs atomic_write_unit_max_bytes =  expected_atomic_write_unit_max - pass
+TEST 5 raid0 step 2 - Verify sysfs atomic_write_unit_boundary_bytes = expected atomic_write_unit_boundary_bytes - pass
+TEST 6 raid0 step 2 - Verify statx stx_atomic_write_unit_min - pass
+TEST 7 raid0 step 2 - Verify statx stx_atomic_write_unit_max - pass
+TEST 8 raid0 step 2 - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+pwrite: Invalid argument
+TEST 9 raid0 step 2 - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes + LBS bytes with RWF_ATOMIC flag - pwritev2 should not be succesful - pass
+TEST 10 raid0 step 2 - perform a pwritev2 with size of sysfs_atomic_unit_min_bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+pwrite: Invalid argument
+TEST 11 raid0 step 2 - perform a pwritev2 with a size of sysfs_atomic_write_unit_max_bytes - LBS bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+TEST 1 raid0 step 3 - Verify md sysfs atomic attributes matches - pass
+TEST 2 raid0 step 3 - Verify sysfs atomic attributes - pass
+TEST 3 raid0 step 3 - Verify md sysfs_atomic_write_max is equal to expected_atomic_write_max - pass
+TEST 4 raid0 step 3 - Verify sysfs atomic_write_unit_max_bytes =  expected_atomic_write_unit_max - pass
+TEST 5 raid0 step 3 - Verify sysfs atomic_write_unit_boundary_bytes = expected atomic_write_unit_boundary_bytes - pass
+TEST 6 raid0 step 3 - Verify statx stx_atomic_write_unit_min - pass
+TEST 7 raid0 step 3 - Verify statx stx_atomic_write_unit_max - pass
+TEST 8 raid0 step 3 - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+pwrite: Invalid argument
+TEST 9 raid0 step 3 - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes + LBS bytes with RWF_ATOMIC flag - pwritev2 should not be succesful - pass
+TEST 10 raid0 step 3 - perform a pwritev2 with size of sysfs_atomic_unit_min_bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+pwrite: Invalid argument
+TEST 11 raid0 step 3 - perform a pwritev2 with a size of sysfs_atomic_write_unit_max_bytes - LBS bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+TEST 1 raid0 step 4 - Verify md sysfs atomic attributes matches - pass
+TEST 2 raid0 step 4 - Verify sysfs atomic attributes - pass
+TEST 3 raid0 step 4 - Verify md sysfs_atomic_write_max is equal to expected_atomic_write_max - pass
+TEST 4 raid0 step 4 - Verify sysfs atomic_write_unit_max_bytes =  expected_atomic_write_unit_max - pass
+TEST 5 raid0 step 4 - Verify sysfs atomic_write_unit_boundary_bytes = expected atomic_write_unit_boundary_bytes - pass
+TEST 6 raid0 step 4 - Verify statx stx_atomic_write_unit_min - pass
+TEST 7 raid0 step 4 - Verify statx stx_atomic_write_unit_max - pass
+TEST 8 raid0 step 4 - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+pwrite: Invalid argument
+TEST 9 raid0 step 4 - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes + LBS bytes with RWF_ATOMIC flag - pwritev2 should not be succesful - pass
+TEST 10 raid0 step 4 - perform a pwritev2 with size of sysfs_atomic_unit_min_bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+pwrite: Invalid argument
+TEST 11 raid0 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
+TEST 1 raid1 step 1 - Verify md sysfs atomic attributes matches - pass
+TEST 2 raid1 step 1 - Verify sysfs atomic attributes - pass
+TEST 3 raid1 step 1 - Verify md sysfs_atomic_write_max is equal to expected_atomic_write_max - pass
+TEST 4 raid1 step 1 - Verify sysfs atomic_write_unit_max_bytes =  expected_atomic_write_unit_max - pass
+TEST 5 raid1 step 1 - Verify sysfs atomic_write_unit_boundary_bytes = expected atomic_write_unit_boundary_bytes - pass
+TEST 6 raid1 step 1 - Verify statx stx_atomic_write_unit_min - pass
+TEST 7 raid1 step 1 - Verify statx stx_atomic_write_unit_max - pass
+TEST 8 raid1 step 1 - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+pwrite: Invalid argument
+TEST 9 raid1 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
+TEST 10 raid1 step 1 - perform a pwritev2 with size of sysfs_atomic_unit_min_bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+pwrite: Invalid argument
+TEST 11 raid1 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
+TEST 1 raid10 step 1 - Verify md sysfs atomic attributes matches - pass
+TEST 2 raid10 step 1 - Verify sysfs atomic attributes - pass
+TEST 3 raid10 step 1 - Verify md sysfs_atomic_write_max is equal to expected_atomic_write_max - pass
+TEST 4 raid10 step 1 - Verify sysfs atomic_write_unit_max_bytes =  expected_atomic_write_unit_max - pass
+TEST 5 raid10 step 1 - Verify sysfs atomic_write_unit_boundary_bytes = expected atomic_write_unit_boundary_bytes - pass
+TEST 6 raid10 step 1 - Verify statx stx_atomic_write_unit_min - pass
+TEST 7 raid10 step 1 - Verify statx stx_atomic_write_unit_max - pass
+TEST 8 raid10 step 1 - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+pwrite: Invalid argument
+TEST 9 raid10 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
+TEST 10 raid10 step 1 - perform a pwritev2 with size of sysfs_atomic_unit_min_bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+pwrite: Invalid argument
+TEST 11 raid10 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
+TEST 1 raid10 step 2 - Verify md sysfs atomic attributes matches - pass
+TEST 2 raid10 step 2 - Verify sysfs atomic attributes - pass
+TEST 3 raid10 step 2 - Verify md sysfs_atomic_write_max is equal to expected_atomic_write_max - pass
+TEST 4 raid10 step 2 - Verify sysfs atomic_write_unit_max_bytes =  expected_atomic_write_unit_max - pass
+TEST 5 raid10 step 2 - Verify sysfs atomic_write_unit_boundary_bytes = expected atomic_write_unit_boundary_bytes - pass
+TEST 6 raid10 step 2 - Verify statx stx_atomic_write_unit_min - pass
+TEST 7 raid10 step 2 - Verify statx stx_atomic_write_unit_max - pass
+TEST 8 raid10 step 2 - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+pwrite: Invalid argument
+TEST 9 raid10 step 2 - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes + LBS bytes with RWF_ATOMIC flag - pwritev2 should not be succesful - pass
+TEST 10 raid10 step 2 - perform a pwritev2 with size of sysfs_atomic_unit_min_bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+pwrite: Invalid argument
+TEST 11 raid10 step 2 - perform a pwritev2 with a size of sysfs_atomic_write_unit_max_bytes - LBS bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+TEST 1 raid10 step 3 - Verify md sysfs atomic attributes matches - pass
+TEST 2 raid10 step 3 - Verify sysfs atomic attributes - pass
+TEST 3 raid10 step 3 - Verify md sysfs_atomic_write_max is equal to expected_atomic_write_max - pass
+TEST 4 raid10 step 3 - Verify sysfs atomic_write_unit_max_bytes =  expected_atomic_write_unit_max - pass
+TEST 5 raid10 step 3 - Verify sysfs atomic_write_unit_boundary_bytes = expected atomic_write_unit_boundary_bytes - pass
+TEST 6 raid10 step 3 - Verify statx stx_atomic_write_unit_min - pass
+TEST 7 raid10 step 3 - Verify statx stx_atomic_write_unit_max - pass
+TEST 8 raid10 step 3 - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+pwrite: Invalid argument
+TEST 9 raid10 step 3 - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes + LBS bytes with RWF_ATOMIC flag - pwritev2 should not be succesful - pass
+TEST 10 raid10 step 3 - perform a pwritev2 with size of sysfs_atomic_unit_min_bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+pwrite: Invalid argument
+TEST 11 raid10 step 3 - perform a pwritev2 with a size of sysfs_atomic_write_unit_max_bytes - LBS bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+TEST 1 raid10 step 4 - Verify md sysfs atomic attributes matches - pass
+TEST 2 raid10 step 4 - Verify sysfs atomic attributes - pass
+TEST 3 raid10 step 4 - Verify md sysfs_atomic_write_max is equal to expected_atomic_write_max - pass
+TEST 4 raid10 step 4 - Verify sysfs atomic_write_unit_max_bytes =  expected_atomic_write_unit_max - pass
+TEST 5 raid10 step 4 - Verify sysfs atomic_write_unit_boundary_bytes = expected atomic_write_unit_boundary_bytes - pass
+TEST 6 raid10 step 4 - Verify statx stx_atomic_write_unit_min - pass
+TEST 7 raid10 step 4 - Verify statx stx_atomic_write_unit_max - pass
+TEST 8 raid10 step 4 - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+pwrite: Invalid argument
+TEST 9 raid10 step 4 - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes + LBS bytes with RWF_ATOMIC flag - pwritev2 should not be succesful - pass
+TEST 10 raid10 step 4 - perform a pwritev2 with size of sysfs_atomic_unit_min_bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+pwrite: Invalid argument
+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
 Test complete
-- 
2.43.5


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH blktests v2 6/9] md/003: add NVMe atomic write tests for stacked devices
  2025-09-22 10:24 [PATCH blktests v2 0/9] Further stacked device atomic writes testing John Garry
                   ` (4 preceding siblings ...)
  2025-09-22 10:24 ` [PATCH blktests v2 5/9] md/002: convert to use _md_atomics_test John Garry
@ 2025-09-22 10:24 ` John Garry
  2025-09-25  8:39   ` Shinichiro Kawasaki
  2025-09-22 10:24 ` [PATCH blktests v2 7/9] md/rc: test atomic writes for dm-linear John Garry
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 18+ messages in thread
From: John Garry @ 2025-09-22 10:24 UTC (permalink / raw)
  To: linux-block, shinichiro.kawasaki; +Cc: John Garry

md/002 only tests SCSI via scsi_debug.

It is also useful to test NVMe, so add a specific test for that.

The results for 002 and 003 should be the same, so link them.

_md_atomics_test requires 4x devices with atomics support, so check for
that.

Signed-off-by: John Garry <john.g.garry@oracle.com>
---
 tests/md/002     |  2 +-
 tests/md/002.out |  2 +-
 tests/md/003     | 44 ++++++++++++++++++++++++++++++++++++++++++++
 tests/md/003.out |  1 +
 4 files changed, 47 insertions(+), 2 deletions(-)
 create mode 100755 tests/md/003
 create mode 120000 tests/md/003.out

diff --git a/tests/md/002 b/tests/md/002
index 3e9c1fa..65a5fa5 100755
--- a/tests/md/002
+++ b/tests/md/002
@@ -25,7 +25,7 @@ test() {
 		per_host_store=true
 	)
 
-	echo "Running ${TEST_NAME}"
+	echo "Running md_atomics_test"
 
 	if ! _configure_scsi_debug "${scsi_debug_params[@]}"; then
 		return 1
diff --git a/tests/md/002.out b/tests/md/002.out
index cd34e38..b311a50 100644
--- a/tests/md/002.out
+++ b/tests/md/002.out
@@ -1,4 +1,4 @@
-Running md/002
+Running md_atomics_test
 TEST 1 raid0 step 1 - Verify md sysfs atomic attributes matches - pass
 TEST 2 raid0 step 1 - Verify sysfs atomic attributes - pass
 TEST 3 raid0 step 1 - Verify md sysfs_atomic_write_max is equal to expected_atomic_write_max - pass
diff --git a/tests/md/003 b/tests/md/003
new file mode 100755
index 0000000..5a68480
--- /dev/null
+++ b/tests/md/003
@@ -0,0 +1,44 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2025 Oracle and/or its affiliates
+#
+# Test NMVe Atomic Writes with MD devices
+
+. tests/md/rc
+. common/nvme
+. common/xfs
+
+DESCRIPTION="test md atomic writes for NVMe drives"
+QUICK=1
+
+requires() {
+	_nvme_requires
+	_stacked_atomic_test_requires
+}
+
+device_requires() {
+	_require_test_dev_is_nvme
+}
+
+test_device_array() {
+	local test_dev
+	local testdev_count=0
+	declare -A NVME_TEST_DEVS_NAME
+
+	echo "Running md_atomics_test"
+
+	for test_dev in "${!TEST_DEV_ARRAY_SYSFS_DIRS[@]}"; do
+		NVME_TEST_DEVS_NAME["$testdev_count"]="${test_dev##*/}"
+		let testdev_count=testdev_count+1;
+	done
+
+	if [[ $testdev_count -lt 4 ]]; then
+		SKIP_REASONS+=("requires at least 4 NVMe devices")
+		return 1
+	fi
+
+	_md_atomics_test "${NVME_TEST_DEVS_NAME[0]}" "${NVME_TEST_DEVS_NAME[1]}" \
+			"${NVME_TEST_DEVS_NAME[2]}" "${NVME_TEST_DEVS_NAME[3]}"
+
+	echo "Test complete"
+}
diff --git a/tests/md/003.out b/tests/md/003.out
new file mode 120000
index 0000000..0412a1f
--- /dev/null
+++ b/tests/md/003.out
@@ -0,0 +1 @@
+002.out
\ No newline at end of file
-- 
2.43.5


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH blktests v2 7/9] md/rc: test atomic writes for dm-linear
  2025-09-22 10:24 [PATCH blktests v2 0/9] Further stacked device atomic writes testing John Garry
                   ` (5 preceding siblings ...)
  2025-09-22 10:24 ` [PATCH blktests v2 6/9] md/003: add NVMe atomic write tests for stacked devices John Garry
@ 2025-09-22 10:24 ` John Garry
  2025-09-22 10:24 ` [PATCH blktests v2 8/9] md/rc: test atomic writes for dm-stripe John Garry
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 18+ messages in thread
From: John Garry @ 2025-09-22 10:24 UTC (permalink / raw)
  To: linux-block, shinichiro.kawasaki; +Cc: John Garry

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 <john.g.garry@oracle.com>
---
 tests/md/002.out | 13 +++++++++++++
 tests/md/rc      | 41 ++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 53 insertions(+), 1 deletion(-)

diff --git a/tests/md/002.out b/tests/md/002.out
index b311a50..5426cf6 100644
--- a/tests/md/002.out
+++ b/tests/md/002.out
@@ -116,4 +116,17 @@ TEST 9 raid10 step 4 - perform a pwritev2 with size of sysfs_atomic_unit_max_byt
 TEST 10 raid10 step 4 - perform a pwritev2 with size of sysfs_atomic_unit_min_bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
 pwrite: Invalid argument
 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
+TEST 1 dm-linear step 1 - Verify md sysfs atomic attributes matches - pass
+TEST 2 dm-linear step 1 - Verify sysfs atomic attributes - pass
+TEST 3 dm-linear step 1 - Verify md sysfs_atomic_write_max is equal to expected_atomic_write_max - pass
+TEST 4 dm-linear step 1 - Verify sysfs atomic_write_unit_max_bytes =  expected_atomic_write_unit_max - pass
+TEST 5 dm-linear step 1 - Verify sysfs atomic_write_unit_boundary_bytes = expected atomic_write_unit_boundary_bytes - pass
+TEST 6 dm-linear step 1 - Verify statx stx_atomic_write_unit_min - pass
+TEST 7 dm-linear step 1 - Verify statx stx_atomic_write_unit_max - pass
+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
+pwrite: Invalid argument
+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
+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
+pwrite: Invalid argument
+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
 Test complete
diff --git a/tests/md/rc b/tests/md/rc
index ee5934c..3209402 100644
--- a/tests/md/rc
+++ b/tests/md/rc
@@ -19,6 +19,9 @@ _stacked_atomic_test_requires() {
 	_have_driver raid0
 	_have_driver raid1
 	_have_driver raid10
+	_have_driver dm-mod
+	_have_program vgcreate
+	_have_program lvm
 }
 
 _max_pow_of_two_factor() {
@@ -85,6 +88,13 @@ _md_atomics_boundaries_max() {
 
 declare -A MD_DEVICES
 
+_get_vgsize() {
+	local vgsize
+
+	vgsize=$(vgdisplay --units b blktests_vg00 | grep 'VG Size' | tr -d -c 0-9)
+	echo "$vgsize"
+}
+
 _md_atomics_test() {
 	local md_sysfs_max_hw_sectors_kb
 	local md_sysfs_max_hw
@@ -147,7 +157,7 @@ _md_atomics_test() {
 		raw_atomic_write_boundary=0;
 	fi
 
-	for personality in raid0 raid1 raid10; do
+	for personality in raid0 raid1 raid10 dm-linear; do
 		local step_limit
 		if [ "$personality" = raid0 ] || [ "$personality" = raid10 ]
 		then
@@ -215,6 +225,26 @@ _md_atomics_test() {
 				md_dev=$(readlink /dev/md/blktests_md | sed 's|\.\./||')
 			fi
 
+			if [ "$personality" = dm-linear ]
+			then
+				for i in "${MD_DEVICES[@]}"; do
+					pvremove --force /dev/"$i" 2> /dev/null 1>&2
+					pvcreate /dev/"$i" 2> /dev/null 1>&2
+				done
+
+				echo y | vgcreate blktests_vg00 /dev/"${dev0}" /dev/"${dev1}" \
+						/dev/"${dev2}" /dev/"${dev3}" 2> /dev/null 1>&2
+			fi
+
+			if [ "$personality" = dm-linear ]
+			then
+				local vgsize
+
+				vgsize=$(_get_vgsize)
+				echo y | lvm lvcreate -v -n blktests_lv -L "${vgsize}"B blktests_vg00 2> /dev/null 1>&2
+				md_dev=$(readlink /dev/mapper/blktests_vg00-blktests_lv | sed 's|\.\./||')
+			fi
+
 			md_dev_sysfs="/sys/devices/virtual/block/${md_dev}"
 
 			sysfs_logical_block_size=$(< "${md_dev_sysfs}"/queue/logical_block_size)
@@ -385,6 +415,15 @@ _md_atomics_test() {
 					mdadm --zero-superblock /dev/"$i" 2> /dev/null 1>&2
 				done
 			fi
+
+			if [ "$personality" = dm-linear ]
+			then
+				lvremove --force  /dev/mapper/blktests_vg00-blktests_lv  2> /dev/null 1>&2
+				vgremove --force blktests_vg00 2> /dev/null 1>&2
+				for i in "${MD_DEVICES[@]}"; do
+					pvremove --force /dev/"$i" 2> /dev/null 1>&2
+				done
+			fi
 		done
 	done
 }
-- 
2.43.5


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH blktests v2 8/9] md/rc: test atomic writes for dm-stripe
  2025-09-22 10:24 [PATCH blktests v2 0/9] Further stacked device atomic writes testing John Garry
                   ` (6 preceding siblings ...)
  2025-09-22 10:24 ` [PATCH blktests v2 7/9] md/rc: test atomic writes for dm-linear John Garry
@ 2025-09-22 10:24 ` John Garry
  2025-09-22 10:24 ` [PATCH blktests v2 9/9] md/rc: test atomic writes for dm-mirror John Garry
  2025-09-25 14:09 ` [PATCH blktests v2 0/9] Further stacked device atomic writes testing Shinichiro Kawasaki
  9 siblings, 0 replies; 18+ messages in thread
From: John Garry @ 2025-09-22 10:24 UTC (permalink / raw)
  To: linux-block, shinichiro.kawasaki; +Cc: John Garry

Ensure that the drives are at least 5MB. This is because we need to know
the size of the volume to create. For dm-linear, we could use vgsize.
However that doesn't work for dm-stripe, as we want the volume to cover
all disks; for that, we need to know the minimum size of each disk.

Signed-off-by: John Garry <john.g.garry@oracle.com>
---
 tests/md/002     |  1 +
 tests/md/002.out | 52 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/md/003     |  1 +
 tests/md/rc      | 29 +++++++++++++++++++++++----
 4 files changed, 79 insertions(+), 4 deletions(-)

diff --git a/tests/md/002 b/tests/md/002
index 65a5fa5..b0cbeb9 100755
--- a/tests/md/002
+++ b/tests/md/002
@@ -23,6 +23,7 @@ test() {
 		num_tgts=1
 		add_host=4
 		per_host_store=true
+		dev_size_mb=5
 	)
 
 	echo "Running md_atomics_test"
diff --git a/tests/md/002.out b/tests/md/002.out
index 5426cf6..cce1b1c 100644
--- a/tests/md/002.out
+++ b/tests/md/002.out
@@ -129,4 +129,56 @@ TEST 9 dm-linear step 1 - perform a pwritev2 with size of sysfs_atomic_unit_max_
 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
 pwrite: Invalid argument
 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
+TEST 1 dm-stripe step 1 - Verify md sysfs atomic attributes matches - pass
+TEST 2 dm-stripe step 1 - Verify sysfs atomic attributes - pass
+TEST 3 dm-stripe step 1 - Verify md sysfs_atomic_write_max is equal to expected_atomic_write_max - pass
+TEST 4 dm-stripe step 1 - Verify sysfs atomic_write_unit_max_bytes =  expected_atomic_write_unit_max - pass
+TEST 5 dm-stripe step 1 - Verify sysfs atomic_write_unit_boundary_bytes = expected atomic_write_unit_boundary_bytes - pass
+TEST 6 dm-stripe step 1 - Verify statx stx_atomic_write_unit_min - pass
+TEST 7 dm-stripe step 1 - Verify statx stx_atomic_write_unit_max - pass
+TEST 8 dm-stripe step 1 - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+pwrite: Invalid argument
+TEST 9 dm-stripe 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
+TEST 10 dm-stripe step 1 - perform a pwritev2 with size of sysfs_atomic_unit_min_bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+pwrite: Invalid argument
+TEST 11 dm-stripe 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
+TEST 1 dm-stripe step 2 - Verify md sysfs atomic attributes matches - pass
+TEST 2 dm-stripe step 2 - Verify sysfs atomic attributes - pass
+TEST 3 dm-stripe step 2 - Verify md sysfs_atomic_write_max is equal to expected_atomic_write_max - pass
+TEST 4 dm-stripe step 2 - Verify sysfs atomic_write_unit_max_bytes =  expected_atomic_write_unit_max - pass
+TEST 5 dm-stripe step 2 - Verify sysfs atomic_write_unit_boundary_bytes = expected atomic_write_unit_boundary_bytes - pass
+TEST 6 dm-stripe step 2 - Verify statx stx_atomic_write_unit_min - pass
+TEST 7 dm-stripe step 2 - Verify statx stx_atomic_write_unit_max - pass
+TEST 8 dm-stripe step 2 - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+pwrite: Invalid argument
+TEST 9 dm-stripe step 2 - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes + LBS bytes with RWF_ATOMIC flag - pwritev2 should not be succesful - pass
+TEST 10 dm-stripe step 2 - perform a pwritev2 with size of sysfs_atomic_unit_min_bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+pwrite: Invalid argument
+TEST 11 dm-stripe step 2 - perform a pwritev2 with a size of sysfs_atomic_write_unit_max_bytes - LBS bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+TEST 1 dm-stripe step 3 - Verify md sysfs atomic attributes matches - pass
+TEST 2 dm-stripe step 3 - Verify sysfs atomic attributes - pass
+TEST 3 dm-stripe step 3 - Verify md sysfs_atomic_write_max is equal to expected_atomic_write_max - pass
+TEST 4 dm-stripe step 3 - Verify sysfs atomic_write_unit_max_bytes =  expected_atomic_write_unit_max - pass
+TEST 5 dm-stripe step 3 - Verify sysfs atomic_write_unit_boundary_bytes = expected atomic_write_unit_boundary_bytes - pass
+TEST 6 dm-stripe step 3 - Verify statx stx_atomic_write_unit_min - pass
+TEST 7 dm-stripe step 3 - Verify statx stx_atomic_write_unit_max - pass
+TEST 8 dm-stripe step 3 - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+pwrite: Invalid argument
+TEST 9 dm-stripe step 3 - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes + LBS bytes with RWF_ATOMIC flag - pwritev2 should not be succesful - pass
+TEST 10 dm-stripe step 3 - perform a pwritev2 with size of sysfs_atomic_unit_min_bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+pwrite: Invalid argument
+TEST 11 dm-stripe step 3 - perform a pwritev2 with a size of sysfs_atomic_write_unit_max_bytes - LBS bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+TEST 1 dm-stripe step 4 - Verify md sysfs atomic attributes matches - pass
+TEST 2 dm-stripe step 4 - Verify sysfs atomic attributes - pass
+TEST 3 dm-stripe step 4 - Verify md sysfs_atomic_write_max is equal to expected_atomic_write_max - pass
+TEST 4 dm-stripe step 4 - Verify sysfs atomic_write_unit_max_bytes =  expected_atomic_write_unit_max - pass
+TEST 5 dm-stripe step 4 - Verify sysfs atomic_write_unit_boundary_bytes = expected atomic_write_unit_boundary_bytes - pass
+TEST 6 dm-stripe step 4 - Verify statx stx_atomic_write_unit_min - pass
+TEST 7 dm-stripe step 4 - Verify statx stx_atomic_write_unit_max - pass
+TEST 8 dm-stripe step 4 - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+pwrite: Invalid argument
+TEST 9 dm-stripe step 4 - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes + LBS bytes with RWF_ATOMIC flag - pwritev2 should not be succesful - pass
+TEST 10 dm-stripe step 4 - perform a pwritev2 with size of sysfs_atomic_unit_min_bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+pwrite: Invalid argument
+TEST 11 dm-stripe 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
 Test complete
diff --git a/tests/md/003 b/tests/md/003
index 5a68480..b9b2075 100755
--- a/tests/md/003
+++ b/tests/md/003
@@ -18,6 +18,7 @@ requires() {
 
 device_requires() {
 	_require_test_dev_is_nvme
+	_require_test_dev_size 5m
 }
 
 test_device_array() {
diff --git a/tests/md/rc b/tests/md/rc
index 3209402..9f0472e 100644
--- a/tests/md/rc
+++ b/tests/md/rc
@@ -157,9 +157,11 @@ _md_atomics_test() {
 		raw_atomic_write_boundary=0;
 	fi
 
-	for personality in raid0 raid1 raid10 dm-linear; do
+
+	for personality in raid0 raid1 raid10 dm-linear dm-stripe; do
 		local step_limit
-		if [ "$personality" = raid0 ] || [ "$personality" = raid10 ]
+		if [ "$personality" = raid0 ] || [ "$personality" = raid10 ] || \
+		    [ "$personality" = dm-stripe ]
 		then
 			step_limit=4
 		else
@@ -225,7 +227,7 @@ _md_atomics_test() {
 				md_dev=$(readlink /dev/md/blktests_md | sed 's|\.\./||')
 			fi
 
-			if [ "$personality" = dm-linear ]
+			if [ "$personality" = dm-linear ] || [ "$personality" = dm-stripe ]
 			then
 				for i in "${MD_DEVICES[@]}"; do
 					pvremove --force /dev/"$i" 2> /dev/null 1>&2
@@ -236,6 +238,25 @@ _md_atomics_test() {
 						/dev/"${dev2}" /dev/"${dev3}" 2> /dev/null 1>&2
 			fi
 
+			if [ "$personality" = dm-stripe ]
+			then
+				atomics_boundaries_unit_max=$(_md_atomics_boundaries_max $raw_atomic_write_boundary $md_chunk_size "1")
+				atomics_boundaries_max=$(_md_atomics_boundaries_max $raw_atomic_write_boundary $md_chunk_size "0")
+
+				# The caller should ensure test device size, we ask for a total of 10M
+				# So each should be at least (10M + meta) / 4 in size, so 5 each should be enough
+				echo y | lvm lvcreate --stripes 4 --stripesize "${md_chunk_size_kb}" -L 10M \
+					-n blktests_lv blktests_vg00 2> /dev/null 1>&2
+				md_dev=$(readlink /dev/mapper/blktests_vg00-blktests_lv | sed 's|\.\./||')
+				expected_atomic_write_unit_min=$(_min "$expected_atomic_write_unit_min" "$atomics_boundaries_unit_max")
+				expected_atomic_write_unit_max=$(_min "$expected_atomic_write_unit_max" "$atomics_boundaries_unit_max")
+				expected_atomic_write_max=$(_min "$expected_atomic_write_max" "$atomics_boundaries_max")
+				if [ "$atomics_boundaries_max" -eq 0 ]
+				then
+					expected_atomic_write_boundary=0
+				fi
+			fi
+
 			if [ "$personality" = dm-linear ]
 			then
 				local vgsize
@@ -416,7 +437,7 @@ _md_atomics_test() {
 				done
 			fi
 
-			if [ "$personality" = dm-linear ]
+			if [ "$personality" = dm-linear ] || [ "$personality" = dm-stripe ]
 			then
 				lvremove --force  /dev/mapper/blktests_vg00-blktests_lv  2> /dev/null 1>&2
 				vgremove --force blktests_vg00 2> /dev/null 1>&2
-- 
2.43.5


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH blktests v2 9/9] md/rc: test atomic writes for dm-mirror
  2025-09-22 10:24 [PATCH blktests v2 0/9] Further stacked device atomic writes testing John Garry
                   ` (7 preceding siblings ...)
  2025-09-22 10:24 ` [PATCH blktests v2 8/9] md/rc: test atomic writes for dm-stripe John Garry
@ 2025-09-22 10:24 ` John Garry
  2025-09-25 14:09 ` [PATCH blktests v2 0/9] Further stacked device atomic writes testing Shinichiro Kawasaki
  9 siblings, 0 replies; 18+ messages in thread
From: John Garry @ 2025-09-22 10:24 UTC (permalink / raw)
  To: linux-block, shinichiro.kawasaki; +Cc: John Garry

Raise the required device size to 16MB, which would be enough to create a
2M mirror array.

Signed-off-by: John Garry <john.g.garry@oracle.com>
---
 tests/md/002     |  2 +-
 tests/md/002.out | 13 +++++++++++++
 tests/md/003     |  2 +-
 tests/md/rc      | 17 +++++++++++++----
 4 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/tests/md/002 b/tests/md/002
index b0cbeb9..1af4bfb 100755
--- a/tests/md/002
+++ b/tests/md/002
@@ -23,7 +23,7 @@ test() {
 		num_tgts=1
 		add_host=4
 		per_host_store=true
-		dev_size_mb=5
+		dev_size_mb=16
 	)
 
 	echo "Running md_atomics_test"
diff --git a/tests/md/002.out b/tests/md/002.out
index cce1b1c..c6628bf 100644
--- a/tests/md/002.out
+++ b/tests/md/002.out
@@ -181,4 +181,17 @@ TEST 9 dm-stripe step 4 - perform a pwritev2 with size of sysfs_atomic_unit_max_
 TEST 10 dm-stripe step 4 - perform a pwritev2 with size of sysfs_atomic_unit_min_bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
 pwrite: Invalid argument
 TEST 11 dm-stripe 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
+TEST 1 dm-mirror step 1 - Verify md sysfs atomic attributes matches - pass
+TEST 2 dm-mirror step 1 - Verify sysfs atomic attributes - pass
+TEST 3 dm-mirror step 1 - Verify md sysfs_atomic_write_max is equal to expected_atomic_write_max - pass
+TEST 4 dm-mirror step 1 - Verify sysfs atomic_write_unit_max_bytes =  expected_atomic_write_unit_max - pass
+TEST 5 dm-mirror step 1 - Verify sysfs atomic_write_unit_boundary_bytes = expected atomic_write_unit_boundary_bytes - pass
+TEST 6 dm-mirror step 1 - Verify statx stx_atomic_write_unit_min - pass
+TEST 7 dm-mirror step 1 - Verify statx stx_atomic_write_unit_max - pass
+TEST 8 dm-mirror step 1 - perform a pwritev2 with size of sysfs_atomic_unit_max_bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+pwrite: Invalid argument
+TEST 9 dm-mirror 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
+TEST 10 dm-mirror step 1 - perform a pwritev2 with size of sysfs_atomic_unit_min_bytes with RWF_ATOMIC flag - pwritev2 should fail - pass
+pwrite: Invalid argument
+TEST 11 dm-mirror 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
 Test complete
diff --git a/tests/md/003 b/tests/md/003
index b9b2075..83746ae 100755
--- a/tests/md/003
+++ b/tests/md/003
@@ -18,7 +18,7 @@ requires() {
 
 device_requires() {
 	_require_test_dev_is_nvme
-	_require_test_dev_size 5m
+	_require_test_dev_size 16m
 }
 
 test_device_array() {
diff --git a/tests/md/rc b/tests/md/rc
index 9f0472e..ba9013d 100644
--- a/tests/md/rc
+++ b/tests/md/rc
@@ -20,6 +20,7 @@ _stacked_atomic_test_requires() {
 	_have_driver raid1
 	_have_driver raid10
 	_have_driver dm-mod
+	_have_driver dm-mirror
 	_have_program vgcreate
 	_have_program lvm
 }
@@ -157,8 +158,7 @@ _md_atomics_test() {
 		raw_atomic_write_boundary=0;
 	fi
 
-
-	for personality in raid0 raid1 raid10 dm-linear dm-stripe; do
+	for personality in raid0 raid1 raid10 dm-linear dm-stripe dm-mirror; do
 		local step_limit
 		if [ "$personality" = raid0 ] || [ "$personality" = raid10 ] || \
 		    [ "$personality" = dm-stripe ]
@@ -227,7 +227,8 @@ _md_atomics_test() {
 				md_dev=$(readlink /dev/md/blktests_md | sed 's|\.\./||')
 			fi
 
-			if [ "$personality" = dm-linear ] || [ "$personality" = dm-stripe ]
+			if [ "$personality" = dm-linear ] || [ "$personality" = dm-stripe ] || \
+				[ "$personality" = dm-mirror ]
 			then
 				for i in "${MD_DEVICES[@]}"; do
 					pvremove --force /dev/"$i" 2> /dev/null 1>&2
@@ -266,6 +267,13 @@ _md_atomics_test() {
 				md_dev=$(readlink /dev/mapper/blktests_vg00-blktests_lv | sed 's|\.\./||')
 			fi
 
+			if [ "$personality" = dm-mirror ]
+			then
+				echo y | lvm lvcreate --type mirror -m3  -L 2M -n blktests_lv blktests_vg00 2> /dev/null 1>&2
+
+				md_dev=$(readlink /dev/mapper/blktests_vg00-blktests_lv | sed 's|\.\./||')
+			fi
+
 			md_dev_sysfs="/sys/devices/virtual/block/${md_dev}"
 
 			sysfs_logical_block_size=$(< "${md_dev_sysfs}"/queue/logical_block_size)
@@ -437,7 +445,8 @@ _md_atomics_test() {
 				done
 			fi
 
-			if [ "$personality" = dm-linear ] || [ "$personality" = dm-stripe ]
+			if [ "$personality" = dm-linear ] || [ "$personality" = dm-stripe ] || \
+				[ "$personality" = dm-mirror ]
 			then
 				lvremove --force  /dev/mapper/blktests_vg00-blktests_lv  2> /dev/null 1>&2
 				vgremove --force blktests_vg00 2> /dev/null 1>&2
-- 
2.43.5


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH blktests v2 6/9] md/003: add NVMe atomic write tests for stacked devices
  2025-09-22 10:24 ` [PATCH blktests v2 6/9] md/003: add NVMe atomic write tests for stacked devices John Garry
@ 2025-09-25  8:39   ` Shinichiro Kawasaki
  2025-09-25  8:46     ` John Garry
  0 siblings, 1 reply; 18+ messages in thread
From: Shinichiro Kawasaki @ 2025-09-25  8:39 UTC (permalink / raw)
  To: John Garry; +Cc: linux-block@vger.kernel.org

On Sep 22, 2025 / 10:24, John Garry wrote:
> md/002 only tests SCSI via scsi_debug.
> 
> It is also useful to test NVMe, so add a specific test for that.
> 
> The results for 002 and 003 should be the same, so link them.
> 
> _md_atomics_test requires 4x devices with atomics support, so check for
> that.
> 
> Signed-off-by: John Garry <john.g.garry@oracle.com>
> ---
>  tests/md/002     |  2 +-
>  tests/md/002.out |  2 +-
>  tests/md/003     | 44 ++++++++++++++++++++++++++++++++++++++++++++
>  tests/md/003.out |  1 +
>  4 files changed, 47 insertions(+), 2 deletions(-)
>  create mode 100755 tests/md/003
>  create mode 120000 tests/md/003.out
> 
> diff --git a/tests/md/002 b/tests/md/002
> index 3e9c1fa..65a5fa5 100755
> --- a/tests/md/002
> +++ b/tests/md/002
> @@ -25,7 +25,7 @@ test() {
>  		per_host_store=true
>  	)
>  
> -	echo "Running ${TEST_NAME}"
> +	echo "Running md_atomics_test"
>  
>  	if ! _configure_scsi_debug "${scsi_debug_params[@]}"; then
>  		return 1
> diff --git a/tests/md/002.out b/tests/md/002.out
> index cd34e38..b311a50 100644
> --- a/tests/md/002.out
> +++ b/tests/md/002.out
> @@ -1,4 +1,4 @@
> -Running md/002
> +Running md_atomics_test
>  TEST 1 raid0 step 1 - Verify md sysfs atomic attributes matches - pass
>  TEST 2 raid0 step 1 - Verify sysfs atomic attributes - pass
>  TEST 3 raid0 step 1 - Verify md sysfs_atomic_write_max is equal to expected_atomic_write_max - pass
> diff --git a/tests/md/003 b/tests/md/003
[...]
> +test_device_array() {
> +	local test_dev
> +	local testdev_count=0
> +	declare -A NVME_TEST_DEVS_NAME
> +
> +	echo "Running md_atomics_test"
> +
> +	for test_dev in "${!TEST_DEV_ARRAY_SYSFS_DIRS[@]}"; do
> +		NVME_TEST_DEVS_NAME["$testdev_count"]="${test_dev##*/}"
> +		let testdev_count=testdev_count+1;
> +	done
> +
> +	if [[ $testdev_count -lt 4 ]]; then
> +		SKIP_REASONS+=("requires at least 4 NVMe devices")
> +		return 1
> +	fi
> +
> +	_md_atomics_test "${NVME_TEST_DEVS_NAME[0]}" "${NVME_TEST_DEVS_NAME[1]}" \
> +			"${NVME_TEST_DEVS_NAME[2]}" "${NVME_TEST_DEVS_NAME[3]}"
> +
> +	echo "Test complete"
> +}

I noticed that the function above can be a bit simpler using TEST_DEV_ARRAY
instead of TEST_DEV_ARRAY_SYSFS_DIRS. The patch below show it.

John, if you are okay with it, I will fold in the change below. Or if you want,
I'm okay to keep your code as it is. Please let me know your thougths.

diff --git a/tests/md/003 b/tests/md/003
index 83746ae..f4f35db 100755
--- a/tests/md/003
+++ b/tests/md/003
@@ -22,24 +22,15 @@ device_requires() {
 }
 
 test_device_array() {
-	local test_dev
-	local testdev_count=0
-	declare -A NVME_TEST_DEVS_NAME
-
 	echo "Running md_atomics_test"
 
-	for test_dev in "${!TEST_DEV_ARRAY_SYSFS_DIRS[@]}"; do
-		NVME_TEST_DEVS_NAME["$testdev_count"]="${test_dev##*/}"
-		let testdev_count=testdev_count+1;
-	done
-
-	if [[ $testdev_count -lt 4 ]]; then
+	if [[ ${#TEST_DEV_ARRAY[@]} -lt 4 ]]; then
 		SKIP_REASONS+=("requires at least 4 NVMe devices")
 		return 1
 	fi
 
-	_md_atomics_test "${NVME_TEST_DEVS_NAME[0]}" "${NVME_TEST_DEVS_NAME[1]}" \
-			"${NVME_TEST_DEVS_NAME[2]}" "${NVME_TEST_DEVS_NAME[3]}"
+	_md_atomics_test "${TEST_DEV_ARRAY[0]##*/}" "${TEST_DEV_ARRAY[1]##*/}" \
+			 "${TEST_DEV_ARRAY[2]##*/}" "${TEST_DEV_ARRAY[3]##*/}"
 
 	echo "Test complete"
 }


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH blktests v2 6/9] md/003: add NVMe atomic write tests for stacked devices
  2025-09-25  8:39   ` Shinichiro Kawasaki
@ 2025-09-25  8:46     ` John Garry
  2025-09-25 14:12       ` Shinichiro Kawasaki
  0 siblings, 1 reply; 18+ messages in thread
From: John Garry @ 2025-09-25  8:46 UTC (permalink / raw)
  To: Shinichiro Kawasaki; +Cc: linux-block@vger.kernel.org

On 25/09/2025 09:39, Shinichiro Kawasaki wrote:
>> +	echo "Test complete"
>> +}
> I noticed that the function above can be a bit simpler using TEST_DEV_ARRAY
> instead of TEST_DEV_ARRAY_SYSFS_DIRS. The patch below show it.
> 
> John, if you are okay with it, I will fold in the change below. Or if you want,
> I'm okay to keep your code as it is. Please let me know your thougths.

Yeah, it seems ok.

Let me know if you have a branch you want to test with all your changes.

Thanks

> 
> diff --git a/tests/md/003 b/tests/md/003
> index 83746ae..f4f35db 100755
> --- a/tests/md/003
> +++ b/tests/md/003
> @@ -22,24 +22,15 @@ device_requires() {
>   }
>   
>   test_device_array() {
> -	local test_dev
> -	local testdev_count=0
> -	declare -A NVME_TEST_DEVS_NAME
> -
>   	echo "Running md_atomics_test"
>   
> -	for test_dev in "${!TEST_DEV_ARRAY_SYSFS_DIRS[@]}"; do
> -		NVME_TEST_DEVS_NAME["$testdev_count"]="${test_dev##*/}"
> -		let testdev_count=testdev_count+1;
> -	done
> -
> -	if [[ $testdev_count -lt 4 ]]; then
> +	if [[ ${#TEST_DEV_ARRAY[@]} -lt 4 ]]; then
>   		SKIP_REASONS+=("requires at least 4 NVMe devices")
>   		return 1
>   	fi
>   
> -	_md_atomics_test "${NVME_TEST_DEVS_NAME[0]}" "${NVME_TEST_DEVS_NAME[1]}" \
> -			"${NVME_TEST_DEVS_NAME[2]}" "${NVME_TEST_DEVS_NAME[3]}"
> +	_md_atomics_test "${TEST_DEV_ARRAY[0]##*/}" "${TEST_DEV_ARRAY[1]##*/}" \
> +			 "${TEST_DEV_ARRAY[2]##*/}" "${TEST_DEV_ARRAY[3]##*/}"
>   
>   	echo "Test complete"
>   }


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH blktests v2 0/9] Further stacked device atomic writes testing
  2025-09-22 10:24 [PATCH blktests v2 0/9] Further stacked device atomic writes testing John Garry
                   ` (8 preceding siblings ...)
  2025-09-22 10:24 ` [PATCH blktests v2 9/9] md/rc: test atomic writes for dm-mirror John Garry
@ 2025-09-25 14:09 ` Shinichiro Kawasaki
  2025-09-25 14:13   ` John Garry
  9 siblings, 1 reply; 18+ messages in thread
From: Shinichiro Kawasaki @ 2025-09-25 14:09 UTC (permalink / raw)
  To: John Garry; +Cc: linux-block@vger.kernel.org

On Sep 22, 2025 / 10:24, John Garry wrote:
> The testing of atomic writes support for stacked devices is limited.
> 
> We only test scsi_debug and for a limited sets of personalities.
> 
> Extend to test NVMe and also extend to the following stacked device
> personalities:
> - dm-linear
> - dm-stripe
> - dm-mirror
> 
> Also add more strict atomic writes limits testing.
> 
> Based on https://lore.kernel.org/linux-block/20250917114920.142996-1-shinichiro.kawasaki@wdc.com/#t
> 
> Differences to v1:
> (all based on comments from Shin'ichiro)
> - Rebase on "support testing with multiple devices" series
> - clean up "make check" issues and other coding style issues
> - Relocate some NVMe helpers
> - Add _stacked_atomic_test_requires helper

Thanks for this v2 series. I applied it.

> 
> John Garry (9):
>   common/rc: add _min()
>   nvme: relocate _nvme_requires and _require_nvme_test_img_size
>   nvme: relocate _require_test_dev_is_nvme

I dropped this patch since it is no longer required by virtue of the other
recent commit [*].

[*] https://github.com/linux-blktests/blktests/commit/ca6de24a9b67d4a7387871cb71307d1f6cc9c0e9

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH blktests v2 6/9] md/003: add NVMe atomic write tests for stacked devices
  2025-09-25  8:46     ` John Garry
@ 2025-09-25 14:12       ` Shinichiro Kawasaki
  2025-09-25 14:14         ` John Garry
  0 siblings, 1 reply; 18+ messages in thread
From: Shinichiro Kawasaki @ 2025-09-25 14:12 UTC (permalink / raw)
  To: John Garry; +Cc: linux-block@vger.kernel.org

On Sep 25, 2025 / 09:46, John Garry wrote:
> On 25/09/2025 09:39, Shinichiro Kawasaki wrote:
> > > +	echo "Test complete"
> > > +}
> > I noticed that the function above can be a bit simpler using TEST_DEV_ARRAY
> > instead of TEST_DEV_ARRAY_SYSFS_DIRS. The patch below show it.
> > 
> > John, if you are okay with it, I will fold in the change below. Or if you want,
> > I'm okay to keep your code as it is. Please let me know your thougths.
> 
> Yeah, it seems ok.

Thanks, I folded in the change then applied together with the other patchces.

> 
> Let me know if you have a branch you want to test with all your changes.

I did test runs using regular QEMU NVME devices, so I have some confidence that
my changes are good. Your confirmation test on the current blktests master
branch tip will be appreciated.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH blktests v2 0/9] Further stacked device atomic writes testing
  2025-09-25 14:09 ` [PATCH blktests v2 0/9] Further stacked device atomic writes testing Shinichiro Kawasaki
@ 2025-09-25 14:13   ` John Garry
  0 siblings, 0 replies; 18+ messages in thread
From: John Garry @ 2025-09-25 14:13 UTC (permalink / raw)
  To: Shinichiro Kawasaki; +Cc: linux-block@vger.kernel.org

On 25/09/2025 15:09, Shinichiro Kawasaki wrote:
> On Sep 22, 2025 / 10:24, John Garry wrote:
>> The testing of atomic writes support for stacked devices is limited.
>>
>> We only test scsi_debug and for a limited sets of personalities.
>>
>> Extend to test NVMe and also extend to the following stacked device
>> personalities:
>> - dm-linear
>> - dm-stripe
>> - dm-mirror
>>
>> Also add more strict atomic writes limits testing.
>>
>> Based on https://lore.kernel.org/linux-block/20250917114920.142996-1-shinichiro.kawasaki@wdc.com/#t
>>
>> Differences to v1:
>> (all based on comments from Shin'ichiro)
>> - Rebase on "support testing with multiple devices" series
>> - clean up "make check" issues and other coding style issues
>> - Relocate some NVMe helpers
>> - Add _stacked_atomic_test_requires helper
> 
> Thanks for this v2 series. I applied it.

Great, thanks

> 
>>
>> John Garry (9):
>>    common/rc: add _min()
>>    nvme: relocate _nvme_requires and _require_nvme_test_img_size
>>    nvme: relocate _require_test_dev_is_nvme
> 
> I dropped this patch since it is no longer required by virtue of the other
> recent commit [*].
> 

Yeah, I noticed that on the list :)

> [*] https://github.com/linux-blktests/blktests/commit/ca6de24a9b67d4a7387871cb71307d1f6cc9c0e9


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH blktests v2 6/9] md/003: add NVMe atomic write tests for stacked devices
  2025-09-25 14:12       ` Shinichiro Kawasaki
@ 2025-09-25 14:14         ` John Garry
  2025-09-25 15:02           ` John Garry
  0 siblings, 1 reply; 18+ messages in thread
From: John Garry @ 2025-09-25 14:14 UTC (permalink / raw)
  To: Shinichiro Kawasaki; +Cc: linux-block@vger.kernel.org

On 25/09/2025 15:12, Shinichiro Kawasaki wrote:
>> Let me know if you have a branch you want to test with all your changes.
> I did test runs using regular QEMU NVME devices, so I have some confidence that
> my changes are good. Your confirmation test on the current blktests master
> branch tip will be appreciated.

Will do today/tomorrow

thanks

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH blktests v2 6/9] md/003: add NVMe atomic write tests for stacked devices
  2025-09-25 14:14         ` John Garry
@ 2025-09-25 15:02           ` John Garry
  2025-09-25 23:53             ` Shinichiro Kawasaki
  0 siblings, 1 reply; 18+ messages in thread
From: John Garry @ 2025-09-25 15:02 UTC (permalink / raw)
  To: Shinichiro Kawasaki; +Cc: linux-block@vger.kernel.org

On 25/09/2025 15:14, John Garry wrote:
> On 25/09/2025 15:12, Shinichiro Kawasaki wrote:
>>> Let me know if you have a branch you want to test with all your changes.
>> I did test runs using regular QEMU NVME devices, so I have some 
>> confidence that
>> my changes are good. Your confirmation test on the current blktests 
>> master
>> branch tip will be appreciated.
> 
> Will do today/tomorrow

it works ok for md/002 and md/003, thanks!

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH blktests v2 6/9] md/003: add NVMe atomic write tests for stacked devices
  2025-09-25 15:02           ` John Garry
@ 2025-09-25 23:53             ` Shinichiro Kawasaki
  0 siblings, 0 replies; 18+ messages in thread
From: Shinichiro Kawasaki @ 2025-09-25 23:53 UTC (permalink / raw)
  To: John Garry; +Cc: linux-block@vger.kernel.org

On Sep 25, 2025 / 16:02, John Garry wrote:
> On 25/09/2025 15:14, John Garry wrote:
> > On 25/09/2025 15:12, Shinichiro Kawasaki wrote:
> > > > Let me know if you have a branch you want to test with all your changes.
> > > I did test runs using regular QEMU NVME devices, so I have some
> > > confidence that
> > > my changes are good. Your confirmation test on the current blktests
> > > master
> > > branch tip will be appreciated.
> > 
> > Will do today/tomorrow
> 
> it works ok for md/002 and md/003, thanks!

It's good to know, thanks!

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2025-09-25 23:53 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-22 10:24 [PATCH blktests v2 0/9] Further stacked device atomic writes testing John Garry
2025-09-22 10:24 ` [PATCH blktests v2 1/9] common/rc: add _min() John Garry
2025-09-22 10:24 ` [PATCH blktests v2 2/9] nvme: relocate _nvme_requires and _require_nvme_test_img_size John Garry
2025-09-22 10:24 ` [PATCH blktests v2 3/9] nvme: relocate _require_test_dev_is_nvme John Garry
2025-09-22 10:24 ` [PATCH blktests v2 4/9] md/rc: add _md_atomics_test John Garry
2025-09-22 10:24 ` [PATCH blktests v2 5/9] md/002: convert to use _md_atomics_test John Garry
2025-09-22 10:24 ` [PATCH blktests v2 6/9] md/003: add NVMe atomic write tests for stacked devices John Garry
2025-09-25  8:39   ` Shinichiro Kawasaki
2025-09-25  8:46     ` John Garry
2025-09-25 14:12       ` Shinichiro Kawasaki
2025-09-25 14:14         ` John Garry
2025-09-25 15:02           ` John Garry
2025-09-25 23:53             ` Shinichiro Kawasaki
2025-09-22 10:24 ` [PATCH blktests v2 7/9] md/rc: test atomic writes for dm-linear John Garry
2025-09-22 10:24 ` [PATCH blktests v2 8/9] md/rc: test atomic writes for dm-stripe John Garry
2025-09-22 10:24 ` [PATCH blktests v2 9/9] md/rc: test atomic writes for dm-mirror John Garry
2025-09-25 14:09 ` [PATCH blktests v2 0/9] Further stacked device atomic writes testing Shinichiro Kawasaki
2025-09-25 14:13   ` John Garry

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox