From patchwork Tue Jul 25 08:04:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eryu Guan X-Patchwork-Id: 9861419 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B1D0D6038C for ; Tue, 25 Jul 2017 08:04:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3C3220952 for ; Tue, 25 Jul 2017 08:04:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 988422860B; Tue, 25 Jul 2017 08:04:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C71C20952 for ; Tue, 25 Jul 2017 08:04:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750895AbdGYIEa (ORCPT ); Tue, 25 Jul 2017 04:04:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54148 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751413AbdGYIE1 (ORCPT ); Tue, 25 Jul 2017 04:04:27 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 557D52027B; Tue, 25 Jul 2017 08:04:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 557D52027B Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=eguan@redhat.com Received: from localhost (dhcp-12-173.nay.redhat.com [10.66.12.173]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF34160602; Tue, 25 Jul 2017 08:04:26 +0000 (UTC) From: Eryu Guan To: fstests@vger.kernel.org Cc: yangx.jy@cn.fujitsu.com, Eryu Guan Subject: [PATCH v2] generic/446: make sure all background processes are dead before umount Date: Tue, 25 Jul 2017 16:04:21 +0800 Message-Id: <20170725080421.15306-1-eguan@redhat.com> In-Reply-To: <20170724101125.13309-1-eguan@redhat.com> References: <20170724101125.13309-1-eguan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 25 Jul 2017 08:04:27 +0000 (UTC) Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The $dread_pid refers to the while-true-do loop, wait for $dread_pid doesn't mean the xfs_io direct read process is already dead, sometimes xfs_io process is still running and blocking _scratch_unmount. Fix it by making the direct read does a fixed number of loop and break out the second mmap-fpunch loop if the first loop exits. At this point we're sure that there's no unfinished background process blocking the umount. Signed-off-by: Eryu Guan Reviewed-by: Xiao Yang --- v2: - move 'kill' to while loop condition to simplify the second loop - add more comments about when to exit the loop tests/generic/446 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/generic/446 b/tests/generic/446 index 62ae449de6b1..6a1b69aa2edc 100755 --- a/tests/generic/446 +++ b/tests/generic/446 @@ -61,20 +61,20 @@ filesz=$((65536 * 2)) $XFS_IO_PROG -f -c "truncate $((filesz * 2))" $SCRATCH_MNT/file >> $seqres.full # run a background dio read to a hole in a loop -while true; do +for i in `seq 0 999`; do $XFS_IO_PROG -d -c "pread 0 $filesz" $SCRATCH_MNT/file > /dev/null 2>&1 done & dread_pid=$! # run mapped write to the same hole as dio read -for i in `seq 0 999`; do +# loop until background dio read exits +while kill -s 0 $dread_pid >/dev/null 2>&1; do $XFS_IO_PROG -c "mmap 0 $filesz" -c "mwrite 0 $filesz" $SCRATCH_MNT/file \ > /dev/null $XFS_IO_PROG -c "fpunch 0 $filesz" $SCRATCH_MNT/file > /dev/null done -kill -9 $dread_pid > /dev/null 2>&1 wait $dread_pid > /dev/null 2>&1 echo "Silence is golden"