Skip to contentSkip to conversation

common/atomicwrites: fix _require_scratch_write_atomic when awu_max_fs is empty

PATCH In review Zorro Lang 4 participants 4 messages Sep 6, 2025 – Nov 14, 2025

lore
Share & tools
lore

Zorro Lang

author
#0 lore raw

PATCH 1/1 common/atomicwrites: fix _require_scratch_write_atomic when awu_max_fs is empty

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.

---
 common/atomicwrites | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
common/atomicwrites +6 -3
index 33526399d..bbcc4e7c5 100644
@@ -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
 }
Signature · 1 line
2.49.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 42 lines · Zorro Lang

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.

---
  common/atomicwrites | 9 ++++++---
  1 file changed, 6 insertions(+), 3 deletions(-)
common/atomicwrites +4 -2
index 33526399d..bbcc4e7c5 100644
@@ -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
 

common/atomicwrites _require_scratch_write_atomic() · line 84

Quoted 9 lines
common/atomicwrites +2 -1
@@ -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 on v1 1/1
#2 lore raw
In reply to Zorro Lang
Quoted 6 lines · Zorro Lang

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)
Quoted 6 lines

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.

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

Feel free to add:

Regards,
ojaswin

#3 lore raw
Quoted 12 lines · Ojaswin Mujoo
Quoted 11 lines · Zorro Lang

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.

Quoted 7 lines
Quoted 1 line

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

Feel free to add:

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

Quoted 4 lines

Regards,
ojaswin