From patchwork Mon Jan 14 08:20:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10761713 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5B5961390 for ; Mon, 14 Jan 2019 08:20:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D6FE28A49 for ; Mon, 14 Jan 2019 08:20:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4112D28A82; Mon, 14 Jan 2019 08:20:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C048128908 for ; Mon, 14 Jan 2019 08:20:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726320AbfANIUv (ORCPT ); Mon, 14 Jan 2019 03:20:51 -0500 Received: from mx2.suse.de ([195.135.220.15]:44936 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726092AbfANIUu (ORCPT ); Mon, 14 Jan 2019 03:20:50 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A0EB4ADC9; Mon, 14 Jan 2019 08:20:48 +0000 (UTC) From: Qu Wenruo To: linux-btrfs@vger.kernel.org, fstests@vger.kernel.org Cc: josef@toxicpanda.com Subject: [PATCH RFC] fstests: btrfs: Test if balance takes too long time or return -ENOSPC unexpected Date: Mon, 14 Jan 2019 16:20:43 +0800 Message-Id: <20190114082043.31220-1-wqu@suse.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Kernel commit 64403612b73a ("btrfs: rework btrfs_check_space_for_delayed_refs") is introducing a regression for btrfs balance performance. Originally, the workload used in the test case only takes seconds for balance on v4.20 while now it takes over 400 seconds for balance. During that 400 seconds balance, it commits over 2000 transactions just for nothing, compare to original several transactions. Add test cases to detect such regression. Signed-off-by: Qu Wenruo Tested-by: David Sterba --- Extra note: In fact, without the snapshots created in the test case, it would return -ENOSPC even we have enough unallocated space. --- tests/btrfs/180 | 80 +++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/180.out | 2 ++ tests/btrfs/group | 1 + 3 files changed, 83 insertions(+) create mode 100755 tests/btrfs/180 create mode 100644 tests/btrfs/180.out diff --git a/tests/btrfs/180 b/tests/btrfs/180 new file mode 100755 index 00000000..534fea01 --- /dev/null +++ b/tests/btrfs/180 @@ -0,0 +1,80 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2019 SUSE Linux Products GmbH. All Rights Reserved. +# +# FS QA Test 180 +# +# Test if metadata balance would take forever to finish or return ENOSPC even +# there there are tons of space. +# +# This is regression caused by upstream commit 64403612b73a +# ("btrfs: rework btrfs_check_space_for_delayed_refs") +# +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 + +# 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_xfs_io_command falloc + +i=0 +loop=16384 + +_scratch_mkfs > /dev/null 2>&1 +_scratch_mount + +$BTRFS_UTIL_PROG subvolume create "$SCRATCH_MNT/src" > /dev/null + +while [ $i -le $loop ]; do + # Use small file to create inline extent + _pwrite_byte 0x00 0 2K "$SCRATCH_MNT/src/inline_$i" > /dev/null + #$XFS_IO_PROG -f -c "falloc 0 4K" "$SCRATCH_MNT/src/regular_$i" > /dev/null + i=$((i + 1)) +done + +# Create enough snapshots so at space reservation part of relocation, we could +# generate enough space pressure +for i in $(seq -w 0 16); do + $BTRFS_UTIL_PROG subvolume snapshot "$SCRATCH_MNT/src" \ + "$SCRATCH_MNT/snapshot_$i" > /dev/null + # touch random files to create some new tree blocks + for j in $(seq -w 0 16); do + victim="$(ls $SCRATCH_MNT/snapshot_$i | sort -R | head -n1)" + touch "$SCRATCH_MNT/snapshot_$i/$victim" + done +done + +# Balancing metadata shouldn't be too time consuming, as the amount of metadata +# is less than 8M, thus normally it should finish very quick. +# +# However with that offending commit, it will take forever to finish or return +# ENOSPC after a long wait. +$BTRFS_UTIL_PROG balance start -m "$SCRATCH_MNT" > /dev/null + +echo "Silence is golden" +# success, all done +status=0 +exit diff --git a/tests/btrfs/180.out b/tests/btrfs/180.out new file mode 100644 index 00000000..50aba766 --- /dev/null +++ b/tests/btrfs/180.out @@ -0,0 +1,2 @@ +QA output created by 180 +Silence is golden diff --git a/tests/btrfs/group b/tests/btrfs/group index 46dd3c95..e724968b 100644 --- a/tests/btrfs/group +++ b/tests/btrfs/group @@ -182,3 +182,4 @@ 177 auto quick swap balance 178 auto quick send 179 auto qgroup dangerous +180 auto balance dangerous