From patchwork Tue Jun 21 17:37:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 12889581 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33B98C43334 for ; Tue, 21 Jun 2022 17:37:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234101AbiFURhk (ORCPT ); Tue, 21 Jun 2022 13:37:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233306AbiFURhj (ORCPT ); Tue, 21 Jun 2022 13:37:39 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D36322CC8A for ; Tue, 21 Jun 2022 10:37:37 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id c21so19954768wrb.1 for ; Tue, 21 Jun 2022 10:37:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lspYXotJXIgD9rJo2AqmUY24qO9c5voykkTiI+kyxYw=; b=K6hFRUntBh+CmCcIqqtFywNaZrXx3wLf3/Gdr1aNxwpiSW+hrPmzAhLDPl/sZQA6kv ZlwY7gwFeIIj47B8p/TwXjqedysJxO2Yr5ty8Vvq9Pgf93WjqKvX1XBSIEo7VM9wuFHR TljM6qEYa6SQzRhSy7ioxC/ypMER4BlwyzwyqfIHKo08w5kWkGkyUuzRgo6krTDZ+7Gb 0TGLnfjgPT75ePTKJSoeFraHOzC/083HGIy/h0JH46OHl++klh/rfl0JAyVdDH9YcIF3 d7cxkGpQ2SCG8UgoXqatNlAYzgCh8JLreeUxWT8SD00ZZxwqxk2BtuXHMXjZFiJTR5hT oYTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lspYXotJXIgD9rJo2AqmUY24qO9c5voykkTiI+kyxYw=; b=748LRYkyWRdjDfrfzsq3w9lomoxzpIgg+4KCE1SdyjQvAi/6Q30pFRAReGoM/KavYU CIXRnCiI/TBiLYeIMuqw7Wtj1SzwOegouFuxdVKJZrGM7+gkjPf3vTli093kj4UlxlIJ ToAGwdpbiF/UiVyXyR3G8xjCt2NC6ME4uB1KjGrX+9Zu0MEDJQ4QIZc/QJhZ6A3nPIOG fFfu2mmOSDPd/y9h3bt/3l625ZcOur45GD1AqYp3td04lqzJNJWKq8lLXyp5LRrZXn51 197pOg5OJNtk6LusS69H2UC1T7WhFj33GUJfDsL7aZrqdcK1K4c31QkhycBs57fcETuz ZQkg== X-Gm-Message-State: AJIora/lv0X+hCpo6kOksgvUaYHdgBmkl+w5I4rccBAYxCi7bdBgkvYz CzB2rw9KIkO8JK7vxB1ITAE= X-Google-Smtp-Source: AGRyM1uDu2WvegPq55U4YQWKetkQpH7NQ8TgIgnBzZVojuueYAM35hL5nesgggLrsTbqR/ERl+SKRg== X-Received: by 2002:a5d:452d:0:b0:21b:81f6:d91 with SMTP id j13-20020a5d452d000000b0021b81f60d91mr21737076wra.521.1655833056322; Tue, 21 Jun 2022 10:37:36 -0700 (PDT) Received: from localhost.localdomain ([77.137.66.49]) by smtp.gmail.com with ESMTPSA id k17-20020a5d6e91000000b0021a39f5ba3bsm16105120wrz.7.2022.06.21.10.37.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jun 2022 10:37:35 -0700 (PDT) From: Amir Goldstein To: Zorro Lang Cc: "Darrick J . Wong" , Dave Chinner , fstests@vger.kernel.org Subject: [PATCH v2 1/3] fstests: add missing _require_freeze() to tests Date: Tue, 21 Jun 2022 20:37:27 +0300 Message-Id: <20220621173729.2135249-2-amir73il@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220621173729.2135249-1-amir73il@gmail.com> References: <20220621173729.2135249-1-amir73il@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org And add a few tests that use freeze to the freeze group Signed-off-by: Amir Goldstein Reviewed-by: Zorro Lang --- tests/xfs/119 | 1 + tests/xfs/318 | 3 ++- tests/xfs/325 | 3 ++- tests/xfs/422 | 3 ++- tests/xfs/438 | 2 +- tests/xfs/517 | 1 + 6 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/xfs/119 b/tests/xfs/119 index a1180371..b6f96601 100755 --- a/tests/xfs/119 +++ b/tests/xfs/119 @@ -20,6 +20,7 @@ _begin_fstest log v2log auto freeze _supported_fs xfs _require_scratch +_require_freeze # this may hang sync diff --git a/tests/xfs/318 b/tests/xfs/318 index 38c7aa60..be93f9ab 100755 --- a/tests/xfs/318 +++ b/tests/xfs/318 @@ -7,7 +7,7 @@ # Simulate free extent errors with a file write and a file remove. # . ./common/preamble -_begin_fstest auto quick rw +_begin_fstest auto quick rw freeze # Override the default cleanup function. _cleanup() @@ -26,6 +26,7 @@ _supported_fs xfs _require_scratch _require_error_injection _require_xfs_io_error_injection "rmap_finish_one" +_require_freeze blksz=65536 blks=64 diff --git a/tests/xfs/325 b/tests/xfs/325 index 5b26b2b3..c6861fbc 100755 --- a/tests/xfs/325 +++ b/tests/xfs/325 @@ -8,7 +8,7 @@ # Inject an error during extent freeing to test log recovery. # . ./common/preamble -_begin_fstest auto quick clone +_begin_fstest auto quick clone freeze # Override the default cleanup function. _cleanup() @@ -29,6 +29,7 @@ _require_cp_reflink _require_scratch_reflink _require_error_injection _require_xfs_io_error_injection "free_extent" +_require_freeze blksz=65536 blks=30 diff --git a/tests/xfs/422 b/tests/xfs/422 index 175253aa..a83a66df 100755 --- a/tests/xfs/422 +++ b/tests/xfs/422 @@ -9,7 +9,7 @@ # activity, so we can't have userspace wandering in and thawing it. # . ./common/preamble -_begin_fstest dangerous_scrub dangerous_online_repair +_begin_fstest dangerous_scrub dangerous_online_repair freeze _register_cleanup "_cleanup" BUS @@ -24,6 +24,7 @@ _require_xfs_scratch_rmapbt _require_xfs_io_command "scrub" _require_xfs_io_error_injection "force_repair" _require_command "$KILLALL_PROG" killall +_require_freeze echo "Format and populate" _scratch_mkfs > "$seqres.full" 2>&1 diff --git a/tests/xfs/438 b/tests/xfs/438 index c3008b1c..cfe75bd8 100755 --- a/tests/xfs/438 +++ b/tests/xfs/438 @@ -21,7 +21,7 @@ # Fixed by upstream commit 373b058 ("xfs: Properly retry failed dquot # items in case of error during buffer writeback") . ./common/preamble -_begin_fstest auto quick quota +_begin_fstest auto quick quota freeze # Override the default cleanup function. _cleanup() diff --git a/tests/xfs/517 b/tests/xfs/517 index 88c4f43b..f7f9a8a2 100755 --- a/tests/xfs/517 +++ b/tests/xfs/517 @@ -29,6 +29,7 @@ _supported_fs xfs _require_xfs_scratch_rmapbt _require_xfs_io_command "fsmap" _require_command "$KILLALL_PROG" killall +_require_freeze echo "Format and populate" _scratch_mkfs > "$seqres.full" 2>&1 From patchwork Tue Jun 21 17:37:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 12889583 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52BC8CCA480 for ; Tue, 21 Jun 2022 17:37:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230056AbiFURhl (ORCPT ); Tue, 21 Jun 2022 13:37:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234526AbiFURhl (ORCPT ); Tue, 21 Jun 2022 13:37:41 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD68D2CC9E for ; Tue, 21 Jun 2022 10:37:39 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id i10so16191588wrc.0 for ; Tue, 21 Jun 2022 10:37:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dhtQxMZduKD7jyt1y7myf8aCdKHX+d2vjbXcShdqJqA=; b=NDYExTb8wS/ybdeqJ6veFC1M3e3aW/V0zEqekSKqZFQmRU1t1gG2o6djFoVmrDDcm1 CYG1Tgm1cWs9IU34ZSqx6rCWzhX1QUrIL8WC8FUDWSOCqe1w050mFueXHbEBxJQL56fw aGyb4HTSdqfaUN8cEFjcQzHM8B1rfWJUPtbJ26VtoB3xfwsOjAVCPF/WXTT+aTxMQaam buWpA2x1QnlCNsbwrgDqaQCw2mRtlsPalhTMJROYo0ZoB845VhTESnQtXpN3aa4pvHBR Tp8UvvaolWjbiyOkWZnm1gPBio0dlL05zvzBKsUvGJ3zGQkQBC6eAGoBjXht5ynUfKes P68g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dhtQxMZduKD7jyt1y7myf8aCdKHX+d2vjbXcShdqJqA=; b=O5Gryl1lqG4UQJdW07MjVdRnbwCE7Y5ZKfixm0QLvr9BlS8jvIa9Fohu3Cqiip1Qyx Hg5YkbKTcCofEkD4Xj+tyhAyxLu8hr0bNe2Jg6dTKUr+oyj8rBjaBO2cWbSRqfZy1sFU GwJNAz4WsTimetkv2DRpbWtJb6XzzAhnxN4zYg0oGTKi/+BGh2pvXXSs7sFKpDktuXOc jPO1NkmqEjcIXqPecdsiw3zo2YqXnFxLYYMtqi410m6HjULfWs1qfAtAJx61T9YMHMmq V0b5AcH9emq4lijB2QUzY7DfIYImK2CJ947/OvxksEbXVELsm8N9MUiE2ILFh1i8K/PD 2Zag== X-Gm-Message-State: AJIora98FrG0rTcPf3e7qw9ieQ1dLROK3J6h2VJ3m6XDPIkoMQy1PKgt 0EYiXsAbuyn6rln2mV4oMZg= X-Google-Smtp-Source: AGRyM1uyS1HogO8aBdOiY9Bty8wJ3zWe7PavQ3GnNCeY1gvKCCh7MuXJ+bf1/Riui++gC0YVHa/2dA== X-Received: by 2002:adf:fbd0:0:b0:21b:90cd:69f2 with SMTP id d16-20020adffbd0000000b0021b90cd69f2mr10251606wrs.525.1655833058073; Tue, 21 Jun 2022 10:37:38 -0700 (PDT) Received: from localhost.localdomain ([77.137.66.49]) by smtp.gmail.com with ESMTPSA id k17-20020a5d6e91000000b0021a39f5ba3bsm16105120wrz.7.2022.06.21.10.37.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jun 2022 10:37:37 -0700 (PDT) From: Amir Goldstein To: Zorro Lang Cc: "Darrick J . Wong" , Dave Chinner , fstests@vger.kernel.org Subject: [PATCH v2 2/3] fstests: unfreeze fs on cleanup routines Date: Tue, 21 Jun 2022 20:37:28 +0300 Message-Id: <20220621173729.2135249-3-amir73il@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220621173729.2135249-1-amir73il@gmail.com> References: <20220621173729.2135249-1-amir73il@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org Many of tests that freeze fs do not make sure that fs is unfrozen on test termination. Some tests also need to kill and wait for writer processes after unfreezing the fs. Signed-off-by: Amir Goldstein Reviewed-by: Zorro Lang --- tests/generic/068 | 14 ++++++++++---- tests/generic/085 | 3 +++ tests/generic/280 | 13 ++++++++++++- tests/generic/390 | 8 +++++++- tests/generic/459 | 2 ++ tests/generic/491 | 9 +++++++++ tests/xfs/011 | 3 ++- tests/xfs/119 | 9 +++++++++ tests/xfs/297 | 11 +++++++++++ tests/xfs/318 | 3 ++- tests/xfs/325 | 3 ++- tests/xfs/438 | 2 ++ 12 files changed, 71 insertions(+), 9 deletions(-) diff --git a/tests/generic/068 b/tests/generic/068 index 56262cd7..eeddf6d1 100755 --- a/tests/generic/068 +++ b/tests/generic/068 @@ -17,9 +17,12 @@ ITERATIONS=10 # Override the default cleanup function. _cleanup() { - cd / - - trap 0 1 2 3 15 + # Make sure $SCRATCH_MNT is unfreezed + xfs_freeze -u $SCRATCH_MNT 2>/dev/null + [ -n "$pid" ] && kill -9 $pid 2>/dev/null + wait $pid + cd / + rm -f $tmp.* } # Import common functions. @@ -60,6 +63,7 @@ touch $tmp.running rm -r $STRESS_DIR/* rmdir $STRESS_DIR } & +pid=$! # start fstest -m loop in a background block; this gets us mmap coverage { @@ -75,6 +79,7 @@ touch $tmp.running rm -rf $FSTEST_DIR/* rmdir $FSTEST_DIR } & +pid="$pid $!" i=0 let ITERATIONS=$ITERATIONS-1 @@ -103,6 +108,7 @@ done rm $tmp.running # wait for fsstresses to finish -wait +wait $pid +unset pid exit 1 diff --git a/tests/generic/085 b/tests/generic/085 index 20cf875a..786d8e6f 100755 --- a/tests/generic/085 +++ b/tests/generic/085 @@ -25,6 +25,8 @@ cleanup_dmdev() { # in case it's still suspended and/or mounted $DMSETUP_PROG resume $lvdev >/dev/null 2>&1 + [ -n "$pid" ] && kill -9 $pid 2>/dev/null + wait $pid $UMOUNT_PROG $lvdev >/dev/null 2>&1 _dmsetup_remove $node } @@ -75,6 +77,7 @@ done & pid="$pid $!" wait $pid +unset pid status=0 exit diff --git a/tests/generic/280 b/tests/generic/280 index 07144555..8e1ae4d2 100755 --- a/tests/generic/280 +++ b/tests/generic/280 @@ -10,6 +10,17 @@ . ./common/preamble _begin_fstest auto quota freeze +# Override the default cleanup function. +_cleanup() +{ + # Make sure $SCRATCH_MNT is unfreezed + xfs_freeze -u $SCRATCH_MNT 2>/dev/null + [ -n "$pid" ] && kill -9 $pid 2>/dev/null + wait $pid + cd / + rm -f $tmp.* +} + # Import common functions. . ./common/filter . ./common/quota @@ -34,7 +45,7 @@ pid=$! sleep 1 xfs_freeze -u $SCRATCH_MNT wait $pid -_scratch_unmount +unset pid # Failure comes in the form of a deadlock. diff --git a/tests/generic/390 b/tests/generic/390 index 20c66e22..e8f6a5dc 100755 --- a/tests/generic/390 +++ b/tests/generic/390 @@ -14,8 +14,12 @@ _begin_fstest auto freeze stress _cleanup() { cd / - # Make sure $SCRATCH_MNT is unfreezed + # Kill freeze loops and make sure $SCRATCH_MNT is unfreezed + [ -n "$freeze_pids" ] && kill -9 $freeze_pids 2>/dev/null + wait $freeze_pids xfs_freeze -u $SCRATCH_MNT 2>/dev/null + [ -n "$fsstress_pid" ] && kill -9 $fsstress_pid 2>/dev/null + wait $fsstress_pid rm -f $tmp.* } @@ -62,7 +66,9 @@ done wait $fsstress_pid result=$? +unset fsstress_pid wait $freeze_pids +unset freeze_pids # Exit with fsstress return value status=$result diff --git a/tests/generic/459 b/tests/generic/459 index 57d58e55..7be39089 100755 --- a/tests/generic/459 +++ b/tests/generic/459 @@ -24,6 +24,8 @@ _begin_fstest auto freeze thin # Override the default cleanup function. _cleanup() { + # Make sure $SCRATCH_MNT is unfreezed + xfs_freeze -u $SCRATCH_MNT 2>/dev/null cd / rm -f $tmp.* $UMOUNT_PROG $SCRATCH_MNT >>$seqres.full 2>&1 diff --git a/tests/generic/491 b/tests/generic/491 index e6e57dcd..797b08d5 100755 --- a/tests/generic/491 +++ b/tests/generic/491 @@ -12,6 +12,15 @@ . ./common/preamble _begin_fstest auto quick freeze mount +# Override the default cleanup function. +_cleanup() +{ + cd / + # Make sure $SCRATCH_MNT is unfreezed + xfs_freeze -u $SCRATCH_MNT 2>/dev/null + rm -f $tmp.* +} + # Import common functions. . ./common/filter diff --git a/tests/xfs/011 b/tests/xfs/011 index d6e9099e..ed44d074 100755 --- a/tests/xfs/011 +++ b/tests/xfs/011 @@ -16,10 +16,11 @@ _begin_fstest auto freeze log metadata quick # Override the default cleanup function. _cleanup() { + # Make sure $SCRATCH_MNT is unfreezed + xfs_freeze -u $SCRATCH_MNT 2>/dev/null $KILLALL_PROG -9 fsstress 2>/dev/null wait cd / - _scratch_unmount 2>/dev/null rm -f $tmp.* } diff --git a/tests/xfs/119 b/tests/xfs/119 index b6f96601..5ffbce25 100755 --- a/tests/xfs/119 +++ b/tests/xfs/119 @@ -11,6 +11,15 @@ . ./common/preamble _begin_fstest log v2log auto freeze +# Override the default cleanup function. +_cleanup() +{ + # Make sure $SCRATCH_MNT is unfreezed + xfs_freeze -u $SCRATCH_MNT 2>/dev/null + cd / + rm -f $tmp.* +} + # Import common functions. . ./common/filter diff --git a/tests/xfs/297 b/tests/xfs/297 index ca482e06..07f84c25 100755 --- a/tests/xfs/297 +++ b/tests/xfs/297 @@ -11,6 +11,17 @@ . ./common/preamble _begin_fstest auto freeze +# Override the default cleanup function. +_cleanup() +{ + # Make sure $SCRATCH_MNT is unfreezed + xfs_freeze -u $SCRATCH_MNT 2>/dev/null + $KILLALL_PROG -q -9 $FSSTRESS_PROG + wait + cd / + rm -f $tmp.* +} + # Import common functions. . ./common/filter diff --git a/tests/xfs/318 b/tests/xfs/318 index be93f9ab..5798f9a3 100755 --- a/tests/xfs/318 +++ b/tests/xfs/318 @@ -12,8 +12,9 @@ _begin_fstest auto quick rw freeze # Override the default cleanup function. _cleanup() { + # Make sure $SCRATCH_MNT is unfreezed + xfs_freeze -u $SCRATCH_MNT 2>/dev/null cd / - _scratch_unmount > /dev/null 2>&1 rm -rf $tmp.* } diff --git a/tests/xfs/325 b/tests/xfs/325 index c6861fbc..43fb09a6 100755 --- a/tests/xfs/325 +++ b/tests/xfs/325 @@ -13,8 +13,9 @@ _begin_fstest auto quick clone freeze # Override the default cleanup function. _cleanup() { + # Make sure $SCRATCH_MNT is unfreezed + xfs_freeze -u $SCRATCH_MNT 2>/dev/null cd / - _scratch_unmount > /dev/null 2>&1 rm -rf $tmp.* } diff --git a/tests/xfs/438 b/tests/xfs/438 index cfe75bd8..0425c5b1 100755 --- a/tests/xfs/438 +++ b/tests/xfs/438 @@ -26,6 +26,8 @@ _begin_fstest auto quick quota freeze # Override the default cleanup function. _cleanup() { + # Make sure $SCRATCH_MNT is unfreezed + xfs_freeze -u $SCRATCH_MNT 2>/dev/null [ -z "${interval}" ] || \ sysctl -w fs.xfs.xfssyncd_centisecs=${interval} >/dev/null 2>&1 cd / From patchwork Tue Jun 21 17:37:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 12889584 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52135C43334 for ; Tue, 21 Jun 2022 17:37:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236039AbiFURhm (ORCPT ); Tue, 21 Jun 2022 13:37:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235961AbiFURhl (ORCPT ); Tue, 21 Jun 2022 13:37:41 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E15DA2CC8A for ; Tue, 21 Jun 2022 10:37:40 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id m39-20020a05600c3b2700b0039c511ebbacso9688771wms.3 for ; Tue, 21 Jun 2022 10:37:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DRkonhqIqKPjwKgYdn753QW8oSwPce1FWrd5SGWX04c=; b=IBjA+woPMcS93VB3rTtjs2IT8Ua3FmMZ1vnmrix5L1HpMrlrJbL8WsF6kSGFp+wzaC pAdHknRb8yI9C3B6bsKRum5fEncnmRX/Ya0rVJBhIDe+ucqhI9gUrm12nXJRywypt2BB 5XNteTvaKGf8dNebZjtIiO4P9zf1iYTKXtWcWZ9SHhgnn3n3ewKoBlCxR1DSSraapoR8 gf1rIBR59CuUG3DLmSU5dg5Zt7U3SH1r0D4rmnn7A0E5CE+eMd0bDyHI63Q1nJzOPGUs TmY+Eqg+5FBmr1cKXY5AFYDnBQnUMJmjdZyaCeNxoMhJ4weUf17xqqrJiiM80Jo1pF6u GyVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DRkonhqIqKPjwKgYdn753QW8oSwPce1FWrd5SGWX04c=; b=5M5OJgI8PntuZTyqOF64mZWR96jtLyzQJt3bl+JlgIYIqahQIWPOruFZZrHtQMVuyC bJ2Xr+8qA1SkEh40GjfWDDomj5vOEEHxn0SvDSi1o9FGyg0KhIeCPFOjeA7LZyRSwbhI CJrTdmD4M6fI8kRP8S1YTXH3mn8CQA+OQoicrLuXXY7Cue1KYUf51jewPZw3UPlWkffr HJ7vojHjuzHSI+2sRkeUMLlkYVV4AmWsPnf/6/q0M6wpaY1XcWUdYQpM4N2ve8KozzgJ TfOD9i3SvAz6nljM3CQImXTvlFfl3kF9gDT94jU9hjMgyPE+jjWS0E9LJ60dDtADXPyB j7YQ== X-Gm-Message-State: AOAM533Lf90Hv0NNWv5aDLrbB4fVBdxkN9Lapl4lTmSrbRDQGbNrFTEX 5AKnK1ziTiTas6UQYTFGSck= X-Google-Smtp-Source: ABdhPJy05xz2ZgN+flNPbmqB2A/Kya/yEYi0JTOzdTH25FAwAHV+981BBtC+UkWPsXfWwPT3SBUP2Q== X-Received: by 2002:a05:600c:4e54:b0:39c:6e5e:c667 with SMTP id e20-20020a05600c4e5400b0039c6e5ec667mr40924897wmq.151.1655833059475; Tue, 21 Jun 2022 10:37:39 -0700 (PDT) Received: from localhost.localdomain ([77.137.66.49]) by smtp.gmail.com with ESMTPSA id k17-20020a5d6e91000000b0021a39f5ba3bsm16105120wrz.7.2022.06.21.10.37.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jun 2022 10:37:38 -0700 (PDT) From: Amir Goldstein To: Zorro Lang Cc: "Darrick J . Wong" , Dave Chinner , fstests@vger.kernel.org Subject: [PATCH v2 3/3] xfs/{422,517}: kill background jobs on test termination Date: Tue, 21 Jun 2022 20:37:29 +0300 Message-Id: <20220621173729.2135249-4-amir73il@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220621173729.2135249-1-amir73il@gmail.com> References: <20220621173729.2135249-1-amir73il@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org Those tests failed to cleanup background jobs properly after test is interrupted and even sometimes when it completed succefully. xfs/517 would sometime fails randomally with this false positive error: QA output created by 517 Format and populate Concurrent fsmap and freeze +Terminated Test done The tests have several background sub-shells that spawn short lived programs in a loop. By killing the spawned programs using killall, killall could find no process to kill and the sub-shell loop could still spawn another process that is not going to be killed and in the worst case, the freeze_loop() could spawn the xfs_io "freeze" command after test has thawn the fs before exit, which leaves the fs frozen after the test. The "Terminated" output is emitted by the sub-shell when killing the programs that it has spawned when the loop did not finish before test timeout. By killing the sub-shell and not the spawned programs, we avoid the false positive "Terminated" error. Use a helper to perform this cleanup dance: First kill and wait the freeze_loop so it won't try to freeze fs again Then make sure fs is not frozen. Then kill and wait for the rest of the sub-shells, because if fs is frozen a killed writer process will never exit. Signed-off-by: Amir Goldstein --- tests/xfs/422 | 32 ++++++++++++++++++++++++++++++-- tests/xfs/517 | 26 +++++++++++++++++++++++--- 2 files changed, 53 insertions(+), 5 deletions(-) diff --git a/tests/xfs/422 b/tests/xfs/422 index a83a66df..fdbb8bf1 100755 --- a/tests/xfs/422 +++ b/tests/xfs/422 @@ -13,6 +13,32 @@ _begin_fstest dangerous_scrub dangerous_online_repair freeze _register_cleanup "_cleanup" BUS +# First kill and wait the freeze loop so it won't try to freeze fs again +# Then make sure fs is not frozen +# Then kill and wait for the rest of the workers +# Because if fs is frozen a killed writer will never exit +kill_loops() { + local sig=$1 + + [ -n "$freeze_pid" ] && kill $sig $freeze_pid + wait $freeze_pid + unset freeze_pid + $XFS_IO_PROG -x -c 'thaw' $SCRATCH_MNT + [ -n "$stress_pid" ] && kill $sig $stress_pid + [ -n "$repair_pid" ] && kill $sig $repair_pid + wait + unset stress_pid + unset repair_pid +} + +# Override the default cleanup function. +_cleanup() +{ + kill_loops -9 > /dev/null 2>&1 + cd / + rm -rf $tmp.* +} + # Import common functions. . ./common/filter . ./common/fuzzy @@ -78,8 +104,11 @@ end=$((start + (30 * TIME_FACTOR) )) echo "Loop started at $(date --date="@${start}"), ending at $(date --date="@${end}")" >> $seqres.full stress_loop $end & +stress_pid=$! freeze_loop $end & +freeze_pid=$! repair_loop $end & +repair_pid=$! # Wait until 2 seconds after the loops should have finished... while [ "$(date +%s)" -lt $((end + 2)) ]; do @@ -87,8 +116,7 @@ while [ "$(date +%s)" -lt $((end + 2)) ]; do done # ...and clean up after the loops in case they didn't do it themselves. -$KILLALL_PROG -TERM xfs_io fsstress >> $seqres.full 2>&1 -$XFS_IO_PROG -x -c 'thaw' $SCRATCH_MNT >> $seqres.full 2>&1 +kill_loops >> $seqres.full 2>&1 echo "Loop finished at $(date)" >> $seqres.full echo "Test done" diff --git a/tests/xfs/517 b/tests/xfs/517 index f7f9a8a2..6877af13 100755 --- a/tests/xfs/517 +++ b/tests/xfs/517 @@ -11,11 +11,29 @@ _begin_fstest auto quick fsmap freeze _register_cleanup "_cleanup" BUS +# First kill and wait the freeze loop so it won't try to freeze fs again +# Then make sure fs is not frozen +# Then kill and wait for the rest of the workers +# Because if fs is frozen a killed writer will never exit +kill_loops() { + local sig=$1 + + [ -n "$freeze_pid" ] && kill $sig $freeze_pid + wait $freeze_pid + unset freeze_pid + $XFS_IO_PROG -x -c 'thaw' $SCRATCH_MNT + [ -n "$stress_pid" ] && kill $sig $stress_pid + [ -n "$fsmap_pid" ] && kill $sig $fsmap_pid + wait + unset stress_pid + unset fsmap_pid +} + # Override the default cleanup function. _cleanup() { + kill_loops -9 > /dev/null 2>&1 cd / - $XFS_IO_PROG -x -c 'thaw' $SCRATCH_MNT > /dev/null 2>&1 rm -rf $tmp.* } @@ -83,8 +101,11 @@ end=$((start + (30 * TIME_FACTOR) )) echo "Loop started at $(date --date="@${start}"), ending at $(date --date="@${end}")" >> $seqres.full stress_loop $end & +stress_pid=$! freeze_loop $end & +freeze_pid=$! fsmap_loop $end & +fsmap_pid=$! # Wait until 2 seconds after the loops should have finished... while [ "$(date +%s)" -lt $((end + 2)) ]; do @@ -92,8 +113,7 @@ while [ "$(date +%s)" -lt $((end + 2)) ]; do done # ...and clean up after the loops in case they didn't do it themselves. -$KILLALL_PROG -TERM xfs_io fsstress >> $seqres.full 2>&1 -$XFS_IO_PROG -x -c 'thaw' $SCRATCH_MNT >> $seqres.full 2>&1 +kill_loops >> $seqres.full 2>&1 echo "Loop finished at $(date)" >> $seqres.full echo "Test done"