From patchwork Mon Apr 18 19:32:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 8874601 Return-Path: X-Original-To: patchwork-fstests@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4E7C3BF29F for ; Mon, 18 Apr 2016 19:33:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 805BF20149 for ; Mon, 18 Apr 2016 19:32:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A88392015A for ; Mon, 18 Apr 2016 19:32:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751552AbcDRTcr (ORCPT ); Mon, 18 Apr 2016 15:32:47 -0400 Received: from mx2.suse.de ([195.135.220.15]:54921 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751781AbcDRTcq (ORCPT ); Mon, 18 Apr 2016 15:32:46 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 8B175AB5D for ; Mon, 18 Apr 2016 19:32:43 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id A99B71E0950; Mon, 18 Apr 2016 21:32:39 +0200 (CEST) From: Jan Kara To: fstests@vger.kernel.org Cc: Jan Kara Subject: [PATCH 5/5] generic/038: Avoid EBUSY errors on umount Date: Mon, 18 Apr 2016 21:32:35 +0200 Message-Id: <1461007955-7921-6-git-send-email-jack@suse.cz> X-Mailer: git-send-email 2.6.6 In-Reply-To: <1461007955-7921-1-git-send-email-jack@suse.cz> References: <1461007955-7921-1-git-send-email-jack@suse.cz> Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Although the test waits for running subshells after sending SIGTERM signal to them, it does not wait for subprocesses of those subshells properly. Thus we can hit EBUSY errors when umount is called. Make subshells wait for executed subprocesses when receiving SIGTERM to avoid the problem. Signed-off-by: Jan Kara --- tests/generic/038 | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/generic/038 b/tests/generic/038 index 59aed67ab2ff..025e1b0fe7a6 100755 --- a/tests/generic/038 +++ b/tests/generic/038 @@ -77,6 +77,10 @@ rm -f $seqres.full # fstrim loop below. fallocate_loop() { + # Wait for running subcommand before exitting so that + # mountpoint is not busy when we try to unmount it + trap "wait; exit" SIGTERM + local name=$1 while true; do $XFS_IO_PROG -f -c "falloc -k 0 1G" \ @@ -90,6 +94,10 @@ fallocate_loop() trim_loop() { + # Wait for running subcommand before exitting so that + # mountpoint is not busy when we try to unmount it + trap "wait; exit" SIGTERM + while true; do $FSTRIM_PROG $SCRATCH_MNT done @@ -115,7 +123,9 @@ create_files() for ((n = 0; n < 4; n++)); do mkdir $SCRATCH_MNT/$n ( - for ((i = 1; i <= $nr_files; i++)); do + trap "wait; exit" SIGTERM + + for ((i = 1; i <= $nr_files; i++)); do $XFS_IO_PROG -f -c "pwrite -S 0xaa 0 3900" \ $SCRATCH_MNT/$n/"${prefix}_$i" &> /dev/null if [ $? -ne 0 ]; then @@ -152,9 +162,6 @@ kill ${fallocate_pids[@]} kill ${trim_pids[@]} wait -# Sleep a bit, otherwise umount fails often with EBUSY (TODO: investigate why). -sleep 3 - # The fstests framework will now check for fs consistency with fsck. # The trimming was racy and caused some btree nodes to get full of zeroes on # disk, which obviously caused fs metadata corruption. The race often lead