2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014 Jaegeuk Kim. All Rights Reserved.
5 # FS QA Test No. generic/393
7 # Test some small truncations to check inline_data and its cached data are
8 # truncated correctly at the same time.
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/
14 # The basic idea is embedding small-sized file's data into relatively large
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.
20 seqres=$RESULT_DIR/$seq
21 echo "QA output created by $seq"
25 status=1 # failure is the default!
26 trap "_cleanup; exit \$status" 0 1 2 3 15
34 # get standard environment, filters and checks
42 testfile=$SCRATCH_MNT/testfile
43 OD_CMD="od -A x -t x1z"
45 _scratch_mkfs > /dev/null 2>&1
48 # 1. make a file containing inline_data.
49 # 2. "truncated 0" is to check cached page #0 was truncated entirely.
50 # 3. "truncated 50" is to check inline_data was truncated within its inode.
52 -c "pwrite -S 0x58 0 40" `# write |XXXXXXXXXXXXXXXXXXXXXXXX|` \
54 -c "truncate 0" `# truncate | |` \
55 -c "truncate 50" `# truncate | |` \
56 $testfile | _filter_xfs_io
58 echo "= truncate inline_data after #0 page was truncated entirely ="
64 # 1. make a file containing inline_data.
65 # 2. "truncated 0" is to check cached page #0 was truncated entirely.
66 # 3. "truncated 4096" is to check inline_data was dismissed and truncated.
68 -c "pwrite -S 0x58 0 40" `# write |XXXXXXXXXXXXXXXXXXXXXXXX|` \
70 -c "truncate 0" `# truncate | |` \
71 -c "truncate 4096" `# truncate | |` \
72 $testfile | _filter_xfs_io
74 echo "= truncate dismissed inline_data after #0 page was truncated entirely ="
80 # 1. make a file containing inline_data.
81 # 2. "truncated 4" is to check cached page #0 was truncated partially.
82 # 3. "truncated 50" is to check inline_data was truncated within its inode.
84 -c "pwrite -S 0x58 0 40" `# write |XXXXXXXXXXXXXXXXXXXXXXXX|` \
86 -c "truncate 4" `# truncate |XXXX |` \
87 -c "truncate 50" `# truncate |XXXX |` \
88 $testfile | _filter_xfs_io
90 echo "= truncate inline_data after #0 page was truncated partially ="
96 # 1. make a file containing inline_data.
97 # 2. "truncated 4" is to check cached page #0 was truncated partially.
98 # 3. "truncated 4096" is to check inline_data was dismissed and truncated.
100 -c "pwrite -S 0x58 0 40" `# write |XXXXXXXXXXXXXXXXXXXXXXXX|` \
102 -c "truncate 4" `# truncate |XXXX |` \
103 -c "truncate 4096" `# truncate |XXXX |` \
104 $testfile | _filter_xfs_io
106 echo "= truncate dismissed inline_data after #0 page was truncated partially ="