From patchwork Tue Sep 10 14:26:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 11139665 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1EBA31599 for ; Tue, 10 Sep 2019 14:26:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E238021019 for ; Tue, 10 Sep 2019 14:26:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568125569; bh=sedSIO1rGbODcL7FwFUnJX3tByeWXLqBjFtJbOMZoCA=; h=From:To:Cc:Subject:Date:List-ID:From; b=Cb6mCPYvEGwpxCk5yNDZ7AN22t02AABmr75mQnMBxwCn2r130TFmIX/DnnoF15B3z VO44RG3CtXJ89fyGz4kUANn5PZYDQTb0ABVMq+eTjlRnEcNWuJpgQngaWSlnTutFQw qqn3QqvP0P/Yts+n3aeLc3YUfUxDrLBDw+ic7LaE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387433AbfIJO0I (ORCPT ); Tue, 10 Sep 2019 10:26:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:47918 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726132AbfIJO0I (ORCPT ); Tue, 10 Sep 2019 10:26:08 -0400 Received: from localhost.localdomain (bl8-197-74.dsl.telepac.pt [85.241.197.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C7C6620863; Tue, 10 Sep 2019 14:26:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568125567; bh=sedSIO1rGbODcL7FwFUnJX3tByeWXLqBjFtJbOMZoCA=; h=From:To:Cc:Subject:Date:From; b=cUgNOLmfvkoQToHA/ZxRyyygrMwpALeNpC34rKiCs5OxcZk37Jp6qbgZP6C1blKnx hhsGcvh3fQPp4e3ahZVqbgq3MffexGMRngwjg4FS+m8WCqlfnN/6Ah3lZbVRjN4IFq vmfrH1+M/Zb3PILm759Yw7NV9vYtbFLqkFXN/6jE= From: fdmanana@kernel.org To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Filipe Manana Subject: [PATCH] btrfs/079: fix failure to umount scratch fs due to running filefrag process Date: Tue, 10 Sep 2019 15:26:01 +0100 Message-Id: <20190910142601.19752-1-fdmanana@kernel.org> X-Mailer: git-send-email 2.11.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Filipe Manana The test fails sporadically when trying to unmount the scratch filesystem because a filefrag process is still running against a file that exists on the scrach filesystem. This is because killing the subshell running the fiemap_work() function does not wait for any filefrag process to complete first. We need to set a trap for the SIGTERM signal on the subshell so that it waits for any filefrag process before exitting. The failure resulted in error messages like the following: btrfs/079 57s ... umount: /home/fdmanana/btrfs-tests/scratch_1: target is busy (In some cases useful info about processes that use the device is found by lsof(8) or fuser(1).) _check_btrfs_filesystem: filesystem on /dev/sdc is inconsistent (see /home/fdmanana/git/hub/xfstests/results//btrfs/079.full for details) Fix this by adding a trap for SIGTERM. Signed-off-by: Filipe Manana --- tests/btrfs/079 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/btrfs/079 b/tests/btrfs/079 index e848a261..1e9411be 100755 --- a/tests/btrfs/079 +++ b/tests/btrfs/079 @@ -77,6 +77,12 @@ _filter_error() { } fiemap_work() { + # Wait for any running 'filefrag' subcommand before exitting so that + # after the test kills the subshell running this function, it does not + # fail with EBUSY when unmounting the scratch device because the filefrag + # subcommand is still running with an open file on the scratch fs. + trap "wait; exit" SIGTERM + filename=$1 while true; do $FILEFRAG_PROG $filename 2> $tmp.output 1> /dev/null