generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / generic / 115
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 115
6 #
7 # Moving and deleting cloned ("reflinked") files on btrfs:
8 #   - Create a file and a reflink
9 #   - Move both to a directory
10 #   - Delete the original (moved) file, check that the copy still exists.
11 #
12 . ./common/preamble
13 _begin_fstest auto quick clone
14
15 # Override the default cleanup function.
16 _cleanup()
17 {
18     cd /
19     rm -f $tmp.* $testdir
20 }
21
22 # Import common functions.
23 . ./common/filter
24 . ./common/reflink
25
26 # real QA test starts here
27 _require_test_reflink
28
29 _require_xfs_io_command "fiemap"
30 _require_cp_reflink
31 _require_test
32
33 testdir1=$TEST_DIR/test-$seq
34 rm -rf $testdir1
35 mkdir $testdir1
36
37 echo "Create the original files and reflink dirs"
38 $XFS_IO_PROG -f -c 'pwrite -S 0x61 0 9000' $testdir1/original \
39     >> $seqres.full
40 cp --reflink $testdir1/original $testdir1/copy
41
42 _verify_reflink $testdir1/original $testdir1/copy
43
44 echo "Move orig & reflink copy to subdir and md5sum:"
45 mkdir $testdir1/subdir
46 mv $testdir1/original $testdir1/subdir/original_moved
47 mv $testdir1/copy $testdir1/subdir/copy_moved
48 _verify_reflink $testdir1/subdir/original_moved \
49     $testdir1/subdir/copy_moved
50
51 md5sum $testdir1/subdir/original_moved | _filter_test_dir
52 md5sum $testdir1/subdir/copy_moved | _filter_test_dir
53
54 echo "remove orig from subdir and md5sum reflink copy:"
55 rm $testdir1/subdir/original_moved
56 md5sum $testdir1/subdir/copy_moved | _filter_test_dir
57 rm -rf $testdir1/subdir
58
59 # success, all done
60 status=0
61 exit