From patchwork Wed Dec 23 14:29:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eryu Guan X-Patchwork-Id: 7912921 Return-Path: X-Original-To: patchwork-fstests@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B03789F1AF for ; Wed, 23 Dec 2015 14:32:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E554A205C7 for ; Wed, 23 Dec 2015 14:32:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1D58520444 for ; Wed, 23 Dec 2015 14:32:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755380AbbLWOcS (ORCPT ); Wed, 23 Dec 2015 09:32:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46836 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753797AbbLWOcS (ORCPT ); Wed, 23 Dec 2015 09:32:18 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 11147461C4 for ; Wed, 23 Dec 2015 14:32:18 +0000 (UTC) Received: from localhost (dhcp-12-106.nay.redhat.com [10.66.12.106]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tBNEWGFZ018534; Wed, 23 Dec 2015 09:32:17 -0500 From: Eryu Guan To: fstests@vger.kernel.org Cc: Eryu Guan Subject: [PATCH] common/scsi_debug: fix removal of scsi_debug module Date: Wed, 23 Dec 2015 22:29:14 +0800 Message-Id: <1450880954-26921-1-git-send-email-eguan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Spam-Status: No, score=-6.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 Occasionally scsi_debug cannot be removed because it's still in use and causes xfs/279 to fail. Now dryrun the removal by modprobe firstly then do the real rmmod. Signed-off-by: Eryu Guan --- common/scsi_debug | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/common/scsi_debug b/common/scsi_debug index d073b6d..eb08126 100644 --- a/common/scsi_debug +++ b/common/scsi_debug @@ -57,7 +57,15 @@ _get_scsi_debug_dev() _put_scsi_debug_dev() { - sleep 1 lsmod | grep -wq scsi_debug || return + + n=2 + # use redirection not -q option of modprobe here, because -q of old + # modprobe is only quiet when the module is not found, not when the + # module is in use. + while [ $n -ge 0 ] && ! modprobe -nr scsi_debug >/dev/null 2>&1; do + sleep 1 + n=$((n-1)) + done rmmod scsi_debug || _fail "Could not remove scsi_debug module" }