2014-12-24 14:48:23 +11:00
|
|
|
#! /bin/bash
|
|
|
|
|
# FS QA Test No. 017
|
|
|
|
|
#
|
|
|
|
|
# Verify that removing shared extents can end up incorrect qgroup accounting.
|
|
|
|
|
#
|
|
|
|
|
# Regression of 'commit fcebe4562dec ("Btrfs: rework qgroup accounting")',
|
|
|
|
|
# this will throw a warning into dmesg.
|
|
|
|
|
#
|
|
|
|
|
# The issue is fixed by https://patchwork.kernel.org/patch/5499981/
|
|
|
|
|
# "Btrfs: fix a warning of qgroup account on shared extents"
|
|
|
|
|
#
|
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
|
# Copyright (c) 2014 Liu Bo. 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
|
|
|
|
|
|
|
|
|
|
# real QA test starts here
|
|
|
|
|
|
|
|
|
|
_supported_fs btrfs
|
|
|
|
|
_supported_os Linux
|
|
|
|
|
_require_scratch
|
|
|
|
|
_require_cloner
|
|
|
|
|
|
|
|
|
|
rm -f $seqres.full
|
|
|
|
|
|
2015-01-21 16:19:21 +11:00
|
|
|
# Currently in btrfs the node/leaf size can not be smaller than the page
|
|
|
|
|
# size (but it can be greater than the page size). So use the largest
|
|
|
|
|
# supported node/leaf size (64Kb) so that the test can run on any platform
|
|
|
|
|
# that Linux supports.
|
|
|
|
|
_scratch_mkfs "--nodesize 65536" >>$seqres.full 2>&1
|
2014-12-24 14:48:23 +11:00
|
|
|
_scratch_mount
|
|
|
|
|
|
2015-12-21 18:01:46 +11:00
|
|
|
BLOCK_SIZE=$(get_block_size $SCRATCH_MNT)
|
|
|
|
|
EXTENT_SIZE=$((2 * $BLOCK_SIZE))
|
|
|
|
|
|
|
|
|
|
$XFS_IO_PROG -f -d -c "pwrite 0 $EXTENT_SIZE" $SCRATCH_MNT/foo \
|
|
|
|
|
| _filter_xfs_io_blocks_modified
|
2014-12-24 14:48:23 +11:00
|
|
|
|
|
|
|
|
_run_btrfs_util_prog subvolume snapshot $SCRATCH_MNT $SCRATCH_MNT/snap
|
|
|
|
|
|
2015-12-21 18:01:46 +11:00
|
|
|
$CLONER_PROG -s 0 -d 0 -l $EXTENT_SIZE $SCRATCH_MNT/foo $SCRATCH_MNT/foo-reflink
|
|
|
|
|
|
|
|
|
|
$CLONER_PROG -s 0 -d 0 -l $EXTENT_SIZE $SCRATCH_MNT/foo \
|
|
|
|
|
$SCRATCH_MNT/snap/foo-reflink
|
|
|
|
|
|
|
|
|
|
$CLONER_PROG -s 0 -d 0 -l $EXTENT_SIZE $SCRATCH_MNT/foo \
|
|
|
|
|
$SCRATCH_MNT/snap/foo-reflink2
|
2014-12-24 14:48:23 +11:00
|
|
|
|
|
|
|
|
_run_btrfs_util_prog quota enable $SCRATCH_MNT
|
|
|
|
|
_run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
|
|
|
|
|
|
|
|
|
|
rm -fr $SCRATCH_MNT/foo*
|
|
|
|
|
rm -fr $SCRATCH_MNT/snap/foo*
|
|
|
|
|
|
|
|
|
|
sync
|
|
|
|
|
|
2015-02-12 14:13:15 +11:00
|
|
|
units=`_btrfs_qgroup_units`
|
|
|
|
|
$BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | $AWK_PROG '/[0-9]/ {print $2" "$3}'
|
2014-12-24 14:48:23 +11:00
|
|
|
|
|
|
|
|
# success, all done
|
|
|
|
|
status=0
|
|
|
|
|
exit
|