diff mbox series

[1/3] xfs/161: adapt the test case for 64k FS blocksize

Message ID 20240506150119.184097-2-kernel@pankajraghav.com (mailing list archive)
State New
Headers show
Series more lbs test fixes | expand

Commit Message

Pankaj Raghav (Samsung) May 6, 2024, 3:01 p.m. UTC
From: Pankaj Raghav <p.raghav@samsung.com>

This test fails when xfs is formatted with 64k filesystem block size*.
It fails because the soft quota is not exceeded with the hardcoded 64k
pwrite, thereby, the grace time is not set. Even though soft quota is
set to 12k for uid1, it is rounded up to the nearest blocksize.

*** Report for user quotas on device /dev/sdb3
Block grace time: 7days; Inode grace time: 7days
                        Block limits                File limits
User            used    soft    hard  grace    used  soft  hard  grace
----------------------------------------------------------------------
0        --       0       0       0      0       3     0     0      0
1        --      64      64    1024      0       1     0     0      0
2        --      64       0       0      0       1     0     0      0

Adapt the pwrite to do more than 64k write when the FS blocksize is 64k.

Cap the blksz to be at least 64k to retain the same behaviour as before
for smaller filesystem blocksizes.

* This happens even on a 64k pagesize system and it is not related to
  LBS effort.

Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
---
 tests/xfs/161 | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Darrick J. Wong May 7, 2024, 10:23 p.m. UTC | #1
On Mon, May 06, 2024 at 05:01:17PM +0200, Pankaj Raghav (Samsung) wrote:
> From: Pankaj Raghav <p.raghav@samsung.com>
> 
> This test fails when xfs is formatted with 64k filesystem block size*.
> It fails because the soft quota is not exceeded with the hardcoded 64k
> pwrite, thereby, the grace time is not set. Even though soft quota is
> set to 12k for uid1, it is rounded up to the nearest blocksize.
> 
> *** Report for user quotas on device /dev/sdb3
> Block grace time: 7days; Inode grace time: 7days
>                         Block limits                File limits
> User            used    soft    hard  grace    used  soft  hard  grace
> ----------------------------------------------------------------------
> 0        --       0       0       0      0       3     0     0      0
> 1        --      64      64    1024      0       1     0     0      0
> 2        --      64       0       0      0       1     0     0      0
> 
> Adapt the pwrite to do more than 64k write when the FS blocksize is 64k.
> 
> Cap the blksz to be at least 64k to retain the same behaviour as before
> for smaller filesystem blocksizes.
> 
> * This happens even on a 64k pagesize system and it is not related to
>   LBS effort.
> 
> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
> ---
>  tests/xfs/161 | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/xfs/161 b/tests/xfs/161
> index 486fa6ca..94290f18 100755
> --- a/tests/xfs/161
> +++ b/tests/xfs/161
> @@ -38,9 +38,15 @@ _qmount_option "usrquota"
>  _scratch_xfs_db -c 'version' -c 'sb 0' -c 'p' >> $seqres.full
>  _scratch_mount >> $seqres.full
>  
> +min_blksz=65536
> +file_blksz=$(_get_file_block_size "$SCRATCH_MNT")
> +# Write more than one block to exceed the soft block quota limit.
> +blksz=$(( 2 * $file_blksz))
> +
> +blksz=$(( blksz > min_blksz ? blksz : min_blksz ))

If we don't set $min_blksize and always write (2 * $file_blksz) does the
test still work?

--D

>  # Force the block counters for uid 1 and 2 above zero
> -_pwrite_byte 0x61 0 64k $SCRATCH_MNT/a >> $seqres.full
> -_pwrite_byte 0x61 0 64k $SCRATCH_MNT/b >> $seqres.full
> +_pwrite_byte 0x61 0 $blksz $SCRATCH_MNT/a >> $seqres.full
> +_pwrite_byte 0x61 0 $blksz $SCRATCH_MNT/b >> $seqres.full
>  sync
>  chown 1 $SCRATCH_MNT/a
>  chown 2 $SCRATCH_MNT/b
> -- 
> 2.34.1
>
Ritesh Harjani (IBM) May 8, 2024, 2:50 a.m. UTC | #2
On Wed, May 8, 2024 at 3:53 AM Darrick J. Wong <djwong@kernel.org> wrote:
>
> On Mon, May 06, 2024 at 05:01:17PM +0200, Pankaj Raghav (Samsung) wrote:
> > From: Pankaj Raghav <p.raghav@samsung.com>
> >
> > This test fails when xfs is formatted with 64k filesystem block size*.
> > It fails because the soft quota is not exceeded with the hardcoded 64k
> > pwrite, thereby, the grace time is not set. Even though soft quota is
> > set to 12k for uid1, it is rounded up to the nearest blocksize.
> >
> > *** Report for user quotas on device /dev/sdb3
> > Block grace time: 7days; Inode grace time: 7days
> >                         Block limits                File limits
> > User            used    soft    hard  grace    used  soft  hard  grace
> > ----------------------------------------------------------------------
> > 0        --       0       0       0      0       3     0     0      0
> > 1        --      64      64    1024      0       1     0     0      0
> > 2        --      64       0       0      0       1     0     0      0
> >
> > Adapt the pwrite to do more than 64k write when the FS blocksize is 64k.
> >
> > Cap the blksz to be at least 64k to retain the same behaviour as before
> > for smaller filesystem blocksizes.
> >
> > * This happens even on a 64k pagesize system and it is not related to
> >   LBS effort.
> >
> > Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
> > ---
> >  tests/xfs/161 | 10 ++++++++--
> >  1 file changed, 8 insertions(+), 2 deletions(-)
> >
> > diff --git a/tests/xfs/161 b/tests/xfs/161
> > index 486fa6ca..94290f18 100755
> > --- a/tests/xfs/161
> > +++ b/tests/xfs/161
> > @@ -38,9 +38,15 @@ _qmount_option "usrquota"
> >  _scratch_xfs_db -c 'version' -c 'sb 0' -c 'p' >> $seqres.full
> >  _scratch_mount >> $seqres.full
> >
> > +min_blksz=65536
> > +file_blksz=$(_get_file_block_size "$SCRATCH_MNT")
> > +# Write more than one block to exceed the soft block quota limit.

Maybe we should improve this comment to -

# Write more than the soft block quota limit of 12k which is set later
via xfs_quota
# On 64k bs this will get rounded to the nearest blocksize which is 64k

> > +blksz=$(( 2 * $file_blksz))
> > +
> > +blksz=$(( blksz > min_blksz ? blksz : min_blksz ))
>
> If we don't set $min_blksize and always write (2 * $file_blksz) does the
> test still work?

I guess it won't (even for bs=4k), because we set the bsoft=12k via xfs_quota.
So we have to write more than 12k to trigger the grace timer.

-ritesh
Pankaj Raghav (Samsung) May 8, 2024, 10:58 a.m. UTC | #3
On Tue, May 07, 2024 at 03:23:23PM -0700, Darrick J. Wong wrote:
> On Mon, May 06, 2024 at 05:01:17PM +0200, Pankaj Raghav (Samsung) wrote:
> > From: Pankaj Raghav <p.raghav@samsung.com>
> > 
> > This test fails when xfs is formatted with 64k filesystem block size*.
> > It fails because the soft quota is not exceeded with the hardcoded 64k
> > pwrite, thereby, the grace time is not set. Even though soft quota is
> > set to 12k for uid1, it is rounded up to the nearest blocksize.
> > 
> > *** Report for user quotas on device /dev/sdb3
> > Block grace time: 7days; Inode grace time: 7days
> >                         Block limits                File limits
> > User            used    soft    hard  grace    used  soft  hard  grace
> > ----------------------------------------------------------------------
> > 0        --       0       0       0      0       3     0     0      0
> > 1        --      64      64    1024      0       1     0     0      0
> > 2        --      64       0       0      0       1     0     0      0
> > 
> > Adapt the pwrite to do more than 64k write when the FS blocksize is 64k.
> > 
> > Cap the blksz to be at least 64k to retain the same behaviour as before
> > for smaller filesystem blocksizes.
> > 
> > * This happens even on a 64k pagesize system and it is not related to
> >   LBS effort.
> > 
> > Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
> > ---
> >  tests/xfs/161 | 10 ++++++++--
> >  1 file changed, 8 insertions(+), 2 deletions(-)
> > 
> > diff --git a/tests/xfs/161 b/tests/xfs/161
> > index 486fa6ca..94290f18 100755
> > --- a/tests/xfs/161
> > +++ b/tests/xfs/161
> > @@ -38,9 +38,15 @@ _qmount_option "usrquota"
> >  _scratch_xfs_db -c 'version' -c 'sb 0' -c 'p' >> $seqres.full
> >  _scratch_mount >> $seqres.full
> >  
> > +min_blksz=65536
> > +file_blksz=$(_get_file_block_size "$SCRATCH_MNT")
> > +# Write more than one block to exceed the soft block quota limit.
> > +blksz=$(( 2 * $file_blksz))
> > +
> > +blksz=$(( blksz > min_blksz ? blksz : min_blksz ))
> 
> If we don't set $min_blksize and always write (2 * $file_blksz) does the
> test still work?

I think something like this is more clean where we don't have anymore
hardcoded variables:

Author: Pankaj Raghav <p.raghav@samsung.com>
Date:   Thu Jan 18 18:40:39 2024 +0100

    xfs/161: adapt the test case for 64k FS blocksize
    
    This test fails when xfs is formatted with 64k filesystem block size*.
    It fails because the soft quota is not exceeded with the hardcoded 64k
    pwrite, thereby, the grace time is not set. Even though soft quota is
    set to 12k for uid1, it is rounded up to the nearest blocksize.
    
    *** Report for user quotas on device /dev/sdb3
    Block grace time: 7days; Inode grace time: 7days
                            Block limits                File limits
    User            used    soft    hard  grace    used  soft  hard  grace
    ----------------------------------------------------------------------
    0        --       0       0       0      0       3     0     0      0
    1        --      64      64    1024      0       1     0     0      0
    2        --      64       0       0      0       1     0     0      0
    
    Adapt the pwrite to do twice the FS block size and set the soft limit
    to be 1 FS block.
    
    * This happens even on a 64k pagesize system and it is not related to
      LBS effort.
    
    Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>

diff --git a/tests/xfs/161 b/tests/xfs/161
index 486fa6ca..074acddc 100755
--- a/tests/xfs/161
+++ b/tests/xfs/161
@@ -38,15 +38,21 @@ _qmount_option "usrquota"
 _scratch_xfs_db -c 'version' -c 'sb 0' -c 'p' >> $seqres.full
 _scratch_mount >> $seqres.full
 
+
+pgsize=`$here/src/feature -s`
+file_blksz=$(_get_file_block_size "$SCRATCH_MNT")
+# Write more than one block to exceed the soft block quota limit.
+blksz=$(( 2 * $file_blksz))
+
 # Force the block counters for uid 1 and 2 above zero
-_pwrite_byte 0x61 0 64k $SCRATCH_MNT/a >> $seqres.full
-_pwrite_byte 0x61 0 64k $SCRATCH_MNT/b >> $seqres.full
+_pwrite_byte 0x61 0 $blksz $SCRATCH_MNT/a >> $seqres.full
+_pwrite_byte 0x61 0 $blksz $SCRATCH_MNT/b >> $seqres.full
 sync
 chown 1 $SCRATCH_MNT/a
 chown 2 $SCRATCH_MNT/b
 
 # Set quota limits on uid 1 before upgrading
-$XFS_QUOTA_PROG -x -c 'limit -u bsoft=12k bhard=1m 1' $SCRATCH_MNT
+$XFS_QUOTA_PROG -x -c 'limit -u bsoft='"$file_blksz"' bhard=1m 1' $SCRATCH_MNT
 
 # Make sure the grace period is at /some/ point in the future.  We have to
 # use bc because not all bashes can handle integer comparisons with 64-bit
@@ -71,7 +77,7 @@ _scratch_mount
 
 # Set a very generous grace period and quota limits on uid 2 after upgrading
 $XFS_QUOTA_PROG -x -c 'timer -u -b -d 2147483647' $SCRATCH_MNT
-$XFS_QUOTA_PROG -x -c 'limit -u bsoft=10000 bhard=150000 2' $SCRATCH_MNT
+$XFS_QUOTA_PROG -x -c 'limit -u bsoft='"$file_blksz"' bhard=150000 2' $SCRATCH_MNT
 
 # Query the grace periods to see if they got set properly after the upgrade.
 repquota -upn $SCRATCH_MNT > $tmp.repquota

> 
> --D
> 
> >  # Force the block counters for uid 1 and 2 above zero
> > -_pwrite_byte 0x61 0 64k $SCRATCH_MNT/a >> $seqres.full
> > -_pwrite_byte 0x61 0 64k $SCRATCH_MNT/b >> $seqres.full
> > +_pwrite_byte 0x61 0 $blksz $SCRATCH_MNT/a >> $seqres.full
> > +_pwrite_byte 0x61 0 $blksz $SCRATCH_MNT/b >> $seqres.full
> >  sync
> >  chown 1 $SCRATCH_MNT/a
> >  chown 2 $SCRATCH_MNT/b
> > -- 
> > 2.34.1
> >
Pankaj Raghav (Samsung) May 8, 2024, 2:49 p.m. UTC | #4
> 
> diff --git a/tests/xfs/161 b/tests/xfs/161
> index 486fa6ca..074acddc 100755
> --- a/tests/xfs/161
> +++ b/tests/xfs/161
> @@ -38,15 +38,21 @@ _qmount_option "usrquota"
>  _scratch_xfs_db -c 'version' -c 'sb 0' -c 'p' >> $seqres.full
>  _scratch_mount >> $seqres.full
>  
> +
> +pgsize=`$here/src/feature -s`
Stale pgsize variable.

> +file_blksz=$(_get_file_block_size "$SCRATCH_MNT")
> +# Write more than one block to exceed the soft block quota limit.
> +blksz=$(( 2 * $file_blksz))
> +
>  # Force the block counters for uid 1 and 2 above zero
> -_pwrite_byte 0x61 0 64k $SCRATCH_MNT/a >> $seqres.full
> -_pwrite_byte 0x61 0 64k $SCRATCH_MNT/b >> $seqres.full
> +_pwrite_byte 0x61 0 $blksz $SCRATCH_MNT/a >> $seqres.full
> +_pwrite_byte 0x61 0 $blksz $SCRATCH_MNT/b >> $seqres.full
>  sync
>  chown 1 $SCRATCH_MNT/a
>  chown 2 $SCRATCH_MNT/b
>  
>  # Set quota limits on uid 1 before upgrading
> -$XFS_QUOTA_PROG -x -c 'limit -u bsoft=12k bhard=1m 1' $SCRATCH_MNT
> +$XFS_QUOTA_PROG -x -c 'limit -u bsoft='"$file_blksz"' bhard=1m 1' $SCRATCH_MNT
>  
>  # Make sure the grace period is at /some/ point in the future.  We have to
>  # use bc because not all bashes can handle integer comparisons with 64-bit
> @@ -71,7 +77,7 @@ _scratch_mount
>  
>  # Set a very generous grace period and quota limits on uid 2 after upgrading
>  $XFS_QUOTA_PROG -x -c 'timer -u -b -d 2147483647' $SCRATCH_MNT
> -$XFS_QUOTA_PROG -x -c 'limit -u bsoft=10000 bhard=150000 2' $SCRATCH_MNT
> +$XFS_QUOTA_PROG -x -c 'limit -u bsoft='"$file_blksz"' bhard=150000 2' $SCRATCH_MNT
>  
>  # Query the grace periods to see if they got set properly after the upgrade.
>  repquota -upn $SCRATCH_MNT > $tmp.repquota
> 
> > 
> > --D
> > 
> > >  # Force the block counters for uid 1 and 2 above zero
> > > -_pwrite_byte 0x61 0 64k $SCRATCH_MNT/a >> $seqres.full
> > > -_pwrite_byte 0x61 0 64k $SCRATCH_MNT/b >> $seqres.full
> > > +_pwrite_byte 0x61 0 $blksz $SCRATCH_MNT/a >> $seqres.full
> > > +_pwrite_byte 0x61 0 $blksz $SCRATCH_MNT/b >> $seqres.full
> > >  sync
> > >  chown 1 $SCRATCH_MNT/a
> > >  chown 2 $SCRATCH_MNT/b
> > > -- 
> > > 2.34.1
> > > 
> 
> -- 
> Pankaj Raghav
Darrick J. Wong May 8, 2024, 4:06 p.m. UTC | #5
On Wed, May 08, 2024 at 08:20:01AM +0530, Ritesh Harjani wrote:
> On Wed, May 8, 2024 at 3:53 AM Darrick J. Wong <djwong@kernel.org> wrote:
> >
> > On Mon, May 06, 2024 at 05:01:17PM +0200, Pankaj Raghav (Samsung) wrote:
> > > From: Pankaj Raghav <p.raghav@samsung.com>
> > >
> > > This test fails when xfs is formatted with 64k filesystem block size*.
> > > It fails because the soft quota is not exceeded with the hardcoded 64k
> > > pwrite, thereby, the grace time is not set. Even though soft quota is
> > > set to 12k for uid1, it is rounded up to the nearest blocksize.
> > >
> > > *** Report for user quotas on device /dev/sdb3
> > > Block grace time: 7days; Inode grace time: 7days
> > >                         Block limits                File limits
> > > User            used    soft    hard  grace    used  soft  hard  grace
> > > ----------------------------------------------------------------------
> > > 0        --       0       0       0      0       3     0     0      0
> > > 1        --      64      64    1024      0       1     0     0      0
> > > 2        --      64       0       0      0       1     0     0      0
> > >
> > > Adapt the pwrite to do more than 64k write when the FS blocksize is 64k.
> > >
> > > Cap the blksz to be at least 64k to retain the same behaviour as before
> > > for smaller filesystem blocksizes.
> > >
> > > * This happens even on a 64k pagesize system and it is not related to
> > >   LBS effort.
> > >
> > > Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
> > > ---
> > >  tests/xfs/161 | 10 ++++++++--
> > >  1 file changed, 8 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/tests/xfs/161 b/tests/xfs/161
> > > index 486fa6ca..94290f18 100755
> > > --- a/tests/xfs/161
> > > +++ b/tests/xfs/161
> > > @@ -38,9 +38,15 @@ _qmount_option "usrquota"
> > >  _scratch_xfs_db -c 'version' -c 'sb 0' -c 'p' >> $seqres.full
> > >  _scratch_mount >> $seqres.full
> > >
> > > +min_blksz=65536
> > > +file_blksz=$(_get_file_block_size "$SCRATCH_MNT")
> > > +# Write more than one block to exceed the soft block quota limit.
> 
> Maybe we should improve this comment to -
> 
> # Write more than the soft block quota limit of 12k which is set later
> via xfs_quota
> # On 64k bs this will get rounded to the nearest blocksize which is 64k
> 
> > > +blksz=$(( 2 * $file_blksz))
> > > +
> > > +blksz=$(( blksz > min_blksz ? blksz : min_blksz ))
> >
> > If we don't set $min_blksize and always write (2 * $file_blksz) does the
> > test still work?
> 
> I guess it won't (even for bs=4k), because we set the bsoft=12k via xfs_quota.
> So we have to write more than 12k to trigger the grace timer.

Ah, ok.  Yes, that makes sense with the improved comment. :)

--D

> -ritesh
>
Pankaj Raghav (Samsung) May 9, 2024, 1:01 p.m. UTC | #6
On Wed, May 08, 2024 at 09:06:27AM -0700, Darrick J. Wong wrote:
> On Wed, May 08, 2024 at 08:20:01AM +0530, Ritesh Harjani wrote:
> > On Wed, May 8, 2024 at 3:53 AM Darrick J. Wong <djwong@kernel.org> wrote:
> > >
> > > On Mon, May 06, 2024 at 05:01:17PM +0200, Pankaj Raghav (Samsung) wrote:
> > > > From: Pankaj Raghav <p.raghav@samsung.com>
> > > >
> > > > This test fails when xfs is formatted with 64k filesystem block size*.
> > > > It fails because the soft quota is not exceeded with the hardcoded 64k
> > > > pwrite, thereby, the grace time is not set. Even though soft quota is
> > > > set to 12k for uid1, it is rounded up to the nearest blocksize.
> > > >
> > > > *** Report for user quotas on device /dev/sdb3
> > > > Block grace time: 7days; Inode grace time: 7days
> > > >                         Block limits                File limits
> > > > User            used    soft    hard  grace    used  soft  hard  grace
> > > > ----------------------------------------------------------------------
> > > > 0        --       0       0       0      0       3     0     0      0
> > > > 1        --      64      64    1024      0       1     0     0      0
> > > > 2        --      64       0       0      0       1     0     0      0
> > > >
> > > > Adapt the pwrite to do more than 64k write when the FS blocksize is 64k.
> > > >
> > > > Cap the blksz to be at least 64k to retain the same behaviour as before
> > > > for smaller filesystem blocksizes.
> > > >
> > > > * This happens even on a 64k pagesize system and it is not related to
> > > >   LBS effort.
> > > >
> > > > Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
> > > > ---
> > > >  tests/xfs/161 | 10 ++++++++--
> > > >  1 file changed, 8 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/tests/xfs/161 b/tests/xfs/161
> > > > index 486fa6ca..94290f18 100755
> > > > --- a/tests/xfs/161
> > > > +++ b/tests/xfs/161
> > > > @@ -38,9 +38,15 @@ _qmount_option "usrquota"
> > > >  _scratch_xfs_db -c 'version' -c 'sb 0' -c 'p' >> $seqres.full
> > > >  _scratch_mount >> $seqres.full
> > > >
> > > > +min_blksz=65536
> > > > +file_blksz=$(_get_file_block_size "$SCRATCH_MNT")
> > > > +# Write more than one block to exceed the soft block quota limit.
> > 
> > Maybe we should improve this comment to -
> > 
> > # Write more than the soft block quota limit of 12k which is set later
> > via xfs_quota
> > # On 64k bs this will get rounded to the nearest blocksize which is 64k
> > 
> > > > +blksz=$(( 2 * $file_blksz))
> > > > +
> > > > +blksz=$(( blksz > min_blksz ? blksz : min_blksz ))
> > >
> > > If we don't set $min_blksize and always write (2 * $file_blksz) does the
> > > test still work?
> > 
> > I guess it won't (even for bs=4k), because we set the bsoft=12k via xfs_quota.
> > So we have to write more than 12k to trigger the grace timer.
> 
> Ah, ok.  Yes, that makes sense with the improved comment. :)

@ritesh and @darrick: I think we can also change the bsoft right? In
the follow up email [1], I made pwrite to 2 fs block and bsoft to be 1
fsblock.


That looks like a cleaner solution than having hardcoded values. Let me
know what you all think.


[1] https://lore.kernel.org/fstests/20240508105852.nfjtlp53v24xb3tw@quentin/
> 
> --D
> 
> > -ritesh
> >
Ritesh Harjani (IBM) May 9, 2024, 5:33 p.m. UTC | #7
"Pankaj Raghav (Samsung)" <kernel@pankajraghav.com> writes:

> On Tue, May 07, 2024 at 03:23:23PM -0700, Darrick J. Wong wrote:
>> On Mon, May 06, 2024 at 05:01:17PM +0200, Pankaj Raghav (Samsung) wrote:
>> > From: Pankaj Raghav <p.raghav@samsung.com>
>> > 
>> > This test fails when xfs is formatted with 64k filesystem block size*.
>> > It fails because the soft quota is not exceeded with the hardcoded 64k
>> > pwrite, thereby, the grace time is not set. Even though soft quota is
>> > set to 12k for uid1, it is rounded up to the nearest blocksize.
>> > 
>> > *** Report for user quotas on device /dev/sdb3
>> > Block grace time: 7days; Inode grace time: 7days
>> >                         Block limits                File limits
>> > User            used    soft    hard  grace    used  soft  hard  grace
>> > ----------------------------------------------------------------------
>> > 0        --       0       0       0      0       3     0     0      0
>> > 1        --      64      64    1024      0       1     0     0      0
>> > 2        --      64       0       0      0       1     0     0      0
>> > 
>> > Adapt the pwrite to do more than 64k write when the FS blocksize is 64k.
>> > 
>> > Cap the blksz to be at least 64k to retain the same behaviour as before
>> > for smaller filesystem blocksizes.
>> > 
>> > * This happens even on a 64k pagesize system and it is not related to
>> >   LBS effort.
>> > 
>> > Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
>> > ---
>> >  tests/xfs/161 | 10 ++++++++--
>> >  1 file changed, 8 insertions(+), 2 deletions(-)
>> > 
>> > diff --git a/tests/xfs/161 b/tests/xfs/161
>> > index 486fa6ca..94290f18 100755
>> > --- a/tests/xfs/161
>> > +++ b/tests/xfs/161
>> > @@ -38,9 +38,15 @@ _qmount_option "usrquota"
>> >  _scratch_xfs_db -c 'version' -c 'sb 0' -c 'p' >> $seqres.full
>> >  _scratch_mount >> $seqres.full
>> >  
>> > +min_blksz=65536
>> > +file_blksz=$(_get_file_block_size "$SCRATCH_MNT")
>> > +# Write more than one block to exceed the soft block quota limit.
>> > +blksz=$(( 2 * $file_blksz))
>> > +
>> > +blksz=$(( blksz > min_blksz ? blksz : min_blksz ))
>> 
>> If we don't set $min_blksize and always write (2 * $file_blksz) does the
>> test still work?
>
> I think something like this is more clean where we don't have anymore
> hardcoded variables:
>

Yes, why not.

> Author: Pankaj Raghav <p.raghav@samsung.com>
> Date:   Thu Jan 18 18:40:39 2024 +0100
>
>     xfs/161: adapt the test case for 64k FS blocksize
>     
>     This test fails when xfs is formatted with 64k filesystem block size*.
>     It fails because the soft quota is not exceeded with the hardcoded 64k
>     pwrite, thereby, the grace time is not set. Even though soft quota is
>     set to 12k for uid1, it is rounded up to the nearest blocksize.
>     
>     *** Report for user quotas on device /dev/sdb3
>     Block grace time: 7days; Inode grace time: 7days
>                             Block limits                File limits
>     User            used    soft    hard  grace    used  soft  hard  grace
>     ----------------------------------------------------------------------
>     0        --       0       0       0      0       3     0     0      0
>     1        --      64      64    1024      0       1     0     0      0
>     2        --      64       0       0      0       1     0     0      0
>     
>     Adapt the pwrite to do twice the FS block size and set the soft limit
>     to be 1 FS block.
>     
>     * This happens even on a 64k pagesize system and it is not related to
>       LBS effort.
>     
>     Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
>
> diff --git a/tests/xfs/161 b/tests/xfs/161
> index 486fa6ca..074acddc 100755
> --- a/tests/xfs/161
> +++ b/tests/xfs/161
> @@ -38,15 +38,21 @@ _qmount_option "usrquota"
>  _scratch_xfs_db -c 'version' -c 'sb 0' -c 'p' >> $seqres.full
>  _scratch_mount >> $seqres.full
>  
> +
> +pgsize=`$here/src/feature -s`
> +file_blksz=$(_get_file_block_size "$SCRATCH_MNT")

small bit: maybe just $blksz is fine.

> +# Write more than one block to exceed the soft block quota limit.
> +blksz=$(( 2 * $file_blksz))

small nit: Instead of blksz here maybe writesz or filesz then?

Then let's make:
lim_bsoft=$blksz, lim_bhard=$(( 10 * blksz )) and writesz=$(( 2 * blksz ))


> +
>  # Force the block counters for uid 1 and 2 above zero
> -_pwrite_byte 0x61 0 64k $SCRATCH_MNT/a >> $seqres.full
> -_pwrite_byte 0x61 0 64k $SCRATCH_MNT/b >> $seqres.full
> +_pwrite_byte 0x61 0 $blksz $SCRATCH_MNT/a >> $seqres.full
> +_pwrite_byte 0x61 0 $blksz $SCRATCH_MNT/b >> $seqres.full
>  sync
>  chown 1 $SCRATCH_MNT/a
>  chown 2 $SCRATCH_MNT/b
>  
>  # Set quota limits on uid 1 before upgrading
> -$XFS_QUOTA_PROG -x -c 'limit -u bsoft=12k bhard=1m 1' $SCRATCH_MNT
> +$XFS_QUOTA_PROG -x -c 'limit -u bsoft='"$file_blksz"' bhard=1m 1' $SCRATCH_MNT

Then we can use $lim_bsoft and $lim_bhard here.

>  
>  # Make sure the grace period is at /some/ point in the future.  We have to
>  # use bc because not all bashes can handle integer comparisons with 64-bit
> @@ -71,7 +77,7 @@ _scratch_mount
>  
>  # Set a very generous grace period and quota limits on uid 2 after upgrading
>  $XFS_QUOTA_PROG -x -c 'timer -u -b -d 2147483647' $SCRATCH_MNT
> -$XFS_QUOTA_PROG -x -c 'limit -u bsoft=10000 bhard=150000 2' $SCRATCH_MNT
> +$XFS_QUOTA_PROG -x -c 'limit -u bsoft='"$file_blksz"' bhard=150000 2' $SCRATCH_MNT
>  
>  # Query the grace periods to see if they got set properly after the upgrade.
>  repquota -upn $SCRATCH_MNT > $tmp.repquota
>


-ritesh
diff mbox series

Patch

diff --git a/tests/xfs/161 b/tests/xfs/161
index 486fa6ca..94290f18 100755
--- a/tests/xfs/161
+++ b/tests/xfs/161
@@ -38,9 +38,15 @@  _qmount_option "usrquota"
 _scratch_xfs_db -c 'version' -c 'sb 0' -c 'p' >> $seqres.full
 _scratch_mount >> $seqres.full
 
+min_blksz=65536
+file_blksz=$(_get_file_block_size "$SCRATCH_MNT")
+# Write more than one block to exceed the soft block quota limit.
+blksz=$(( 2 * $file_blksz))
+
+blksz=$(( blksz > min_blksz ? blksz : min_blksz ))
 # Force the block counters for uid 1 and 2 above zero
-_pwrite_byte 0x61 0 64k $SCRATCH_MNT/a >> $seqres.full
-_pwrite_byte 0x61 0 64k $SCRATCH_MNT/b >> $seqres.full
+_pwrite_byte 0x61 0 $blksz $SCRATCH_MNT/a >> $seqres.full
+_pwrite_byte 0x61 0 $blksz $SCRATCH_MNT/b >> $seqres.full
 sync
 chown 1 $SCRATCH_MNT/a
 chown 2 $SCRATCH_MNT/b