2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2020 Red Hat, Inc. All Rights Reserved.
7 # Verify that forkoff can be returned as 0 properly if it isn't
8 # able to fit inline for XFS.
9 # However, this test is fs-neutral and can be done quickly so
11 # This test verifies the problem fixed in kernel with commit
12 # ada49d64fb35 ("xfs: fix forkoff miscalculation related to XFS_LITINO(mp)")
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
20 status=1 # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
29 # get standard environment, filters and checks
34 # remove previous $seqres.full before test
37 # real QA test starts here
43 if [ $FSTYP = "xfs" ]; then
44 # avoid crashing the system if possible
45 _require_no_xfs_bug_on_assert
47 # Use fixed inode size 512, so both v4 and v5 can be tested,
48 # and also make sure the issue can be triggered if the default
49 # inode size is changed later.
50 MKFS_OPTIONS="$MKFS_OPTIONS -i size=512"
53 _scratch_mkfs > $seqres.full 2>&1
56 localfile="${SCRATCH_MNT}/testfile"
59 # value cannot exceed XFS_ATTR_SF_ENTSIZE_MAX (256) or it will turn into leaf
60 # form directly; the following combination can trigger the issue for both v4
61 # (XFS_LITINO = 412) & v5 (XFS_LITINO = 336) fses, in details the 2nd setattr
62 # causes an integer underflow that is incorrectly typecast, leading to the
64 "${SETFATTR_PROG}" -n user.0 -v "`seq 0 80`" "${localfile}"
65 "${SETFATTR_PROG}" -n user.1 -v "`seq 0 80`" "${localfile}"
67 # Make sure that changes are written to disk
70 # getfattr won't succeed with the expected result if fails
71 _getfattr --absolute-names -ebase64 -d $localfile | tail -n +2 | sort