From patchwork Wed Apr 13 16:44:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Disseldorp X-Patchwork-Id: 12812245 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB45BC433F5 for ; Wed, 13 Apr 2022 16:45:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235348AbiDMQrW (ORCPT ); Wed, 13 Apr 2022 12:47:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237040AbiDMQrD (ORCPT ); Wed, 13 Apr 2022 12:47:03 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB9513B2B9 for ; Wed, 13 Apr 2022 09:44:32 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id DB4C21FCFD; Wed, 13 Apr 2022 16:44:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1649868270; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gTNBRUCOFQUiFwHnsPPG16Gbly90U1iDWMl2GbyBw0E=; b=Om0UJW5GSHVUPOsJlxeNKZVpI4saTsJdyOp2PzfiS1a02IWVNvMk0ACNFwaemgJdZSEs2s tnQEH1Jqk6yy6iLtTXu+US3rAGfpMzI3vtr/Weu30vuM5qLHT7g5UpdGr7tqPyCt4E7pWo FD0Ulw1kWxDvIdU+h2QzBUAFflXDMtg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1649868270; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gTNBRUCOFQUiFwHnsPPG16Gbly90U1iDWMl2GbyBw0E=; b=/hZIhK9cwOLyPEyE/LTYcwwzp+/gr/r5kX701QfhV6n3oiPV+owK2AxAlf50A5t0uCmrHD L0TaGlgxB+43bcCQ== Received: from echidna.suse.de (unknown [10.163.47.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id BCEADA3BA4; Wed, 13 Apr 2022 16:44:30 +0000 (UTC) From: David Disseldorp To: fstests@vger.kernel.org Cc: dchinner@redhat.com, David Disseldorp Subject: [PATCH v3 1/4] generic/020: move MAX_ATTRS and MAX_ATTRVAL_SIZE logic Date: Wed, 13 Apr 2022 18:44:19 +0200 Message-Id: <20220413164422.30077-2-ddiss@suse.de> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220413164422.30077-1-ddiss@suse.de> References: <20220413164422.30077-1-ddiss@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org No functional change. MAX_ATTRS and MAX_ATTRVAL_SIZE are only used within generic/020, so move the logic for determining these values over there. Signed-off-by: David Disseldorp --- common/attr | 75 ---------------------------------------------- tests/generic/020 | 76 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 75 deletions(-) diff --git a/common/attr b/common/attr index dae8a1bb..cce4d1b2 100644 --- a/common/attr +++ b/common/attr @@ -264,80 +264,5 @@ _getfattr() return ${PIPESTATUS[0]} } -# set maximum total attr space based on fs type -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` - # user.attribute_XXX="value.XXX" is about 32 bytes; leave some overhead - let MAX_ATTRS=$BLOCK_SIZE/40 -esac - -export MAX_ATTRS - -# Set max attr value size based on fs type -case "$FSTYP" in -xfs|udf|btrfs) - MAX_ATTRVAL_SIZE=64 - ;; -pvfs2) - MAX_ATTRVAL_SIZE=8192 - ;; -9p|ceph|nfs) - MAX_ATTRVAL_SIZE=65536 - ;; -bcachefs) - MAX_ATTRVAL_SIZE=1024 - ;; -*) - # Assume max ~1 block of attrs - BLOCK_SIZE=`_get_block_size $TEST_DIR` - # leave a little overhead - let MAX_ATTRVAL_SIZE=$BLOCK_SIZE-256 -esac - -export MAX_ATTRVAL_SIZE # make sure this script returns success /bin/true diff --git a/tests/generic/020 b/tests/generic/020 index 29ef853c..c2c285f6 100755 --- a/tests/generic/020 +++ b/tests/generic/020 @@ -51,6 +51,82 @@ _attr_list() fi } +# set maximum total attr space based on fs type +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` + # user.attribute_XXX="value.XXX" is about 32 bytes; leave some overhead + let MAX_ATTRS=$BLOCK_SIZE/40 +esac + +export MAX_ATTRS + +# Set max attr value size based on fs type +case "$FSTYP" in +xfs|udf|btrfs) + MAX_ATTRVAL_SIZE=64 + ;; +pvfs2) + MAX_ATTRVAL_SIZE=8192 + ;; +9p|ceph|nfs) + MAX_ATTRVAL_SIZE=65536 + ;; +bcachefs) + MAX_ATTRVAL_SIZE=1024 + ;; +*) + # Assume max ~1 block of attrs + BLOCK_SIZE=`_get_block_size $TEST_DIR` + # leave a little overhead + let MAX_ATTRVAL_SIZE=$BLOCK_SIZE-256 +esac + +export MAX_ATTRVAL_SIZE + # real QA test starts here _supported_fs generic From patchwork Wed Apr 13 16:44:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Disseldorp X-Patchwork-Id: 12812244 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBDEBC433EF for ; Wed, 13 Apr 2022 16:45:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237032AbiDMQrY (ORCPT ); Wed, 13 Apr 2022 12:47:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237049AbiDMQrD (ORCPT ); Wed, 13 Apr 2022 12:47:03 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB8E03B2B7 for ; Wed, 13 Apr 2022 09:44:32 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 099DF1FCFE; Wed, 13 Apr 2022 16:44:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1649868271; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7C+0Q+oglDhX03MMtuaPNFmC0yYRmwoX/+Af89y17RI=; b=zcpjXelDwRsfYZYDp/lNauQ2ZUoZ4F60qnxEPMS5Vg58X+i9tphUOTdWVB4LismmOH4wo9 zzw8IUBgPOsYRP18BSrbK73SS38blSCvlwveVqvm36QFLwgQXrwxIm9J2GubfIerOqGgfs QBBtIAZsq3qPJsn5LEhX7CSPmD3x2PU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1649868271; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7C+0Q+oglDhX03MMtuaPNFmC0yYRmwoX/+Af89y17RI=; b=I/34RO/KCuFiXchJt01hy3CwFpDeI3yqrZl1aULuHmgrU1w7dManOLmN5k6Fcos4IbHCli iG3CEnExvBH67gBQ== Received: from echidna.suse.de (unknown [10.163.47.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id E26BAA3BA5; Wed, 13 Apr 2022 16:44:30 +0000 (UTC) From: David Disseldorp To: fstests@vger.kernel.org Cc: dchinner@redhat.com, David Disseldorp Subject: [PATCH v3 2/4] generic/020: add and use _attr_get_max() Date: Wed, 13 Apr 2022 18:44:20 +0200 Message-Id: <20220413164422.30077-3-ddiss@suse.de> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220413164422.30077-1-ddiss@suse.de> References: <20220413164422.30077-1-ddiss@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org In preparation for taking into account the attr name length when calculating $MAX_ATTRVAL_SIZE, put the current logic in a _attr_get_max() helper function and set local $max_attrval_size / $max_attrs variables instead of using export. Signed-off-by: David Disseldorp --- tests/generic/020 | 178 +++++++++++++++++++++++++--------------------- 1 file changed, 95 insertions(+), 83 deletions(-) diff --git a/tests/generic/020 b/tests/generic/020 index c2c285f6..cbd3f227 100755 --- a/tests/generic/020 +++ b/tests/generic/020 @@ -51,81 +51,89 @@ _attr_list() fi } -# set maximum total attr space based on fs type -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` - # user.attribute_XXX="value.XXX" is about 32 bytes; leave some overhead - let MAX_ATTRS=$BLOCK_SIZE/40 -esac - -export MAX_ATTRS - -# Set max attr value size based on fs type -case "$FSTYP" in -xfs|udf|btrfs) - MAX_ATTRVAL_SIZE=64 - ;; -pvfs2) - MAX_ATTRVAL_SIZE=8192 - ;; -9p|ceph|nfs) - MAX_ATTRVAL_SIZE=65536 - ;; -bcachefs) - MAX_ATTRVAL_SIZE=1024 - ;; -*) - # Assume max ~1 block of attrs - BLOCK_SIZE=`_get_block_size $TEST_DIR` - # leave a little overhead - let MAX_ATTRVAL_SIZE=$BLOCK_SIZE-256 -esac - -export MAX_ATTRVAL_SIZE +# set fs-specific max_attrs and max_attrval_size values. The parameter +# @max_attrval_namelen is required for filesystems which take into account attr +# name lengths (including namespace prefix) when determining limits. +_attr_get_max() +{ + local max_attrval_namelen="$1" + + # set maximum total attr space based on fs type + 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` + # user.attribute_XXX="value.XXX" is about 32 bytes; leave some + # overhead + let max_attrs=$BLOCK_SIZE/40 + esac + + # Set max attr value size based on fs type + case "$FSTYP" in + xfs|udf|btrfs) + max_attrval_size=64 + ;; + pvfs2) + max_attrval_size=8192 + ;; + 9p|ceph|nfs) + max_attrval_size=65536 + ;; + bcachefs) + max_attrval_size=1024 + ;; + *) + # Assume max ~1 block of attrs + BLOCK_SIZE=`_get_block_size $TEST_DIR` + # leave a little overhead + let max_attrval_size=$BLOCK_SIZE-256 + esac +} # real QA test starts here _supported_fs generic @@ -161,10 +169,13 @@ echo "*** remove attribute" _attr -r fish $testfile _attr_list $testfile +max_attrval_name="long_attr" # add 5 for "user." prefix +_attr_get_max "$(( 5 + ${#max_attrval_name} ))" + echo "*** add lots of attributes" v=0 -while [ $v -lt $MAX_ATTRS ] +while [ $v -lt $max_attrs ] do echo -n "value_$v" | attr -s "attribute_$v" $testfile >>$seqres.full if [ $? -ne 0 ] @@ -185,11 +196,11 @@ _getfattr --absolute-names $testfile \ /^[ ]*$/ { next } { l++ } END {print " *** " (l - 1) " attribute(s)" }' \ - | sed s/$MAX_ATTRS/MAX_ATTRS/ + | sed s/$max_attrs/MAX_ATTRS/ echo "*** remove lots of attributes" v=0 -while [ $v -lt $MAX_ATTRS ] +while [ $v -lt $max_attrs ] do if ! $ATTR_PROG -r "attribute_$v" $testfile >>$seqres.full then @@ -203,12 +214,13 @@ done _attr_list $testfile echo "*** really long value" -dd if=/dev/zero bs=1 count=$MAX_ATTRVAL_SIZE 2>/dev/null \ - | _attr -s "long_attr" $testfile >/dev/null +dd if=/dev/zero bs=1 count=$max_attrval_size 2>/dev/null \ + | _attr -s "$max_attrval_name" $testfile >/dev/null -OCTAL_SIZE=`echo "obase=8; $MAX_ATTRVAL_SIZE" | bc` -_attr -q -g "long_attr" $testfile | od -t x1 | sed -e "s/^0*$OCTAL_SIZE$/ATTRSIZE/" -_attr -r "long_attr" $testfile >/dev/null +OCTAL_SIZE=`echo "obase=8; $max_attrval_size" | bc` +_attr -q -g "$max_attrval_name" $testfile | od -t x1 \ + | sed -e "s/^0*$OCTAL_SIZE$/ATTRSIZE/" +_attr -r "$max_attrval_name" $testfile >/dev/null echo "*** set/get/remove really long names (expect failure)" short="XXXXXXXXXX" From patchwork Wed Apr 13 16:44:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Disseldorp X-Patchwork-Id: 12812242 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C70E6C43217 for ; Wed, 13 Apr 2022 16:44:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237026AbiDMQrQ (ORCPT ); Wed, 13 Apr 2022 12:47:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237056AbiDMQrE (ORCPT ); Wed, 13 Apr 2022 12:47:04 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBDFA3B3C2 for ; Wed, 13 Apr 2022 09:44:32 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 2F12A1FCFF; Wed, 13 Apr 2022 16:44:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1649868271; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jhH/84AHGN0q6LaLG+GTHnxJWCqg1Ebh5hju/hRj41M=; b=mkJ+uKEpF++RJN6eVJ0GToFgnlJlT1rTQVnnz7LMWlIp5uAbXSKDZRYb9dbhiydXBPBLwj boN5MbvO74bpfNqAbq+6QurJvM4eNuX19LV+9ztpPt4NKEJYgFY/oSf7WtOEYySndYTIHl eCz34ld0ievWyF+tG41ln3dy/2rWgow= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1649868271; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jhH/84AHGN0q6LaLG+GTHnxJWCqg1Ebh5hju/hRj41M=; b=dW1fBdbX1bSlm+UOsBxd8Npud5ycmLqOTlPCEOQqYl13qRlJqhAWxwyfCrRWI3sXJ/2Ygq 2ZzIUqOnrHj/OkDg== Received: from echidna.suse.de (unknown [10.163.47.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 12883A3BA7; Wed, 13 Apr 2022 16:44:31 +0000 (UTC) From: David Disseldorp To: fstests@vger.kernel.org Cc: dchinner@redhat.com, David Disseldorp Subject: [PATCH v3 3/4] generic/020: fix max_attrval_size for XFS, UDF, Btrfs and NFS Date: Wed, 13 Apr 2022 18:44:21 +0200 Message-Id: <20220413164422.30077-4-ddiss@suse.de> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220413164422.30077-1-ddiss@suse.de> References: <20220413164422.30077-1-ddiss@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org 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 a 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 --- tests/generic/020 | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/generic/020 b/tests/generic/020 index cbd3f227..f50a4f87 100755 --- a/tests/generic/020 +++ b/tests/generic/020 @@ -113,20 +113,32 @@ _attr_get_max() let max_attrs=$BLOCK_SIZE/40 esac - # 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` From patchwork Wed Apr 13 16:44:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Disseldorp X-Patchwork-Id: 12812246 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85CF9C4332F for ; Wed, 13 Apr 2022 16:45:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236995AbiDMQrZ (ORCPT ); Wed, 13 Apr 2022 12:47:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237047AbiDMQrD (ORCPT ); Wed, 13 Apr 2022 12:47:03 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB6473B2A4 for ; Wed, 13 Apr 2022 09:44:32 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 52E84210DD; Wed, 13 Apr 2022 16:44:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1649868271; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6ZeaAY/xvoAhNyah9CoB19X9VkIzjTjylmwiEeYqFdw=; b=s9Zzf4zm8E228HQ0MYLw+zjpZM4zOK40olkLl2h5eoqG8GFub1LLtpW/7aS+VJjDAOt5Wc jw4Bt3g+KX202yU6KL00cXbloy4h9oM0GdzlpQfC45/f0YLRV+ySUSzMw3hzhrKq/aNLl/ J+QZwDST4Za2Brm7wr7glFQSIvp1QeU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1649868271; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6ZeaAY/xvoAhNyah9CoB19X9VkIzjTjylmwiEeYqFdw=; b=A+6vda1qqaXnb1Sw96aNotLW2f3QVFMeXHL1ZNr4LUbC/c67qclwPDEbh2L/bfsm58vwGT Lrr6jQU0nVyfOWCA== Received: from echidna.suse.de (unknown [10.163.47.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 3606DA3BA8; Wed, 13 Apr 2022 16:44:31 +0000 (UTC) From: David Disseldorp To: fstests@vger.kernel.org Cc: dchinner@redhat.com, David Disseldorp Subject: [PATCH v3 4/4] generic/020: fix max_attrval_size output filter Date: Wed, 13 Apr 2022 18:44:22 +0200 Message-Id: <20220413164422.30077-5-ddiss@suse.de> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220413164422.30077-1-ddiss@suse.de> References: <20220413164422.30077-1-ddiss@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org The current attr -g "$max_attrval_name" output filter is broken if $max_attrval_size isn't 16-byte aligned, due to od's duplicate suppression behaviour. Fix it by having od only dump one byte per line. Signed-off-by: David Disseldorp Reviewed-by: Dave Chinner --- tests/generic/020 | 2 +- tests/generic/020.out | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/generic/020 b/tests/generic/020 index f50a4f87..d8648e96 100755 --- a/tests/generic/020 +++ b/tests/generic/020 @@ -230,7 +230,7 @@ dd if=/dev/zero bs=1 count=$max_attrval_size 2>/dev/null \ | _attr -s "$max_attrval_name" $testfile >/dev/null OCTAL_SIZE=`echo "obase=8; $max_attrval_size" | bc` -_attr -q -g "$max_attrval_name" $testfile | od -t x1 \ +_attr -q -g "$max_attrval_name" $testfile | od -w1 -t x1 \ | sed -e "s/^0*$OCTAL_SIZE$/ATTRSIZE/" _attr -r "$max_attrval_name" $testfile >/dev/null diff --git a/tests/generic/020.out b/tests/generic/020.out index 7e3e65bd..0dc5e09f 100644 --- a/tests/generic/020.out +++ b/tests/generic/020.out @@ -47,7 +47,7 @@ user.snrub="fish2\012" user.snrub="fish2\012" *** really long value -0000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +0000000 00 * ATTRSIZE *** set/get/remove really long names (expect failure)