Skip to contentSkip to conversation

generic/033: Check that the 'fzero' operations supports KEEP_SIZE

PATCH In review Anna Schumaker 4 participants 4 messages Apr 24, 2025 – Apr 25, 2025

Subsystems (2)
lore
Share & tools
lore

Anna Schumaker

author maintainer
#0 lore raw

PATCH 1/1 generic/033: Check that the 'fzero' operations supports KEEP_SIZE

From: Anna Schumaker <[email protected]>

Otherwise this test will fail on filesystems that implement FALLOC_FL_ZERO_RANGE but not the optional FALLOC_FL_KEEP_SIZE flag.

---
 tests/generic/033 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/generic/033 +1 -1
index a9a9ff5a3431..a33f6add67bf 100755
@@ -20,7 +20,7 @@ _begin_fstest auto quick rw zero
 
 # Modify as appropriate.
 _require_scratch
-_require_xfs_io_command "fzero"
+_require_xfs_io_command "fzero" "-k"
 
 _scratch_mkfs >/dev/null 2>&1
 _scratch_mount
Signature · 1 line
2.49.0
#1 lore raw
Quoted 15 lines · Anna Schumaker

From: Anna Schumaker <[email protected]>

Otherwise this test will fail on filesystems that implement FALLOC_FL_ZERO_RANGE but not the optional FALLOC_FL_KEEP_SIZE flag.

---
 tests/generic/033 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/generic/033 +0 -0
index a9a9ff5a3431..a33f6add67bf 100755

tests/generic/033 _begin_fstest auto quick rw zero · line 23

Quoted 5 lines
tests/generic/033 +1 -1
@@ -20,7 +20,7 @@ _begin_fstest auto quick rw zero
 
 # Modify as appropriate.
 _require_scratch
-_require_xfs_io_command "fzero"
+_require_xfs_io_command "fzero" "-k"

I wonder, does this test even need KEEP_SIZE? It writes 64MB to the file, then it fzeros every other 4k up to (64M-4k), then fzeroes everything else. AFAICT the fzero commands never exceed the file size...though I could be wrong.

--D

Quoted 7 lines
tests/generic/033 +0 -0
 _scratch_mkfs >/dev/null 2>&1
 _scratch_mount
Signature · 1 line
2.49.0
#2 lore raw
Quoted 17 lines · Darrick J. Wong
Quoted 16 lines · Anna Schumaker

From: Anna Schumaker <[email protected]>

Otherwise this test will fail on filesystems that implement FALLOC_FL_ZERO_RANGE but not the optional FALLOC_FL_KEEP_SIZE flag.

---
 tests/generic/033 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/generic/033 +0 -0
index a9a9ff5a3431..a33f6add67bf 100755
@@ -20,7 +20,7 @@ _begin_fstest auto quick rw zero
 
Quoted 9 lines

tests/generic/033 _begin_fstest auto quick rw zero · line 23

Quoted 4 lines
tests/generic/033 +1 -1
 # Modify as appropriate.
 _require_scratch
-_require_xfs_io_command "fzero"
+_require_xfs_io_command "fzero" "-k"

I wonder, does this test even need KEEP_SIZE? It writes 64MB to the file, then it fzeros every other 4k up to (64M-4k), then fzeroes everything else. AFAICT the fzero commands never exceed the file size...though I could be wrong.

Hmm... I think you're right, the code logic is:

  bytes=$((64 * 1024))
  $XFS_IO_PROG -f -c "pwrite 0 $bytes" $file
  endoff=$((bytes - 4096))
  for i in $(seq 0 8192 $endoff); do
          $XFS_IO_PROG -c "fzero -k $i 4k" $file
  done
  for i in $(seq 4096 8192 $endoff); do
          $XFS_IO_PROG -c "fzero -k $i 4k" $file
  done

So looks like the offset+len isn't greater than the file size. So we might can remove the "-k" directly. What do you think ?

Thanks,
Zorro

Quoted 11 lines

--D

Quoted 7 lines
tests/generic/033 +0 -0
 _scratch_mkfs >/dev/null 2>&1
 _scratch_mount
Signature · 1 line
2.49.0
#3 lore raw
Quoted 40 lines · Zorro Lang
Quoted 17 lines · Darrick J. Wong
Quoted 16 lines · Anna Schumaker

From: Anna Schumaker <[email protected]>

Otherwise this test will fail on filesystems that implement FALLOC_FL_ZERO_RANGE but not the optional FALLOC_FL_KEEP_SIZE flag.

---
 tests/generic/033 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/generic/033 +0 -0
index a9a9ff5a3431..a33f6add67bf 100755
@@ -20,7 +20,7 @@ _begin_fstest auto quick rw zero
 
Quoted 9 lines

tests/generic/033 _begin_fstest auto quick rw zero · line 23

Quoted 4 lines
tests/generic/033 +1 -1
 # Modify as appropriate.
 _require_scratch
-_require_xfs_io_command "fzero"
+_require_xfs_io_command "fzero" "-k"

I wonder, does this test even need KEEP_SIZE? It writes 64MB to the file, then it fzeros every other 4k up to (64M-4k), then fzeroes everything else. AFAICT the fzero commands never exceed the file size...though I could be wrong.

Hmm... I think you're right, the code logic is:

  bytes=$((64 * 1024))
  $XFS_IO_PROG -f -c "pwrite 0 $bytes" $file
  endoff=$((bytes - 4096))
  for i in $(seq 0 8192 $endoff); do
          $XFS_IO_PROG -c "fzero -k $i 4k" $file
  done
  for i in $(seq 4096 8192 $endoff); do
          $XFS_IO_PROG -c "fzero -k $i 4k" $file
  done
Quoted 2 lines

So looks like the offset+len isn't greater than the file size. So we might can remove the "-k" directly. What do you think ?

I quickly tested this with my NFS ZERO_RANGE patch, and didn't have any problems. I'll send a v2 removing the "-k" argument in a few minutes!

Anna

Quoted 16 lines

Thanks,
Zorro

Quoted 11 lines

--D

Quoted 7 lines
tests/generic/033 +0 -0
 _scratch_mkfs >/dev/null 2>&1
 _scratch_mount
Signature · 1 line
2.49.0