From patchwork Wed Jan 16 07:35:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 10765463 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 1CC5091E for ; Wed, 16 Jan 2019 07:35:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB4392A806 for ; Wed, 16 Jan 2019 07:35:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D80292B8A3; Wed, 16 Jan 2019 07:35:22 +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 D6EDA2A806 for ; Wed, 16 Jan 2019 07:35:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388433AbfAPHfM (ORCPT ); Wed, 16 Jan 2019 02:35:12 -0500 Received: from mx2.suse.de ([195.135.220.15]:46576 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388430AbfAPHfM (ORCPT ); Wed, 16 Jan 2019 02:35:12 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 4278DABD5; Wed, 16 Jan 2019 07:35:11 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , Martin Wilck , linux-scsi@vger.kernel.org, Hannes Reinecke , Hannes Reinecke Subject: [PATCH] sd: skip non-removable devices in sd_check_events() Date: Wed, 16 Jan 2019 08:35:09 +0100 Message-Id: <20190116073509.131535-1-hare@suse.de> X-Mailer: git-send-email 2.16.4 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If the device is _not_ removable we should not start the event poller as the media will not go away. Having the event poller running will block the open() call as it will try to flush outstanding events, which it can't if the device is in state 'BLOCKED'. So the open() call will be stalled until the device state changed, which might be quite some time depending on the transport. Signed-off-by: Hannes Reinecke Acked-by: Martin Wilck --- drivers/scsi/sd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index a1a44f52e0e8..521f0a384446 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1539,6 +1539,9 @@ static unsigned int sd_check_events(struct gendisk *disk, unsigned int clearing) return 0; sdp = sdkp->device; + if (!sdp->removable) + return 0; + SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, "sd_check_events\n")); /*