common/rc: add _scratch_{u}mount_idmapped() helpers
[xfstests-dev.git] / tests / generic / 618
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2020 Red Hat, Inc. All Rights Reserved.
4 #
5 # FS QA Test 618
6 #
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
10 # leave it in generic
11 # This test verifies the problem fixed in kernel with commit
12 # ada49d64fb35 ("xfs: fix forkoff miscalculation related to XFS_LITINO(mp)")
13
14 seq=`basename $0`
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
17
18 here=`pwd`
19 tmp=/tmp/$$
20 status=1        # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
22
23 _cleanup()
24 {
25         cd /
26         rm -f $tmp.*
27 }
28
29 # get standard environment, filters and checks
30 . ./common/rc
31 . ./common/filter
32 . ./common/attr
33
34 # remove previous $seqres.full before test
35 rm -f $seqres.full
36
37 # real QA test starts here
38
39 _supported_fs generic
40 _require_scratch
41 _require_attrs user
42
43 if [ $FSTYP = "xfs" ]; then
44         # avoid crashing the system if possible
45         _require_no_xfs_bug_on_assert
46
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"
51 fi
52
53 _scratch_mkfs > $seqres.full 2>&1
54 _scratch_mount
55
56 localfile="${SCRATCH_MNT}/testfile"
57 touch $localfile
58
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
63 # assert triggering.
64 "${SETFATTR_PROG}" -n user.0 -v "`seq 0 80`" "${localfile}"
65 "${SETFATTR_PROG}" -n user.1 -v "`seq 0 80`" "${localfile}"
66
67 # Make sure that changes are written to disk
68 _scratch_cycle_mount
69
70 # getfattr won't succeed with the expected result if fails
71 _getfattr --absolute-names -ebase64 -d $localfile | tail -n +2 | sort
72
73 _scratch_unmount
74 status=0
75 exit