Skip to contentSkip to conversation

generic/{175,297,298}: fix use of uninitialized var

PATCH Superseded Amir Goldstein 3 participants 5 messages Aug 12, 2023 – Aug 15, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 generic/{175,297,298}: fix use of uninitialized var

Not sure how those tests pass in regression tests. Probably truncate silently fails and is not critical to the test.

in kdevops I get errors like:
/data/fstests-install/xfstests/tests/generic/298: line 45: /dev/loop12):
syntax error: operand expected (error token is "/dev/loop12)")

---
 tests/generic/175 | 2 +-
 tests/generic/297 | 2 +-
 tests/generic/298 | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
tests/generic/175 +1 -1
index 07af2199..14825a39 100755
@@ -33,7 +33,7 @@ _pwrite_byte 0x61 0 $blksz "$testdir/file1" >> "$seqres.full"
 
 fnr=19
 echo "Create extents"
-truncate -s $(( (2 ** i) * blksz)) "$testdir/file1"
+truncate -s $(( (2 ** (fnr + 1)) * blksz)) "$testdir/file1"
 for i in $(seq 0 $fnr); do
 	echo " ++ Reflink size $i, $((2 ** i)) blocks" >> "$seqres.full"
 	n=$(( (2 ** i) * blksz))
tests/generic/297 +1 -1
index 6bdc3e1c..1fc48671 100755
@@ -42,7 +42,7 @@ _pwrite_byte 0x61 0 $blksz $testdir/file1 >> $seqres.full
 fnr=26		# 2^26 reflink extents should be enough to find a slow op?
 timeout=8	# guarantee a good long run...
 echo "Find a reflink size that takes a long time"
-truncate -s $(( (2 ** i) * blksz)) $testdir/file1
+truncate -s $(( (2 ** (fnr + 1)) * blksz)) $testdir/file1
 for i in $(seq 0 $fnr); do
 	echo " ++ Reflink size $i, $((2 ** i)) blocks" >> $seqres.full
 	n=$(( (2 ** i) * blksz))
tests/generic/298 +1 -1
index 95d4c02b..2e917a87 100755
@@ -42,7 +42,7 @@ _pwrite_byte 0x61 0 $blksz $testdir/file1 >> $seqres.full
 fnr=26		# 2^26 reflink extents should be enough to find a slow op?
 timeout=8	# guarantee a good long run...
 echo "Find a reflink size that takes a long time"
-truncate -s $(( (2 ** i) * blksz)) $testdir/file1
+truncate -s $(( (2 ** (fnr + 1)) * blksz)) $testdir/file1
 for i in $(seq 0 $fnr); do
 	echo " ++ Reflink size $i, $((2 ** i)) blocks" >> $seqres.full
 	n=$(( (2 ** i) * blksz))
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Amir Goldstein

Not sure how those tests pass in regression tests. Probably truncate silently fails and is not critical to the test.

in kdevops I get errors like:
/data/fstests-install/xfstests/tests/generic/298: line 45: /dev/loop12):
syntax error: operand expected (error token is "/dev/loop12)")

---

Hmm, weird, I never hit this failure, all test passed [1]. But I think the reason is [2], $(()) looks like treat empty variable as 0.

Anyway, this patch makes sense, so

[1]

# ./check -s simpledev generic/175 generic/297 generic/298
SECTION       -- simpledev
FSTYP         -- xfs (non-debug)
PLATFORM      -- Linux/x86_64 hp-dl380pg8-01 6.5.0-0.rc3.23.fc39.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Jul 24 13:32:24 UTC 2023
MKFS_OPTIONS  -- -f /dev/sda3
MOUNT_OPTIONS -- -o context=system_u:object_r:root_t:s0 /dev/sda3 /mnt/scratch

generic/175 91s ... 40s
generic/297 44s
generic/298 125s ... 44s
Ran: generic/175 generic/297 generic/298
Passed all 3 tests

SECTION -- simpledev
=========================
Ran: generic/175 generic/297 generic/298
Passed all 3 tests

[2]
# blksz=4096

# echo $blksz
4096
# echo $i
# echo $(( (2 ** i) * blksz))
4096
# echo $i
# echo $((i))
0
Quoted 47 lines
 tests/generic/175 | 2 +-
 tests/generic/297 | 2 +-
 tests/generic/298 | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
tests/generic/175 +1 -1
index 07af2199..14825a39 100755
@@ -33,7 +33,7 @@ _pwrite_byte 0x61 0 $blksz "$testdir/file1" >> "$seqres.full"
 
 fnr=19
 echo "Create extents"
-truncate -s $(( (2 ** i) * blksz)) "$testdir/file1"
+truncate -s $(( (2 ** (fnr + 1)) * blksz)) "$testdir/file1"
 for i in $(seq 0 $fnr); do
 	echo " ++ Reflink size $i, $((2 ** i)) blocks" >> "$seqres.full"
 	n=$(( (2 ** i) * blksz))
tests/generic/297 +1 -1
index 6bdc3e1c..1fc48671 100755
@@ -42,7 +42,7 @@ _pwrite_byte 0x61 0 $blksz $testdir/file1 >> $seqres.full
 fnr=26		# 2^26 reflink extents should be enough to find a slow op?
 timeout=8	# guarantee a good long run...
 echo "Find a reflink size that takes a long time"
-truncate -s $(( (2 ** i) * blksz)) $testdir/file1
+truncate -s $(( (2 ** (fnr + 1)) * blksz)) $testdir/file1
 for i in $(seq 0 $fnr); do
 	echo " ++ Reflink size $i, $((2 ** i)) blocks" >> $seqres.full
 	n=$(( (2 ** i) * blksz))
tests/generic/298 +1 -1
index 95d4c02b..2e917a87 100755
@@ -42,7 +42,7 @@ _pwrite_byte 0x61 0 $blksz $testdir/file1 >> $seqres.full
 fnr=26		# 2^26 reflink extents should be enough to find a slow op?
 timeout=8	# guarantee a good long run...
 echo "Find a reflink size that takes a long time"
-truncate -s $(( (2 ** i) * blksz)) $testdir/file1
+truncate -s $(( (2 ** (fnr + 1)) * blksz)) $testdir/file1
 for i in $(seq 0 $fnr); do
 	echo " ++ Reflink size $i, $((2 ** i)) blocks" >> $seqres.full
 	n=$(( (2 ** i) * blksz))
Signature · 1 line
2.34.1
#2 lore raw
In reply to Amir Goldstein
Quoted 19 lines · Amir Goldstein

Not sure how those tests pass in regression tests. Probably truncate silently fails and is not critical to the test.

in kdevops I get errors like:
/data/fstests-install/xfstests/tests/generic/298: line 45: /dev/loop12):
syntax error: operand expected (error token is "/dev/loop12)")

---
 tests/generic/175 | 2 +-
 tests/generic/297 | 2 +-
 tests/generic/298 | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
tests/generic/175 +0 -0
index 07af2199..14825a39 100755

tests/generic/175 _pwrite_byte 0x61 0 $blksz "$testdir/file1" >> "$seqres.full" · line 37

Quoted 6 lines
tests/generic/175 +1 -1
@@ -33,7 +33,7 @@ _pwrite_byte 0x61 0 $blksz "$testdir/file1" >> "$seqres.full"
 
 fnr=19
 echo "Create extents"
-truncate -s $(( (2 ** i) * blksz)) "$testdir/file1"
+truncate -s $(( (2 ** (fnr + 1)) * blksz)) "$testdir/file1"
 for i in $(seq 0 $fnr); do

Hmm. Frankly I don't remember why I put those truncate calls in there. Does the test still work if you remove them entirely? AFAICT the test writes a single block's worth of data to the file, then truncates the file size to one block. Which I think is pointless.

Quoted 7 lines
tests/generic/175 +0 -0
 	echo " ++ Reflink size $i, $((2 ** i)) blocks" >> "$seqres.full"
 	n=$(( (2 ** i) * blksz))
tests/generic/297 +0 -0
index 6bdc3e1c..1fc48671 100755

tests/generic/297 _pwrite_byte 0x61 0 $blksz $testdir/file1 >> $seqres.full · line 48

Quoted 8 lines
tests/generic/297 +1 -1
@@ -42,7 +42,7 @@ _pwrite_byte 0x61 0 $blksz $testdir/file1 >> $seqres.full
 fnr=26		# 2^26 reflink extents should be enough to find a slow op?
 timeout=8	# guarantee a good long run...
 echo "Find a reflink size that takes a long time"
-truncate -s $(( (2 ** i) * blksz)) $testdir/file1
+truncate -s $(( (2 ** (fnr + 1)) * blksz)) $testdir/file1
 for i in $(seq 0 $fnr); do
 	echo " ++ Reflink size $i, $((2 ** i)) blocks" >> $seqres.full
 	n=$(( (2 ** i) * blksz))

The loop control logic could be converted to:

echo "Find a reflink size that takes a long time"
deadline="$(( $(date +%s) + timeout ))"
for ((i = 0, now = $(date +%s); i < fnr && now < deadline; i++, now = $(date +%s))); do

	echo " ++ Reflink size $i, $((2 ** i)) blocks" >> $seqres.full
	n=$(( (2 ** i) * blksz))
	$XFS_IO_PROG -f -c "reflink $testdir/file1 0 $n $n" $testdir/file1 >> $seqres.full 2>&1

done

(also in 298)

--D

Quoted 16 lines
tests/generic/298 +1 -1
index 95d4c02b..2e917a87 100755
@@ -42,7 +42,7 @@ _pwrite_byte 0x61 0 $blksz $testdir/file1 >> $seqres.full
 fnr=26		# 2^26 reflink extents should be enough to find a slow op?
 timeout=8	# guarantee a good long run...
 echo "Find a reflink size that takes a long time"
-truncate -s $(( (2 ** i) * blksz)) $testdir/file1
+truncate -s $(( (2 ** (fnr + 1)) * blksz)) $testdir/file1
 for i in $(seq 0 $fnr); do
 	echo " ++ Reflink size $i, $((2 ** i)) blocks" >> $seqres.full
 	n=$(( (2 ** i) * blksz))
Signature · 1 line
2.34.1
#3 lore raw
Quoted 22 lines · Darrick J. Wong
Quoted 20 lines · Amir Goldstein

Not sure how those tests pass in regression tests. Probably truncate silently fails and is not critical to the test.

in kdevops I get errors like:
/data/fstests-install/xfstests/tests/generic/298: line 45: /dev/loop12):
syntax error: operand expected (error token is "/dev/loop12)")

---
 tests/generic/175 | 2 +-
 tests/generic/297 | 2 +-
 tests/generic/298 | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
tests/generic/175 +0 -0
index 07af2199..14825a39 100755
@@ -33,7 +33,7 @@ _pwrite_byte 0x61 0 $blksz "$testdir/file1" >> "$seqres.full"
 
Quoted 7 lines

tests/generic/175 _pwrite_byte 0x61 0 $blksz "$testdir/file1" >> "$seqres.full" · line 37

Quoted 5 lines
tests/generic/175 +1 -1
 fnr=19
 echo "Create extents"
-truncate -s $(( (2 ** i) * blksz)) "$testdir/file1"
+truncate -s $(( (2 ** (fnr + 1)) * blksz)) "$testdir/file1"
 for i in $(seq 0 $fnr); do

Hmm. Frankly I don't remember why I put those truncate calls in there.

You specifically added truncate in commit
ddf6ff2f reflink: ensure that we can handle reflinking a lot of extents and then it was copied to the two new tests.
maybe this will give you a hint?

Quoted 25 lines

Does the test still work if you remove them entirely? AFAICT the test writes a single block's worth of data to the file, then truncates the file size to one block. Which I think is pointless.

Quoted 7 lines
tests/generic/175 +0 -0
      echo " ++ Reflink size $i, $((2 ** i)) blocks" >> "$seqres.full"
      n=$(( (2 ** i) * blksz))
tests/generic/297 +0 -0
index 6bdc3e1c..1fc48671 100755

tests/generic/297 _pwrite_byte 0x61 0 $blksz $testdir/file1 >> $seqres.full · line 48

Quoted 8 lines
tests/generic/297 +1 -1
@@ -42,7 +42,7 @@ _pwrite_byte 0x61 0 $blksz $testdir/file1 >> $seqres.full
 fnr=26               # 2^26 reflink extents should be enough to find a slow op?
 timeout=8    # guarantee a good long run...
 echo "Find a reflink size that takes a long time"
-truncate -s $(( (2 ** i) * blksz)) $testdir/file1
+truncate -s $(( (2 ** (fnr + 1)) * blksz)) $testdir/file1
 for i in $(seq 0 $fnr); do
      echo " ++ Reflink size $i, $((2 ** i)) blocks" >> $seqres.full
      n=$(( (2 ** i) * blksz))

The loop control logic could be converted to:

echo "Find a reflink size that takes a long time"
deadline="$(( $(date +%s) + timeout ))"
for ((i = 0, now = $(date +%s); i < fnr && now < deadline; i++, now = $(date +%s))); do

Quoted 7 lines
        echo " ++ Reflink size $i, $((2 ** i)) blocks" >> $seqres.full
        n=$(( (2 ** i) * blksz))
        $XFS_IO_PROG -f -c "reflink $testdir/file1 0 $n $n" $testdir/file1 >> $seqres.full 2>&1

done

(also in 298)

Whatever works is fine by me.
Feel free to keep my commit message or drop it.

Thanks,
Amir.

#4 lore raw
Quoted 31 lines · Amir Goldstein
Quoted 22 lines · Darrick J. Wong
Quoted 20 lines · Amir Goldstein

Not sure how those tests pass in regression tests. Probably truncate silently fails and is not critical to the test.

in kdevops I get errors like:
/data/fstests-install/xfstests/tests/generic/298: line 45: /dev/loop12):
syntax error: operand expected (error token is "/dev/loop12)")

---
 tests/generic/175 | 2 +-
 tests/generic/297 | 2 +-
 tests/generic/298 | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
tests/generic/175 +0 -0
index 07af2199..14825a39 100755
@@ -33,7 +33,7 @@ _pwrite_byte 0x61 0 $blksz "$testdir/file1" >> "$seqres.full"
 
Quoted 7 lines

tests/generic/175 _pwrite_byte 0x61 0 $blksz "$testdir/file1" >> "$seqres.full" · line 37

Quoted 5 lines
tests/generic/175 +1 -1
 fnr=19
 echo "Create extents"
-truncate -s $(( (2 ** i) * blksz)) "$testdir/file1"
+truncate -s $(( (2 ** (fnr + 1)) * blksz)) "$testdir/file1"
 for i in $(seq 0 $fnr); do

Hmm. Frankly I don't remember why I put those truncate calls in there.

Quoted 4 lines

You specifically added truncate in commit
ddf6ff2f reflink: ensure that we can handle reflinking a lot of extents and then it was copied to the two new tests.
maybe this will give you a hint?

Alas, no. Total etch-a-sketch over here. :(

AFAICT the tests work just fine without the truncate calls, so let's remove them.

--D

Quoted 38 lines
Quoted 25 lines

Does the test still work if you remove them entirely? AFAICT the test writes a single block's worth of data to the file, then truncates the file size to one block. Which I think is pointless.

Quoted 7 lines
tests/generic/175 +0 -0
      echo " ++ Reflink size $i, $((2 ** i)) blocks" >> "$seqres.full"
      n=$(( (2 ** i) * blksz))
tests/generic/297 +0 -0
index 6bdc3e1c..1fc48671 100755

tests/generic/297 _pwrite_byte 0x61 0 $blksz $testdir/file1 >> $seqres.full · line 48

Quoted 8 lines
tests/generic/297 +1 -1
@@ -42,7 +42,7 @@ _pwrite_byte 0x61 0 $blksz $testdir/file1 >> $seqres.full
 fnr=26               # 2^26 reflink extents should be enough to find a slow op?
 timeout=8    # guarantee a good long run...
 echo "Find a reflink size that takes a long time"
-truncate -s $(( (2 ** i) * blksz)) $testdir/file1
+truncate -s $(( (2 ** (fnr + 1)) * blksz)) $testdir/file1
 for i in $(seq 0 $fnr); do
      echo " ++ Reflink size $i, $((2 ** i)) blocks" >> $seqres.full
      n=$(( (2 ** i) * blksz))

The loop control logic could be converted to:

echo "Find a reflink size that takes a long time"
deadline="$(( $(date +%s) + timeout ))"
for ((i = 0, now = $(date +%s); i < fnr && now < deadline; i++, now = $(date +%s))); do

Quoted 7 lines
        echo " ++ Reflink size $i, $((2 ** i)) blocks" >> $seqres.full
        n=$(( (2 ** i) * blksz))
        $XFS_IO_PROG -f -c "reflink $testdir/file1 0 $n $n" $testdir/file1 >> $seqres.full 2>&1

done

(also in 298)

Whatever works is fine by me.
Feel free to keep my commit message or drop it.

Thanks,
Amir.