From patchwork Tue May 11 23:32:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gao Xiang X-Patchwork-Id: 12252371 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5620AC433ED for ; Tue, 11 May 2021 23:32:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2A81F6162B for ; Tue, 11 May 2021 23:32:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229848AbhEKXeC (ORCPT ); Tue, 11 May 2021 19:34:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:35138 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229637AbhEKXeC (ORCPT ); Tue, 11 May 2021 19:34:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620775975; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8Q7ECzdN2wLaPzs1B7mX9Ae2MBtvdyw42LZi11howts=; b=dnnyjGM3FV5Sf9aIx2SgNP4oGW2XNwuMIT63tQwTpTazAhyRwQHnBL92IQ7xW14XzaBUFK vvuF33dHe5IwdXUbLpUzwAra18jIE6bzYYKNB9DMOvJS/57wIz+FGyNfIFhliTYgmC0c7j f/w0RwBu15XsQIfMXFGl9pNqxtgBjYc= Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-288-3UnULu2sMh2Nf6VmCjgj4g-1; Tue, 11 May 2021 19:32:53 -0400 X-MC-Unique: 3UnULu2sMh2Nf6VmCjgj4g-1 Received: by mail-pg1-f199.google.com with SMTP id z19-20020a63e1130000b02901fcdcf0c5a3so13160809pgh.19 for ; Tue, 11 May 2021 16:32:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8Q7ECzdN2wLaPzs1B7mX9Ae2MBtvdyw42LZi11howts=; b=l/QDdo5RTqy//B3kS6drOMmzV2wbZ6jKcb9aDi3VhA5QKHkILA2+WpSW5TQNuTWbYU x7N7wPuFTiRBP1GG/hz2+zmrsKaNIvsp+KgPMgc6GULmb4Hg54uEOEujqbowG+kSezuJ W7gff4Wxoedqpnea+klXIdOuQiFsVTxWHAFsMZLYx7XaWrI70Je68TyMbuFWt9bL39OV 8Y1m/iX6dI6Gmc1wrm5mFUg8nSJ6kc+j6339VIHpae4n6PlyymLRS7VlychYpBL/pTkI tPZ0wub9OUsWIUyJxrif1d5bkiebyyPv34+iXpO6Ea38crQMII3Yijk516GjhshPgLN4 hRGA== X-Gm-Message-State: AOAM533K3ck47AlX+u97OiQUcdxl4zcvgWjshlU/6vJ6Y7VvYe0yxRXg ezR9SVrCk1qJNVslyx7J40LsDlh8fUBufg1JQi0yfnrIRumS/Nj2KtbVUr/uv8UdRwe4u/YPEwi 8exkuKvrj43J2iEA3dA== X-Received: by 2002:a17:903:10d:b029:ef:11d:ffd7 with SMTP id y13-20020a170903010db02900ef011dffd7mr28213081plc.53.1620775972177; Tue, 11 May 2021 16:32:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxymIThsAUMhDve9vfgbfy/XUrO/qJgAd/Z9DNb/aEixVZge8cWaaIU3ljBAJKTrAy3Pz++tQ== X-Received: by 2002:a17:903:10d:b029:ef:11d:ffd7 with SMTP id y13-20020a170903010db02900ef011dffd7mr28213058plc.53.1620775971861; Tue, 11 May 2021 16:32:51 -0700 (PDT) Received: from xiangao.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id s3sm15828393pgs.62.2021.05.11.16.32.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 16:32:51 -0700 (PDT) From: Gao Xiang To: linux-xfs@vger.kernel.org, fstests@vger.kernel.org Cc: "Darrick J. Wong" , Zorro Lang , Eryu Guan , Gao Xiang Subject: [PATCH v6 1/3] common/xfs: add _require_xfs_scratch_shrink helper Date: Wed, 12 May 2021 07:32:26 +0800 Message-Id: <20210511233228.1018269-2-hsiangkao@redhat.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210511233228.1018269-1-hsiangkao@redhat.com> References: <20210511233228.1018269-1-hsiangkao@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org In order to detect whether the current kernel supports XFS shrinking. Reviewed-by: Darrick J. Wong Signed-off-by: Gao Xiang --- common/xfs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/common/xfs b/common/xfs index 69f76d6e..a0a4032a 100644 --- a/common/xfs +++ b/common/xfs @@ -766,6 +766,26 @@ _require_xfs_mkfs_without_validation() fi } +_require_xfs_scratch_shrink() +{ + _require_scratch + _require_command "$XFS_GROWFS_PROG" xfs_growfs + + _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs >/dev/null + . $tmp.mkfs + _scratch_mount + # here just to check if kernel supports, no need do more extra work + errmsg=$($XFS_GROWFS_PROG -D$((dblocks-1)) "$SCRATCH_MNT" 2>&1) + if [ "$?" -ne 0 ]; then + echo "$errmsg" | grep 'XFS_IOC_FSGROWFSDATA xfsctl failed: Invalid argument' > /dev/null && \ + _notrun "kernel does not support shrinking" + echo "$errmsg" | grep 'data size .* too small, old size is ' > /dev/null && \ + _notrun "xfsprogs does not support shrinking" + _fail "$XFS_GROWFS_PROG failed unexpectedly: $errmsg" + fi + _scratch_unmount +} + # XFS ability to change UUIDs on V5/CRC filesystems # _require_meta_uuid() From patchwork Tue May 11 23:32:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gao Xiang X-Patchwork-Id: 12252373 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C29EC433B4 for ; Tue, 11 May 2021 23:33:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0349E6187E for ; Tue, 11 May 2021 23:32:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229714AbhEKXeG (ORCPT ); Tue, 11 May 2021 19:34:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:51740 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229637AbhEKXeF (ORCPT ); Tue, 11 May 2021 19:34:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620775978; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hfCHImshba9IOoo/nBIHq5PDDEyhMTFYZzJFFaF5/XI=; b=QzUW0EL30+ezGu5uIalkQeUdP3lVGscoz01ZWszrfhKQEmWaScoHzc9Zq4yC/4ouO4n2m6 s+4+TPW3dyyQTYFouhtzvaUbJRStH+Hu7LKvuH2I6mssi+i371eI4bOiDz24W6Ix9QFu9a X6bP7p8RONa992VtqyJB4EPxuLJsJDk= Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-409-a28gbqBROLqwzgJVUo-MyQ-1; Tue, 11 May 2021 19:32:56 -0400 X-MC-Unique: a28gbqBROLqwzgJVUo-MyQ-1 Received: by mail-pf1-f200.google.com with SMTP id j184-20020a6255c10000b0290214249d921cso13746812pfb.17 for ; Tue, 11 May 2021 16:32:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hfCHImshba9IOoo/nBIHq5PDDEyhMTFYZzJFFaF5/XI=; b=F7rEuxcpM1DMrcWR4rNvDR8gCvCQSK4xGfc7QM24zCvwy+K23rPGmOUNNyLoQm2jUy LNRdH/gr5sK4RNahFFws5CXcjrVJVSsK3uWw1S6GsIjqSUb7DDpV/xK/ICVpSQ0DL6KP Y6WbDNW/ZICuhtJ6CRBnhaNfzGMQ299umtMSDqU1ySEDFtTgcusjvGA7Wl+2fxNemTjj B34X5GtjfapwCResePSCXIOgCGNMOyOYA8qo0b+a2UpB7cL6vrj0u7BlRPoRuadBIbEm 9RhGxOD6sCWDiaT2pDqnxACeqH8RmDjDJInqrbJgZHpV2dbH2laRLNBWW/tj6/Y4YoVm VUsg== X-Gm-Message-State: AOAM531a49fLHNexZVRhoHEcYAsWjQHxe1SXoVe4KTB2hotnFpkVTuLK WYQmi3xBYKcddbzpmR6S9c8BxfpYH47GM6DMjAjGY4uRtjaDdu781ckEugrlROjpmev9zCxqeDn 7otMYkxjGFORQhnbW0w== X-Received: by 2002:a63:1d06:: with SMTP id d6mr32657803pgd.202.1620775975759; Tue, 11 May 2021 16:32:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfNy7iy4UrXyLd1lXYaA+H37XVetpD34r/bIBT+aJ2w69IB6SLNkXjvv11Mgp4LXS8JEM/MA== X-Received: by 2002:a63:1d06:: with SMTP id d6mr32657785pgd.202.1620775975507; Tue, 11 May 2021 16:32:55 -0700 (PDT) Received: from xiangao.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id s3sm15828393pgs.62.2021.05.11.16.32.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 16:32:55 -0700 (PDT) From: Gao Xiang To: linux-xfs@vger.kernel.org, fstests@vger.kernel.org Cc: "Darrick J. Wong" , Zorro Lang , Eryu Guan , Gao Xiang Subject: [PATCH v6 2/3] xfs: basic functionality test for shrinking free space in the last AG Date: Wed, 12 May 2021 07:32:27 +0800 Message-Id: <20210511233228.1018269-3-hsiangkao@redhat.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210511233228.1018269-1-hsiangkao@redhat.com> References: <20210511233228.1018269-1-hsiangkao@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org Add basic test to make sure the functionality works as expected. Reviewed-by: Darrick J. Wong Signed-off-by: Gao Xiang --- tests/xfs/990 | 73 +++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/990.out | 12 ++++++++ tests/xfs/group | 1 + 3 files changed, 86 insertions(+) create mode 100755 tests/xfs/990 create mode 100644 tests/xfs/990.out diff --git a/tests/xfs/990 b/tests/xfs/990 new file mode 100755 index 00000000..ec2592f6 --- /dev/null +++ b/tests/xfs/990 @@ -0,0 +1,73 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021 Red Hat, Inc. All Rights Reserved. +# +# FS QA Test 990 +# +# XFS shrinkfs basic functionality test +# +# This test attempts to shrink with a small size (512K), half AG size and +# an out-of-bound size (agsize + 1) to observe if it works as expected. +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +test_shrink() +{ + $XFS_GROWFS_PROG -D"$1" $SCRATCH_MNT >> $seqres.full 2>&1 + ret=$? + + _scratch_unmount + _check_scratch_fs + _scratch_mount + + $XFS_INFO_PROG $SCRATCH_MNT 2>&1 | _filter_mkfs 2>$tmp.growfs >/dev/null + . $tmp.growfs + [ $ret -eq 0 -a $1 -eq $dblocks ] +} + +# real QA test starts here +_supported_fs xfs +_require_xfs_scratch_shrink + +rm -f $seqres.full +echo "Format and mount" + +# agcount = 1 is forbidden on purpose, and need to ensure shrinking to +# 2 AGs isn't feasible yet. So agcount = 3 is the minimum number now. +_scratch_mkfs -dsize="$((512 * 1024 * 1024))" -dagcount=3 2>&1 | \ + tee -a $seqres.full | _filter_mkfs 2>$tmp.mkfs +. $tmp.mkfs +t_dblocks=$dblocks +_scratch_mount >> $seqres.full + +echo "Shrink fs (small size)" +test_shrink $((t_dblocks-512*1024/dbsize)) || \ + echo "Shrink fs (small size) failure" + +echo "Shrink fs (half AG)" +test_shrink $((t_dblocks-agsize/2)) || \ + echo "Shrink fs (half AG) failure" + +echo "Shrink fs (out-of-bound)" +test_shrink $((t_dblocks-agsize-1)) && \ + echo "Shrink fs (out-of-bound) failure" +[ $dblocks -ne $((t_dblocks-agsize/2)) ] && \ + echo "dblocks changed after shrinking failure" + +$XFS_INFO_PROG $SCRATCH_MNT >> $seqres.full +echo "*** done" + +# success, all done +status=0 +exit diff --git a/tests/xfs/990.out b/tests/xfs/990.out new file mode 100644 index 00000000..812f89ef --- /dev/null +++ b/tests/xfs/990.out @@ -0,0 +1,12 @@ +QA output created by 990 +Format and mount +meta-data=DDEV isize=XXX agcount=N, agsize=XXX blks +data = bsize=XXX blocks=XXX, imaxpct=PCT + = sunit=XXX swidth=XXX, unwritten=X +naming =VERN bsize=XXX +log =LDEV bsize=XXX blocks=XXX +realtime =RDEV extsz=XXX blocks=XXX, rtextents=XXX +Shrink fs (small size) +Shrink fs (half AG) +Shrink fs (out-of-bound) +*** done diff --git a/tests/xfs/group b/tests/xfs/group index fe83f82d..472c8f9a 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -520,3 +520,4 @@ 537 auto quick 538 auto stress 539 auto quick mount +990 auto quick growfs shrinkfs From patchwork Tue May 11 23:32:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gao Xiang X-Patchwork-Id: 12252375 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B902C433B4 for ; Tue, 11 May 2021 23:33:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F06AC616E9 for ; Tue, 11 May 2021 23:33:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229637AbhEKXeM (ORCPT ); Tue, 11 May 2021 19:34:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:35405 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229736AbhEKXeL (ORCPT ); Tue, 11 May 2021 19:34:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620775984; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sL1wCx8ELFuxvB703Ojb+3QWnMC1Qc5Cu6MqVlj4zW0=; b=IA5RTuYm7A74intpis3OKCG3Zy3ARpsF+3XoNIGeYxfgB0Vaqn+PVAI0eCF8vVLtMoVnVY 2udxBXwe+ZO/e/7AsXciFZeZvg+MniupeIUOa6LQpfqJfnewyJgQIT/xE3KxZ6TQvfY5tM 5IzwLf2BmRXwULsDcbn9osxsHYmSLGc= Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-300-QxkzAomsO1Cb7Be6KctOjg-1; Tue, 11 May 2021 19:33:00 -0400 X-MC-Unique: QxkzAomsO1Cb7Be6KctOjg-1 Received: by mail-pj1-f69.google.com with SMTP id n3-20020a17090a2bc3b029015857ee4777so2614007pje.3 for ; Tue, 11 May 2021 16:33:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sL1wCx8ELFuxvB703Ojb+3QWnMC1Qc5Cu6MqVlj4zW0=; b=K6J7okrf8U2AEXWsphA8SoeG8u8ZCFRA0c9AcpbmorsxtZnAWeurApx76fRZaLRXA7 rMHMqTvoJCaW+OOJygzmPIC7eltGZaVpJgJYwWwIlyxHnzqyqrB8+bgygG8A+q+SI2/I rWrfPMOmWdiD+WSs7tUYB8ReQtNH3Z9VdnGttOSCVzes8CKdBRolm5IyyXusTHMJwCkq 5MB2/JhyDOFRd2CuSSVJGFtoPkPv1EYK7B2/wpKiFUPYd6eu5pd17nXahRXrn14YbCMj BQ2odU20RBqNlWSrFUVv7o0xXvMJUKIVNBEym7/Gz5kjF5/TunzRNZt2DTgqlHLiE/nd /7HQ== X-Gm-Message-State: AOAM530SRYO2cs65F/qZwKK1PH26Nu8E9ohtZrx+AvCXTD/NmletVH1G H5n4cjFzZbwHXiUszlxNS8jdxzgApoohMud8+lHpVCl9roYFnsCWEgQiaD+rqtl0gc1sv3nFP/q okpZJktJUdNGcjTiM5Q== X-Received: by 2002:a63:c13:: with SMTP id b19mr33227366pgl.198.1620775979549; Tue, 11 May 2021 16:32:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZYLDNIKGf8j3vzgFHYYot+eUqy/6lNa+LMOqutSWDdMNnuoGtxWEIvH7KpS2rDEde5/CzPw== X-Received: by 2002:a63:c13:: with SMTP id b19mr33227346pgl.198.1620775979298; Tue, 11 May 2021 16:32:59 -0700 (PDT) Received: from xiangao.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id s3sm15828393pgs.62.2021.05.11.16.32.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 16:32:59 -0700 (PDT) From: Gao Xiang To: linux-xfs@vger.kernel.org, fstests@vger.kernel.org Cc: "Darrick J. Wong" , Zorro Lang , Eryu Guan , Gao Xiang Subject: [PATCH v6 3/3] xfs: stress test for shrinking free space in the last AG Date: Wed, 12 May 2021 07:32:28 +0800 Message-Id: <20210511233228.1018269-4-hsiangkao@redhat.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210511233228.1018269-1-hsiangkao@redhat.com> References: <20210511233228.1018269-1-hsiangkao@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org This adds a stress testcase to shrink free space as much as possible in the last AG with background fsstress workload. The expectation is that no crash happens with expected output. Reviewed-by: Darrick J. Wong Signed-off-by: Gao Xiang --- tests/xfs/991 | 122 ++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/991.out | 8 +++ tests/xfs/group | 1 + 3 files changed, 131 insertions(+) create mode 100755 tests/xfs/991 create mode 100644 tests/xfs/991.out diff --git a/tests/xfs/991 b/tests/xfs/991 new file mode 100755 index 00000000..7f4001ab --- /dev/null +++ b/tests/xfs/991 @@ -0,0 +1,122 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2020-2021 Red Hat, Inc. All Rights Reserved. +# +# FS QA Test 991 +# +# XFS online shrinkfs stress test +# +# This test attempts to shrink unused space as much as possible with +# background fsstress workload. It will decrease the shrink size if +# larger size fails. And totally repeat 2 * TIME_FACTOR times. +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +create_scratch() +{ + _scratch_mkfs_xfs $@ | tee -a $seqres.full | \ + _filter_mkfs 2>$tmp.mkfs >/dev/null + . $tmp.mkfs + + _scratch_mount + # fix the reserve block pool to a known size so that the enospc + # calculations work out correctly. + _scratch_resvblks 1024 > /dev/null 2>&1 +} + +fill_scratch() +{ + $XFS_IO_PROG -f -c "falloc 0 $1" $SCRATCH_MNT/resvfile +} + +stress_scratch() +{ + local procs=3 + local nops=1000 + # -w ensures that the only ops are ones which cause write I/O + local FSSTRESS_ARGS=`_scale_fsstress_args -d $SCRATCH_MNT -w \ + -p $procs -n $nops $FSSTRESS_AVOID` + $FSSTRESS_PROG $FSSTRESS_ARGS >> $seqres.full 2>&1 +} + +# real QA test starts here +_supported_fs xfs +_require_xfs_scratch_shrink +_require_xfs_io_command "falloc" + +rm -f $seqres.full +_scratch_mkfs_xfs | tee -a $seqres.full | _filter_mkfs 2>$tmp.mkfs +. $tmp.mkfs # extract blocksize and data size for scratch device + +endsize=`expr 125 \* 1048576` # stop after shrinking this big +[ `expr $endsize / $dbsize` -lt $dblocks ] || _notrun "Scratch device too small" + +nags=2 +totalcount=$((2 * TIME_FACTOR)) + +while [ $totalcount -gt 0 ]; do + size=`expr 1010 \* 1048576` # 1010 megabytes initially + logblks=$(_scratch_find_xfs_min_logblocks -dsize=${size} -dagcount=${nags}) + + create_scratch -lsize=${logblks}b -dsize=${size} -dagcount=${nags} + + for i in `seq 125 -1 90`; do + fillsize=`expr $i \* 1048576` + out="$(fill_scratch $fillsize 2>&1)" + echo "$out" | grep -q 'No space left on device' && continue + test -n "${out}" && echo "$out" + break + done + + # shrink in chunks of this size at most + decsize=`expr 41 \* 1048576 + 1 + $RANDOM \* $RANDOM % 1048576` + + while [ $size -gt $endsize ]; do + stress_scratch & + sleep 1 + + decb=`expr $decsize / $dbsize` # in data blocks + while [ $decb -gt 0 ]; do + sizeb=`expr $size / $dbsize - $decb` + + $XFS_GROWFS_PROG -D ${sizeb} $SCRATCH_MNT \ + >> $seqres.full 2>&1 && break + + [ $decb -gt 100 ] && decb=`expr $decb + $RANDOM % 10` + decb=`expr $decb / 2` + done + + wait + [ $decb -eq 0 ] && break + + # get latest dblocks + $XFS_INFO_PROG $SCRATCH_MNT 2>&1 | _filter_mkfs 2>$tmp.growfs >/dev/null + . $tmp.growfs + + size=`expr $dblocks \* $dbsize` + _scratch_unmount + _scratch_xfs_repair -n >> $seqres.full 2>&1 || \ + _fail "xfs_repair failed with shrinking $sizeb" + _scratch_mount + done + + _scratch_unmount + _scratch_xfs_repair -n >> $seqres.full 2>&1 || \ + _fail "xfs_repair failed with shrinking $sizeb" + totalcount=`expr $totalcount - 1` +done + +echo "*** done" +status=0 +exit diff --git a/tests/xfs/991.out b/tests/xfs/991.out new file mode 100644 index 00000000..e8209672 --- /dev/null +++ b/tests/xfs/991.out @@ -0,0 +1,8 @@ +QA output created by 991 +meta-data=DDEV isize=XXX agcount=N, agsize=XXX blks +data = bsize=XXX blocks=XXX, imaxpct=PCT + = sunit=XXX swidth=XXX, unwritten=X +naming =VERN bsize=XXX +log =LDEV bsize=XXX blocks=XXX +realtime =RDEV extsz=XXX blocks=XXX, rtextents=XXX +*** done diff --git a/tests/xfs/group b/tests/xfs/group index 472c8f9a..53e68bea 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -521,3 +521,4 @@ 538 auto stress 539 auto quick mount 990 auto quick growfs shrinkfs +991 auto growfs shrinkfs ioctl prealloc stress