public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] common/atomicwrites: fix _require_scratch_write_atomic when awu_max_fs is empty
@ 2025-09-06 13:17 Zorro Lang
  2025-10-20 11:33 ` Pavel Reichl
  2025-11-14 10:24 ` Ojaswin Mujoo
  0 siblings, 2 replies; 4+ messages in thread
From: Zorro Lang @ 2025-09-06 13:17 UTC (permalink / raw)
  To: fstests; +Cc: djwong

If a kernel doesn't support atomic write, _get_atomic_write_unit_min
and _get_atomic_write_unit_max will get nothing.

  local awu_min_bdev=$(_get_atomic_write_unit_min $SCRATCH_DEV)
  local awu_max_bdev=$(_get_atomic_write_unit_max $SCRATCH_DEV)

If $awu_min_bdev and $awu_max_bdev are empty, then the logic likes
"[ $awu_min_bdev -eq 0 ] && [ $awu_max_bdev -eq 0 ]" is meaningless,
and it causes g/767 hang on system which doesn't support atomic
write.

Signed-off-by: Zorro Lang <zlang@kernel.org>
---
 common/atomicwrites | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/common/atomicwrites b/common/atomicwrites
index 33526399d..bbcc4e7c5 100644
--- a/common/atomicwrites
+++ b/common/atomicwrites
@@ -47,8 +47,9 @@ _require_scratch_write_atomic_multi_fsblock()
 
 	_scratch_unmount
 
-	test $awu_max_fs -ge $((bsize * 2)) || \
+	if [ -z "$awu_max_fs" -o $awu_max_fs -lt $((bsize * 2)) ];then
 		_notrun "multi-block atomic writes not supported by this filesystem"
+	fi
 }
 
 _require_scratch_write_atomic()
@@ -58,7 +59,8 @@ _require_scratch_write_atomic()
 	local awu_min_bdev=$(_get_atomic_write_unit_min $SCRATCH_DEV)
 	local awu_max_bdev=$(_get_atomic_write_unit_max $SCRATCH_DEV)
 
-	if [ $awu_min_bdev -eq 0 ] && [ $awu_max_bdev -eq 0 ]; then
+	if [ -z "$awu_min_bdev" -o -z "$awu_max_bdev" ] || \
+		[ $awu_min_bdev -eq 0 -a $awu_max_bdev -eq 0 ];then
 		_notrun "write atomic not supported by this block device"
 	fi
 
@@ -75,7 +77,8 @@ _require_scratch_write_atomic()
 
 	_scratch_unmount
 
-	if [ $awu_min_fs -eq 0 ] && [ $awu_max_fs -eq 0 ]; then
+	if [ -z "$awu_min_fs" -o -z "$awu_max_fs" ] || \
+		[ $awu_min_fs -eq 0 -a $awu_max_fs -eq 0 ];then
 		_notrun "write atomic not supported by this filesystem"
 	fi
 }
-- 
2.49.0


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

* Re: [PATCH] common/atomicwrites: fix _require_scratch_write_atomic when awu_max_fs is empty
  2025-09-06 13:17 [PATCH] common/atomicwrites: fix _require_scratch_write_atomic when awu_max_fs is empty Zorro Lang
@ 2025-10-20 11:33 ` Pavel Reichl
  2025-11-14 10:24 ` Ojaswin Mujoo
  1 sibling, 0 replies; 4+ messages in thread
From: Pavel Reichl @ 2025-10-20 11:33 UTC (permalink / raw)
  To: Zorro Lang, fstests; +Cc: djwong

On 06/09/2025 15:17, Zorro Lang wrote:
> If a kernel doesn't support atomic write, _get_atomic_write_unit_min
> and _get_atomic_write_unit_max will get nothing.
>
>    local awu_min_bdev=$(_get_atomic_write_unit_min $SCRATCH_DEV)
>    local awu_max_bdev=$(_get_atomic_write_unit_max $SCRATCH_DEV)
>
> If $awu_min_bdev and $awu_max_bdev are empty, then the logic likes
> "[ $awu_min_bdev -eq 0 ] && [ $awu_max_bdev -eq 0 ]" is meaningless,
> and it causes g/767 hang on system which doesn't support atomic
> write.
>
> Signed-off-by: Zorro Lang <zlang@kernel.org>
> ---
>   common/atomicwrites | 9 ++++++---
>   1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/common/atomicwrites b/common/atomicwrites
> index 33526399d..bbcc4e7c5 100644
> --- a/common/atomicwrites
> +++ b/common/atomicwrites
> @@ -47,8 +47,9 @@ _require_scratch_write_atomic_multi_fsblock()
>   
>   	_scratch_unmount
>   
> -	test $awu_max_fs -ge $((bsize * 2)) || \
> +	if [ -z "$awu_max_fs" -o $awu_max_fs -lt $((bsize * 2)) ];then
>   		_notrun "multi-block atomic writes not supported by this filesystem"
> +	fi
>   }
>   
>   _require_scratch_write_atomic()
> @@ -58,7 +59,8 @@ _require_scratch_write_atomic()
>   	local awu_min_bdev=$(_get_atomic_write_unit_min $SCRATCH_DEV)
>   	local awu_max_bdev=$(_get_atomic_write_unit_max $SCRATCH_DEV)
>   
> -	if [ $awu_min_bdev -eq 0 ] && [ $awu_max_bdev -eq 0 ]; then
> +	if [ -z "$awu_min_bdev" -o -z "$awu_max_bdev" ] || \
> +		[ $awu_min_bdev -eq 0 -a $awu_max_bdev -eq 0 ];then
>   		_notrun "write atomic not supported by this block device"
>   	fi
>   
> @@ -75,7 +77,8 @@ _require_scratch_write_atomic()
>   
>   	_scratch_unmount
>   
> -	if [ $awu_min_fs -eq 0 ] && [ $awu_max_fs -eq 0 ]; then
> +	if [ -z "$awu_min_fs" -o -z "$awu_max_fs" ] || \
> +		[ $awu_min_fs -eq 0 -a $awu_max_fs -eq 0 ];then
>   		_notrun "write atomic not supported by this filesystem"
>   	fi
>   }

LGTM

Reviewed-by: Pavel Reichl <preichl@redhat.com>



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

* Re: [PATCH] common/atomicwrites: fix _require_scratch_write_atomic when awu_max_fs is empty
  2025-09-06 13:17 [PATCH] common/atomicwrites: fix _require_scratch_write_atomic when awu_max_fs is empty Zorro Lang
  2025-10-20 11:33 ` Pavel Reichl
@ 2025-11-14 10:24 ` Ojaswin Mujoo
  2025-11-14 16:17   ` Zorro Lang
  1 sibling, 1 reply; 4+ messages in thread
From: Ojaswin Mujoo @ 2025-11-14 10:24 UTC (permalink / raw)
  To: Zorro Lang; +Cc: fstests, djwong

On Sat, Sep 06, 2025 at 09:17:22PM +0800, Zorro Lang wrote:
> If a kernel doesn't support atomic write, _get_atomic_write_unit_min
> and _get_atomic_write_unit_max will get nothing.
> 
>   local awu_min_bdev=$(_get_atomic_write_unit_min $SCRATCH_DEV)
>   local awu_max_bdev=$(_get_atomic_write_unit_max $SCRATCH_DEV)
> 
> If $awu_min_bdev and $awu_max_bdev are empty, then the logic likes
> "[ $awu_min_bdev -eq 0 ] && [ $awu_max_bdev -eq 0 ]" is meaningless,
> and it causes g/767 hang on system which doesn't support atomic
> write.
> 
> Signed-off-by: Zorro Lang <zlang@kernel.org>

I can confirm that this fixes the hang seen when xfs_io doesn't report
atomic write limits.

Feel free to add:
Reviewed-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>

Regards,
ojaswin

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

* Re: [PATCH] common/atomicwrites: fix _require_scratch_write_atomic when awu_max_fs is empty
  2025-11-14 10:24 ` Ojaswin Mujoo
@ 2025-11-14 16:17   ` Zorro Lang
  0 siblings, 0 replies; 4+ messages in thread
From: Zorro Lang @ 2025-11-14 16:17 UTC (permalink / raw)
  To: Ojaswin Mujoo; +Cc: Zorro Lang, fstests, djwong

On Fri, Nov 14, 2025 at 03:54:00PM +0530, Ojaswin Mujoo wrote:
> On Sat, Sep 06, 2025 at 09:17:22PM +0800, Zorro Lang wrote:
> > If a kernel doesn't support atomic write, _get_atomic_write_unit_min
> > and _get_atomic_write_unit_max will get nothing.
> > 
> >   local awu_min_bdev=$(_get_atomic_write_unit_min $SCRATCH_DEV)
> >   local awu_max_bdev=$(_get_atomic_write_unit_max $SCRATCH_DEV)
> > 
> > If $awu_min_bdev and $awu_max_bdev are empty, then the logic likes
> > "[ $awu_min_bdev -eq 0 ] && [ $awu_max_bdev -eq 0 ]" is meaningless,
> > and it causes g/767 hang on system which doesn't support atomic
> > write.
> > 
> > Signed-off-by: Zorro Lang <zlang@kernel.org>
> 
> I can confirm that this fixes the hang seen when xfs_io doesn't report
> atomic write limits.
> 
> Feel free to add:
> Reviewed-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>

Thanks Ojaswin, this patch has been merged, feel free to use the lastest
xfstests to avoid this issue :)

> 
> Regards,
> ojaswin
> 


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

end of thread, other threads:[~2025-11-14 16:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-06 13:17 [PATCH] common/atomicwrites: fix _require_scratch_write_atomic when awu_max_fs is empty Zorro Lang
2025-10-20 11:33 ` Pavel Reichl
2025-11-14 10:24 ` Ojaswin Mujoo
2025-11-14 16:17   ` Zorro Lang

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