From patchwork Thu May 10 16:38:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zorro Lang X-Patchwork-Id: 10392097 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C3D0C60353 for ; Thu, 10 May 2018 16:38:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B1E0B286E1 for ; Thu, 10 May 2018 16:38:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A47FF28BFB; Thu, 10 May 2018 16:38:41 +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 1F4BB286E1 for ; Thu, 10 May 2018 16:38:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966396AbeEJQik (ORCPT ); Thu, 10 May 2018 12:38:40 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:42658 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965017AbeEJQik (ORCPT ); Thu, 10 May 2018 12:38:40 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B182CEFF09 for ; Thu, 10 May 2018 16:38:39 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-12-31.pek2.redhat.com [10.72.12.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8C76B64660 for ; Thu, 10 May 2018 16:38:38 +0000 (UTC) From: Zorro Lang To: fstests@vger.kernel.org Subject: [PATCH v2] xfs: new helper grows the mounted scratch XFS filesystem Date: Fri, 11 May 2018 00:38:32 +0800 Message-Id: <20180510163832.7858-1-zlang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 10 May 2018 16:38:39 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 10 May 2018 16:38:39 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'zlang@redhat.com' RCPT:'' Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When test on large SCRATCH_DEV, grow a small XFS to huge size is a horrible thing (e.g grow 128m to 500T). So add a helper named _scratch_xfs_growfs() to do below things: 1) If a 'size' argument is specified, the filesystem will not be grown larger than that size (depend on the device size). 2) else if LARGE_SCRATCH_DEV = yes (--large-fs option), the filesystem will not be grown larger than 10x the current fs size. 3) else the scratch filesystem will be expanded to fit the scratch device. Signed-off-by: Zorro Lang --- Hi, Thanks Eryu and Darrick help to review this patch. V2 has below changes: 1) Change function name _scratch_xfs_growfs_limited to _scratch_xfs_growfs 2) Change the comment about _scratch_xfs_growfs 3) Change local variable limit_size to max_size Thanks, Zorro common/xfs | 36 ++++++++++++++++++++++++++++++++++++ tests/xfs/002 | 2 +- tests/xfs/127 | 2 +- tests/xfs/233 | 2 +- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/common/xfs b/common/xfs index e0bc3f43..a6fe5bf9 100644 --- a/common/xfs +++ b/common/xfs @@ -721,3 +721,39 @@ _require_xfs_db_write_array() rm -f $TEST_DIR/$seq.img [ $supported -eq 0 ] && _notrun "xfs_db write can't support array" } + +# Usage: _scratch_xfs_growfs [max_size_in_bytes] +# +# If max_size_in_bytes is specified, the filesystem will *not* be grown larger +# than that size (depend on the device size). +# Else if LARGE_SCRATCH_DEV = yes (--large-fs option), the filesystem will +# not be grown larger than 10x the current fs size. +# Else the scratch filesystem will be expanded to fit the scratch device. +_scratch_xfs_growfs() +{ + local max_size="$1" + local option="" + + if [ "$LARGE_SCRATCH_DEV" = "yes" -o -n "$max_size" ]; then + local tmp=`mktemp -u` + xfs_info $SCRATCH_MNT | _filter_mkfs > /dev/null 2>$tmp.info + . $tmp.info + rm -f $tmp.info + + local fs_size=$((dbsize * dblocks)) + local dev_size_kb=`_get_device_size $SCRATCH_DEV` + + # default max_size is 10 times current fs size. + if [ -z "$max_size" ]; then + max_size=$((fs_size * 10)) + fi + # don't limit growfs size if device size is smaller + if [ $((dev_size_kb * 1024)) -gt $max_size ]; then + option="-D $((max_size / dbsize))" + else + option="" + fi + fi + + $XFS_GROWFS_PROG $option $SCRATCH_MNT +} diff --git a/tests/xfs/002 b/tests/xfs/002 index 741117be..a77a8719 100755 --- a/tests/xfs/002 +++ b/tests/xfs/002 @@ -68,7 +68,7 @@ _scratch_xfs_db -x -c "sb 2" -c "type data" -c "write fill 0xff 224 4" _scratch_mount # This should pass -$XFS_GROWFS_PROG $SCRATCH_MNT >> $seqres.full 2>&1 || _fail "growfs failed" +_scratch_xfs_growfs >> $seqres.full 2>&1 || _fail "growfs failed" # success, all done status=0 diff --git a/tests/xfs/127 b/tests/xfs/127 index 9df99904..272ea959 100755 --- a/tests/xfs/127 +++ b/tests/xfs/127 @@ -61,7 +61,7 @@ _cp_reflink $testdir/original $testdir/copy1 _cp_reflink $testdir/copy1 $testdir/copy2 echo "Grow fs" -$XFS_GROWFS_PROG $SCRATCH_MNT 2>&1 | _filter_growfs >> $seqres.full +_scratch_xfs_growfs 2>&1 | _filter_growfs >> $seqres.full _scratch_cycle_mount echo "Create more reflink copies" diff --git a/tests/xfs/233 b/tests/xfs/233 index e61c444d..f3689bc9 100755 --- a/tests/xfs/233 +++ b/tests/xfs/233 @@ -59,7 +59,7 @@ cp -p $testdir/original $testdir/copy1 cp -p $testdir/copy1 $testdir/copy2 echo "Grow fs" -$XFS_GROWFS_PROG $SCRATCH_MNT 2>&1 | _filter_growfs >> $seqres.full +_scratch_xfs_growfs 2>&1 | _filter_growfs >> $seqres.full _scratch_cycle_mount echo "Create more copies"