From patchwork Tue Mar 7 17:15:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 9609697 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 073DF602B4 for ; Tue, 7 Mar 2017 19:26:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C430B2850D for ; Tue, 7 Mar 2017 19:26:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B8E132851A; Tue, 7 Mar 2017 19:26:19 +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.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable 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 B6B3E2850D for ; Tue, 7 Mar 2017 19:26:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755864AbdCGT0P (ORCPT ); Tue, 7 Mar 2017 14:26:15 -0500 Received: from mail-pf0-f169.google.com ([209.85.192.169]:36637 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755965AbdCGTZp (ORCPT ); Tue, 7 Mar 2017 14:25:45 -0500 Received: by mail-pf0-f169.google.com with SMTP id o126so4236165pfb.3 for ; Tue, 07 Mar 2017 11:25:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=sHw2y3KZnsbM5y1lJcYW/oFu+Sks99POsu2TXYwXZX8=; b=yu7Xy04Hcz/RJFbSTJ5wQP/QPBf663vCK+LYaLdO4RmGxHHX9b06uA3A5PC5wbQtXS YwTH/WJHNd8JS+GayiYceM2qgBZk+0pPf8JouhztdOAka2VkgGyXpMCcsxHHZG71HH+A G0F0poH4kgjhXnO3duh4D7psX2+KZOx8Q/JFmGx5vXCDFsvF4t+TVXSRb+JNScTGV/gx ERgdKFrUeF0XxT8HROgvEnOUD/I1HRWeHOe/jwOCjY4zYtrB/YklRXvlG4Or3Ns+Cd87 8592NTGYs7ceP9PIT399/K6DQUsyo2UxAu4Dq8Cvxj4b/5lPRUN2s9sO2hQpDwyeMf0U ClCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=sHw2y3KZnsbM5y1lJcYW/oFu+Sks99POsu2TXYwXZX8=; b=WR5C6qS/sEki1xDboO0dXAZ/dTKQltXJ14+EzzV0PFfh1xIXDfoC2afQsPTEluHUt2 M/cTeobrcJ4YedWgxI3f06Jp9rWK1trIU8ueOezOj3WGaeAD533ROVPhVAp0B3rTLoc3 xn5Jy9KV40Vru97FKqazWnq30yJivYmM7Mc7proBM8wDa3RkcRTb91gfF+TIEbTHs1cA 72e/WVcfJ/YBaZHYkmm8ZVeImfrOMd6+25ysrV1r2vuUktV4m0S4anOV3XEC6fIOTHRb XHE+sIXCOGhxSxA6kweHOaAtT1y2hoUn3Dza52cqE1Ss/lfeymEVYXtqxXNrDMq5aWn4 jvFA== X-Gm-Message-State: AMke39knPMlK0qs5y5aFy8L0f0KhDHpusF5bnOSDlzEhIOCMCojWykqa5sVnP902Oj3pxA== X-Received: by 10.98.16.136 with SMTP id 8mr1595493pfq.104.1488906969278; Tue, 07 Mar 2017 09:16:09 -0800 (PST) Received: from xeon-e3.wavecable.com (204-195-18-65.wavecable.com. [204.195.18.65]) by smtp.gmail.com with ESMTPSA id r13sm994871pfg.55.2017.03.07.09.16.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Mar 2017 09:16:07 -0800 (PST) From: Stephen Hemminger X-Google-Original-From: Stephen Hemminger To: kys@microsoft.com, haiyangz@microsoft.com, longli@microsoft.com, martin.petersen@oracle.com, hch@lst.de, hare@suse.de Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, devel@linuxdriverproject.org, Stephen Hemminger Subject: [PATCH] storvsc: workaround for virtual DVD SCSI version Date: Tue, 7 Mar 2017 09:15:53 -0800 Message-Id: <20170307171553.13247-1-sthemmin@microsoft.com> X-Mailer: git-send-email 2.11.0 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 Hyper-V host emulation of SCSI for virtual DVD device reports SCSI version 0 (UNKNOWN) but is still capable of supporting REPORTLUN. Without this patch, a GEN2 Linux guest on Hyper-V will not boot 4.11 successfully with virtual DVD ROM device. What happens is that the SCSI scan process falls back to doing sequential probing by INQUIRY. But the storvsc driver has a previous workaround that masks/blocks all errors reports from INQUIRY (or MODE_SENSE) commands. This workaround causes the scan to then populate a full set of bogus LUN's on the target and then sends kernel spinning off into a death spiral doing block reads on the non-existent LUNs. By setting the correct blacklist flags, the target with the DVD device is scanned with REPORTLUN and that works correctly. Patch needs to go in current 4.11, it is safe but not necessary in older kernels. Signed-off-by: Stephen Hemminger Reviewed-by: K. Y. Srinivasan Reviewed-by: Christoph Hellwig Reviewed-by: Hannes Reinecke --- drivers/scsi/storvsc_drv.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) PS: The error handling does need to be fixed (have patches pending) but that is interrelated with hotplug and can wait. diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c index 638e5f427c90..19973e874830 100644 --- a/drivers/scsi/storvsc_drv.c +++ b/drivers/scsi/storvsc_drv.c @@ -400,8 +400,6 @@ MODULE_PARM_DESC(storvsc_vcpus_per_sub_channel, "Ratio of VCPUs to subchannels") */ static int storvsc_timeout = 180; -static int msft_blist_flags = BLIST_TRY_VPD_PAGES; - #if IS_ENABLED(CONFIG_SCSI_FC_ATTRS) static struct scsi_transport_template *fc_transport_template; #endif @@ -1383,6 +1381,22 @@ static int storvsc_do_io(struct hv_device *device, return ret; } +static int storvsc_device_alloc(struct scsi_device *sdevice) +{ + /* + * Set blist flag to permit the reading of the VPD pages even when + * the target may claim SPC-2 compliance. MSFT targets currently + * claim SPC-2 compliance while they implement post SPC-2 features. + * With this flag we can correctly handle WRITE_SAME_16 issues. + * + * Hypervisor reports SCSI_UNKNOWN type for DVD ROM device but + * still supports REPORT LUN. + */ + sdevice->sdev_bflags = BLIST_REPORTLUN2 | BLIST_TRY_VPD_PAGES; + + return 0; +} + static int storvsc_device_configure(struct scsi_device *sdevice) { @@ -1396,14 +1410,6 @@ static int storvsc_device_configure(struct scsi_device *sdevice) sdevice->no_write_same = 1; /* - * Add blist flags to permit the reading of the VPD pages even when - * the target may claim SPC-2 compliance. MSFT targets currently - * claim SPC-2 compliance while they implement post SPC-2 features. - * With this patch we can correctly handle WRITE_SAME_16 issues. - */ - sdevice->sdev_bflags |= msft_blist_flags; - - /* * If the host is WIN8 or WIN8 R2, claim conformance to SPC-3 * if the device is a MSFT virtual device. If the host is * WIN10 or newer, allow write_same. @@ -1661,6 +1667,7 @@ static struct scsi_host_template scsi_driver = { .eh_host_reset_handler = storvsc_host_reset_handler, .proc_name = "storvsc_host", .eh_timed_out = storvsc_eh_timed_out, + .slave_alloc = storvsc_device_alloc, .slave_configure = storvsc_device_configure, .cmd_per_lun = 255, .this_id = -1,