From: David Disseldorp <ddiss@suse.de>
To: fstests@vger.kernel.org
Cc: dchinner@redhat.com, David Disseldorp <ddiss@suse.de>
Subject: [PATCH v2 2/3] common/attr: fix MAX_ATTRVAL_SIZE for XFS, UDF, Btrfs and NFS
Date: Tue, 12 Apr 2022 12:50:00 +0200 [thread overview]
Message-ID: <20220412105001.14325-3-ddiss@suse.de> (raw)
In-Reply-To: <20220412105001.14325-1-ddiss@suse.de>
As found by Dave Chinner, fff4359d ("020: make this xattr test generic")
unintentionally changed the long attribute value length from 100K to 64
*bytes* for XFS, UDF and Btrfs.
Update XFS and UDF to use 64K MAX_ATTRVAL_SIZE value. For Btrfs, use the
nodesize, xattr length and tree entry overhead sizes to calculate the
maximum.
NFS doesn't provide a way to find out the MAX_ATTRVAL_SIZE for the
underlying filesystem on the server, so just use a rough 1K limit.
Signed-off-by: David Disseldorp <ddiss@suse.de>
---
common/attr | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/common/attr b/common/attr
index a80b10a1..1e1c8f6e 100644
--- a/common/attr
+++ b/common/attr
@@ -328,20 +328,32 @@ _attr_get_max()
export MAX_ATTRS
- # Set max attr value size based on fs type
+ # Set max attr value size in bytes based on fs type
case "$FSTYP" in
- xfs|udf|btrfs)
- MAX_ATTRVAL_SIZE=64
+ btrfs)
+ _require_btrfs_command inspect-internal dump-super
+ local ns=$($BTRFS_UTIL_PROG inspect-internal dump-super \
+ $TEST_DEV | sed -n 's/nodesize\s*\(.*\)/\1/p')
+ [ -n "$ns" ] || _fail "failed to obtain nodesize"
+ # max == nodesize - sizeof(struct btrfs_header)
+ # - sizeof(struct btrfs_item)
+ # - sizeof(struct btrfs_dir_item) - name_len
+ MAX_ATTRVAL_SIZE=$(( $ns - 156 - $max_attrval_namelen ))
;;
pvfs2)
MAX_ATTRVAL_SIZE=8192
;;
- 9p|ceph|nfs)
+ xfs|udf|9p|ceph)
MAX_ATTRVAL_SIZE=65536
;;
bcachefs)
MAX_ATTRVAL_SIZE=1024
;;
+ nfs)
+ # NFS doesn't provide a way to find out the MAX_ATTRVAL_SIZE for
+ # the underlying filesystem, so just use the lowest value above.
+ MAX_ATTRVAL_SIZE=1024
+ ;;
*)
# Assume max ~1 block of attrs
BLOCK_SIZE=`_get_block_size $TEST_DIR`
--
2.34.1
next prev parent reply other threads:[~2022-04-12 11:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-12 10:49 [PATCH v2 0/3]: generic/020: fix MAX_ATTRVAL_SIZE values David Disseldorp
2022-04-12 10:49 ` [PATCH v2 1/3] common/attr: add and use _attr_get_max() David Disseldorp
2022-04-13 0:31 ` Dave Chinner
2022-04-12 10:50 ` David Disseldorp [this message]
2022-04-12 10:50 ` [PATCH v2 3/3] generic/020: fix unaligned MAX_ATTRVAL_SIZE output filter David Disseldorp
2022-04-13 0:32 ` Dave Chinner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220412105001.14325-3-ddiss@suse.de \
--to=ddiss@suse.de \
--cc=dchinner@redhat.com \
--cc=fstests@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox