2 # FS QA Test No. btrfs/053
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).
9 # This issue is fixed by the following linux kernel btrfs patch:
11 # Btrfs: send, use the right limits for xattr names and values
13 #-----------------------------------------------------------------------
14 # Copyright (c) 2014 Filipe Manana. All Rights Reserved.
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.
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.
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 #-----------------------------------------------------------------------
32 seqres=$RESULT_DIR/$seq
33 echo "QA output created by $seq"
36 status=1 # failure is the default!
37 trap "_cleanup; exit \$status" 0 1 2 3 15
41 rm -fr $send_files_dir
45 # get standard environment, filters and checks
50 # real QA test starts here
59 # max(16384, PAGE_SIZE) is the default leaf/node size on btrfs-progs v3.12+.
60 # Older versions just use max(4096, PAGE_SIZE).
61 # mkfs.btrfs can't create an fs with a leaf/node size smaller than PAGE_SIZE.
62 leaf_size=$(echo -e "16384\n`getconf PAGE_SIZE`" | sort -nr | head -1)
64 send_files_dir=$TEST_DIR/btrfs-test-$seq
67 rm -fr $send_files_dir
70 _scratch_mkfs "-l $leaf_size" >/dev/null 2>&1
73 echo "hello world" > $SCRATCH_MNT/foobar
75 $SETFATTR_PROG -n user.xattr_name_1 -v `$PERL_PROG -e 'print "A" x 6000;'` \
78 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
79 run_check $FSSUM_PROG -A -f -w $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
81 # Update existing xattr value and add a new xattr too.
82 $SETFATTR_PROG -n user.xattr_name_1 -v `$PERL_PROG -e 'print "Z" x 6666;'` \
84 $SETFATTR_PROG -n user.xattr_name_2 -v `$PERL_PROG -e 'print "U" x 5555;'` \
87 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2
88 run_check $FSSUM_PROG -A -f -w $send_files_dir/2.fssum \
89 -x $SCRATCH_MNT/mysnap2/mysnap1 $SCRATCH_MNT/mysnap2
91 _run_btrfs_util_prog send $SCRATCH_MNT/mysnap1 -f $send_files_dir/1.snap
92 _run_btrfs_util_prog send -p $SCRATCH_MNT/mysnap1 $SCRATCH_MNT/mysnap2 \
93 -f $send_files_dir/2.snap
98 _scratch_mkfs "-l $leaf_size" >/dev/null 2>&1
101 _run_btrfs_util_prog receive $SCRATCH_MNT -f $send_files_dir/1.snap
102 run_check $FSSUM_PROG -r $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
104 _run_btrfs_util_prog receive $SCRATCH_MNT -f $send_files_dir/2.snap
105 run_check $FSSUM_PROG -r $send_files_dir/2.fssum $SCRATCH_MNT/mysnap2