Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932941AbdCGR6H (ORCPT ); Tue, 7 Mar 2017 12:58:07 -0500 Received: from mail-bl2nam02on0139.outbound.protection.outlook.com ([104.47.38.139]:34266 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752135AbdCGR56 (ORCPT ); Tue, 7 Mar 2017 12:57:58 -0500 From: KY Srinivasan To: Stephen Hemminger , Haiyang Zhang , Long Li , "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: RE: [PATCH] storvsc: workaround for virtual DVD SCSI version Thread-Topic: [PATCH] storvsc: workaround for virtual DVD SCSI version Thread-Index: AQHSl2aKoCAMBtemh0Ko/D5JslDtwqGJntfQ Date: Tue, 7 Mar 2017 17:19:03 +0000 Message-ID: References: <20170307171553.13247-1-sthemmin@microsoft.com> In-Reply-To: <20170307171553.13247-1-sthemmin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: networkplumber.org; dkim=none (message not signed) header.d=none;networkplumber.org; dmarc=none action=none header.from=microsoft.com; x-originating-ip: [2601:600:8c00:1040:cc2c:19a0:55d5:2f8f] x-ms-office365-filtering-correlation-id: 952581f4-9319-4395-94c7-08d4657e0da5 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(48565401081);SRVR:BLUPR03MB1411; x-microsoft-exchange-diagnostics: 1;BLUPR03MB1411;7:mgJVV+HHiTp1UvOFjeshjezd6YZr3hM1hrYiizc9PRDVKYXp5to76EItPAyeDLo2pqkooIY5QRBYCLFSDljEZtjSiHmKfHImhLnp8l/SNRUii/SblUo6eJoKepYHgRHTp1ONaHDUMJAWjr26ZWOnNipXFpb4VFEOKON7oBRfXSP0vtguDdBIRj6Loy3X/YEGPh+IiQPjv+2mcUDdBRENcYk/wjvsjQj1uwK36sirV4/sTqimBwCCNE3o/xl+3v66H7fzCXIJqwgpJNQ0d9LdNorRqvK1VD8bxnCRabysGIZw9mQsJmXKUGnnQRjA6SRKUyZx32G/2cJfv3BWTRqh+B4C9+1h7g6zS4vRpwU5fQg= x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(20558992708506)(9452136761055)(146099531331640); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041248)(20161123564025)(20161123555025)(20161123562025)(20161123558025)(20161123560025)(6042181)(6072148);SRVR:BLUPR03MB1411;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB1411; x-forefront-prvs: 0239D46DB6 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(7916002)(377454003)(13464003)(2900100001)(99286003)(86362001)(2501003)(10090500001)(54906002)(189998001)(81166006)(5005710100001)(8990500004)(10290500002)(55016002)(86612001)(6436002)(54356999)(2561002)(33656002)(8676002)(25786008)(7696004)(53546006)(102836003)(6116002)(2201001)(8936002)(76176999)(50986999)(9686003)(3280700002)(3660700001)(4326008)(5660300001)(7736002)(2950100002)(305945005)(74316002)(6506006)(2906002)(53936002)(229853002)(77096006)(1511001)(122556002)(106116001)(107886003)(38730400002)(6246003)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:BLUPR03MB1411;H:DM5PR03MB2490.namprd03.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Mar 2017 17:19:03.3603 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB1411 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id v27HwIHl001172 Content-Length: 4037 Lines: 107 > -----Original Message----- > From: Stephen Hemminger [mailto:stephen@networkplumber.org] > Sent: Tuesday, March 7, 2017 9:16 AM > To: KY Srinivasan ; Haiyang Zhang > ; Long Li ; > 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 > > 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 > --- > 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, > -- > 2.11.0