All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ritesh Harjani <riteshh@linux.ibm.com>
To: fstests@vger.kernel.org
Cc: linux-ext4@vger.kernel.org, "Theodore Ts'o" <tytso@mit.edu>,
	"Darrick J . Wong" <djwong@kernel.org>,
	Ritesh Harjani <riteshh@linux.ibm.com>
Subject: [PATCHv2 9/9] common/attr: Reduce MAX_ATTRS to leave some overhead for 64K blocksize
Date: Wed, 21 Jul 2021 10:58:02 +0530	[thread overview]
Message-ID: <1109c811f550f918b8ea8bbe49323f32653b488f.1626844259.git.riteshh@linux.ibm.com> (raw)
In-Reply-To: <cover.1626844259.git.riteshh@linux.ibm.com>

Test generic/020 fails for ext4 with 64K blocksize.
This adds changes in common/attr for MAX_ATTRS calculations for
ext2|ext3|ext4 along with comments explaining the calculations.

Suggested-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>
---
 common/attr | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/common/attr b/common/attr
index d3902346..35682d7c 100644
--- a/common/attr
+++ b/common/attr
@@ -256,6 +256,45 @@ case "$FSTYP" in
 xfs|udf|pvfs2|9p|ceph|nfs)
 	MAX_ATTRS=1000
 	;;
+ext2|ext3|ext4)
+	# For 4k blocksizes, most of the attributes have an attr_name of
+	# "attribute_NN" which is 12, and "value_NN" which is 8.
+	# But for larger block sizes, we start having extended attributes of the
+	# form "attribute_NNN" or "attribute_NNNN", and "value_NNN" and
+	# "value_NNNN", which causes the round(len(..), 4) to jump up by 4
+	# bytes.  So round_up(len(attr_name, 4)) becomes 16 instead of 12, and
+	# round_up(len(value, 4)) becomes 12 instead of 8.
+	#
+	# For 64K blocksize the calculation becomes
+	# 	max_attrs = (block_size - 32) / (16 + 12 + 16)
+	# or
+	# 	max_attrs = (block_size - 32) / 44
+	#
+	# For 4K blocksize:-
+	# 	max_attrs = (block_size - 32) / (16 + 8 + 12)
+	# or
+	# 	max_attrs = (block_size - 32) / 36
+	#
+	# Note (for 4K bs) above are exact calculations for attrs of type
+	# attribute_NN with values of type value_NN.
+	# With above calculations, for 4k blocksize max_attrs becomes 112.
+	# This means we can have few attrs of type attribute_NNN with values of
+	# type value_NNN. To avoid/handle this we need to add extra 4 bytes of
+	# headroom.
+	#
+	# So for 4K, the calculations becomes:-
+	# 	max_attrs = (block_size - 32) / (16 + 8 + 12 + 4)
+	# or
+	# 	max_attrs = (block_size - 32) / 40
+	#
+	# Assume max ~1 block of attrs
+	BLOCK_SIZE=`_get_block_size $TEST_DIR`
+	if [ $BLOCK_SIZE -le 4096 ]; then
+		let MAX_ATTRS=$((($BLOCK_SIZE - 32) / (16 + 8 + 12 + 4)))
+	else
+		let MAX_ATTRS=$((($BLOCK_SIZE - 32) / (16 + 12 + 16 )))
+	fi
+	;;
 *)
 	# Assume max ~1 block of attrs
 	BLOCK_SIZE=`_get_block_size $TEST_DIR`
-- 
2.31.1


  parent reply	other threads:[~2021-07-21  5:28 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-21  5:27 [PATCHv2 0/9] xfstests: 64K blocksize related fixes Ritesh Harjani
2021-07-21  5:27 ` [PATCHv2 1/9] ext4/003: Fix this test on 64K platform for dax config Ritesh Harjani
2021-07-21  5:27 ` [PATCHv2 2/9] ext4/027: Correct the right code of block and inode bitmap Ritesh Harjani
2021-07-21  5:27 ` [PATCHv2 3/9] ext4/306: Add -b blocksize parameter too to avoid failure with DAX config Ritesh Harjani
2021-07-21  5:27 ` [PATCHv2 4/9] ext4/022: exclude this test for dax config on 64KB pagesize platform Ritesh Harjani
2021-07-21  5:27 ` [PATCHv2 5/9] generic/031: Fix the test case for 64k blocksize config Ritesh Harjani
2021-08-01 16:00   ` Eryu Guan
2021-08-03  5:00     ` Ritesh Harjani
2021-08-08 12:36       ` Eryu Guan
2021-07-21  5:27 ` [PATCHv2 6/9] common/rc: Add _mkfs_dev_blocksized functionality Ritesh Harjani
2021-07-21  5:28 ` [PATCHv2 7/9] generic/620: Use _mkfs_dev_blocksized to use 4k bs Ritesh Harjani
2021-08-01 16:03   ` Eryu Guan
2021-08-03  5:06     ` Ritesh Harjani
2021-08-08 13:32       ` Eryu Guan
2021-07-21  5:28 ` [PATCHv2 8/9] common/attr: Cleanup end of line whitespaces issues Ritesh Harjani
2021-07-21  5:28 ` Ritesh Harjani [this message]
2021-08-01 16:05 ` [PATCHv2 0/9] xfstests: 64K blocksize related fixes Eryu Guan

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=1109c811f550f918b8ea8bbe49323f32653b488f.1626844259.git.riteshh@linux.ibm.com \
    --to=riteshh@linux.ibm.com \
    --cc=djwong@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.