generic/020: move MAX_ATTRS and MAX_ATTRVAL_SIZE logic
authorDavid Disseldorp <ddiss@suse.de>
Wed, 13 Apr 2022 16:44:19 +0000 (18:44 +0200)
committerEryu Guan <guaneryu@gmail.com>
Sun, 17 Apr 2022 12:08:04 +0000 (20:08 +0800)
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 <ddiss@suse.de>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
common/attr
tests/generic/020

index dae8a1bb0824a153c2b4945621ccf6f2a69371a9..cce4d1b201b2790a8cf2250b234ddfe16634c5e4 100644 (file)
@@ -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
index 29ef853c87f389492c1fdcc5abef0d17c79383d2..c2c285f60d595a6c22def6d4cf28dbfceec4eceb 100755 (executable)
@@ -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