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
41 testfile=$SCRATCH_MNT/testfile
42 OD_CMD="od -A x -t x1z"
44 _scratch_mkfs > /dev/null 2>&1
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.
51 -c "pwrite -S 0x58 0 40" `# write |XXXXXXXXXXXXXXXXXXXXXXXX|` \
53 -c "truncate 0" `# truncate | |` \
54 -c "truncate 50" `# truncate | |` \
55 $testfile | _filter_xfs_io
57 echo "= truncate inline_data after #0 page was truncated entirely ="
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.
67 -c "pwrite -S 0x58 0 40" `# write |XXXXXXXXXXXXXXXXXXXXXXXX|` \
69 -c "truncate 0" `# truncate | |` \
70 -c "truncate 4096" `# truncate | |` \
71 $testfile | _filter_xfs_io
73 echo "= truncate dismissed inline_data after #0 page was truncated entirely ="
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.
83 -c "pwrite -S 0x58 0 40" `# write |XXXXXXXXXXXXXXXXXXXXXXXX|` \
85 -c "truncate 4" `# truncate |XXXX |` \
86 -c "truncate 50" `# truncate |XXXX |` \
87 $testfile | _filter_xfs_io
89 echo "= truncate inline_data after #0 page was truncated partially ="
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.
99 -c "pwrite -S 0x58 0 40" `# write |XXXXXXXXXXXXXXXXXXXXXXXX|` \
101 -c "truncate 4" `# truncate |XXXX |` \
102 -c "truncate 4096" `# truncate |XXXX |` \
103 $testfile | _filter_xfs_io
105 echo "= truncate dismissed inline_data after #0 page was truncated partially ="