From patchwork Mon Jan 14 06:21:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yangerkun X-Patchwork-Id: 10761679 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4B86091E for ; Mon, 14 Jan 2019 06:17:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 337062899C for ; Mon, 14 Jan 2019 06:17:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 25D832899E; Mon, 14 Jan 2019 06:17:58 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 6F2CE2899C for ; Mon, 14 Jan 2019 06:17:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726436AbfANGR4 (ORCPT ); Mon, 14 Jan 2019 01:17:56 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:47996 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726067AbfANGRz (ORCPT ); Mon, 14 Jan 2019 01:17:55 -0500 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id DF049B05E384573BD521; Mon, 14 Jan 2019 14:17:53 +0800 (CST) Received: from RH5885H-V3.huawei.com (10.90.53.225) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.408.0; Mon, 14 Jan 2019 14:17:44 +0800 From: yangerkun To: , CC: , , Subject: [PATCH V2] common/scsi_debug: make sure scsi_debug been removed correctly Date: Mon, 14 Jan 2019 14:21:25 +0800 Message-ID: <20190114062125.24432-1-yangerkun@huawei.com> X-Mailer: git-send-email 2.9.5 MIME-Version: 1.0 X-Originating-IP: [10.90.53.225] X-CFilter-Loop: Reflected Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Case generic/108 sometimes may fail while testing with some fs, and the reson is that rmmod scsi_debug in _put_scsi_debug_dev can randomly fail due to open references from udev scan. Now add the loop to do rmmod to make sure scsi_debug can remove correctly. This patch is a reference to 'https://gitlab.com/cryptsetup/cryptsetup.git' commit d7b9ed05f0931b416c33c8eb2ff1e6efa39270ff from Ondrej Kozina, thanks a lot! Signed-off-by: yangerkun --- common/scsi_debug | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common/scsi_debug b/common/scsi_debug index d9aa0bd..890ec68 100644 --- a/common/scsi_debug +++ b/common/scsi_debug @@ -45,11 +45,13 @@ _put_scsi_debug_dev() { lsmod | grep -wq scsi_debug || return - n=2 + n=15 # 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 + while [ $n -ge 0 ]; do + modprobe -r scsi_debug >/dev/null 2>&1 + [ $? -eq 0 ] && return 0 sleep 1 n=$((n-1)) done