From patchwork Wed Mar 27 17:11:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13607095 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B32812F583; Wed, 27 Mar 2024 17:11:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711559515; cv=none; b=VlFfPNIQsy7CqZZ+PUIxuJRRb+4oHrO5yK+nbxRhvxIWHAFAPWgZlrNLWBWOznBc8lkmIxVBm0KOs6b4kjLlZ9CUAnKOVqPGkdh+DaBWUXWiVwtE2m2l4a9Q7eA2GyhfEcQmPvIqHOtQ7DUkMPp2v+JLs4GW84LSq/Y+HEiGNBk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711559515; c=relaxed/simple; bh=9dTQ6HTsVMosSX2B+VSD/sl3vITeUwC0dNmSPaqrc3g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tMpLmhYS6L7CgKhfI7A0aQx2tTCJc9b+OmP3bIcIe2UYp8bMvMoz4yA+U8ufS3MOWJRcywZkCHTuETKdXbFckESl/G83yhfqzcCukJlFWQIizWShE4otC34wVVqiux94jy0AdE9y/4KnusZWy0rNZ3Y5O0/APbdcj9SoiuEKa84= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=A7bZDDLS; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="A7bZDDLS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F136AC433F1; Wed, 27 Mar 2024 17:11:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711559514; bh=9dTQ6HTsVMosSX2B+VSD/sl3vITeUwC0dNmSPaqrc3g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A7bZDDLS1HB87I05uJvuvlZajS5J0OxW5J+NvreqnlzONbqk7rEEJ6PeY1/0eA007 4lHgQrCBwSfhnnpwHjnqyT+1pirHE3bAj8FLMmdJUs8UbPAr2b5f5kriU9vurhm5Ol i9fwBrbbYyunprgyehJ2Wukg/of6NWwI4kXy1Asj1gtDyuSE+EvPiTAlskfi5X/1/O KfvGuz4319nGeTj0mx3h4NziIHYGLdHM9BLKYHbgAtTMuajJkjIW2Tf3mx5RPhvwXt nIzAWKMxcS6dcBtC0ATqot7AzEBC07HHwHX8RDCFvmcvWVM1pEdYyufl86wm9yrykU HfJhvE3nOS0fQ== From: fdmanana@kernel.org To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Filipe Manana Subject: [PATCH 01/10] btrfs: add helper to kill background process running _btrfs_stress_balance Date: Wed, 27 Mar 2024 17:11:35 +0000 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: fstests@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana Killing a background process running _btrfs_stress_balance() is not as simple as sending a signal to the process and waiting for it to die. Therefore we have the following logic to terminate such process: kill $pid wait $pid # Wait for the balance operation to finish. while ps aux | grep "balance start" | grep -qv grep; do sleep 1 done Since this is repeated in several test cases, move this logic to a common helper and use it in all affected test cases. This will help to avoid repeating the same code again several times in upcoming changes. Signed-off-by: Filipe Manana Reviewed-by: Anand Jain --- common/btrfs | 14 ++++++++++++++ tests/btrfs/060 | 8 ++------ tests/btrfs/061 | 10 ++++------ tests/btrfs/062 | 10 ++++------ tests/btrfs/063 | 10 ++++------ tests/btrfs/064 | 10 ++++------ tests/btrfs/255 | 8 ++------ 7 files changed, 34 insertions(+), 36 deletions(-) diff --git a/common/btrfs b/common/btrfs index aa344706..e95cff7f 100644 --- a/common/btrfs +++ b/common/btrfs @@ -308,6 +308,20 @@ _btrfs_stress_balance() done } +# Kill a background process running _btrfs_stress_balance() +_btrfs_kill_stress_balance_pid() +{ + local balance_pid=$1 + + # Ignore if process already died. + kill $balance_pid &> /dev/null + wait $balance_pid &> /dev/null + # Wait for the balance operation to finish. + while ps aux | grep "balance start" | grep -qv grep; do + sleep 1 + done +} + # stress btrfs by creating/mounting/umounting/deleting subvolume in a loop _btrfs_stress_subvolume() { diff --git a/tests/btrfs/060 b/tests/btrfs/060 index a0184891..58167cc6 100755 --- a/tests/btrfs/060 +++ b/tests/btrfs/060 @@ -57,12 +57,8 @@ run_test() wait $fsstress_pid touch $stop_file - kill $balance_pid - wait - # wait for the balance operation to finish - while ps aux | grep "balance start" | grep -qv grep; do - sleep 1 - done + wait $subvol_pid + _btrfs_kill_stress_balance_pid $balance_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 diff --git a/tests/btrfs/061 b/tests/btrfs/061 index c1010413..d0b55e48 100755 --- a/tests/btrfs/061 +++ b/tests/btrfs/061 @@ -51,12 +51,10 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $balance_pid $scrub_pid - wait - # wait for the balance and scrub operations to finish - while ps aux | grep "balance start" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_balance_pid $balance_pid + kill $scrub_pid + wait $scrub_pid + # wait for the crub operation to finish while ps aux | grep "scrub start" | grep -qv grep; do sleep 1 done diff --git a/tests/btrfs/062 b/tests/btrfs/062 index 818a0156..a2639d6c 100755 --- a/tests/btrfs/062 +++ b/tests/btrfs/062 @@ -52,12 +52,10 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $balance_pid $defrag_pid - wait - # wait for the balance and defrag operations to finish - while ps aux | grep "balance start" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_balance_pid $balance_pid + kill $defrag_pid + wait $defrag_pid + # wait for the defrag operation to finish while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do sleep 1 done diff --git a/tests/btrfs/063 b/tests/btrfs/063 index 2f771baf..baf0c356 100755 --- a/tests/btrfs/063 +++ b/tests/btrfs/063 @@ -51,12 +51,10 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $balance_pid $remount_pid - wait - # wait for the balance and remount loop to finish - while ps aux | grep "balance start" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_balance_pid $balance_pid + kill $remount_pid + wait $remount_pid + # wait for the remount loop to finish while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do sleep 1 done diff --git a/tests/btrfs/064 b/tests/btrfs/064 index e9b46ce6..58b53afe 100755 --- a/tests/btrfs/064 +++ b/tests/btrfs/064 @@ -63,12 +63,10 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $balance_pid $replace_pid - wait - # wait for the balance and replace operations to finish - while ps aux | grep "balance start" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_balance_pid $balance_pid + kill $replace_pid + wait $replace_pid + # wait for the replace operation to finish while ps aux | grep "replace start" | grep -qv grep; do sleep 1 done diff --git a/tests/btrfs/255 b/tests/btrfs/255 index 7e70944a..aa250467 100755 --- a/tests/btrfs/255 +++ b/tests/btrfs/255 @@ -41,12 +41,8 @@ for ((i = 0; i < 20; i++)); do $BTRFS_UTIL_PROG quota enable $SCRATCH_MNT $BTRFS_UTIL_PROG quota disable $SCRATCH_MNT done -kill $balance_pid &> /dev/null -wait -# wait for the balance operation to finish -while ps aux | grep "balance start" | grep -qv grep; do - sleep 1 -done + +_btrfs_kill_stress_balance_pid $balance_pid echo "Silence is golden" status=0 From patchwork Wed Mar 27 17:11:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13607096 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E46C12F583; Wed, 27 Mar 2024 17:11:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711559516; cv=none; b=fdE0+BUVs2nJiYb0z9YNl34prLxWnJlRzuk+3SEQ41DCPrtU4jZLI0OgEvQK8K6MOoxkopiRsD4pASyoRLow3wEpe+Qm6nf0b+e1dY3oPQZTN3+742b+aZGkgW8o+cDk65P4IJgkvPR/HmWy0ykKkqVdfawo6G6q5bE3oIKER3E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711559516; c=relaxed/simple; bh=PejVCeyImKVb9tF6Ui/cbZM3A2MJUS8mmfB5DA0lsws=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gwG6nOJ5KM9ldV5qkDrKfAkVOoncaJL0HZsHMNEeg3PW/z1Nt3K+AeS2wRlN0/QVZmbZVHH4kfTzi8NubOjbZeRXZovYomfIrXZnYfWq93kMeWiWRa3c4r3m4FGZoRRDgcn92PhKbADQvjeBvik+nPg/DhZkSrMYuXvzxpImslE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pgHrDJ7z; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pgHrDJ7z" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4703DC43394; Wed, 27 Mar 2024 17:11:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711559516; bh=PejVCeyImKVb9tF6Ui/cbZM3A2MJUS8mmfB5DA0lsws=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pgHrDJ7zwGmuCxnzlnA+1MQ86YwmCAwEpIK4RS7kUEx5pu24JGq20JrM+pXkCLO6r VJBaIn5jpf3ZJRxBQEgKUowfP+HeA4GCPuMhxkrHjYbQsTO2zhm8lHoTGd+wkqDYvc dMCadNdaWovUFiqqRAwdTqqFFiTjgFimPqLp4R9T1hDOCSfGg/4mBVYBce0y5g1yBF iJGFW48u79YDhHp0jN9RDlWecrliVYVcbQbLFs1iF7a9R1bsulIEm8JTR4ZXZWCAQ0 boHXwrSU2BY4Umakw94J2Pvh/A2u6DJIfOuFpiQFJZCKfm9anIoG5X3j4Ufcc5QhY6 OMwiCYHwAHhng== From: fdmanana@kernel.org To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Filipe Manana Subject: [PATCH 02/10] btrfs/028: use the helper _btrfs_kill_stress_balance_pid Date: Wed, 27 Mar 2024 17:11:36 +0000 Message-ID: <375e94a8cc448c369d4346cba2f6ef6f65b34df6.1711558345.git.fdmanana@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: fstests@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana Now that there's a helper to kill a background process that is running _btrfs_stress_balance(), use it in btrfs/028. It's equivalent to the existing code in btrfs/028. Signed-off-by: Filipe Manana --- tests/btrfs/028 | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/btrfs/028 b/tests/btrfs/028 index d860974e..8fbe8887 100755 --- a/tests/btrfs/028 +++ b/tests/btrfs/028 @@ -44,12 +44,9 @@ balance_pid=$! # 30s is enough to trigger bug sleep $((30*$TIME_FACTOR)) -kill $fsstress_pid $balance_pid &> /dev/null -wait - -# kill _btrfs_stress_balance can't end balance, so call btrfs balance cancel -# to cancel running or paused balance. -$BTRFS_UTIL_PROG balance cancel $SCRATCH_MNT &> /dev/null +kill $fsstress_pid &> /dev/null +wait $fsstress_pid &> /dev/null +_btrfs_kill_stress_balance_pid $balance_pid _run_btrfs_util_prog filesystem sync $SCRATCH_MNT From patchwork Wed Mar 27 17:11:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13607097 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E1AF51304A6; Wed, 27 Mar 2024 17:11:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711559518; cv=none; b=q+zHGbbY3QSGqxYMsvVklQ4KKcAhXWBsCZ8AY456CuJ0NHbHGMJH+fR78Q5bvUnulVOXMg4UwshyCmkBRk/IaRJK1jcOYBOFzX/ik+ayZ/nv7QFnEtitPaJBY0q1/3NjMRq2IoTFAUY0X1pK7Tz1ssB77MrZSllvSC+0HsDw+ug= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711559518; c=relaxed/simple; bh=ykXCDwMyRWtbED3Ezmvr40N9Yt2CVj0igZe+WCNHjz4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=vB2FXsX0SGV36Y5FrJ6Sob7G6qr8nyU+kwk+a9061EqFot1/YsTaq6hGBVhJ9vJd+EK5byxubLtVCfDL9jZYsYGBt/W+Vx984d6z0rb5vW+huY//SOLE+mMz4wCBf689KsQm3FfwGyqd2T9tu88RpgT5GQfkX5RN92qNJU1msX0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uaVh9Ks5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uaVh9Ks5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91B32C433B1; Wed, 27 Mar 2024 17:11:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711559517; bh=ykXCDwMyRWtbED3Ezmvr40N9Yt2CVj0igZe+WCNHjz4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uaVh9Ks5BLLWNTYtfgEzmOkrZ6S8WTXcSnsK6dtP00rpth9RapmsFvlDZqN7IWGYD X7irz6DYzTGN5wk6XYeKoJFZH51H95cvVuLWq8OlzOCWArTDuqAuFMRiCj282qjLUv X12HoEJBWdomzbOGtbTfEnr4DHmfqMdVjpeCveN6Vy92yiX+WnFF1XcPOW/gwB+5TZ nivskJqIHEwU9OCnAX8QJfjQJdV1IeaYuKEHiPwPoKBCeGT886l7/ySl03CBn3WPgX +OIxWmonSnziiWICAjLU4cXZX086dUh8lGlp0NjEe7iGLAZjoWHd+v6v6USEZFQvk4 zCaQigBpXocHw== From: fdmanana@kernel.org To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Filipe Manana Subject: [PATCH 03/10] btrfs/028: removed redundant sync and scratch filesystem unmount Date: Wed, 27 Mar 2024 17:11:37 +0000 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: fstests@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana There's no need to have an explicit scratch filesystem sync and unmount at the of the test, as the fstests framework automatically unmounts the filesystem and the unmount naturally syncs any data and metadata. So remove them and update the comment to be more clear. Signed-off-by: Filipe Manana --- tests/btrfs/028 | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/btrfs/028 b/tests/btrfs/028 index 8fbe8887..0c96b2fe 100755 --- a/tests/btrfs/028 +++ b/tests/btrfs/028 @@ -48,11 +48,8 @@ kill $fsstress_pid &> /dev/null wait $fsstress_pid &> /dev/null _btrfs_kill_stress_balance_pid $balance_pid -_run_btrfs_util_prog filesystem sync $SCRATCH_MNT - -_scratch_unmount - -# qgroup will be checked at _check_scratch_fs() by fstest. +# The qgroups accounting will be checked by 'btrfs check' (fsck) after the +# fstests framework unmounts the filesystem. echo "Silence is golden" status=0 From patchwork Wed Mar 27 17:11:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13607098 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E603214D439; Wed, 27 Mar 2024 17:11:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711559519; cv=none; b=KC+PVKzuHZJVxJS/ZawdrTOC24uOPrZs4Nb9a/OobTLi0+ykSnLGU3M9kcBe3Gj11qQJAJ4wrPZZ1Q0VUP2Hhir8xmpHOh+gixk8jA3Q+vR1OtiGUqTlc6S5Mu1redNgFBS/k3PO8ULU+s+sOkKxvz9OGCy0EFQ4eLsRONmKZfU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711559519; c=relaxed/simple; bh=6/kSIBnnTuaxbsOQsIl08wSEZZOIpHWuf3lwX6fTGRs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LV64uyNuhOpNOLEAroDE+mAjuA4cj0W9FS2mYmIWcDrTZo5+AxuOX6yraIgSNHWkR4UzAoY2Htd4WEEk3hQUqvlXXbCeJGNIO00BtzS40k/u+3neWYHkpeyCGh52Sl7Dh5H4eEHiTXmgKvytllz1erWCXMheivwiMDtIShhqql0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=K0pmoB4s; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="K0pmoB4s" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DBB6DC43390; Wed, 27 Mar 2024 17:11:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711559518; bh=6/kSIBnnTuaxbsOQsIl08wSEZZOIpHWuf3lwX6fTGRs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K0pmoB4sIaAtnW/8LtMzfmH8IZIfrNmVg/AVhO7MXbIx6RrjbU599e53Bs0mS1BKH 3DSc70eWBWfktmoDpOChvcwfpiLL2omYvGwDnuCKyT8mQRNnNjsqhOs6KDAMvQ1VTv iQsaJIn4odNg5Bz88fW8mFuiQYa50j1sy59NnCnJOKyM4giLhllmcJoZ8LG4RnAINQ UcGVoM8v3wkzhpHyWaS8QXQLjJih/VYE/W9zWih4bYS+lsc+Ym9F/BjWN3P0yLzOEt YI1fsrIDjXaSpSN6NuvHahKFvfw8TIrtuWgOABmcNQMbqJJiBJMNNZzEWsJmdCx45F ym9b+E7OdTyog== From: fdmanana@kernel.org To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Filipe Manana Subject: [PATCH 04/10] btrfs: add helper to kill background process running _btrfs_stress_scrub Date: Wed, 27 Mar 2024 17:11:38 +0000 Message-ID: <091a8f4e0211299e21c3a3231584d0e8dac49ed1.1711558345.git.fdmanana@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: fstests@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana Killing a background process running _btrfs_stress_scrub() is not as simple as sending a signal to the process and waiting for it to die. Therefore we have the following logic to terminate such process: kill $pid wait $pid while ps aux | grep "scrub start" | grep -qv grep; do sleep 1 done Since this is repeated in several test cases, move this logic to a common helper and use it in all affected test cases. This will help to avoid repeating the same code again several times in upcoming changes. Signed-off-by: Filipe Manana --- common/btrfs | 14 ++++++++++++++ tests/btrfs/061 | 7 +------ tests/btrfs/066 | 8 ++------ tests/btrfs/069 | 11 +++++------ tests/btrfs/072 | 11 +++++------ tests/btrfs/073 | 11 +++++------ 6 files changed, 32 insertions(+), 30 deletions(-) diff --git a/common/btrfs b/common/btrfs index e95cff7f..d0adeea1 100644 --- a/common/btrfs +++ b/common/btrfs @@ -349,6 +349,20 @@ _btrfs_stress_scrub() done } +# Kill a background process running _btrfs_stress_scrub() +_btrfs_kill_stress_scrub_pid() +{ + local scrub_pid=$1 + + # Ignore if process already died. + kill $scrub_pid &> /dev/null + wait $scrub_pid &> /dev/null + # Wait for the scrub operation to finish. + while ps aux | grep "scrub start" | grep -qv grep; do + sleep 1 + done +} + # stress btrfs by defragmenting every file/dir in a loop and compress file # contents while defragmenting if second argument is not "nocompress" _btrfs_stress_defrag() diff --git a/tests/btrfs/061 b/tests/btrfs/061 index d0b55e48..b8b2706c 100755 --- a/tests/btrfs/061 +++ b/tests/btrfs/061 @@ -52,12 +52,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid _btrfs_kill_stress_balance_pid $balance_pid - kill $scrub_pid - wait $scrub_pid - # wait for the crub operation to finish - while ps aux | grep "scrub start" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_scrub_pid $scrub_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 diff --git a/tests/btrfs/066 b/tests/btrfs/066 index a29034bb..29821fdd 100755 --- a/tests/btrfs/066 +++ b/tests/btrfs/066 @@ -57,12 +57,8 @@ run_test() wait $fsstress_pid touch $stop_file - kill $scrub_pid - wait - # wait for the scrub operation to finish - while ps aux | grep "scrub start" | grep -qv grep; do - sleep 1 - done + wait $subvol_pid + _btrfs_kill_stress_scrub_pid $scrub_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 diff --git a/tests/btrfs/069 b/tests/btrfs/069 index 139dde48..20f44b39 100755 --- a/tests/btrfs/069 +++ b/tests/btrfs/069 @@ -59,17 +59,16 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $replace_pid $scrub_pid - wait + kill $replace_pid + wait $replace_pid - # wait for the scrub and replace operations to finish - while ps aux | grep "scrub start" | grep -qv grep; do - sleep 1 - done + # wait for the replace operation to finish while ps aux | grep "replace start" | grep -qv grep; do sleep 1 done + _btrfs_kill_stress_scrub_pid $scrub_pid + echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 if [ $? -ne 0 ]; then diff --git a/tests/btrfs/072 b/tests/btrfs/072 index 4b6b6fb5..6c15b51f 100755 --- a/tests/btrfs/072 +++ b/tests/btrfs/072 @@ -52,16 +52,15 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $scrub_pid $defrag_pid - wait - # wait for the scrub and defrag operations to finish - while ps aux | grep "scrub start" | grep -qv grep; do - sleep 1 - done + kill $defrag_pid + wait $defrag_pid + # wait for the defrag operation to finish while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do sleep 1 done + _btrfs_kill_stress_scrub_pid $scrub_pid + echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 if [ $? -ne 0 ]; then diff --git a/tests/btrfs/073 b/tests/btrfs/073 index b1604f94..49a4abd1 100755 --- a/tests/btrfs/073 +++ b/tests/btrfs/073 @@ -51,16 +51,15 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $scrub_pid $remount_pid - wait - # wait for the scrub and remount operations to finish - while ps aux | grep "scrub start" | grep -qv grep; do - sleep 1 - done + kill $remount_pid + wait $remount_pid + # wait for the remount operation to finish while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do sleep 1 done + _btrfs_kill_stress_scrub_pid $scrub_pid + echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 if [ $? -ne 0 ]; then From patchwork Wed Mar 27 17:11:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13607099 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 36BE114E2F3; Wed, 27 Mar 2024 17:12:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711559520; cv=none; b=jLYJKzCntmDp78lEjwfl6j8Son2NE5hFCJHHFhOCcyYpEWQiO569pjMYaDhybFU27HPR9HPQQLyx++rrDsJrdHb8Q+obbozmEfCacZUddgoqWDmb13sKlAnrWrbV1MNJiuxVQk3ntHQttZTtRZh5TGr+H2Ffw0ee+xhFoPFTTso= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711559520; c=relaxed/simple; bh=Zb/dlXz6K/v2wrzxkvGZAVHTuf3HA4j87EhPu1yDskQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=steXFxT/2bluVZQrDEq0kjNemWUZGA9iTgcUgv2OJs60s01BWAAJoMlIxVjooucAhfQXyCBBdAcEJB5S7Swr6Vs8Bu9fK93+7d8xFXGHBcsXPCnyxQe8A7/E62mS3YdgyCjxRYE7UcLrojcVzNXPQEFslFdy+5DaGSyCQmB/1IY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tcvUjbSZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tcvUjbSZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32174C433F1; Wed, 27 Mar 2024 17:11:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711559520; bh=Zb/dlXz6K/v2wrzxkvGZAVHTuf3HA4j87EhPu1yDskQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tcvUjbSZgXLIO3WWnt9PicjRsgjdAS3+Fi65M5GH9/PjQ5lWW3omfjpZCZsjFNZYE jwsL+/EiORI0g3JzM27GtwZx8z2CTbVVKDHHNdsaa42gENE05u+1Id5lQQlo+IsqIx AjI5HliFWby/onUqvN3+Zj7ByTBJW7gZtTRuzUEgtvN902gUleogXnB6IKcKPKXUdE RKZrV9EzL/C75AiHF9xiIwqyL4snU8KkkuQ2hznhJRv3ZoUfTPYNe+ObYrimldnUt+ T6L0pZ4P3OQWRk7ZD14z0DJzD4b5cSwEJrDh5ihrZGrLgHG8xEi6PCg5Enu5aCWT3f 72QrHEtUYBXDQ== From: fdmanana@kernel.org To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Filipe Manana Subject: [PATCH 05/10] btrfs: add helper to kill background process running _btrfs_stress_defrag Date: Wed, 27 Mar 2024 17:11:39 +0000 Message-ID: <247bde0d4f7d943337e228dded8ad03753b0e3c9.1711558345.git.fdmanana@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: fstests@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana Killing a background process running _btrfs_stress_defrag() is not as simple as sending a signal to the process and waiting for it to die. Therefore we have the following logic to terminate such process: kill $pid wait $pid while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do sleep 1 done Since this is repeated in several test cases, move this logic to a common helper and use it in all affected test cases. This will help to avoid repeating the same code again several times in upcoming changes. Signed-off-by: Filipe Manana Reviewed-by: Anand Jain --- common/btrfs | 14 ++++++++++++++ tests/btrfs/062 | 7 +------ tests/btrfs/067 | 8 ++------ tests/btrfs/070 | 11 +++++------ tests/btrfs/072 | 7 +------ tests/btrfs/074 | 11 +++++------ 6 files changed, 28 insertions(+), 30 deletions(-) diff --git a/common/btrfs b/common/btrfs index d0adeea1..46056d4a 100644 --- a/common/btrfs +++ b/common/btrfs @@ -383,6 +383,20 @@ _btrfs_stress_defrag() done } +# Kill a background process running _btrfs_stress_defrag() +_btrfs_kill_stress_defrag_pid() +{ + local defrag_pid=$1 + + # Ignore if process already died. + kill $defrag_pid &> /dev/null + wait $defrag_pid &> /dev/null + # Wait for the defrag operation to finish. + while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do + sleep 1 + done +} + # stress btrfs by remounting it with different compression algorithms in a loop # run this with fsstress running at background could exercise the compression # code path and ensure no race when switching compression algorithm with constant diff --git a/tests/btrfs/062 b/tests/btrfs/062 index a2639d6c..59d581be 100755 --- a/tests/btrfs/062 +++ b/tests/btrfs/062 @@ -53,12 +53,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid _btrfs_kill_stress_balance_pid $balance_pid - kill $defrag_pid - wait $defrag_pid - # wait for the defrag operation to finish - while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_defrag_pid $defrag_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 diff --git a/tests/btrfs/067 b/tests/btrfs/067 index 709db155..2bb00b87 100755 --- a/tests/btrfs/067 +++ b/tests/btrfs/067 @@ -58,12 +58,8 @@ run_test() wait $fsstress_pid touch $stop_file - kill $defrag_pid - wait - # wait for btrfs defrag process to exit, otherwise it will block umount - while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do - sleep 1 - done + wait $subvol_pid + _btrfs_kill_stress_defrag_pid $defrag_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 diff --git a/tests/btrfs/070 b/tests/btrfs/070 index 54aa275c..cefa5723 100755 --- a/tests/btrfs/070 +++ b/tests/btrfs/070 @@ -60,17 +60,16 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $replace_pid $defrag_pid - wait + kill $replace_pid + wait $replace_pid - # wait for the defrag and replace operations to finish - while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do - sleep 1 - done + # wait for the replace operation to finish while ps aux | grep "replace start" | grep -qv grep; do sleep 1 done + _btrfs_kill_stress_defrag_pid $defrag_pid + echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 if [ $? -ne 0 ]; then diff --git a/tests/btrfs/072 b/tests/btrfs/072 index 6c15b51f..505d0b57 100755 --- a/tests/btrfs/072 +++ b/tests/btrfs/072 @@ -52,13 +52,8 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $defrag_pid - wait $defrag_pid - # wait for the defrag operation to finish - while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_defrag_pid $defrag_pid _btrfs_kill_stress_scrub_pid $scrub_pid echo "Scrub the filesystem" >>$seqres.full diff --git a/tests/btrfs/074 b/tests/btrfs/074 index 9b22c620..d51922d0 100755 --- a/tests/btrfs/074 +++ b/tests/btrfs/074 @@ -52,16 +52,15 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $defrag_pid $remount_pid - wait - # wait for the defrag and remount operations to finish - while ps aux | grep "btrfs filesystem defrag" | grep -qv grep; do - sleep 1 - done + kill $remount_pid + wait $remount_pid + # wait for the remount operation to finish while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do sleep 1 done + _btrfs_kill_stress_defrag_pid $defrag_pid + echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 if [ $? -ne 0 ]; then From patchwork Wed Mar 27 17:11:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13607100 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8334F130AFC; Wed, 27 Mar 2024 17:12:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711559521; cv=none; b=TTuz3tmjBxKqmxnxfdTCiUIsSriDUz5qPE9mcD0Pkg0djvvzWaTxDJTKehoZgTOKmUPkCWjArD5sfbkIsLHfmo3568Bax32qoNwQc0b8pMHrZqwh8M8Xt/kQSmmDfT4N/69RBruBEEo2ad0bfToP9f2g5HSHIKPtFHXNzndb/Zo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711559521; c=relaxed/simple; bh=HtwhMmoubzcWK5MoH0oMJbVCTY9IinGu2kBMPiHu2d0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OiaMpv46s7Phd3Ta80sfxnudiOSuRagrgkEv0ilamhtEM8Marz7LpWlRGUb2qm5Ab2SSZHH2lTzZBedTttf0ozjI1YiRha+wS0EifiMzhjMnH6rQ/Yd9UCpuGaiNXTYVkvI+qbhFkTouC+zfLIINlxQ2zUPbrJAkXWM65WfmcG8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Hz8Cm1B+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Hz8Cm1B+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B5B7C43390; Wed, 27 Mar 2024 17:12:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711559521; bh=HtwhMmoubzcWK5MoH0oMJbVCTY9IinGu2kBMPiHu2d0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hz8Cm1B+iGgc/gobAfSu7blnsOqIiHnZYc6GB2wHYdsDkKeAm8VRLT6SrJ/xU/KzN /UeOBEZ8YwXW/zpgcLjOmwZzZ9JzcfhhtYt7/D5ITL3s0LsQB9N8RZgWuWF3PZcCx9 QsOQz4ijpBPkMfUHYMcOXT2Zi+6GMqkMpqkkFFBgubqKk36URKlNM3F64i8sgxCEFr dajQ+wgfMa7K8zXCUoRhMc0ri1ApWQTy2WHO1lw/+9qDjHgbG8YcvIvPg7BWHrz1T7 EcQXL3c0cjWIScyydBJTNbQX3w5eWGz7+SYQjNJ5XuymstfAMwCmH6rNYkb1RG9stV FuvKTOOsNl49A== From: fdmanana@kernel.org To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Filipe Manana Subject: [PATCH 06/10] btrfs: add helper to kill background process running _btrfs_stress_remount_compress Date: Wed, 27 Mar 2024 17:11:40 +0000 Message-ID: <0689a969e9834f4c2e694404f41f0bf8b7a34a2f.1711558345.git.fdmanana@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: fstests@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana Killing a background process running _btrfs_stress_remount_compress() is not as simple as sending a signal to the process and waiting for it to die. Therefore we have the following logic to terminate such process: kill $pid wait $pid while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do sleep 1 done Since this is repeated in several test cases, move this logic to a common helper and use it in all affected test cases. This will help to avoid repeating the same code again several times in upcoming changes. Signed-off-by: Filipe Manana Reviewed-by: Anand Jain --- common/btrfs | 15 +++++++++++++++ tests/btrfs/063 | 7 +------ tests/btrfs/068 | 8 ++------ tests/btrfs/071 | 12 +++++------- tests/btrfs/073 | 8 +------- tests/btrfs/074 | 8 +------- 6 files changed, 25 insertions(+), 33 deletions(-) diff --git a/common/btrfs b/common/btrfs index 46056d4a..66a3a347 100644 --- a/common/btrfs +++ b/common/btrfs @@ -411,6 +411,21 @@ _btrfs_stress_remount_compress() done } +# Kill a background process running _btrfs_stress_remount_compress() +_btrfs_kill_stress_remount_compress_pid() +{ + local remount_pid=$1 + local btrfs_mnt=$2 + + # Ignore if process already died. + kill $remount_pid &> /dev/null + wait $remount_pid &> /dev/null + # Wait for the remount loop to finish. + while ps aux | grep "mount.*${btrfs_mnt}" | grep -qv grep; do + sleep 1 + done +} + # stress btrfs by replacing devices in a loop # Note that at least 3 devices are needed in SCRATCH_DEV_POOL and the last # device should be free(not used by btrfs) diff --git a/tests/btrfs/063 b/tests/btrfs/063 index baf0c356..5ee2837f 100755 --- a/tests/btrfs/063 +++ b/tests/btrfs/063 @@ -52,12 +52,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid _btrfs_kill_stress_balance_pid $balance_pid - kill $remount_pid - wait $remount_pid - # wait for the remount loop to finish - while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 diff --git a/tests/btrfs/068 b/tests/btrfs/068 index 15fd41db..db53254a 100755 --- a/tests/btrfs/068 +++ b/tests/btrfs/068 @@ -58,12 +58,8 @@ run_test() wait $fsstress_pid touch $stop_file - kill $remount_pid - wait - # wait for the remount loop process to finish - while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do - sleep 1 - done + wait $subvol_pid + _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 diff --git a/tests/btrfs/071 b/tests/btrfs/071 index 6ebbd8cc..7ba15390 100755 --- a/tests/btrfs/071 +++ b/tests/btrfs/071 @@ -58,17 +58,15 @@ run_test() echo "$remount_pid" >>$seqres.full echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full - wait $fsstress_pid - kill $replace_pid $remount_pid - wait + kill $replace_pid + wait $fsstress_pid $replace_pid - # wait for the remount and replace operations to finish + # wait for the replace operationss to finish while ps aux | grep "replace start" | grep -qv grep; do sleep 1 done - while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do - sleep 1 - done + + _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 diff --git a/tests/btrfs/073 b/tests/btrfs/073 index 49a4abd1..50358286 100755 --- a/tests/btrfs/073 +++ b/tests/btrfs/073 @@ -51,13 +51,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $remount_pid - wait $remount_pid - # wait for the remount operation to finish - while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do - sleep 1 - done - + _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT _btrfs_kill_stress_scrub_pid $scrub_pid echo "Scrub the filesystem" >>$seqres.full diff --git a/tests/btrfs/074 b/tests/btrfs/074 index d51922d0..6e93b36a 100755 --- a/tests/btrfs/074 +++ b/tests/btrfs/074 @@ -52,13 +52,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $remount_pid - wait $remount_pid - # wait for the remount operation to finish - while ps aux | grep "mount.*$SCRATCH_MNT" | grep -qv grep; do - sleep 1 - done - + _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT _btrfs_kill_stress_defrag_pid $defrag_pid echo "Scrub the filesystem" >>$seqres.full From patchwork Wed Mar 27 17:11:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13607101 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F73613172F; Wed, 27 Mar 2024 17:12:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711559523; cv=none; b=HaPiCkJv7h1LRqpVgbia+dIXkWkaroQqQCJhsa7HcWjYEFvOqwLpYJsZeARJlUG+6w6KtWDeF2Dbj9pB1BdAjvPGutG2YT8Vd0MUBRjES1h76GuGQmt7OETTQ3BzvtP7CHsvBpcduRyPQTGG4mphywDa9r3VZApBwMehkxKtQX4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711559523; c=relaxed/simple; bh=o1+Rj5wGAc25lZ/MqgrSMd2jFsPLItLcz4elQ7JI/kc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=on/78VH3L4EPILzQL5NDrdv0bkeiHEjbSObScTlsjpry1rueTLQqbXpJFAn8xGfeoiEVc84BQHY20WzyhDUp6EGNKBGz8c5y0a6Szhm5G92JTTBuT6IHfHhCvsyIt+6Ti9gfA/Vw+XlrIYqcTefr4FnH8D4KdxOx/qQNiUcdwjo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uPLzhVbn; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uPLzhVbn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6369C43394; Wed, 27 Mar 2024 17:12:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711559522; bh=o1+Rj5wGAc25lZ/MqgrSMd2jFsPLItLcz4elQ7JI/kc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uPLzhVbnDGCLxy4oZLihOJOJJuKfltTf41h6yv26SlokMVPEPMAUrML/EMsRU8cEN mqF9KL55nnyfHet4PXsrhRUT3DJNxChlU9XtNb2jq97bdORq9AbFiXMms1K4aZx5lS Szu/YxHuc7Lmfi7t8T5KdY7klCITubYLmL9r1ib0DVmt4FmzVyDJyDSlDce9QYJFyB 7evWiu20sIm1hfZ8OVK5GdC7Ql42BksU9ifeSVsWUhK9rfY+Hg0/pJK7uTuKfF3ac6 gAzgekodHLVUetXGiKXFQxlSEFBID+QL8htXGjU7IeJ1n0YQ/uVWkeDwEphwmX0BBV BWaK8RnAxzgEg== From: fdmanana@kernel.org To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Filipe Manana Subject: [PATCH 07/10] btrfs: add helper to kill background process running _btrfs_stress_replace Date: Wed, 27 Mar 2024 17:11:41 +0000 Message-ID: <3334980dc99188a6742b28ba813268221d20a3b4.1711558345.git.fdmanana@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: fstests@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana Killing a background process running _btrfs_stress_replace() is not as simple as sending a signal to the process and waiting for it to die. Therefore we have the following logic to terminate such process: kill $pid wait $pid while ps aux | grep "replace start" | grep -qv grep; do sleep 1 done Since this is repeated in several test cases, move this logic to a common helper and use it in all affected test cases. This will help to avoid repeating the same code again several times in upcoming changes. Signed-off-by: Filipe Manana Reviewed-by: Anand Jain --- common/btrfs | 14 ++++++++++++++ tests/btrfs/064 | 7 +------ tests/btrfs/065 | 8 ++------ tests/btrfs/069 | 9 +-------- tests/btrfs/070 | 9 +-------- tests/btrfs/071 | 10 ++-------- 6 files changed, 21 insertions(+), 36 deletions(-) diff --git a/common/btrfs b/common/btrfs index 66a3a347..6d7e7a68 100644 --- a/common/btrfs +++ b/common/btrfs @@ -475,6 +475,20 @@ _btrfs_stress_replace() done } +# Kill a background process running _btrfs_stress_replace() +_btrfs_kill_stress_replace_pid() +{ + local replace_pid=$1 + + # Ignore if process already died. + kill $replace_pid &> /dev/null + wait $replace_pid &> /dev/null + # Wait for the replace operation to finish. + while ps aux | grep "replace start" | grep -qv grep; do + sleep 1 + done +} + # find the right option to force output in bytes, older versions of btrfs-progs # print that by default, newer print human readable numbers with unit suffix _btrfs_qgroup_units() diff --git a/tests/btrfs/064 b/tests/btrfs/064 index 58b53afe..9e0b3b30 100755 --- a/tests/btrfs/064 +++ b/tests/btrfs/064 @@ -64,12 +64,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid _btrfs_kill_stress_balance_pid $balance_pid - kill $replace_pid - wait $replace_pid - # wait for the replace operation to finish - while ps aux | grep "replace start" | grep -qv grep; do - sleep 1 - done + _btrfs_kill_stress_replace_pid $replace_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 diff --git a/tests/btrfs/065 b/tests/btrfs/065 index c4b6aafe..d2b04178 100755 --- a/tests/btrfs/065 +++ b/tests/btrfs/065 @@ -65,12 +65,8 @@ run_test() wait $fsstress_pid touch $stop_file - kill $replace_pid - wait - # wait for the replace operation to finish - while ps aux | grep "replace start" | grep -qv grep; do - sleep 1 - done + wait $subvol_pid + _btrfs_kill_stress_replace_pid $replace_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 diff --git a/tests/btrfs/069 b/tests/btrfs/069 index 20f44b39..ad1609d4 100755 --- a/tests/btrfs/069 +++ b/tests/btrfs/069 @@ -59,15 +59,8 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $replace_pid - wait $replace_pid - - # wait for the replace operation to finish - while ps aux | grep "replace start" | grep -qv grep; do - sleep 1 - done - _btrfs_kill_stress_scrub_pid $scrub_pid + _btrfs_kill_stress_replace_pid $replace_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 diff --git a/tests/btrfs/070 b/tests/btrfs/070 index cefa5723..3054c270 100755 --- a/tests/btrfs/070 +++ b/tests/btrfs/070 @@ -60,14 +60,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - kill $replace_pid - wait $replace_pid - - # wait for the replace operation to finish - while ps aux | grep "replace start" | grep -qv grep; do - sleep 1 - done - + _btrfs_kill_stress_replace_pid $replace_pid _btrfs_kill_stress_defrag_pid $defrag_pid echo "Scrub the filesystem" >>$seqres.full diff --git a/tests/btrfs/071 b/tests/btrfs/071 index 7ba15390..36b39341 100755 --- a/tests/btrfs/071 +++ b/tests/btrfs/071 @@ -58,14 +58,8 @@ run_test() echo "$remount_pid" >>$seqres.full echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full - kill $replace_pid - wait $fsstress_pid $replace_pid - - # wait for the replace operationss to finish - while ps aux | grep "replace start" | grep -qv grep; do - sleep 1 - done - + wait $fsstress_pid + _btrfs_kill_stress_replace_pid $replace_pid _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT echo "Scrub the filesystem" >>$seqres.full From patchwork Wed Mar 27 17:11:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13607102 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A2B314D70A; Wed, 27 Mar 2024 17:12:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711559524; cv=none; b=AyHLjdIaEvRDcBLJ14bduyiTSUKPoOkWOsDk4hmfj2NftoeTL79lH7lWtIEmRypReZfJXXPwVmBIuneOZ+qQpevUgy6xK6aK1XM93qRvejvyDJG8PANM+RpxtnSfOhKfV+5hLMJpAe4oqyKv5zWFSzL6oBg5uhrIOBEMDlm9VoM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711559524; c=relaxed/simple; bh=f/azJUMBGXsfSJOxJFP4khx7N7IMoR4krNW88Ug1bgo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fCGn11ZsUHmoGEW50H3zeEgisuA16TBt8f2rpB2CcsYiViZfLBmKzJy7k3L5dtMJKsrmhvup3MLXYOUmBqTHZRxyV9+SVMMJDGGJL5QyUAyw5fNeu5C+PzpkzrHvWL9KtvdvAebilzHT97mr+qzqjIk72MNMoeidUXGoP+lM1rU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Z94/qJ7C; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Z94/qJ7C" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1BBF7C433F1; Wed, 27 Mar 2024 17:12:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711559524; bh=f/azJUMBGXsfSJOxJFP4khx7N7IMoR4krNW88Ug1bgo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z94/qJ7CKI4Qi6JLdI0QlPPiJEEwWMvGkh+z5BlbVOoHT5C/kRoj9YkPdbDYU2UMM c1tPhuBn574M9bGQrcVeYoc9XzDCDHCo2ry6MHvLWoExpKwwuqJviLD3CpXEmN77t/ XHfttjAaq5S4M/yt6Wef8OtxhLS3Gu57QtyY/9eA/Og7Mnn7+XfEy1QGt8A0SY6lxE +k0UE4i509erLfFwAIa6EqehYV4Cw5r1AP9hONHNPHvVwyn50UA0xWErlnkbfRPlDU ssMYBrpTT/Wadm+bRgJy7TZH66hH1vjk9z1D/8sdBkSwLntiRxOYzKQ8aFqJYIB9ow 9jSIWMh08IWxQ== From: fdmanana@kernel.org To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Filipe Manana Subject: [PATCH 08/10] btrfs: add helper to stop background process running _btrfs_stress_subvolume Date: Wed, 27 Mar 2024 17:11:42 +0000 Message-ID: <478d09248cf2a98a59853718197104735edd52c7.1711558345.git.fdmanana@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: fstests@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana We have this logic to stop a process running _btrfs_stress_subvolume() spread in several test cases: touch $stop_file wait $subvol_pid Add a helper to encapsulate that logic and also remove the stop file after the process terminated as there's no point having it around anymore. This will help to avoid repeating the same code again several times in upcoming changes. Signed-off-by: Filipe Manana Reviewed-by: Anand Jain --- common/btrfs | 12 ++++++++++++ tests/btrfs/060 | 3 +-- tests/btrfs/065 | 3 +-- tests/btrfs/066 | 3 +-- tests/btrfs/067 | 3 +-- tests/btrfs/068 | 3 +-- 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/common/btrfs b/common/btrfs index 6d7e7a68..e19a6ad1 100644 --- a/common/btrfs +++ b/common/btrfs @@ -340,6 +340,18 @@ _btrfs_stress_subvolume() done } +# Kill a background process running _btrfs_stress_subvolume() +_btrfs_kill_stress_subvolume_pid() +{ + local subvol_pid=$1 + local stop_file=$2 + + touch $stop_file + # Ignore if process already died. + wait $subvol_pid &> /dev/null + rm -f $stop_file +} + # stress btrfs by running scrub in a loop _btrfs_stress_scrub() { diff --git a/tests/btrfs/060 b/tests/btrfs/060 index 58167cc6..87823aba 100755 --- a/tests/btrfs/060 +++ b/tests/btrfs/060 @@ -56,8 +56,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - touch $stop_file - wait $subvol_pid + _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file _btrfs_kill_stress_balance_pid $balance_pid echo "Scrub the filesystem" >>$seqres.full diff --git a/tests/btrfs/065 b/tests/btrfs/065 index d2b04178..ddc28616 100755 --- a/tests/btrfs/065 +++ b/tests/btrfs/065 @@ -64,8 +64,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - touch $stop_file - wait $subvol_pid + _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file _btrfs_kill_stress_replace_pid $replace_pid echo "Scrub the filesystem" >>$seqres.full diff --git a/tests/btrfs/066 b/tests/btrfs/066 index 29821fdd..c7488602 100755 --- a/tests/btrfs/066 +++ b/tests/btrfs/066 @@ -56,8 +56,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - touch $stop_file - wait $subvol_pid + _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file _btrfs_kill_stress_scrub_pid $scrub_pid echo "Scrub the filesystem" >>$seqres.full diff --git a/tests/btrfs/067 b/tests/btrfs/067 index 2bb00b87..ebbec1be 100755 --- a/tests/btrfs/067 +++ b/tests/btrfs/067 @@ -57,8 +57,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - touch $stop_file - wait $subvol_pid + _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file _btrfs_kill_stress_defrag_pid $defrag_pid echo "Scrub the filesystem" >>$seqres.full diff --git a/tests/btrfs/068 b/tests/btrfs/068 index db53254a..5f41fb74 100755 --- a/tests/btrfs/068 +++ b/tests/btrfs/068 @@ -57,8 +57,7 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid - touch $stop_file - wait $subvol_pid + _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT echo "Scrub the filesystem" >>$seqres.full From patchwork Wed Mar 27 17:11:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13607103 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C969D13E043; Wed, 27 Mar 2024 17:12:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711559525; cv=none; b=etQQ4rVydA5Ir3ObraQbthgD3Ht8Ywc0VtL4pTH61OHPUhY1aYfFuHygd/m7Ky48eXrHBB8Laq4fP0OmSloJEXjJy5hrZ8td8GwYUqe8jSirOPyI1SM2UgnZyO3hBB4gC0NcPfKlwlzx3E2OGfHTe4J7VFLPE117TNeygnGN59M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711559525; c=relaxed/simple; bh=rf8bzn44A2EaONt7W6/bPCIPHdoJKNHcHV0jFhxBPtA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=krVwWkZ3/A0VE2DQzjjvLYgHlGQ4QiKGQEqlZeGM2y+lPkWwovELkb/gMQQAuYgVKhAh9rnoYRi2GkK15Kuyt/JzlPtiWtLaYmX/0jU8eAgfQF6hpQr6449cVdEG7qF1v89GXzdRNG22jo1e19w7tcrsnna+VE5ia0wNyOuBW1s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=vOrE8dsP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="vOrE8dsP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A633C433C7; Wed, 27 Mar 2024 17:12:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711559525; bh=rf8bzn44A2EaONt7W6/bPCIPHdoJKNHcHV0jFhxBPtA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vOrE8dsPvjLVPW3fdB9P9pJXMNaL3kv6mRhlncKYHugDqFe0ATY6i7ex5btyQ/K1c 9aUcOr2zUpfEDdYxswcChUrcMQ0FSoSENDgtex7Pd7QsGLAUxgsURxGwJORrMaXiwU vH5SJ+7DBb1U7SgFQF/8wgyD+oejLuLKXSc8mppw85kMG8iFRpSpZ6rN9N7sYuqlqr BlsJJiDm9nwhEZaUG2uIwC7JTsnY7MhIygE6f3YttFKT4c3o4sHeuyGFfJyDmlEKk9 P6FxMSat+XMnsGA+nm+u2GSkok2NH2o3RYaYsal4wsOJXBYH4A8yWGAKKUuxKsmY7A q/lLnjDFaAyMA== From: fdmanana@kernel.org To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Filipe Manana Subject: [PATCH 09/10] btrfs: remove stop file early at _btrfs_stress_subvolume Date: Wed, 27 Mar 2024 17:11:43 +0000 Message-ID: <5b91f615f28c14274d9ad96c69cd098c1a9a6f9b.1711558345.git.fdmanana@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: fstests@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana Instead of having every test case that uses _btrfs_stress_subvolume() removing the stop file before calling that function, do the file remove at _btrfs_stress_subvolume(). There's no point in doing it in every single test case. Signed-off-by: Filipe Manana Reviewed-by: Anand Jain --- common/btrfs | 1 + tests/btrfs/060 | 2 -- tests/btrfs/065 | 2 -- tests/btrfs/066 | 2 -- tests/btrfs/067 | 2 -- tests/btrfs/068 | 2 -- 6 files changed, 1 insertion(+), 10 deletions(-) diff --git a/common/btrfs b/common/btrfs index e19a6ad1..29061c23 100644 --- a/common/btrfs +++ b/common/btrfs @@ -331,6 +331,7 @@ _btrfs_stress_subvolume() local subvol_mnt=$4 local stop_file=$5 + rm -f $stop_file mkdir -p $subvol_mnt while [ ! -e $stop_file ]; do $BTRFS_UTIL_PROG subvolume create $btrfs_mnt/$subvol_name diff --git a/tests/btrfs/060 b/tests/btrfs/060 index 87823aba..53cbd3a0 100755 --- a/tests/btrfs/060 +++ b/tests/btrfs/060 @@ -46,8 +46,6 @@ run_test() balance_pid=$! echo "$balance_pid" >>$seqres.full - # make sure the stop sign is not there - rm -f $stop_file echo -n "Start subvolume worker: " >>$seqres.full _btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt $stop_file >/dev/null 2>&1 & subvol_pid=$! diff --git a/tests/btrfs/065 b/tests/btrfs/065 index ddc28616..f9e43cdc 100755 --- a/tests/btrfs/065 +++ b/tests/btrfs/065 @@ -49,8 +49,6 @@ run_test() $FSSTRESS_PROG $args >>$seqres.full & fsstress_pid=$! - # make sure the stop sign is not there - rm -f $stop_file echo -n "Start subvolume worker: " >>$seqres.full _btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt $stop_file >/dev/null 2>&1 & subvol_pid=$! diff --git a/tests/btrfs/066 b/tests/btrfs/066 index c7488602..b6f904ac 100755 --- a/tests/btrfs/066 +++ b/tests/btrfs/066 @@ -41,8 +41,6 @@ run_test() $FSSTRESS_PROG $args >>$seqres.full & fsstress_pid=$! - # make sure the stop sign is not there - rm -f $stop_file echo -n "Start subvolume worker: " >>$seqres.full _btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt $stop_file >/dev/null 2>&1 & subvol_pid=$! diff --git a/tests/btrfs/067 b/tests/btrfs/067 index ebbec1be..7be09d52 100755 --- a/tests/btrfs/067 +++ b/tests/btrfs/067 @@ -42,8 +42,6 @@ run_test() $FSSTRESS_PROG $args >>$seqres.full & fsstress_pid=$! - # make sure the stop sign is not there - rm -f $stop_file echo -n "Start subvolume worker: " >>$seqres.full _btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt $stop_file >/dev/null 2>&1 & subvol_pid=$! diff --git a/tests/btrfs/068 b/tests/btrfs/068 index 5f41fb74..19e37010 100755 --- a/tests/btrfs/068 +++ b/tests/btrfs/068 @@ -42,8 +42,6 @@ run_test() $FSSTRESS_PROG $args >>$seqres.full & fsstress_pid=$! - # make sure the stop sign is not there - rm -f $stop_file echo -n "Start subvolume worker: " >>$seqres.full _btrfs_stress_subvolume $SCRATCH_DEV $SCRATCH_MNT subvol_$$ $subvol_mnt $stop_file >/dev/null 2>&1 & subvol_pid=$! From patchwork Wed Mar 27 17:11:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13607104 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA14513774D; Wed, 27 Mar 2024 17:12:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711559526; cv=none; b=C0iaokcoFUiwNcoMyff4o/84Sau7cack8IJeSA9ToR7+VhLRvdVCVMpLz1ZeP2o6GPazmcA9r/Zbtf7FCPbMFD3YGBsXx7JZYCXatUsWd/UCerNJGgq27pBJu6PBmcW1vB7MaeRIhLYQ4AkuIywJgDwBYYrUfC8R9rIKKsjAkz8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711559526; c=relaxed/simple; bh=v5pf0lSa3h+btHzVGfzTgJcWCE5ool7jkXrROY+POeA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=haqe9jioNabssigd/wn55oEdKhCTAYzI9/COrUHCfCMgzN/WkM5kF/KocT5H2UXSKdt0irNeNJXmfiSsAMOsb7ohQvvuHSu0ZWsZMCO32TJvs4yfb4ijp9OMq0/ubt62k6f/Dez6n7R19LW7KCuK58TtGMWIP0Z5YjlN1AGzyl8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pza8ACff; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pza8ACff" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5622C433F1; Wed, 27 Mar 2024 17:12:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711559526; bh=v5pf0lSa3h+btHzVGfzTgJcWCE5ool7jkXrROY+POeA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pza8ACffRZ/fDde3XhkKZMJNfMpP8vHZfEh3JrIDG0Y0AyLVb7PvS6aOAntxEEqAB Sy0RTBUqbNN9EmZbCthzfDPEuHEMGQeuNZ9S7j4VkFl6+FZQIQSqqsC2VJHkmr/qaR LwtaqQg0aATjmdsofwX8kF/imTNxrb3Pi/mpvEkTfzaYawFRfB7sf5vDH4oGVjG4cD xhAJBNZbq0j5+Ez63QVh7N89itlLEqvrEap30KMZkX6M/1XVMir59r6fPAnMmEFLA5 x4uu+jRTR6fYC/bNTaLfyJmERitu7OFbTY3JdcaQskrQuum5Eb3C2wfEhUCX33ZO1y d5+ENzIK6DwDA== From: fdmanana@kernel.org To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Filipe Manana Subject: [PATCH 10/10] btrfs/06[0-9]..07[0-4]: kill all background tasks when test is killed/interrupted Date: Wed, 27 Mar 2024 17:11:44 +0000 Message-ID: <48866623524ab565944db6f7fa61f6a0ce0c0996.1711558345.git.fdmanana@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: fstests@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana Test cases btrfs/06[0-9] and btrfs/07[0-4] exercise multiple concurrent operations while fsstress is running in parallel, and all these are left as child processes running in the background, which are correctly stopped if the tests are not interrupted/killed. However if any of these tests is interrupted/killed, it often leaves child processes still running in the background, which prevent further running fstests again. For example: $ /check -g auto (...) btrfs/060 394s ... 264s btrfs/061 83s ... 69s btrfs/062 109s ... 105s btrfs/063 52s ... 67s btrfs/064 53s ... 51s btrfs/065 88s ... 271s btrfs/066 127s ... 241s btrfs/067 435s ... 248s btrfs/068 161s ... ^C^C ^C $ ./check btrfs/068 FSTYP -- btrfs PLATFORM -- Linux/x86_64 debian0 6.8.0-rc7-btrfs-next-153+ #1 SMP PREEMPT_DYNAMIC Mon Mar 4 17:19:19 WET 2024 MKFS_OPTIONS -- /dev/sdb MOUNT_OPTIONS -- /dev/sdb /home/fdmanana/btrfs-tests/scratch_1 our local _scratch_mkfs routine ... btrfs-progs v6.6.2 See https://btrfs.readthedocs.io for more information. ERROR: unable to open /dev/sdb: Device or resource busy check: failed to mkfs $SCRATCH_DEV using specified options Interrupted! Passed all 0 tests In this case there was still a process running _btrfs_stress_subvolume() from common/btrfs. This is a bit annoying because it requires manually finding out which process is preventing unmounting the scratch device and then properly stop/kill it. So fix this by adding a _cleanup() function to all these tests and then making sure it stops all the child processes it spawned and are running in the background. All these tests have the same structure as they were part of the same patchset and from the same author. Signed-off-by: Filipe Manana Reviewed-by: Anand Jain --- tests/btrfs/060 | 22 +++++++++++++++++++++- tests/btrfs/061 | 19 +++++++++++++++++++ tests/btrfs/062 | 19 +++++++++++++++++++ tests/btrfs/063 | 19 +++++++++++++++++++ tests/btrfs/064 | 19 +++++++++++++++++++ tests/btrfs/065 | 22 +++++++++++++++++++++- tests/btrfs/066 | 22 +++++++++++++++++++++- tests/btrfs/067 | 22 +++++++++++++++++++++- tests/btrfs/068 | 22 +++++++++++++++++++++- tests/btrfs/069 | 19 +++++++++++++++++++ tests/btrfs/070 | 19 +++++++++++++++++++ tests/btrfs/071 | 19 +++++++++++++++++++ tests/btrfs/072 | 19 +++++++++++++++++++ tests/btrfs/073 | 19 +++++++++++++++++++ tests/btrfs/074 | 19 +++++++++++++++++++ 15 files changed, 295 insertions(+), 5 deletions(-) diff --git a/tests/btrfs/060 b/tests/btrfs/060 index 53cbd3a0..f74d9593 100755 --- a/tests/btrfs/060 +++ b/tests/btrfs/060 @@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto balance subvol scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then + _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file + fi + if [ ! -z "$balance_pid" ]; then + _btrfs_kill_stress_balance_pid $balance_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter @@ -20,11 +36,12 @@ _require_scratch_nocheck _require_scratch_dev_pool 4 _btrfs_get_profile_configs +stop_file=$TEST_DIR/$seq.stop.$$ + run_test() { local mkfs_opts=$1 local subvol_mnt=$TEST_DIR/$seq.mnt - local stop_file=$TEST_DIR/$seq.stop.$$ echo "Test $mkfs_opts" >>$seqres.full @@ -53,9 +70,12 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file + unset subvol_pid _btrfs_kill_stress_balance_pid $balance_pid + unset balance_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 diff --git a/tests/btrfs/061 b/tests/btrfs/061 index b8b2706c..fec90882 100755 --- a/tests/btrfs/061 +++ b/tests/btrfs/061 @@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto balance scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$balance_pid" ]; then + _btrfs_kill_stress_balance_pid $balance_pid + fi + if [ ! -z "$scrub_pid" ]; then + _btrfs_kill_stress_scrub_pid $scrub_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter @@ -51,8 +67,11 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_balance_pid $balance_pid + unset balance_pid _btrfs_kill_stress_scrub_pid $scrub_pid + unset scrub_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 diff --git a/tests/btrfs/062 b/tests/btrfs/062 index 59d581be..0b57681f 100755 --- a/tests/btrfs/062 +++ b/tests/btrfs/062 @@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto balance defrag compress scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$balance_pid" ]; then + _btrfs_kill_stress_balance_pid $balance_pid + fi + if [ ! -z "$defrag_pid" ]; then + _btrfs_kill_stress_defrag_pid $defrag_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter @@ -52,8 +68,11 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_balance_pid $balance_pid + unset balance_pid _btrfs_kill_stress_defrag_pid $defrag_pid + unset defrag_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 diff --git a/tests/btrfs/063 b/tests/btrfs/063 index 5ee2837f..99d9d2c1 100755 --- a/tests/btrfs/063 +++ b/tests/btrfs/063 @@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto balance remount compress scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$balance_pid" ]; then + _btrfs_kill_stress_balance_pid $balance_pid + fi + if [ ! -z "$remount_pid" ]; then + _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter @@ -51,8 +67,11 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_balance_pid $balance_pid + unset balance_pid _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT + unset remount_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 diff --git a/tests/btrfs/064 b/tests/btrfs/064 index 9e0b3b30..663442c6 100755 --- a/tests/btrfs/064 +++ b/tests/btrfs/064 @@ -12,6 +12,22 @@ . ./common/preamble _begin_fstest auto balance replace volume scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$balance_pid" ]; then + _btrfs_kill_stress_balance_pid $balance_pid + fi + if [ ! -z "$replace_pid" ]; then + _btrfs_kill_stress_replace_pid $replace_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter @@ -63,8 +79,11 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_balance_pid $balance_pid + unset balance_pid _btrfs_kill_stress_replace_pid $replace_pid + unset replace_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 diff --git a/tests/btrfs/065 b/tests/btrfs/065 index f9e43cdc..b1e54fc8 100755 --- a/tests/btrfs/065 +++ b/tests/btrfs/065 @@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto subvol replace volume scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then + _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file + fi + if [ ! -z "$replace_pid" ]; then + _btrfs_kill_stress_replace_pid $replace_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter @@ -21,12 +37,13 @@ _require_scratch_dev_pool 5 _require_scratch_dev_pool_equal_size _btrfs_get_profile_configs replace +stop_file=$TEST_DIR/$seq.stop.$$ + run_test() { local mkfs_opts=$1 local saved_scratch_dev_pool=$SCRATCH_DEV_POOL local subvol_mnt=$TEST_DIR/$seq.mnt - local stop_file=$TEST_DIR/$seq.stop.$$ echo "Test $mkfs_opts" >>$seqres.full @@ -61,9 +78,12 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file + unset subvol_pid _btrfs_kill_stress_replace_pid $replace_pid + unset replace_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 diff --git a/tests/btrfs/066 b/tests/btrfs/066 index b6f904ac..feb6062e 100755 --- a/tests/btrfs/066 +++ b/tests/btrfs/066 @@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto subvol scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then + _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file + fi + if [ ! -z "$scrub_pid" ]; then + _btrfs_kill_stress_scrub_pid $scrub_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter @@ -20,11 +36,12 @@ _require_scratch_nocheck _require_scratch_dev_pool 4 _btrfs_get_profile_configs +stop_file=$TEST_DIR/$seq.stop.$$ + run_test() { local mkfs_opts=$1 local subvol_mnt=$TEST_DIR/$seq.mnt - local stop_file=$TEST_DIR/$seq.stop.$$ echo "Test $mkfs_opts" >>$seqres.full @@ -53,9 +70,12 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file + unset subvol_pid _btrfs_kill_stress_scrub_pid $scrub_pid + unset scrub_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 diff --git a/tests/btrfs/067 b/tests/btrfs/067 index 7be09d52..0bbfe83f 100755 --- a/tests/btrfs/067 +++ b/tests/btrfs/067 @@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto subvol defrag compress scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then + _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file + fi + if [ ! -z "$defrag_pid" ]; then + _btrfs_kill_stress_defrag_pid $defrag_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter @@ -20,12 +36,13 @@ _require_scratch_nocheck _require_scratch_dev_pool 4 _btrfs_get_profile_configs +stop_file=$TEST_DIR/$seq.stop.$$ + run_test() { local mkfs_opts=$1 local with_compress=$2 local subvol_mnt=$TEST_DIR/$seq.mnt - local stop_file=$TEST_DIR/$seq.stop.$$ echo "Test $mkfs_opts with $with_compress" >>$seqres.full @@ -54,9 +71,12 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file + unset subvol_pid _btrfs_kill_stress_defrag_pid $defrag_pid + unset defrag_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 diff --git a/tests/btrfs/068 b/tests/btrfs/068 index 19e37010..7ab6feca 100755 --- a/tests/btrfs/068 +++ b/tests/btrfs/068 @@ -11,6 +11,22 @@ . ./common/preamble _begin_fstest auto subvol remount compress scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$stop_file" ] && [ ! -z "$subvol_pid" ]; then + _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file + fi + if [ ! -z "$remount_pid" ]; then + _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter @@ -21,11 +37,12 @@ _require_scratch_nocheck _require_scratch_dev_pool 4 _btrfs_get_profile_configs +stop_file=$TEST_DIR/$seq.stop.$$ + run_test() { local mkfs_opts=$1 local subvol_mnt=$TEST_DIR/$seq.mnt - local stop_file=$TEST_DIR/$seq.stop.$$ echo "Test $mkfs_opts with $with_compress" >>$seqres.full @@ -54,9 +71,12 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_subvolume_pid $subvol_pid $stop_file + unset subvol_pid _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT + unset remount_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 diff --git a/tests/btrfs/069 b/tests/btrfs/069 index ad1609d4..3fbfecdb 100755 --- a/tests/btrfs/069 +++ b/tests/btrfs/069 @@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto replace scrub volume +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$replace_pid" ]; then + _btrfs_kill_stress_replace_pid $replace_pid + fi + if [ ! -z "$scrub_pid" ]; then + _btrfs_kill_stress_scrub_pid $scrub_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter @@ -59,8 +75,11 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_scrub_pid $scrub_pid + unset scrub_pid _btrfs_kill_stress_replace_pid $replace_pid + unset replace_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 diff --git a/tests/btrfs/070 b/tests/btrfs/070 index 3054c270..11fddc86 100755 --- a/tests/btrfs/070 +++ b/tests/btrfs/070 @@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto replace defrag compress volume scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$replace_pid" ]; then + _btrfs_kill_stress_replace_pid $replace_pid + fi + if [ ! -z "$defrag_pid" ]; then + _btrfs_kill_stress_defrag_pid $defrag_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter @@ -60,8 +76,11 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_replace_pid $replace_pid + unset replace_pid _btrfs_kill_stress_defrag_pid $defrag_pid + unset defrag_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 diff --git a/tests/btrfs/071 b/tests/btrfs/071 index 36b39341..1a91ec45 100755 --- a/tests/btrfs/071 +++ b/tests/btrfs/071 @@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto replace remount compress volume scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$replace_pid" ]; then + _btrfs_kill_stress_replace_pid $replace_pid + fi + if [ ! -z "$remount_pid" ]; then + _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter @@ -59,8 +75,11 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_replace_pid $replace_pid + unset replace_pid _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT + unset remount_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 diff --git a/tests/btrfs/072 b/tests/btrfs/072 index 505d0b57..e66e49c9 100755 --- a/tests/btrfs/072 +++ b/tests/btrfs/072 @@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto scrub defrag compress +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$defrag_pid" ]; then + _btrfs_kill_stress_defrag_pid $defrag_pid + fi + if [ ! -z "$scrub_pid" ]; then + _btrfs_kill_stress_scrub_pid $scrub_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter @@ -52,9 +68,12 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_defrag_pid $defrag_pid + unset defrag_pid _btrfs_kill_stress_scrub_pid $scrub_pid + unset scrub_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 diff --git a/tests/btrfs/073 b/tests/btrfs/073 index 50358286..e6cfd92a 100755 --- a/tests/btrfs/073 +++ b/tests/btrfs/073 @@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto scrub remount compress +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$remount_pid" ]; then + _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT + fi + if [ ! -z "$scrub_pid" ]; then + _btrfs_kill_stress_scrub_pid $scrub_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter @@ -51,8 +67,11 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT + unset remount_pid _btrfs_kill_stress_scrub_pid $scrub_pid + unset scrub_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 diff --git a/tests/btrfs/074 b/tests/btrfs/074 index 6e93b36a..1dd88bcd 100755 --- a/tests/btrfs/074 +++ b/tests/btrfs/074 @@ -10,6 +10,22 @@ . ./common/preamble _begin_fstest auto defrag remount compress scrub +_cleanup() +{ + cd / + rm -rf $tmp.* + if [ ! -z "$remount_pid" ]; then + _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT + fi + if [ ! -z "$defrag_pid" ]; then + _btrfs_kill_stress_defrag_pid $defrag_pid + fi + if [ ! -z "$fsstress_pid" ]; then + kill $fsstress_pid &> /dev/null + wait $fsstress_pid &> /dev/null + fi +} + # Import common functions. . ./common/filter @@ -52,8 +68,11 @@ run_test() echo "Wait for fsstress to exit and kill all background workers" >>$seqres.full wait $fsstress_pid + unset fsstress_pid _btrfs_kill_stress_remount_compress_pid $remount_pid $SCRATCH_MNT + unset remount_pid _btrfs_kill_stress_defrag_pid $defrag_pid + unset defrag_pid echo "Scrub the filesystem" >>$seqres.full $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1