Skip to contentSkip to conversation

shared/298: run xfs_db against the loop device instead of the image file

PATCH In review Christoph Hellwig 3 participants 7 messages Mar 1, 2024 – Mar 3, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 shared/298: run xfs_db against the loop device instead of the image file

xfs_db fails to properly detect the device sector size and thus segfaults when run again an image file with 4k sector size. While that's something we should fix in xfs_db it will require a fair amount of refactoring of the libxfs init code. For now just change shared/298 to run xfs_db against the loop device created on the image file that is used for I/O, which feels like the right thing to do anyway to avoid cache coherency issues.

---
 tests/shared/298 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/shared/298 +1 -1
index 071c03dee..f657578c7 100755
@@ -69,7 +69,7 @@ get_free_sectors()
 	agsize=`$XFS_INFO_PROG $loop_mnt | $SED_PROG -n 's/.*agsize=\(.*\) blks.*/\1/p'`
 	# Convert free space (agno, block, length) to (start sector, end sector)
 	_umount $loop_mnt
-	$XFS_DB_PROG -r -c "freesp -d" $img_file | $SED_PROG '/^.*from/,$d'| \
+	$XFS_DB_PROG -r -c "freesp -d" $loop_dev | $SED_PROG '/^.*from/,$d'| \
 		 $AWK_PROG -v spb=$sectors_per_block -v agsize=$agsize \
 		'{ print spb * ($1 * agsize + $2), spb * ($1 * agsize + $2 + $3) - 1 }'
 	;;
Signature · 1 line
2.39.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines · Christoph Hellwig

xfs_db fails to properly detect the device sector size and thus segfaults when run again an image file with 4k sector size. While that's something we should fix in xfs_db it will require a fair amount of refactoring of the libxfs init code. For now just change shared/298 to run xfs_db against the loop device created on the image file that is used for I/O, which feels like the right thing to do anyway to avoid cache coherency issues.

---
 tests/shared/298 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/shared/298 +0 -0
index 071c03dee..f657578c7 100755

tests/shared/298 get_free_sectors() · line 72

Quoted 5 lines
tests/shared/298 +1 -1
@@ -69,7 +69,7 @@ get_free_sectors()
 	agsize=`$XFS_INFO_PROG $loop_mnt | $SED_PROG -n 's/.*agsize=\(.*\) blks.*/\1/p'`
 	# Convert free space (agno, block, length) to (start sector, end sector)
 	_umount $loop_mnt
-	$XFS_DB_PROG -r -c "freesp -d" $img_file | $SED_PROG '/^.*from/,$d'| \
+	$XFS_DB_PROG -r -c "freesp -d" $loop_dev | $SED_PROG '/^.*from/,$d'| \

Might want to leave a comment here about why xfs uses $loop_dev unlike the other clauses that use $img_file

# Use $loop_dev to work around sector size misdetection bugs in xfs_db $XFS_DB_PROG...

With that changed,

--D

Quoted 7 lines
tests/shared/298 +0 -0
 		 $AWK_PROG -v spb=$sectors_per_block -v agsize=$agsize \
 		'{ print spb * ($1 * agsize + $2), spb * ($1 * agsize + $2 + $3) - 1 }'
 	;;
Signature · 1 line
2.39.2
#2 lore raw
Quoted 2 lines · Darrick J. Wong

Might want to leave a comment here about why xfs uses $loop_dev unlike the other clauses that use $img_file

Well, as I tried to explain in my commit message running it against the file always seemed weird. The loop device is the canonical place to run fs tools against. I can throw in a cleanup patch to also do this for the other file systems.

#3 lore raw
Quoted 8 lines · Christoph Hellwig
Quoted 2 lines · Darrick J. Wong

Might want to leave a comment here about why xfs uses $loop_dev unlike the other clauses that use $img_file

Well, as I tried to explain in my commit message running it against the file always seemed weird. The loop device is the canonical place to run fs tools against. I can throw in a cleanup patch to also do this for the other file systems.

That would also work.

--D

#4 lore raw
In reply to Christoph Hellwig
Quoted 18 lines · Christoph Hellwig

xfs_db fails to properly detect the device sector size and thus segfaults when run again an image file with 4k sector size. While that's something we should fix in xfs_db it will require a fair amount of refactoring of the libxfs init code. For now just change shared/298 to run xfs_db against the loop device created on the image file that is used for I/O, which feels like the right thing to do anyway to avoid cache coherency issues.

---
 tests/shared/298 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/shared/298 +0 -0
index 071c03dee..f657578c7 100755

tests/shared/298 get_free_sectors() · line 71

Quoted 3 lines
tests/shared/298 +0 -0
@@ -69,7 +69,7 @@ get_free_sectors()
 	agsize=`$XFS_INFO_PROG $loop_mnt | $SED_PROG -n 's/.*agsize=\(.*\) blks.*/\1/p'`
 	# Convert free space (agno, block, length) to (start sector, end sector)
 	_umount $loop_mnt
        ^^^^^^^

Above line causes a conflict, due to it doesn't match the current shared/298 code. It's "$UMOUNT_PROG $loop_mnt" in current fstests. So you might have another patch to do this change.

tests/shared/298 get_free_sectors() · line 72

Quoted 2 lines
tests/shared/298 +1 -1
-	$XFS_DB_PROG -r -c "freesp -d" $img_file | $SED_PROG '/^.*from/,$d'| \
+	$XFS_DB_PROG -r -c "freesp -d" $loop_dev | $SED_PROG '/^.*from/,$d'| \

As this patch focus on this change, so I'll only make this change. But if above "_umount $loop_mnt" is needed too, please tell me.

Thanks,
Zorro

Quoted 7 lines
tests/shared/298 +0 -0
 		 $AWK_PROG -v spb=$sectors_per_block -v agsize=$agsize \
 		'{ print spb * ($1 * agsize + $2), spb * ($1 * agsize + $2 + $3) - 1 }'
 	;;
Signature · 1 line
2.39.2
#5 lore raw
Quoted 6 lines · Zorro Lang

tests/shared/298 get_free_sectors() · line 71

Quoted 2 lines
tests/shared/298 +0 -0
 	# Convert free space (agno, block, length) to (start sector, end sector)
 	_umount $loop_mnt
        ^^^^^^^

Above line causes a conflict, due to it doesn't match the current shared/298 code. It's "$UMOUNT_PROG $loop_mnt" in current fstests. So you might have another patch to do this change.

That line actually is from a patch in Darrick's patch queue that I'm working ontop of right now for some feture development. Sorry for not remembering to rebase against current for-next first.

#6 lore raw
Quoted 11 lines · Christoph Hellwig
Quoted 6 lines · Zorro Lang

tests/shared/298 get_free_sectors() · line 71

Quoted 2 lines
tests/shared/298 +0 -0
 	# Convert free space (agno, block, length) to (start sector, end sector)
 	_umount $loop_mnt
        ^^^^^^^

Above line causes a conflict, due to it doesn't match the current shared/298 code. It's "$UMOUNT_PROG $loop_mnt" in current fstests. So you might have another patch to do this change.

That line actually is from a patch in Darrick's patch queue that I'm working ontop of right now for some feture development. Sorry for not remembering to rebase against current for-next first.

Never mind:) As that "_umount $loop_mnt" isn't needed, I'll change the single line only. This patch and the other patch "[PATCH] common:
dm-error now supports zoned devices" are in fstests' "patches-in-queue" branch, they'll be in next release.

Thanks,
Zorro

Quoted 2 lines