Skip to contentSkip to conversation

generic/544: Fix inode number ordering code

PATCH In review Kent Overstreet 2 participants 2 messages Nov 13, 2021 – Nov 16, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 generic/544: Fix inode number ordering code

The code that creates files and moves them to low/high inode number files writes different file contents before doing the move - leading to non-reproducible results.

Fix this by writing the file contents after moving them to high/low inode number files.

---
 tests/generic/544 | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
tests/generic/544 +6 -2
index 4a9f48526d..4dbaea4de0 100755
@@ -44,8 +44,9 @@ inum() {
 # Create two test files, make $low_file the file with the lower inode
 # number, and make $high_file the file with the higher inode number.
 create_files() {
-	_pwrite_byte 0x60 0 $filesize $testdir/file1 >> $seqres.full
-	_pwrite_byte 0x61 0 $filesize $testdir/file2 >> $seqres.full
+	touch $testdir/file1
+	touch $testdir/file2
+
 	if [ "$(inum $testdir/file1)" -lt "$(inum $testdir/file2)" ]; then
 		mv $testdir/file1 $low_file
 		mv $testdir/file2 $high_file
@@ -53,6 +54,9 @@ create_files() {
 		mv $testdir/file2 $low_file
 		mv $testdir/file1 $high_file
 	fi
+
+	_pwrite_byte 0x60 0 $filesize $low_file >> $seqres.full
+	_pwrite_byte 0x61 0 $filesize $high_file >> $seqres.full
 }
 
 # Check md5sum of both files, but keep results sorted by inode order
Signature · 1 line
2.33.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Kent Overstreet

The code that creates files and moves them to low/high inode number files writes different file contents before doing the move - leading to non-reproducible results.

Fix this by writing the file contents after moving them to high/low inode number files.

DOH. Yep, this is correct.

--D

Quoted 33 lines
---
 tests/generic/544 | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
tests/generic/544 +6 -2
index 4a9f48526d..4dbaea4de0 100755
@@ -44,8 +44,9 @@ inum() {
 # Create two test files, make $low_file the file with the lower inode
 # number, and make $high_file the file with the higher inode number.
 create_files() {
-	_pwrite_byte 0x60 0 $filesize $testdir/file1 >> $seqres.full
-	_pwrite_byte 0x61 0 $filesize $testdir/file2 >> $seqres.full
+	touch $testdir/file1
+	touch $testdir/file2
+
 	if [ "$(inum $testdir/file1)" -lt "$(inum $testdir/file2)" ]; then
 		mv $testdir/file1 $low_file
 		mv $testdir/file2 $high_file
@@ -53,6 +54,9 @@ create_files() {
 		mv $testdir/file2 $low_file
 		mv $testdir/file1 $high_file
 	fi
+
+	_pwrite_byte 0x60 0 $filesize $low_file >> $seqres.full
+	_pwrite_byte 0x61 0 $filesize $high_file >> $seqres.full
 }
 
 # Check md5sum of both files, but keep results sorted by inode order
Signature · 1 line
2.33.1