generic: test for file loss after mix of rename, fsync and inode eviction
[xfstests-dev.git] / tests / generic / 474
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Chengguang Xu <cgxu519@icloud.com>
4 #
5 # FS QA Test 474
6 #
7 # Inspired by syncfs bug of overlayfs which does not sync dirty inodes in
8 # underlying filesystem.
9 #
10 # Create a small file then run syncfs and shutdown filesystem(or underlying
11 # filesystem of overlayfs) to check syncfs result.
12 #
13 # Test will be skipped if filesystem(or underlying filesystem of overlayfs)
14 # does not support shutdown.
15 #
16 . ./common/preamble
17 _begin_fstest auto quick shutdown metadata
18
19 status=0
20
21 # Import common functions.
22 . ./common/filter
23
24 # real QA test starts here
25
26 _supported_fs generic
27 _require_fssum
28 _require_scratch
29 _require_scratch_shutdown
30 _require_xfs_io_command "syncfs"
31
32 _scratch_mkfs >/dev/null 2>&1
33 _scratch_mount
34
35 # Background writeback will flush dirty inode by dirty ratio and dirty time
36 # period(default 30 seconds), in order to avoid interference from it,
37 # run sync before test to make all dirty inodes clean, and it also
38 # accelerates syncfs on testing filesystem so that test case can finish
39 # in 30 seconds.
40
41 sync
42
43 # Large fs has a huge size .use_space file, will take long time on running
44 # fssum $SCRATCH_MNT. So change the target path to a sub-dir of $SCRATCH_MNT.
45 localdir=$SCRATCH_MNT/dir
46 mkdir $localdir
47 $XFS_IO_PROG -f -c "pwrite 0 4K" $localdir/testfile >/dev/null 2>&1
48
49 # fssum used for comparing checksum of test file(data & metedata),
50 # exclude checking about atime, block structure, open error.
51 $FSSUM_PROG -ugomAcdES -f -w $tmp.fssum $localdir
52 $XFS_IO_PROG -c "syncfs" $localdir/testfile >/dev/null 2>&1
53 _scratch_shutdown
54 _scratch_cycle_mount
55 $FSSUM_PROG -r $tmp.fssum $localdir
56
57 exit