btrfs: fsync after hole punching with no-holes mode
[xfstests-dev.git] / tests / btrfs / 059
1 #! /bin/bash
2 # FS QA Test No. btrfs/059
3 #
4 # Regression test for btrfs where removing the flag FS_COMPR_FL (chattr -c)
5 # from an inode wouldn't clear its compression property.
6 # This was fixed in the following linux kernel patch:
7 #
8 #     Btrfs: add missing compression property remove in btrfs_ioctl_setflags
9 #
10 #-----------------------------------------------------------------------
11 # Copyright (C) 2014 SUSE Linux Products GmbH. All Rights Reserved.
12 # Author: Filipe Manana <fdmanana@suse.com>
13 #
14 # This program is free software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License as
16 # published by the Free Software Foundation.
17 #
18 # This program is distributed in the hope that it would be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 # GNU General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write the Free Software Foundation,
25 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
26 #-----------------------------------------------------------------------
27 #
28
29 seq=`basename $0`
30 seqres=$RESULT_DIR/$seq
31 echo "QA output created by $seq"
32
33 here=`pwd`
34 tmp=/tmp/$$
35
36 status=1        # failure is the default!
37 trap "_cleanup; exit \$status" 0 1 2 3 15
38
39 _cleanup()
40 {
41         rm -fr $tmp
42 }
43
44 # get standard environment, filters and checks
45 . ./common/rc
46 . ./common/filter
47 . ./common/filter.btrfs
48
49 # real QA test starts here
50 _supported_fs btrfs
51 _supported_os Linux
52 _require_test
53 _require_scratch
54 _require_btrfs_command "property"
55
56 rm -f $seqres.full
57
58 _scratch_mkfs >> $seqres.full 2>&1
59 _scratch_mount
60
61 mkdir $SCRATCH_MNT/testdir
62 echo "Setting compression flag in the directory..."
63 $CHATTR_PROG +c $SCRATCH_MNT/testdir
64 echo "Directory compression property value:"
65 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir compression | \
66         _filter_btrfs_compress_property
67
68 touch $SCRATCH_MNT/testdir/file1
69 echo "file1 compression property value:"
70 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/file1 compression | \
71         _filter_btrfs_compress_property
72
73 echo "Clearing compression flag from directory..."
74 $CHATTR_PROG -c $SCRATCH_MNT/testdir
75 echo "Directory compression property value:"
76 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir compression | \
77         _filter_btrfs_compress_property
78
79 touch $SCRATCH_MNT/testdir/file2
80 echo "file2 compression property value:"
81 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/file2 compression | \
82         _filter_btrfs_compress_property
83
84 touch $SCRATCH_MNT/testdir/file1
85 echo "file1 compression property value:"
86 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/file1 compression | \
87         _filter_btrfs_compress_property
88
89 status=0
90 exit