generic: test for file loss after mix of rename, fsync and inode eviction
[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 . ./common/preamble
15 _begin_fstest auto quick attr
16
17 # Import common functions.
18 . ./common/filter
19 . ./common/attr
20
21 # real QA test starts here
22
23 _supported_fs generic
24 _require_scratch
25 _require_attrs user
26
27 if [ $FSTYP = "xfs" ]; then
28         # avoid crashing the system if possible
29         _require_no_xfs_bug_on_assert
30
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"
35 fi
36
37 _scratch_mkfs > $seqres.full 2>&1
38 _scratch_mount
39
40 localfile="${SCRATCH_MNT}/testfile"
41 touch $localfile
42
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
47 # assert triggering.
48 "${SETFATTR_PROG}" -n user.0 -v "`seq 0 80`" "${localfile}"
49 "${SETFATTR_PROG}" -n user.1 -v "`seq 0 80`" "${localfile}"
50
51 # Make sure that changes are written to disk
52 _scratch_cycle_mount
53
54 # getfattr won't succeed with the expected result if fails
55 _getfattr --absolute-names -ebase64 -d $localfile | tail -n +2 | sort
56
57 _scratch_unmount
58 status=0
59 exit