generic: test for creating duplicate filenames in encrypted dir
[xfstests-dev.git] / tests / generic / 291
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 291
6 #
7 # Ensuring that copy on write in buffered mode to the source file when the
8 # CoW range covers holes and regular shared blocks.
9 #   - Create two files.
10 #   - Truncate the first file.
11 #   - Write the odd blocks of the first file.
12 #   - Reflink the odd blocks of the first file into the second file.
13 #   - CoW the first file across the halfway mark, starting with the
14 #     regular extent.
15 #   - Check that the files are now different where we say they're different.
16 #
17 seq=`basename $0`
18 seqres=$RESULT_DIR/$seq
19 echo "QA output created by $seq"
20
21 here=`pwd`
22 tmp=/tmp/$$
23 status=1    # failure is the default!
24 trap "_cleanup; exit \$status" 0 1 2 3 15
25
26 _cleanup()
27 {
28     cd /
29     rm -rf $tmp.*
30 }
31
32 # get standard environment, filters and checks
33 . ./common/rc
34 . ./common/filter
35 . ./common/reflink
36
37 # real QA test starts here
38 _require_scratch_reflink
39 _require_xfs_io_command "falloc"
40
41 rm -f $seqres.full
42
43 echo "Format and mount"
44 _scratch_mkfs > $seqres.full 2>&1
45 _scratch_mount >> $seqres.full 2>&1
46
47 testdir=$SCRATCH_MNT/test-$seq
48 mkdir $testdir
49
50 echo "Create the original files"
51 blksz=65536
52 nr=64
53 filesize=$((blksz * nr))
54 _sweave_reflink_holes $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
55 _scratch_cycle_mount
56
57 echo "Compare files"
58 md5sum $testdir/file1 | _filter_scratch
59 md5sum $testdir/file3 | _filter_scratch
60 md5sum $testdir/file1.chk | _filter_scratch
61
62 echo "CoW across the transition"
63 cowoff=$((filesize / 4))
64 cowsz=$((filesize / 2))
65 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $cowsz $cowoff $cowsz" $testdir/file1 >> $seqres.full
66 _pwrite_byte 0x63 $cowoff $cowsz $testdir/file1.chk >> $seqres.full
67 _scratch_cycle_mount
68
69 echo "Compare files"
70 md5sum $testdir/file1 | _filter_scratch
71 md5sum $testdir/file3 | _filter_scratch
72 md5sum $testdir/file1.chk | _filter_scratch
73
74 # success, all done
75 status=0
76 exit