generic: test for creating duplicate filenames in encrypted dir
[xfstests-dev.git] / tests / generic / 272
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. 272
6 #
7 # Test DIO CoW behavior when the write permanently fails.
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1    # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20     cd /
21     rm -rf $tmp.*
22     _dmerror_cleanup
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28 . ./common/reflink
29 . ./common/dmerror
30
31 # real QA test starts here
32 _require_scratch_reflink
33 _require_cp_reflink
34 _require_dm_target error
35 _require_odirect
36
37 rm -f $seqres.full
38
39
40 echo "Format and mount"
41 _scratch_mkfs > $seqres.full 2>&1
42 _dmerror_init
43 _dmerror_mount >> $seqres.full 2>&1
44
45 testdir=$SCRATCH_MNT/test-$seq
46 mkdir $testdir
47
48 blksz=65536
49 nr=640
50 bufnr=128
51 filesize=$((blksz * nr))
52 bufsize=$((blksz * bufnr))
53
54 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
55
56 echo "Create the original files"
57 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $bufsize 0 $filesize" $testdir/file1 >> $seqres.full
58 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
59 _dmerror_unmount
60 _dmerror_mount
61
62 echo "Compare files"
63 md5sum $testdir/file1 | _filter_scratch
64 md5sum $testdir/file2 | _filter_scratch
65
66 echo "CoW and unmount"
67 sync
68 _dmerror_load_error_table
69 urk=$($XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $testdir/file2 2>&1)
70 echo $urk >> $seqres.full
71 echo "$urk" | grep -q "error" || _fail "dio pwrite did not fail"
72
73 echo "Clean up the mess"
74 _dmerror_unmount
75 _dmerror_cleanup
76 _repair_scratch_fs >> $seqres.full
77 _scratch_mount >> $seqres.full 2>&1
78
79 echo "Compare files"
80 md5sum $testdir/file1 | _filter_scratch
81
82 # success, all done
83 status=0
84 exit