From patchwork Thu Apr 7 06:12:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 8775661 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 43137C0553 for ; Thu, 7 Apr 2016 18:09:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 67DDC20222 for ; Thu, 7 Apr 2016 18:09:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7994F20166 for ; Thu, 7 Apr 2016 18:09:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756790AbcDGSJZ (ORCPT ); Thu, 7 Apr 2016 14:09:25 -0400 Received: from mail.kernel.org ([198.145.29.136]:33927 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756645AbcDGSJZ (ORCPT ); Thu, 7 Apr 2016 14:09:25 -0400 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EC24820212 for ; Thu, 7 Apr 2016 18:09:23 +0000 (UTC) Received: from debian3.lan (dsl-112-39.bl26.telepac.pt [176.78.112.39]) (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CED4620166 for ; Thu, 7 Apr 2016 18:09:22 +0000 (UTC) From: fdmanana@kernel.org To: fstests@vger.kernel.org Subject: [PATCH] Pass --retry to dmsetup when removing flakey and error devices Date: Thu, 7 Apr 2016 07:12:28 +0100 Message-Id: <1460009548-20668-1-git-send-email-fdmanana@kernel.org> X-Mailer: git-send-email 2.7.0.rc3 X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00, DATE_IN_PAST_06_12, 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 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Filipe Manana When running multiple tests using dm's flakey target, often (very rarely) I was getting an error when a test tried to setup a dm flakey target, resulting in the following messages in the test's .out.bad file: device-mapper: reload ioctl on flakey-test failed: Device or resource busy Command failed failed to create flakey device Upon further investigation it turns out that it was because the previous test that ran had failed to remove the flakey device because the device was being used at the time but this has not made that previous test fail because we simply redirect the stderr (and stdout) to /dev/null and don't fail if the dmsetup remove command exits with a non-zero status. The device was in use, when the test attempted to remove it, by an udev rule (btrfs udev rule). Fix this by passing the option --retry to dmsetup remove, which serves to deal with such cases. From dmsetup's man page: "If an attempt to remove a device fails, perhaps because a process run from a quick udev rule temporarily opened the device, the --retry option will cause the operation to be retried for a few seconds before failing." Signed-off-by: Filipe Manana --- common/dmerror | 4 ++-- common/dmflakey | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/common/dmerror b/common/dmerror index 5d2c1b6..c898df0 100644 --- a/common/dmerror +++ b/common/dmerror @@ -22,7 +22,7 @@ _dmerror_init() { local dm_backing_dev=$SCRATCH_DEV - $DMSETUP_PROG remove error-test > /dev/null 2>&1 + $DMSETUP_PROG remove --retry error-test > /dev/null 2>&1 local blk_dev_size=`blockdev --getsz $dm_backing_dev` @@ -57,7 +57,7 @@ _dmerror_cleanup() # wait for device to be fully settled so that 'dmsetup remove' doesn't # fail due to EBUSY $UDEV_SETTLE_PROG >/dev/null 2>&1 - $DMSETUP_PROG remove error-test > /dev/null 2>&1 + $DMSETUP_PROG remove --retry error-test > /dev/null 2>&1 } _dmerror_load_error_table() diff --git a/common/dmflakey b/common/dmflakey index 4434307..cc458f0 100644 --- a/common/dmflakey +++ b/common/dmflakey @@ -57,7 +57,7 @@ _cleanup_flakey() # wait for device to be fully settled so that 'dmsetup remove' doesn't # fail due to EBUSY $UDEV_SETTLE_PROG >/dev/null 2>&1 - $DMSETUP_PROG remove flakey-test > /dev/null 2>&1 + $DMSETUP_PROG remove --retry flakey-test > /dev/null 2>&1 $DMSETUP_PROG mknodes > /dev/null 2>&1 }