generic: test for file loss after mix of rename, fsync and inode eviction
[xfstests-dev.git] / tests / generic / 092
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Facebook.  All Rights Reserved.
4 #
5 # FS QA Test No. 092
6 #
7 # fallocate/truncate tests with FALLOC_FL_KEEP_SIZE option.
8 # Verify if the disk space is released after truncating a file to i_size after
9 # writing to a portion of a preallocated range.
10 #
11 # This also verifies that truncat'ing up past i_size doesn't remove the
12 # preallocated space.
13 #
14 . ./common/preamble
15 _begin_fstest auto quick prealloc
16
17 status=0        # success is the default!
18
19 # Import common functions.
20 . ./common/filter
21 . ./common/punch
22
23 # real QA test starts here
24
25 # Modify as appropriate.
26 _supported_fs generic
27 _require_test
28 _require_xfs_io_command "falloc"
29 _require_xfs_io_command "fiemap"
30
31 # First test to make sure that truncating at i_size trims the preallocated bit
32 # past i_size
33 $XFS_IO_PROG -f -c "falloc -k 0 10M" -c "pwrite 0 5M" -c "truncate 5M"\
34         $TEST_DIR/testfile.$seq | _filter_xfs_io
35 sync
36 $XFS_IO_PROG -c "fiemap -v" $TEST_DIR/testfile.$seq | _filter_fiemap
37
38 # Now verify that if we truncate up past i_size we don't trim the preallocated
39 # bit
40 $XFS_IO_PROG -c "falloc -k 5M 5M" -c "truncate 7M" $TEST_DIR/testfile.$seq
41 $XFS_IO_PROG -c "fiemap -v" $TEST_DIR/testfile.$seq | _filter_fiemap
42
43 # success, all done
44 exit