399411073c942e4ece9a4f0e7dc8b5cd7fe14d7b
[xfstests-dev.git] / tests / btrfs / 053
1 #! /bin/bash
2 # FS QA Test No. btrfs/053
3 #
4 # Verify that btrfs send is able to replicate xattrs larger than PATH_MAX.
5 # This is possible if the b+tree leaf size is larger than 4Kb (mkfs.btrfs's
6 # default is max(16Kb, PAGE_SIZE) as of btrfs-progs v3.12, and max(4Kb,
7 # PAGE_SIZE in older versions).
8 #
9 # This issue is fixed by the following linux kernel btrfs patch:
10 #
11 #   Btrfs: send, use the right limits for xattr names and values
12 #
13 #-----------------------------------------------------------------------
14 # Copyright (c) 2014 Filipe Manana.  All Rights Reserved.
15 #
16 # This program is free software; you can redistribute it and/or
17 # modify it under the terms of the GNU General Public License as
18 # published by the Free Software Foundation.
19 #
20 # This program is distributed in the hope that it would be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 # GNU General Public License for more details.
24 #
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write the Free Software Foundation,
27 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
28 #-----------------------------------------------------------------------
29 #
30
31 seq=`basename $0`
32 seqres=$RESULT_DIR/$seq
33 echo "QA output created by $seq"
34
35 tmp=/tmp/$$
36 status=1        # failure is the default!
37 trap "_cleanup; exit \$status" 0 1 2 3 15
38
39 _cleanup()
40 {
41     rm -fr $send_files_dir
42     rm -fr $tmp
43 }
44
45 # get standard environment, filters and checks
46 . ./common/rc
47 . ./common/filter
48 . ./common/attr
49
50 # real QA test starts here
51 _supported_fs btrfs
52 _supported_os Linux
53 _require_scratch
54 _require_fssum
55 _require_attrs
56 _need_to_be_root
57
58 # max(16384, PAGE_SIZE) is the default leaf/node size on btrfs-progs v3.12+.
59 # Older versions just use max(4096, PAGE_SIZE).
60 # mkfs.btrfs can't create an fs with a leaf/node size smaller than PAGE_SIZE.
61 leaf_size=$(echo -e "16384\n`getconf PAGE_SIZE`" | sort -nr | head -1)
62
63 send_files_dir=$TEST_DIR/btrfs-test-$seq
64
65 rm -f $seqres.full
66 rm -fr $send_files_dir
67 mkdir $send_files_dir
68
69 _scratch_mkfs "-l $leaf_size" >/dev/null 2>&1
70 _scratch_mount
71
72 echo "hello world" > $SCRATCH_MNT/foobar
73
74 $SETFATTR_PROG -n user.xattr_name_1 -v `$PERL_PROG -e 'print "A" x 6000;'` \
75         $SCRATCH_MNT/foobar
76
77 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
78 run_check $FSSUM_PROG -A -f -w $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
79
80 # Update existing xattr value and add a new xattr too.
81 $SETFATTR_PROG -n user.xattr_name_1 -v `$PERL_PROG -e 'print "Z" x 6666;'` \
82         $SCRATCH_MNT/foobar
83 $SETFATTR_PROG -n user.xattr_name_2 -v `$PERL_PROG -e 'print "U" x 5555;'` \
84         $SCRATCH_MNT/foobar
85
86 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2
87 run_check $FSSUM_PROG -A -f -w $send_files_dir/2.fssum \
88         -x $SCRATCH_MNT/mysnap2/mysnap1 $SCRATCH_MNT/mysnap2
89
90 _run_btrfs_util_prog send $SCRATCH_MNT/mysnap1 -f $send_files_dir/1.snap
91 _run_btrfs_util_prog send -p $SCRATCH_MNT/mysnap1 $SCRATCH_MNT/mysnap2 \
92         -f $send_files_dir/2.snap
93
94 _scratch_unmount
95 _check_scratch_fs
96
97 _scratch_mkfs "-l $leaf_size" >/dev/null 2>&1
98 _scratch_mount
99
100 _run_btrfs_util_prog receive $SCRATCH_MNT -f $send_files_dir/1.snap
101 run_check $FSSUM_PROG -r $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
102
103 _run_btrfs_util_prog receive $SCRATCH_MNT -f $send_files_dir/2.snap
104 run_check $FSSUM_PROG -r $send_files_dir/2.fssum $SCRATCH_MNT/mysnap2
105
106 _check_scratch_fs
107
108 status=0
109 exit