Re: [PATCH 2/2] generic/563: create the loop dev with the same block size as the scratch dev

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



On Sun, Oct 22, 2023 at 05:55:29PM -0400, Theodore Ts'o wrote:
> The generic/563 test creates the loop device using $SCRATCH_DEV
> directly.  We need to create the loop device with the same logical
> block size.  Otherwise, the loop device will always be created with
> the default logical block size of 512, and if its underlying backing
> store has a different logical block size, then mkfs may create a file
> system in the loop device that will fail to mount.
> 
> Signed-off-by: Theodore Ts'o <tytso@xxxxxxx>

Looks fine to me,
Reviewed-by: Darrick J. Wong <djwong@xxxxxxxxxx>

--D

> ---
>  common/rc         | 10 ++++++++--
>  tests/generic/563 |  2 +-
>  2 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/common/rc b/common/rc
> index 8d7179567..01f065a9f 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -4246,9 +4246,15 @@ _require_userns()
>  
>  _create_loop_device()
>  {
> -	local file=$1 dev
> -	dev=`losetup -f --show $file` || _fail "Cannot assign $file to a loop device"
> +	local file=$1
> +	local blocksize=$2
> +	local dev
> +
> +	if [ -n "$blocksize" ]; then
> +		blocksize="-b $blocksize"
> +	fi
>  
> +	dev=`losetup -f $blocksize --show $file` || _fail "Cannot assign $file to a loop device"
>  	# Try to enable asynchronous directio mode on the loopback device so
>  	# that writeback started by a filesystem mounted on the loop device
>  	# won't be throttled by buffered writes to the lower filesystem.  This
> diff --git a/tests/generic/563 b/tests/generic/563
> index f98c6e42b..7e6bab49e 100755
> --- a/tests/generic/563
> +++ b/tests/generic/563
> @@ -89,7 +89,7 @@ reset()
>  
>  # cgroup I/O accounting doesn't work on partitions. Use a loop device to rule
>  # that out.
> -LOOP_DEV=$(_create_loop_device $SCRATCH_DEV)
> +LOOP_DEV=$(_create_loop_device $SCRATCH_DEV $(blockdev --getss $SCRATCH_DEV))
>  smajor=$((0x`stat -L -c %t $LOOP_DEV`))
>  sminor=$((0x`stat -L -c %T $LOOP_DEV`))
>  
> -- 
> 2.31.0
> 



[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux