common: kill _supported_os
[xfstests-dev.git] / tests / f2fs / 001
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. f2fs/001
6 #
7 # Test inline_data behaviors when filesystem is full.
8 #
9 # The inline_data feature was introduced in ext4 and f2fs as follows.
10 #  ext4 : http://lwn.net/Articles/468678/
11 #  f2fs : http://lwn.net/Articles/573408/
12 #
13 # The basic idea is embedding small-sized file's data into relatively large
14 # inode space.
15 # In ext4, up to 132 bytes of data can be stored in 256 bytes-sized inode.
16 # In f2fs, up to 3.4KB of data can be embedded into 4KB-sized inode block.
17 #
18 seq=`basename $0`
19 seqres=$RESULT_DIR/$seq
20 echo "QA output created by $seq"
21
22 here=`pwd`
23 tmp=/tmp/$$
24 status=1        # failure is the default!
25 trap "_cleanup; exit \$status" 0 1 2 3 15
26
27 _cleanup()
28 {
29     cd /
30     rm -f $tmp.*
31 }
32
33 # get standard environment, filters and checks
34 . ./common/rc
35 . ./common/filter
36
37 _supported_fs f2fs
38 _require_scratch
39
40 testfile=$SCRATCH_MNT/testfile
41 dummyfile=$SCRATCH_MNT/dummyfile
42
43 # build 4GB filesystem
44 _scratch_mkfs_sized $((4 * 1024 * 1024 * 1024)) > /dev/null 2>&1
45 _scratch_mount
46
47 echo "==== create small file ===="
48 $XFS_IO_PROG -t -f -c "pwrite -S 0x58 0 40" $testfile | _filter_xfs_io
49
50 # -ENOSPC should be triggered
51 echo "==== Fullfill the partition ===="
52 $XFS_IO_PROG -t -f -c "falloc 0 5g" $dummyfile | _filter_xfs_io
53
54 # -ENOSPC should be triggered without any panic
55 echo "==== change i_size & write data ===="
56 $XFS_IO_PROG -c "truncate 96" -c "pwrite -S 0x58 8192 4096" $testfile 2>&1 \
57         | _filter_xfs_io_error
58
59 echo "==== check data contents ===="
60 hexdump -C $testfile
61 _scratch_cycle_mount
62 hexdump -C $testfile
63
64 rm $testfile
65 rm $dummyfile
66
67 status=0
68 exit