generic: test for file loss after mix of rename, fsync and inode eviction
[xfstests-dev.git] / tests / generic / 639
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2021, Jeff Layton <jlayton@redhat.com>
4 #
5 # FS QA Test No. 639
6 #
7 # Open a file and write a little data to it. Unmount (to clean out the cache)
8 # and then mount again. Then write some data to it beyond the EOF and ensure
9 # the result is correct.
10 #
11 # Prompted by a bug in ceph_write_begin that was fixed by commit 827a746f405d.
12 #
13 . ./common/preamble
14 _begin_fstest auto quick rw
15
16 # Import common functions.
17 . ./common/filter
18
19 # real QA test starts here
20 _supported_fs generic
21 _require_test
22
23 testfile="$TEST_DIR/test_write_begin.$$"
24
25 # write some data to file and fsync it out
26 $XFS_IO_PROG -f -c "pwrite -q 0 32" $testfile
27
28 # cycle the mount to clean out the pagecache
29 _test_cycle_mount
30
31 # now, write to the file (near the end)
32 $XFS_IO_PROG -c "pwrite -q 32 32" $testfile
33
34 # dump what we think is in there
35 echo "The result should be 64 bytes filled with 0xcd:"
36 hexdump -C $testfile
37
38 status=0
39 exit