generic: test for creating duplicate filenames in encrypted dir
[xfstests-dev.git] / tests / generic / 393
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014 Jaegeuk Kim.  All Rights Reserved.
4 #
5 # FS QA Test No. generic/393
6 #
7 # Test some small truncations to check inline_data and its cached data are
8 # truncated correctly at the same time.
9 #
10 # The inline_data feature was introduced in ext4 and f2fs as follows.
11 #  ext4 : http://lwn.net/Articles/468678/
12 #  f2fs : http://lwn.net/Articles/573408/
13 #
14 # The basic idea is embedding small-sized file's data into relatively large
15 # inode space.
16 # In ext4, up to 132 bytes of data can be stored in 256 bytes-sized inode.
17 # In f2fs, up to 3.4KB of data can be embedded into 4KB-sized inode block.
18 #
19 seq=`basename $0`
20 seqres=$RESULT_DIR/$seq
21 echo "QA output created by $seq"
22
23 here=`pwd`
24 tmp=/tmp/$$
25 status=1        # failure is the default!
26 trap "_cleanup; exit \$status" 0 1 2 3 15
27
28 _cleanup()
29 {
30         cd /
31         rm -f $tmp.*
32 }
33
34 # get standard environment, filters and checks
35 . ./common/rc
36 . ./common/filter
37
38 _supported_fs generic
39 _require_scratch
40
41 testfile=$SCRATCH_MNT/testfile
42 OD_CMD="od -A x -t x1z"
43
44 _scratch_mkfs > /dev/null 2>&1
45 _scratch_mount
46
47 # 1. make a file containing inline_data.
48 # 2. "truncated 0"  is to check cached page #0 was truncated entirely.
49 # 3. "truncated 50" is to check inline_data was truncated within its inode.
50 $XFS_IO_PROG -t -f \
51         -c "pwrite -S 0x58 0 40" `# write    |XXXXXXXXXXXXXXXXXXXXXXXX|` \
52         -c "fsync"                                                       \
53         -c "truncate 0"          `# truncate |                        |` \
54         -c "truncate 50"         `# truncate |                        |` \
55 $testfile | _filter_xfs_io
56
57 echo "= truncate inline_data after #0 page was truncated entirely ="
58 $OD_CMD $testfile
59 _scratch_cycle_mount
60 $OD_CMD $testfile
61 rm $testfile
62
63 # 1. make a file containing inline_data.
64 # 2. "truncated 0"     is to check cached page #0 was truncated entirely.
65 # 3. "truncated 4096"  is to check inline_data was dismissed and truncated.
66 $XFS_IO_PROG -t -f \
67         -c "pwrite -S 0x58 0 40" `# write    |XXXXXXXXXXXXXXXXXXXXXXXX|` \
68         -c "fsync"                                                       \
69         -c "truncate 0"          `# truncate |                        |` \
70         -c "truncate 4096"       `# truncate |                        |` \
71 $testfile | _filter_xfs_io
72
73 echo "= truncate dismissed inline_data after #0 page was truncated entirely ="
74 $OD_CMD $testfile
75 _scratch_cycle_mount
76 $OD_CMD $testfile
77 rm $testfile
78
79 # 1. make a file containing inline_data.
80 # 2. "truncated 4"   is to check cached page #0 was truncated partially.
81 # 3. "truncated 50"  is to check inline_data was truncated within its inode.
82 $XFS_IO_PROG -t -f \
83         -c "pwrite -S 0x58 0 40" `# write    |XXXXXXXXXXXXXXXXXXXXXXXX|` \
84         -c "fsync"                                                       \
85         -c "truncate 4"          `# truncate |XXXX                    |` \
86         -c "truncate 50"         `# truncate |XXXX                    |` \
87 $testfile | _filter_xfs_io
88
89 echo "= truncate inline_data after #0 page was truncated partially ="
90 $OD_CMD $testfile
91 _scratch_cycle_mount
92 $OD_CMD $testfile
93 rm $testfile
94
95 # 1. make a file containing inline_data.
96 # 2. "truncated 4"     is to check cached page #0 was truncated partially.
97 # 3. "truncated 4096"  is to check inline_data was dismissed and truncated.
98 $XFS_IO_PROG -t -f \
99         -c "pwrite -S 0x58 0 40" `# write    |XXXXXXXXXXXXXXXXXXXXXXXX|` \
100         -c "fsync"                                                       \
101         -c "truncate 4"          `# truncate |XXXX                    |` \
102         -c "truncate 4096"       `# truncate |XXXX                    |` \
103 $testfile | _filter_xfs_io
104
105 echo "= truncate dismissed inline_data after #0 page was truncated partially ="
106 $OD_CMD $testfile
107 _scratch_cycle_mount
108 $OD_CMD $testfile
109 rm $testfile
110
111 status=0
112 exit