Files
apfstests/tests/btrfs/130
T
Anand Jain 7c8651be0a btrfs/130: fix Invalid argument
btrfs-progs patch[1] replaced read(2) write(2) with splice(2) and
caused the append-redirect to stop working.

Before:
 btrfs send /btrfs/ro_send > /dev/null
 At subvol /btrfs/ro_snap

 btrfs send /btrfs/ro_send >> /dev/null
 At subvol /btrfs/ro_snap

After:
 btrfs send /btrfs/ro_send > /dev/null
 At subvol /btrfs/ro_snap

 btrfs send /btrfs/ro_send >> /dev/null
 At subvol /btrfs/ro_snap
 ERROR: failed to read stream from kernel: Invalid argument

Further in the test case the line..
btrfs/130
  ::
 _run_btrfs_util_prog send $SCRATCH_MNT/ro_snap > /dev/null 2>&1

which intended to redirect send output to /dev/null, but ended up
append redirect to the $seqres.full file. And so this test case
failed as 'Invalid argument' for sometime now.

Still as append of a btrfs send output doesn't make sense, so fix
the fstests.

Also adds logs going into $seqres.full.

[1]
ba23855cdc8961bbaef1fcad4854d494cdb3afd3
 btrfs-progs: send: use splice syscall instead of read/write to transfer buffer

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2018-04-24 17:48:44 +08:00

93 lines
2.8 KiB
Bash
Executable File

#! /bin/bash
# FS QA Test 130
#
# Check if btrfs send can handle large deduped file, whose file extents
# are all pointing to one extent.
# Such file structure will cause quite large pressure to any operation which
# iterates all backref of one extent.
# And unfortunately, btrfs send is one of these operations, and will cause
# softlock or OOM on systems with small memory(<4G).
#
#-----------------------------------------------------------------------
# Copyright (c) 2016 Fujitsu. All Rights Reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it would be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#-----------------------------------------------------------------------
#
seq=`basename $0`
seqres=$RESULT_DIR/$seq
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
_cleanup()
{
cd /
rm -f $tmp.*
}
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
. ./common/reflink
# remove previous $seqres.full before test
rm -f $seqres.full
# real QA test starts here
# Modify as appropriate.
_supported_fs btrfs
_supported_os Linux
_require_scratch
_require_scratch_reflink
_scratch_mkfs > /dev/null 2>&1
_scratch_mount
nr_extents=$((4096 * $LOAD_FACTOR))
# Use 128K blocksize, the default value of both deduperemove or
# inband dedupe
blocksize=$((128 * 1024))
file=$SCRATCH_MNT/foobar
echo LOAD_FACTOR=$LOAD_FACTOR nr_extents=$nr_extents blocksize=$blocksize >> $seqres.full
# create the initial file, whose file extents are all point to one extent
_pwrite_byte 0xcdcdcdcd 0 $blocksize $file | _filter_xfs_io
for i in $(seq 1 $(($nr_extents - 1))); do
_reflink_range $file 0 $file $(($i * $blocksize)) $blocksize \
>> $seqres.full 2>&1
done
# create a RO snapshot, so we can send out the snapshot
_run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/ro_snap
# send out the subvolume, and it will either:
# 1) OOM since memory is allocated inside a O(n^3) loop
# 2) Softlock since time consuming backref walk is called without scheduling.
# the send destination is not important, just send will cause the problem
echo "# $BTRFS_UTIL_PROG send $SCRATCH_MNT/ro_snap > /dev/null" >> $seqres.full
$BTRFS_UTIL_PROG send $SCRATCH_MNT/ro_snap > /dev/null 2>>$seqres.full
# success, all done
status=0
exit