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
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)
63 send_files_dir=$TEST_DIR/btrfs-test-$seq
66 rm -fr $send_files_dir
69 _scratch_mkfs "-l $leaf_size" >/dev/null 2>&1
72 echo "hello world" > $SCRATCH_MNT/foobar
74 $SETFATTR_PROG -n user.xattr_name_1 -v `$PERL_PROG -e 'print "A" x 6000;'` \
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
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;'` \
83 $SETFATTR_PROG -n user.xattr_name_2 -v `$PERL_PROG -e 'print "U" x 5555;'` \
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
90 _run_btrfs_util_prog send -f $send_files_dir/1.snap $SCRATCH_MNT/mysnap1
91 _run_btrfs_util_prog send -p $SCRATCH_MNT/mysnap1 -f $send_files_dir/2.snap \
97 _scratch_mkfs "-l $leaf_size" >/dev/null 2>&1
100 _run_btrfs_util_prog receive -f $send_files_dir/1.snap $SCRATCH_MNT
101 run_check $FSSUM_PROG -r $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1
103 _run_btrfs_util_prog receive -f $send_files_dir/2.snap $SCRATCH_MNT
104 run_check $FSSUM_PROG -r $send_files_dir/2.fssum $SCRATCH_MNT/mysnap2