FS/XFS testing framework
 help / color / mirror / Atom feed
* [PATCH] xfs/191: fix xattr leaf block emptying on 64k blocksized fses
@ 2023-02-02 21:09 Anthony Iliopoulos
  2023-02-03  0:04 ` Darrick J. Wong
  2023-02-03  0:33 ` Bill O'Donnell
  0 siblings, 2 replies; 3+ messages in thread
From: Anthony Iliopoulos @ 2023-02-02 21:09 UTC (permalink / raw)
  To: fstests

This test is failing on filesystems with 64k blocksize since the leaf
hdr.firstused field is 16 bit and as such trying to reset it to $dbsize
overflows and is rejected by xfs_db. The leaf is never properly resetted
and the discrepancy is picked up by xfs_repair, thus failing the test.

Fix it by setting it to XFS_ATTR3_LEAF_NULLOFF (0) as this is the proper
on-disk value to indicate an empty leaf on 64k blocksized fses.

Signed-off-by: Anthony Iliopoulos <ailiop@suse.com>
---
 tests/xfs/191 | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/tests/xfs/191 b/tests/xfs/191
index 4f0a9b9eeef5..8dd875fcd28b 100755
--- a/tests/xfs/191
+++ b/tests/xfs/191
@@ -78,10 +78,20 @@ make_empty_leaf() {
 
 	base=$(_scratch_xfs_get_metadata_field "hdr.freemap[0].base" "inode $inum" "ablock 0")
 
+	# 64k dbsize is a special case since it overflows the 16 bit firstused
+	# field and it needs to be set to the special XFS_ATTR3_LEAF_NULLOFF (0)
+	# value to indicate a null leaf. For more details see kernel commit:
+	# e87021a2bc10 ("xfs: use larger in-core attr firstused field and detect overflow").
+	if [ $dbsize -eq 65536 ]; then
+		firstused=0;
+	else
+		firstused=$dbsize;
+	fi
+
 	_scratch_xfs_db -x -c "inode $inum" -c "ablock 0" \
 		-c "write -d hdr.count 0" \
 		-c "write -d hdr.usedbytes 0" \
-		-c "write -d hdr.firstused $dbsize" \
+		-c "write -d hdr.firstused $firstused" \
 		-c "write -d hdr.freemap[0].size $((dbsize - base))" \
 		-c print >> $seqres.full
 }
-- 
2.35.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] xfs/191: fix xattr leaf block emptying on 64k blocksized fses
  2023-02-02 21:09 [PATCH] xfs/191: fix xattr leaf block emptying on 64k blocksized fses Anthony Iliopoulos
@ 2023-02-03  0:04 ` Darrick J. Wong
  2023-02-03  0:33 ` Bill O'Donnell
  1 sibling, 0 replies; 3+ messages in thread
From: Darrick J. Wong @ 2023-02-03  0:04 UTC (permalink / raw)
  To: Anthony Iliopoulos; +Cc: fstests

On Thu, Feb 02, 2023 at 10:09:40PM +0100, Anthony Iliopoulos wrote:
> This test is failing on filesystems with 64k blocksize since the leaf
> hdr.firstused field is 16 bit and as such trying to reset it to $dbsize
> overflows and is rejected by xfs_db. The leaf is never properly resetted
> and the discrepancy is picked up by xfs_repair, thus failing the test.
> 
> Fix it by setting it to XFS_ATTR3_LEAF_NULLOFF (0) as this is the proper
> on-disk value to indicate an empty leaf on 64k blocksized fses.
> 
> Signed-off-by: Anthony Iliopoulos <ailiop@suse.com>
> ---
>  tests/xfs/191 | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/xfs/191 b/tests/xfs/191
> index 4f0a9b9eeef5..8dd875fcd28b 100755
> --- a/tests/xfs/191
> +++ b/tests/xfs/191
> @@ -78,10 +78,20 @@ make_empty_leaf() {
>  
>  	base=$(_scratch_xfs_get_metadata_field "hdr.freemap[0].base" "inode $inum" "ablock 0")
>  
> +	# 64k dbsize is a special case since it overflows the 16 bit firstused
> +	# field and it needs to be set to the special XFS_ATTR3_LEAF_NULLOFF (0)
> +	# value to indicate a null leaf. For more details see kernel commit:
> +	# e87021a2bc10 ("xfs: use larger in-core attr firstused field and detect overflow").

Do we need a second _fixed_by_kernel_commit here?

> +	if [ $dbsize -eq 65536 ]; then
> +		firstused=0;
> +	else
> +		firstused=$dbsize;

Trailing semicolon not necessary here.

> +	fi

Otherwise, looks correct to me, so
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> +
>  	_scratch_xfs_db -x -c "inode $inum" -c "ablock 0" \
>  		-c "write -d hdr.count 0" \
>  		-c "write -d hdr.usedbytes 0" \
> -		-c "write -d hdr.firstused $dbsize" \
> +		-c "write -d hdr.firstused $firstused" \
>  		-c "write -d hdr.freemap[0].size $((dbsize - base))" \
>  		-c print >> $seqres.full
>  }
> -- 
> 2.35.3
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] xfs/191: fix xattr leaf block emptying on 64k blocksized fses
  2023-02-02 21:09 [PATCH] xfs/191: fix xattr leaf block emptying on 64k blocksized fses Anthony Iliopoulos
  2023-02-03  0:04 ` Darrick J. Wong
@ 2023-02-03  0:33 ` Bill O'Donnell
  1 sibling, 0 replies; 3+ messages in thread
From: Bill O'Donnell @ 2023-02-03  0:33 UTC (permalink / raw)
  To: Anthony Iliopoulos; +Cc: fstests

On Thu, Feb 02, 2023 at 10:09:40PM +0100, Anthony Iliopoulos wrote:
> This test is failing on filesystems with 64k blocksize since the leaf
> hdr.firstused field is 16 bit and as such trying to reset it to $dbsize
> overflows and is rejected by xfs_db. The leaf is never properly resetted
> and the discrepancy is picked up by xfs_repair, thus failing the test.
> 
> Fix it by setting it to XFS_ATTR3_LEAF_NULLOFF (0) as this is the proper
> on-disk value to indicate an empty leaf on 64k blocksized fses.
> 
> Signed-off-by: Anthony Iliopoulos <ailiop@suse.com>

On my ppc64le box, this patch fixes the problem nicely. Thanks!

Reviewed-by: Bill O'Donnell <bodonnel@redhat.com>

> ---
>  tests/xfs/191 | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/xfs/191 b/tests/xfs/191
> index 4f0a9b9eeef5..8dd875fcd28b 100755
> --- a/tests/xfs/191
> +++ b/tests/xfs/191
> @@ -78,10 +78,20 @@ make_empty_leaf() {
>  
>  	base=$(_scratch_xfs_get_metadata_field "hdr.freemap[0].base" "inode $inum" "ablock 0")
>  
> +	# 64k dbsize is a special case since it overflows the 16 bit firstused
> +	# field and it needs to be set to the special XFS_ATTR3_LEAF_NULLOFF (0)
> +	# value to indicate a null leaf. For more details see kernel commit:
> +	# e87021a2bc10 ("xfs: use larger in-core attr firstused field and detect overflow").
> +	if [ $dbsize -eq 65536 ]; then
> +		firstused=0;
> +	else
> +		firstused=$dbsize;
> +	fi
> +
>  	_scratch_xfs_db -x -c "inode $inum" -c "ablock 0" \
>  		-c "write -d hdr.count 0" \
>  		-c "write -d hdr.usedbytes 0" \
> -		-c "write -d hdr.firstused $dbsize" \
> +		-c "write -d hdr.firstused $firstused" \
>  		-c "write -d hdr.freemap[0].size $((dbsize - base))" \
>  		-c print >> $seqres.full
>  }
> -- 
> 2.35.3
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-02-03  0:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-02 21:09 [PATCH] xfs/191: fix xattr leaf block emptying on 64k blocksized fses Anthony Iliopoulos
2023-02-03  0:04 ` Darrick J. Wong
2023-02-03  0:33 ` Bill O'Donnell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox