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 _begin_fstest auto quick attr
17 # Import common functions.
21 # real QA test starts here
27 if [ $FSTYP = "xfs" ]; then
28 # avoid crashing the system if possible
29 _require_no_xfs_bug_on_assert
31 # Use fixed inode size 512, so both v4 and v5 can be tested,
32 # and also make sure the issue can be triggered if the default
33 # inode size is changed later.
34 MKFS_OPTIONS="$MKFS_OPTIONS -i size=512"
37 _scratch_mkfs > $seqres.full 2>&1
40 localfile="${SCRATCH_MNT}/testfile"
43 # value cannot exceed XFS_ATTR_SF_ENTSIZE_MAX (256) or it will turn into leaf
44 # form directly; the following combination can trigger the issue for both v4
45 # (XFS_LITINO = 412) & v5 (XFS_LITINO = 336) fses, in details the 2nd setattr
46 # causes an integer underflow that is incorrectly typecast, leading to the
48 "${SETFATTR_PROG}" -n user.0 -v "`seq 0 80`" "${localfile}"
49 "${SETFATTR_PROG}" -n user.1 -v "`seq 0 80`" "${localfile}"
51 # Make sure that changes are written to disk
54 # getfattr won't succeed with the expected result if fails
55 _getfattr --absolute-names -ebase64 -d $localfile | tail -n +2 | sort