]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
common/xfs: Add a helper to export inode core size
authorZiyang Zhang <ZiyangZhang@linux.alibaba.com>
Mon, 12 Dec 2022 05:56:44 +0000 (13:56 +0800)
committerZorro Lang <zlang@kernel.org>
Tue, 13 Dec 2022 09:14:37 +0000 (17:14 +0800)
Some xfs test cases need the number of bytes reserved for only the inode
record, excluding the immediate fork areas. Now the value is hard-coded
and it is not a good chioce. Add a helper in common/xfs to export the
inode core size.

Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Ziyang Zhang <ZiyangZhang@linux.alibaba.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
common/xfs
tests/xfs/335
tests/xfs/336
tests/xfs/337
tests/xfs/341
tests/xfs/342

index f466d2c42fdd59e20c9387bc3e8cfbb535cdef18..04ae121d4d03a07eddefb5572077d88cee87a4c7 100644 (file)
@@ -1495,3 +1495,18 @@ _require_xfsrestore_xflag()
        $XFSRESTORE_PROG -h 2>&1 | grep -q -e '-x' || \
                        _notrun 'xfsrestore does not support -x flag.'
 }
+
+# Number of bytes reserved for only the inode record, excluding the
+# immediate fork areas.
+_xfs_get_inode_core_bytes()
+{
+       local dir="$1"
+
+       if _xfs_has_feature "$dir" crc; then
+               # v5 filesystems
+               echo 176
+       else
+               # v4 filesystems
+               echo 96
+       fi
+}
index d07485b216cbc3664fd36b15d6c31d1344aae5bf..79d0711647d40f885cce0445a90926e77d7e37b1 100755 (executable)
@@ -31,7 +31,8 @@ blksz="$(_get_block_size $SCRATCH_MNT)"
 echo "Create a three-level rtrmapbt"
 # inode core size is at least 176 bytes; btree header is 56 bytes;
 # rtrmap record is 32 bytes; and rtrmap key/pointer are 56 bytes.
-i_ptrs=$(( (isize - 176) / 56 ))
+i_core_size="$(_xfs_get_inode_core_bytes $SCRATCH_MNT)"
+i_ptrs=$(( (isize - i_core_size) / 56 ))
 bt_ptrs=$(( (blksz - 56) / 56 ))
 bt_recs=$(( (blksz - 56) / 32 ))
 
index ee8ec649cb5de4456395f2f9b83b05f6fa55061c..8d50729e4ffcbcffa3ff4b889b0af89574b49e62 100755 (executable)
@@ -42,7 +42,8 @@ rm -rf $metadump_file
 echo "Create a three-level rtrmapbt"
 # inode core size is at least 176 bytes; btree header is 56 bytes;
 # rtrmap record is 32 bytes; and rtrmap key/pointer are 56 bytes.
-i_ptrs=$(( (isize - 176) / 56 ))
+i_core_size="$(_xfs_get_inode_core_bytes $SCRATCH_MNT)"
+i_ptrs=$(( (isize - i_core_size) / 56 ))
 bt_ptrs=$(( (blksz - 56) / 56 ))
 bt_recs=$(( (blksz - 56) / 32 ))
 
index 8502a5ff201395be28ec486333d1f9be74866092..f74baae9b007d0b22a8a77b289b52bf1f0b24de1 100755 (executable)
@@ -33,7 +33,8 @@ blksz="$(_get_block_size $SCRATCH_MNT)"
 
 # inode core size is at least 176 bytes; btree header is 56 bytes;
 # rtrmap record is 32 bytes; and rtrmap key/pointer are 56 bytes.
-i_ptrs=$(( (isize - 176) / 56 ))
+i_core_size="$(_xfs_get_inode_core_bytes $SCRATCH_MNT)"
+i_ptrs=$(( (isize - i_core_size) / 56 ))
 bt_ptrs=$(( (blksz - 56) / 56 ))
 bt_recs=$(( (blksz - 56) / 32 ))
 
index 122def0f13c6178f31767da243fc8b4c62beab34..1f734c90150f1d2d6c08152f033b3490e96a7d6c 100755 (executable)
@@ -33,7 +33,8 @@ rtextsz_blks=$((rtextsz / blksz))
 
 # inode core size is at least 176 bytes; btree header is 56 bytes;
 # rtrmap record is 32 bytes; and rtrmap key/pointer are 56 bytes.
-i_ptrs=$(( (isize - 176) / 56 ))
+i_core_size="$(_xfs_get_inode_core_bytes $SCRATCH_MNT)"
+i_ptrs=$(( (isize - i_core_size) / 56 ))
 bt_recs=$(( (blksz - 56) / 32 ))
 
 blocks=$((i_ptrs * bt_recs + 1))
index 73f7fc04e5ded7c4fd57618a676d29a52163c260..538c8987ef241acc4a58b1da17340dd7ad2b5db7 100755 (executable)
@@ -30,7 +30,8 @@ blksz="$(_get_block_size $SCRATCH_MNT)"
 
 # inode core size is at least 176 bytes; btree header is 56 bytes;
 # rtrmap record is 32 bytes; and rtrmap key/pointer are 56 bytes.
-i_ptrs=$(( (isize - 176) / 56 ))
+i_core_size="$(_xfs_get_inode_core_bytes $SCRATCH_MNT)"
+i_ptrs=$(( (isize - i_core_size) / 56 ))
 bt_recs=$(( (blksz - 56) / 32 ))
 
 blocks=$((i_ptrs * bt_recs + 1))