Linux block layer
 help / color / mirror / Atom feed
From: John Garry <john.g.garry@oracle.com>
To: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Cc: "linux-block@vger.kernel.org" <linux-block@vger.kernel.org>
Subject: Re: [PATCH blktests 2/7] md/rc: add _md_atomics_test
Date: Thu, 18 Sep 2025 08:36:43 +0100	[thread overview]
Message-ID: <524a89e8-a9bf-47f8-adf4-3f2432ef7d58@oracle.com> (raw)
In-Reply-To: <lraho55tl3vglno2cpcackn2s6fwirhbyzbtjj3tdwij4z7yav@ka6oyi2p4ohr>

On 18/09/2025 05:17, Shinichiro Kawasaki wrote:
> On Sep 12, 2025 / 09:57, John Garry wrote:
>> 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 | 372 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 372 insertions(+)
>>
>> diff --git a/tests/md/rc b/tests/md/rc
>> index 96bcd97..105d283 100644
>> --- a/tests/md/rc
>> +++ b/tests/md/rc
>> @@ -5,9 +5,381 @@
>>   # Tests for md raid
>>   
>>   . common/rc
>> +. common/xfs
>>   
>>   group_requires() {
>> +	_have_kver 6 14 0
>>   	_have_root
>>   	_have_program mdadm
>> +	_have_xfs_io_atomic_write
> 
> I don't think either "_have_kver 6 14 0" or "_have_xfs_io_atomic_write" is
> required for md/001. I suggest to introduce a new helper,
> 
>   _stacked_atomic_test_requires() {
>       _have_kver 6 14 0
>       _have_xfs_io_atomic_write
>   }
> 
> and call it from requires() of md/002 and md/003.

ok, fine

> 
>> +	_have_driver raid0
>> +	_have_driver raid1
>> +	_have_driver raid10
>>   	_have_driver md-mod
>>   }
>> +
>> +declare -A MD_DEVICES
>> +
>> +_max_pow_of_two_factor() {
>> +	part1=$1
>> +	part2=-$1
>> +	retval=$(($part1 & $part2))
> 
> Nit: "local" declarations are missing for part1, part2 and retval.
> Same comment for some other local variables introduced by this patch.
> 

ok, will fix

>> +	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() {
>> +	boundary=$1
>> +	chunk=$2
>> +	unit=$3
>> +
>> +	if [ "$boundary" -eq 0 ]
>> +	then
>> +		if [ "$unit" -eq 1 ]
>> +		then
>> +			retval=$(_max_pow_of_two_factor $chunk)
>> +			echo "$retval"
>> +			return 1
>> +		fi
>> +
>> +		echo "$chunk"
>> +		return 1
> 
> When bash functions return non-zero value, it implies the functions failed.
> When this function returns 1 at the line above, does it indicate failure?
> It looks echoing back a good number, so I guess just "return" is more
> appropriate. Same comment for other "return 1" in this function.

this function should not fail, so I will just use "return"

> 
>> +	fi
>> +
>> +	# boundary is always a power-of-2
>> +	if [ "$boundary" -eq "$chunk" ]
>> +	then
>> +		echo "$boundary"
>> +		return 1
>> +	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 1
>> +			fi
>> +			echo "$chunk"
>> +			return 1
>> +		fi
>> +		echo "0"
>> +		return 1
>> +	fi
>> +
>> +	if (( $chunk % $boundary == 0))
>> +	then
>> +		echo "$boundary"
>> +		return 1
>> +	fi
>> +
>> +	echo "0"
>> +}

Thanks,
John

  reply	other threads:[~2025-09-18  7:36 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-12  9:57 [PATCH blktests 0/7] Further stacked device atomic writes testing John Garry
2025-09-12  9:57 ` [PATCH blktests 1/7] common/rc: add _min() John Garry
2025-09-18  4:08   ` Shinichiro Kawasaki
2025-09-18  7:33     ` John Garry
2025-09-12  9:57 ` [PATCH blktests 2/7] md/rc: add _md_atomics_test John Garry
2025-09-18  4:17   ` Shinichiro Kawasaki
2025-09-18  7:36     ` John Garry [this message]
2025-09-12  9:57 ` [PATCH blktests 3/7] md/002: convert to use _md_atomics_test John Garry
2025-09-12  9:57 ` [PATCH blktests 4/7] md/003: add NVMe atomic write tests for stacked devices John Garry
2025-09-18  4:27   ` Shinichiro Kawasaki
2025-09-18  7:44     ` John Garry
2025-09-12  9:57 ` [PATCH blktests 5/7] md/rc: test atomic writes for dm-linear John Garry
2025-09-12  9:57 ` [PATCH blktests 6/7] md/rc: test atomic writes for dm-stripe John Garry
2025-09-12  9:57 ` [PATCH blktests 7/7] md/rc: test atomic writes for dm-mirror John Garry
2025-09-16  8:55 ` [PATCH blktests 0/7] Further stacked device atomic writes testing Shinichiro Kawasaki
2025-09-16 10:20   ` John Garry
2025-09-16 11:55     ` John Garry
2025-09-16 12:23       ` Shinichiro Kawasaki
2025-09-16 12:27         ` John Garry
2025-09-17 12:02           ` Shinichiro Kawasaki
2025-09-17 13:12             ` John Garry
2025-09-17 16:22               ` John Garry
2025-09-18  4:36                 ` Shinichiro Kawasaki
2025-09-18  7:48                   ` John Garry
2025-09-18 10:37                     ` Shinichiro Kawasaki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=524a89e8-a9bf-47f8-adf4-3f2432ef7d58@oracle.com \
    --to=john.g.garry@oracle.com \
    --cc=linux-block@vger.kernel.org \
    --cc=shinichiro.kawasaki@wdc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox