Skip to contentSkip to conversation

ext4/307: Calculate donor size to avoid failures for 64k bs

PATCH In review Ojaswin Mujoo 2 participants 2 messages Apr 1 – May 15

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ext4/307: Calculate donor size to avoid failures for 64k bs

Calculating size of donor file based on du output causes the following issue:

e4compact.c:68: do_defrag_range: Assertion `donor->length >= len' failed.
./common/rc: line 4616: 1583182 Aborted (core dumped)

The issue is that e4compat asserts that the stat.st_size of all files combined shouldn't be more than that of the donor file. In case of 64k blocksize, fsstress often creates sparse files which have >3G size even though their disk utilization is <100M. Since donor file is not big enough, this trips e4compat causing the failure.

Fix this by using stat.st_size rather than du value to get the size. Also, make some changes to avoid future ENOSPC like reducing the -n passed to fsstress to keep the size around 2G and making sure we use the whole SCRATCH disk instead of 500M.

While we are at it, add some new lines to make the code bit more readable.

---
 tests/ext4/307 | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
tests/ext4/307 +13 -5
index 48073347..ed6fc664 100755
@@ -19,18 +19,26 @@ _workout()
 	echo ""
 	echo "Run fsstress"
 	out=$SCRATCH_MNT/fsstress.$$
-	args=`_scale_fsstress_args -p4 -n999 -f setattr=1 -d $out`
+	args=`_scale_fsstress_args -p4 -n500 -f setattr=1 -d $out`
 	echo "fsstress $args" >> $seqres.full
 	_run_fsstress $args
+
 	find $out -type f > $out.list
 	cat $out.list | xargs  md5sum > $out.md5sum
-	# Use -m to get integer MB size to avoid decimals (e.g. 1.5M) which xfs_io rejects
-	usage=$(du -sm $out | awk '{print $1}')
+
+	# Get the total of stat.st_size of each file to determine the
+	# size of donor file. We use st_size here instead of blocks used
+	# because thats what e4compat.c checks against.
+	bytes=$(xargs -r stat -c %s < $out.list | awk '{s+=$1} END{print s}')
+	echo "Total bytes used: $bytes" >> $seqres.full
+
 	echo "Allocate donor file"
-	$XFS_IO_PROG -c "falloc 0 ${usage}m" -f $SCRATCH_MNT/donor | _filter_xfs_io
+	$XFS_IO_PROG -c "falloc 0 $bytes" -f $SCRATCH_MNT/donor | _filter_xfs_io
+
 	echo "Perform compacting"
 	cat $out.list | run_check $here/src/e4compact \
 		-i -v -f $SCRATCH_MNT/donor  >> $seqres.full 2>&1
+
 	echo "Check data"
 	run_check md5sum -c $out.md5sum
 }
@@ -42,7 +50,7 @@ _require_scratch
 _require_defrag
 _require_xfs_io_command "falloc"
 
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs >> $seqres.full 2>&1
 _scratch_mount
 
 _workout
Signature · 1 line
2.52.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 17 lines · Ojaswin Mujoo

Calculating size of donor file based on du output causes the following issue:

e4compact.c:68: do_defrag_range: Assertion `donor->length >= len' failed.
./common/rc: line 4616: 1583182 Aborted (core dumped)

The issue is that e4compat asserts that the stat.st_size of all files combined shouldn't be more than that of the donor file. In case of 64k blocksize, fsstress often creates sparse files which have >3G size even though their disk utilization is <100M. Since donor file is not big enough, this trips e4compat causing the failure.

Fix this by using stat.st_size rather than du value to get the size. Also, make some changes to avoid future ENOSPC like reducing the -n passed to fsstress to keep the size around 2G and making sure we use the whole SCRATCH disk instead of 500M.

Quoted 7 lines

While we are at it, add some new lines to make the code bit more readable.

---

It tests good to me,

Quoted 51 lines
 tests/ext4/307 | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
tests/ext4/307 +13 -5
index 48073347..ed6fc664 100755
@@ -19,18 +19,26 @@ _workout()
 	echo ""
 	echo "Run fsstress"
 	out=$SCRATCH_MNT/fsstress.$$
-	args=`_scale_fsstress_args -p4 -n999 -f setattr=1 -d $out`
+	args=`_scale_fsstress_args -p4 -n500 -f setattr=1 -d $out`
 	echo "fsstress $args" >> $seqres.full
 	_run_fsstress $args
+
 	find $out -type f > $out.list
 	cat $out.list | xargs  md5sum > $out.md5sum
-	# Use -m to get integer MB size to avoid decimals (e.g. 1.5M) which xfs_io rejects
-	usage=$(du -sm $out | awk '{print $1}')
+
+	# Get the total of stat.st_size of each file to determine the
+	# size of donor file. We use st_size here instead of blocks used
+	# because thats what e4compat.c checks against.
+	bytes=$(xargs -r stat -c %s < $out.list | awk '{s+=$1} END{print s}')
+	echo "Total bytes used: $bytes" >> $seqres.full
+
 	echo "Allocate donor file"
-	$XFS_IO_PROG -c "falloc 0 ${usage}m" -f $SCRATCH_MNT/donor | _filter_xfs_io
+	$XFS_IO_PROG -c "falloc 0 $bytes" -f $SCRATCH_MNT/donor | _filter_xfs_io
+
 	echo "Perform compacting"
 	cat $out.list | run_check $here/src/e4compact \
 		-i -v -f $SCRATCH_MNT/donor  >> $seqres.full 2>&1
+
 	echo "Check data"
 	run_check md5sum -c $out.md5sum
 }
@@ -42,7 +50,7 @@ _require_scratch
 _require_defrag
 _require_xfs_io_command "falloc"
 
-_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1
+_scratch_mkfs >> $seqres.full 2>&1
 _scratch_mount
 
 _workout
Signature · 1 line
2.52.0