diff mbox series

[1/2] generic/219: use filesystem blocksize while calculating the file size

Message ID 20241024112311.615360-2-p.raghav@samsung.com (mailing list archive)
State New
Headers show
Series fix generic quota tests for XFS with 32k and 64k block sizes | expand

Commit Message

Pankaj Raghav Oct. 24, 2024, 11:23 a.m. UTC
generic/219 was failing for XFS with 32k and 64k blocksize. Even though
we do only 48k IO, XFS will allocate blocks rounded to the nearest
blocksize.

Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
---
 tests/generic/219 | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

Comments

Darrick J. Wong Oct. 24, 2024, 6:19 p.m. UTC | #1
On Thu, Oct 24, 2024 at 01:23:10PM +0200, Pankaj Raghav wrote:
> generic/219 was failing for XFS with 32k and 64k blocksize. Even though
> we do only 48k IO, XFS will allocate blocks rounded to the nearest
> blocksize.
> 
> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
> ---
>  tests/generic/219 | 18 +++++++++++++++---
>  1 file changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/generic/219 b/tests/generic/219
> index 940b902e..d72aa745 100755
> --- a/tests/generic/219
> +++ b/tests/generic/219
> @@ -49,12 +49,24 @@ check_usage()
>  	fi
>  }
>  
> +_round_up_to_fs_blksz()
> +{
> +	local n=$1
> +	local bs=$(_get_file_block_size "$SCRATCH_MNT")
> +	local bs_kb=$(( bs >> 10 ))
> +
> +	echo $(( (n + bs_kb - 1) & ~(bs_kb - 1) ))

Nit: you can divide here, right?

	echo $(( (n + bs_kb - 1) / bs_kb ))

The rest seems fine.

--D

> +}
> +
>  test_accounting()
>  {
> -	echo "### some controlled buffered, direct and mmapd IO (type=$type)"
> -	echo "--- initiating parallel IO..." >>$seqres.full
>  	# Small ios here because ext3 will account for indirect blocks too ...
>  	# 48k will fit w/o indirect for 4k blocks (default blocksize)
> +	io_sz=$(_round_up_to_fs_blksz 48)
> +	sz=$(( io_sz * 3 ))
> +
> +	echo "### some controlled buffered, direct and mmapd IO (type=$type)"
> +	echo "--- initiating parallel IO..." >>$seqres.full
>  	$XFS_IO_PROG -c 'pwrite 0 48k' -c 'fsync' \
>  					$SCRATCH_MNT/buffer >>$seqres.full 2>&1 &
>  	$XFS_IO_PROG -c 'pwrite 0 48k' -d \
> @@ -73,7 +85,7 @@ test_accounting()
>  	else
>  		id=$qa_group
>  	fi
> -	repquota -$type $SCRATCH_MNT | grep "^$id" | check_usage 144 3
> +	repquota -$type $SCRATCH_MNT | grep "^$id" | check_usage $sz 3
>  }
>  
>  
> -- 
> 2.44.1
> 
>
Pankaj Raghav (Samsung) Oct. 25, 2024, 1:12 a.m. UTC | #2
On Thu, Oct 24, 2024 at 11:19:10AM -0700, Darrick J. Wong wrote:
> On Thu, Oct 24, 2024 at 01:23:10PM +0200, Pankaj Raghav wrote:
> > generic/219 was failing for XFS with 32k and 64k blocksize. Even though
> > we do only 48k IO, XFS will allocate blocks rounded to the nearest
> > blocksize.
> > 
> > Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
> > ---
> >  tests/generic/219 | 18 +++++++++++++++---
> >  1 file changed, 15 insertions(+), 3 deletions(-)
> > 
> > diff --git a/tests/generic/219 b/tests/generic/219
> > index 940b902e..d72aa745 100755
> > --- a/tests/generic/219
> > +++ b/tests/generic/219
> > @@ -49,12 +49,24 @@ check_usage()
> >  	fi
> >  }
> >  
> > +_round_up_to_fs_blksz()
> > +{
> > +	local n=$1
> > +	local bs=$(_get_file_block_size "$SCRATCH_MNT")
> > +	local bs_kb=$(( bs >> 10 ))
> > +
> > +	echo $(( (n + bs_kb - 1) & ~(bs_kb - 1) ))
> 
> Nit: you can divide here, right?

No. I think you are talking about DIV_ROUND_UP(). We are doing a
round_up operation here.

We should get 64k as sz for bs 32k and 64k.

round_up(48k, 32k/64k) = 64k

> 
> 	echo $(( (n + bs_kb - 1) / bs_kb ))
> 
> The rest seems fine.
> 
> --D
> 
> > +}
> > +
> >  test_accounting()
> >  {
> > -	echo "### some controlled buffered, direct and mmapd IO (type=$type)"
> > -	echo "--- initiating parallel IO..." >>$seqres.full
> >  	# Small ios here because ext3 will account for indirect blocks too ...
> >  	# 48k will fit w/o indirect for 4k blocks (default blocksize)
> > +	io_sz=$(_round_up_to_fs_blksz 48)
> > +	sz=$(( io_sz * 3 ))
> > +
> > +	echo "### some controlled buffered, direct and mmapd IO (type=$type)"
> > +	echo "--- initiating parallel IO..." >>$seqres.full
> >  	$XFS_IO_PROG -c 'pwrite 0 48k' -c 'fsync' \
> >  					$SCRATCH_MNT/buffer >>$seqres.full 2>&1 &
> >  	$XFS_IO_PROG -c 'pwrite 0 48k' -d \
> > @@ -73,7 +85,7 @@ test_accounting()
> >  	else
> >  		id=$qa_group
> >  	fi
> > -	repquota -$type $SCRATCH_MNT | grep "^$id" | check_usage 144 3
> > +	repquota -$type $SCRATCH_MNT | grep "^$id" | check_usage $sz 3
> >  }
> >  
> >  
> > -- 
> > 2.44.1
> > 
> >
Darrick J. Wong Oct. 25, 2024, 5:28 a.m. UTC | #3
On Fri, Oct 25, 2024 at 06:42:20AM +0530, Pankaj Raghav (Samsung) wrote:
> On Thu, Oct 24, 2024 at 11:19:10AM -0700, Darrick J. Wong wrote:
> > On Thu, Oct 24, 2024 at 01:23:10PM +0200, Pankaj Raghav wrote:
> > > generic/219 was failing for XFS with 32k and 64k blocksize. Even though
> > > we do only 48k IO, XFS will allocate blocks rounded to the nearest
> > > blocksize.
> > > 
> > > Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
> > > ---
> > >  tests/generic/219 | 18 +++++++++++++++---
> > >  1 file changed, 15 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/tests/generic/219 b/tests/generic/219
> > > index 940b902e..d72aa745 100755
> > > --- a/tests/generic/219
> > > +++ b/tests/generic/219
> > > @@ -49,12 +49,24 @@ check_usage()
> > >  	fi
> > >  }
> > >  
> > > +_round_up_to_fs_blksz()
> > > +{
> > > +	local n=$1
> > > +	local bs=$(_get_file_block_size "$SCRATCH_MNT")
> > > +	local bs_kb=$(( bs >> 10 ))
> > > +
> > > +	echo $(( (n + bs_kb - 1) & ~(bs_kb - 1) ))
> > 
> > Nit: you can divide here, right?
> 
> No. I think you are talking about DIV_ROUND_UP(). We are doing a
> round_up operation here.

Hah oops yeah.

> We should get 64k as sz for bs 32k and 64k.
> 
> round_up(48k, 32k/64k) = 64k

<nod>

post clue-bat,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D


> > 
> > 	echo $(( (n + bs_kb - 1) / bs_kb ))
> > 
> > The rest seems fine.
> > 
> > --D
> > 
> > > +}
> > > +
> > >  test_accounting()
> > >  {
> > > -	echo "### some controlled buffered, direct and mmapd IO (type=$type)"
> > > -	echo "--- initiating parallel IO..." >>$seqres.full
> > >  	# Small ios here because ext3 will account for indirect blocks too ...
> > >  	# 48k will fit w/o indirect for 4k blocks (default blocksize)
> > > +	io_sz=$(_round_up_to_fs_blksz 48)
> > > +	sz=$(( io_sz * 3 ))
> > > +
> > > +	echo "### some controlled buffered, direct and mmapd IO (type=$type)"
> > > +	echo "--- initiating parallel IO..." >>$seqres.full
> > >  	$XFS_IO_PROG -c 'pwrite 0 48k' -c 'fsync' \
> > >  					$SCRATCH_MNT/buffer >>$seqres.full 2>&1 &
> > >  	$XFS_IO_PROG -c 'pwrite 0 48k' -d \
> > > @@ -73,7 +85,7 @@ test_accounting()
> > >  	else
> > >  		id=$qa_group
> > >  	fi
> > > -	repquota -$type $SCRATCH_MNT | grep "^$id" | check_usage 144 3
> > > +	repquota -$type $SCRATCH_MNT | grep "^$id" | check_usage $sz 3
> > >  }
> > >  
> > >  
> > > -- 
> > > 2.44.1
> > > 
> > > 
> 
> -- 
> Pankaj Raghav
>
diff mbox series

Patch

diff --git a/tests/generic/219 b/tests/generic/219
index 940b902e..d72aa745 100755
--- a/tests/generic/219
+++ b/tests/generic/219
@@ -49,12 +49,24 @@  check_usage()
 	fi
 }
 
+_round_up_to_fs_blksz()
+{
+	local n=$1
+	local bs=$(_get_file_block_size "$SCRATCH_MNT")
+	local bs_kb=$(( bs >> 10 ))
+
+	echo $(( (n + bs_kb - 1) & ~(bs_kb - 1) ))
+}
+
 test_accounting()
 {
-	echo "### some controlled buffered, direct and mmapd IO (type=$type)"
-	echo "--- initiating parallel IO..." >>$seqres.full
 	# Small ios here because ext3 will account for indirect blocks too ...
 	# 48k will fit w/o indirect for 4k blocks (default blocksize)
+	io_sz=$(_round_up_to_fs_blksz 48)
+	sz=$(( io_sz * 3 ))
+
+	echo "### some controlled buffered, direct and mmapd IO (type=$type)"
+	echo "--- initiating parallel IO..." >>$seqres.full
 	$XFS_IO_PROG -c 'pwrite 0 48k' -c 'fsync' \
 					$SCRATCH_MNT/buffer >>$seqres.full 2>&1 &
 	$XFS_IO_PROG -c 'pwrite 0 48k' -d \
@@ -73,7 +85,7 @@  test_accounting()
 	else
 		id=$qa_group
 	fi
-	repquota -$type $SCRATCH_MNT | grep "^$id" | check_usage 144 3
+	repquota -$type $SCRATCH_MNT | grep "^$id" | check_usage $sz 3
 }