2 # FS QA Test No. btrfs/048
4 # Btrfs properties test. The btrfs properties feature was introduced in the
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2014 Filipe Manana. All Rights Reserved.
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #-----------------------------------------------------------------------
26 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
32 status=1 # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
37 rm -fr $send_files_dir
41 # get standard environment, filters and checks
45 # real QA test starts here
50 _require_btrfs "property"
53 send_files_dir=$TEST_DIR/btrfs-test-$seq
56 rm -fr $send_files_dir
59 _scratch_mkfs >/dev/null 2>&1
62 echo "Testing label property"
63 $BTRFS_UTIL_PROG property get $SCRATCH_MNT label
65 $BTRFS_UTIL_PROG property set $SCRATCH_MNT label foobar
66 $BTRFS_UTIL_PROG property get $SCRATCH_MNT label
68 $BTRFS_UTIL_PROG property get $SCRATCH_MNT
70 $BTRFS_UTIL_PROG property set $SCRATCH_MNT label ''
71 $BTRFS_UTIL_PROG property get $SCRATCH_MNT label
73 mkdir $SCRATCH_MNT/testdir
74 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir label
77 echo -e "\nTesting subvolume ro property"
78 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/sv1
79 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/sv1 ro
81 $BTRFS_UTIL_PROG property set $SCRATCH_MNT/sv1 ro foo
83 $BTRFS_UTIL_PROG property set $SCRATCH_MNT/sv1 ro true
85 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/sv1 ro
87 touch $SCRATCH_MNT/sv1/foobar 2>&1 | _filter_scratch
89 $BTRFS_UTIL_PROG property set $SCRATCH_MNT/sv1 ro false
90 touch $SCRATCH_MNT/sv1/foobar 2>&1 | _filter_scratch
91 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/sv1
94 echo -e "\nTesting compression property"
95 mkdir $SCRATCH_MNT/testdir/subdir1
96 touch $SCRATCH_MNT/testdir/file1
97 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/file1 compression
98 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/subdir1 compression
100 $BTRFS_UTIL_PROG property set $SCRATCH_MNT/testdir/file1 compression \
101 foo 2>&1 | _filter_scratch
103 $BTRFS_UTIL_PROG property set $SCRATCH_MNT/testdir/file1 compression lzo
104 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/file1 compression
106 # Verify property was persisted.
110 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/file1 compression
111 $BTRFS_UTIL_PROG property set $SCRATCH_MNT/testdir/file1 compression zlib
112 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/file1 compression
113 $BTRFS_UTIL_PROG property set $SCRATCH_MNT/testdir/file1 compression ''
114 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/file1 compression
116 # Test compression property inheritance.
118 $BTRFS_UTIL_PROG property set $SCRATCH_MNT/testdir/subdir1 compression lzo
119 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/subdir1 compression
121 mkdir $SCRATCH_MNT/testdir/subdir1/subsubdir
122 touch $SCRATCH_MNT/testdir/subdir1/some_file
123 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/subdir1/subsubdir compression
125 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/subdir1/some_file compression
127 mkdir $SCRATCH_MNT/testdir/subdir1/subsubdir/foo
128 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/subdir1/subsubdir/foo \
132 # Verify property was persisted.
136 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/subdir1/subsubdir compression
138 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/subdir1/subsubdir/foo \
141 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/subdir1/some_file compression
143 $BTRFS_UTIL_PROG property set $SCRATCH_MNT/testdir/subdir1/subsubdir \
145 $BTRFS_UTIL_PROG property set $SCRATCH_MNT/testdir/subdir1/some_file \
147 $BTRFS_UTIL_PROG property set $SCRATCH_MNT/testdir/subdir1 compression ''
149 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/subdir1/subsubdir compression
151 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/subdir1/some_file compression
153 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/subdir1 compression
155 touch $SCRATCH_MNT/testdir/subdir1/some_file_2
156 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/subdir1/some_file_2 \
160 # Verify send is able to replicate properties.
161 echo -e "\nTesting properties with send"
162 $BTRFS_UTIL_PROG property set $SCRATCH_MNT/testdir/subdir1 compression lzo
163 touch $SCRATCH_MNT/testdir/subdir1/foobar
164 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/subdir1 compression
165 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/testdir/subdir1/foobar compression
168 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
169 touch $SCRATCH_MNT/testdir/subdir1/foobar2
170 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2
172 _run_btrfs_util_prog send $SCRATCH_MNT/mysnap1 -f $send_files_dir/1.snap
173 _run_btrfs_util_prog send -p $SCRATCH_MNT/mysnap1 $SCRATCH_MNT/mysnap2 \
174 -f $send_files_dir/2.snap
178 _scratch_mkfs >/dev/null 2>&1
181 _run_btrfs_util_prog receive $SCRATCH_MNT -f $send_files_dir/1.snap
182 _run_btrfs_util_prog receive $SCRATCH_MNT -f $send_files_dir/2.snap
183 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/mysnap2/testdir/subdir1 compression
184 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/mysnap2/testdir/subdir1/foobar \
186 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/mysnap2/testdir/subdir1/foobar2 \
192 _scratch_mkfs >/dev/null 2>&1
195 echo -e "\nTesting subvolume properties"
196 $BTRFS_UTIL_PROG property set $SCRATCH_MNT compression 'lzo'
197 $BTRFS_UTIL_PROG property get $SCRATCH_MNT compression
199 touch $SCRATCH_MNT/file1
200 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/file1 compression
202 mkdir $SCRATCH_MNT/dir1
203 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/dir1 compression
205 mkdir $SCRATCH_MNT/dir1/subdir1
206 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/dir1/subdir1 compression
208 $BTRFS_UTIL_PROG property set $SCRATCH_MNT/dir1/subdir1 compression 'zlib'
209 touch $SCRATCH_MNT/dir1/subdir1/foo
210 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/dir1/subdir1/foo compression
212 echo -e "\nTesting subvolume property inheritance"
213 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/sv1
214 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/sv1 compression
215 touch $SCRATCH_MNT/sv1/file2
216 $BTRFS_UTIL_PROG property get $SCRATCH_MNT/sv1/file2 compression