From patchwork Sat Mar 4 23:55:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: KY Srinivasan X-Patchwork-Id: 9604327 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 4405C6016C for ; Sat, 4 Mar 2017 23:56:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3EC6728394 for ; Sat, 4 Mar 2017 23:56:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 331C1283AC; Sat, 4 Mar 2017 23:56:18 +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.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, 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 0301528394 for ; Sat, 4 Mar 2017 23:56:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752529AbdCDX4Q (ORCPT ); Sat, 4 Mar 2017 18:56:16 -0500 Received: from mail-by2nam03on0122.outbound.protection.outlook.com ([104.47.42.122]:44973 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752522AbdCDX4P (ORCPT ); Sat, 4 Mar 2017 18:56:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=gdIyEbl/yDb7z3664yHQqbNSTOvSERWT0SFc2uDrjjI=; b=N2zwtZ3v22XP1si6up5+sIJe7v6l1MDUkgRWf6elRL/dKf4QntfVigzk4WcNO6lgKm5KitE+Ec41Fl9FCXeWW/triWQIwufKbNJ/0Q6+gnQsK5ej3pL3d0qlVdmooDteUjI0rQ3oox/UUbMlfjHLfjQwFDQiJ3BSQ8lEipGf+ZI= Received: from DM5PR03MB2490.namprd03.prod.outlook.com (10.168.233.136) by DM5PR03MB2667.namprd03.prod.outlook.com (10.168.197.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.947.12; Sat, 4 Mar 2017 23:56:11 +0000 Received: from DM5PR03MB2490.namprd03.prod.outlook.com ([10.168.233.136]) by DM5PR03MB2490.namprd03.prod.outlook.com ([10.168.233.136]) with mapi id 15.01.0947.018; Sat, 4 Mar 2017 23:55:50 +0000 From: KY Srinivasan To: James Bottomley , Stephen Hemminger CC: Hannes Reinecke , Christoph Hellwig , Jens Axboe , Linus Torvalds , "Martin K. Petersen" , Dexuan Cui , Long Li , Josh Poulson , "Adrian Suhov (Cloudbase Solutions SRL)" , "linux-scsi@vger.kernel.org" , Haiyang Zhang Subject: RE: [RFC] hv_storvsc: error handling. Thread-Topic: [RFC] hv_storvsc: error handling. Thread-Index: AQHSlIFO0SkI7YXr5E+wsDj8AJ/5rqGE/jbggAA3r4CAAABhMIAAGhBQ Date: Sat, 4 Mar 2017 23:55:50 +0000 Message-ID: References: <1488301573.3046.9.camel@linux.vnet.ibm.com> <20170228105741.6253bb8a@xeon-e3> <1488325732.11610.9.camel@linux.vnet.ibm.com> <20170228172532.280811ed@xeon-e3> <1488349258.20321.11.camel@linux.vnet.ibm.com> <20170228224845.1da358ee@xeon-e3> <20170301155057.GA13167@lst.de> <20170301075412.2e5f1e98@xeon-e3> <20170302000135.GA22886@lst.de> <20170302005615.GA23687@lst.de> <20170301174058.383da142@xeon-e3> <20170302102324.47dbe3ad@xeon-e3> <895c4f2e-7faa-41e1-b5de-eedb4ae0f882@email.android.com> <20170302110505.6ad2eb61@xeon-e3> <1b325703-b823-4304-9d9d-86071811e000@email.android.com> <20170303165011.53a38794@xeon-e3> <1488663419.2985.4.camel@linux.vnet.ibm.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: linux.vnet.ibm.com; dkim=none (message not signed) header.d=none;linux.vnet.ibm.com; dmarc=none action=none header.from=microsoft.com; x-originating-ip: [2601:600:8c00:1040:7415:79b8:a2c0:fe22] x-ms-office365-filtering-correlation-id: 5dc9b9cc-6c5f-4b96-92cf-08d46359fc83 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081); SRVR:DM5PR03MB2667; x-microsoft-exchange-diagnostics: 1; DM5PR03MB2667; 7:1/RtRT1ma7Nt+4QcJdLgCN4IPmPxvQVsrMKDprS+t5JKRLDN5YkMJPwSxbpXmfSGX7iFRq1RDtszKU4JA6ghoSxYiKGngDWqNh0TsKvdjYi3xugl2SxtL2WC5VdkqpUNRdO/JZACM32wO2nyVzKiO7c346hFmLVjCe0wQth8ioFqON74oVGPsK/Zw45DAsO1wSUvnYlQNHZVrherlkAezs746zYHLlrLzgz6/tUzT1XAlvKv1M2utDY8ARB60k/BJ4a5MwM0qP8Sexp7GA4crgCEoxPOYN6t36uppHZ8tHdchhxK/JKIajQCRVxGNQ0zzuyaIl0ehxkxs3Qvg5oUZ9EvvXNLQqaV/LI7xF6ywjU= x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(9452136761055)(104084551191319)(146099531331640); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(61425038)(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041248)(20161123558025)(20161123562025)(20161123564025)(20161123555025)(20161123560025)(6072148); SRVR:DM5PR03MB2667; BCL:0; PCL:0; RULEID:; SRVR:DM5PR03MB2667; x-forefront-prvs: 0236114672 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6009001)(7916002)(39850400002)(39860400002)(39840400002)(39450400003)(377454003)(377424004)(24454002)(13464003)(38730400002)(6246003)(93886004)(122556002)(102836003)(6116002)(54356999)(33656002)(76176999)(50986999)(25786008)(6436002)(55016002)(575784001)(86362001)(9686003)(6506006)(99286003)(54906002)(77096006)(2900100001)(8676002)(53936002)(92566002)(8990500004)(10090500001)(106116001)(5005710100001)(10290500002)(53546006)(7696004)(7736002)(305945005)(2906002)(3660700001)(189998001)(4326008)(74316002)(2950100002)(5660300001)(3280700002)(24704002); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR03MB2667; H:DM5PR03MB2490.namprd03.prod.outlook.com; FPR:; SPF:None; MLV:sfv; LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Mar 2017 23:55:50.4240 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2667 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 > -----Original Message----- > From: KY Srinivasan > Sent: Saturday, March 4, 2017 1:40 PM > To: 'James Bottomley' ; Stephen Hemminger > > Cc: Hannes Reinecke ; Christoph Hellwig ; Jens > Axboe ; Linus Torvalds foundation.org>; Martin K. Petersen ; > Dexuan Cui ; Long Li ; Josh > Poulson ; Adrian Suhov (Cloudbase Solutions SRL) > ; linux-scsi@vger.kernel.org; Haiyang Zhang > > Subject: RE: [RFC] hv_storvsc: error handling. > > > > > -----Original Message----- > > From: James Bottomley [mailto:jejb@linux.vnet.ibm.com] > > Sent: Saturday, March 4, 2017 1:37 PM > > To: KY Srinivasan ; Stephen Hemminger > > > > Cc: Hannes Reinecke ; Christoph Hellwig ; > Jens > > Axboe ; Linus Torvalds > foundation.org>; Martin K. Petersen ; > > Dexuan Cui ; Long Li ; Josh > > Poulson ; Adrian Suhov (Cloudbase Solutions > SRL) > > ; linux-scsi@vger.kernel.org; Haiyang Zhang > > > > Subject: Re: [RFC] hv_storvsc: error handling. > > > > On Sat, 2017-03-04 at 21:03 +0000, KY Srinivasan wrote: > > > > > > > -----Original Message----- > > > > From: Stephen Hemminger [mailto:stephen@networkplumber.org] > > > > Sent: Friday, March 3, 2017 4:50 PM > > > > To: James Bottomley > > > > Cc: Hannes Reinecke ; Christoph Hellwig > ; > > > > James Bottomley ; Jens Axboe > > > > ; Linus Torvalds ; > > > > Martin K. Petersen ; KY Srinivasan > > > > ; Dexuan Cui ; Long Li > > > > ; Josh Poulson ; > > > > Adrian > > > > Suhov (Cloudbase Solutions SRL) ; linux- > > > > scsi@vger.kernel.org; Haiyang Zhang > > > > Subject: [RFC] hv_storvsc: error handling. > > > > > > > > Needs more testing but this does fix the observed problem. > > > > > > > > From: Stephen Hemminger > > > > > > > > Subject: [PATCH] hv_storvsc: fix error handling > > > > > > > > The Hyper-V storvsc SCSI driver was hiding all errors in INQUIRY > > > > and > > > > MODE_SENSE commands. This caused the scan process to incorrectly > > > > think > > > > devices were present and online. Also invalid LUN errors were not > > > > being handled correctly. > > > > > > > > This fixes problems booting a GEN2 VM on Hyper-V. It effectively > > > > reverts commit 4ed51a21c0f69 ("Staging: hv: storvsc: Fixup > > > > srb and scsi status for INQUIRY and MODE_SENSE") > > > > > > > > Signed-off-by: Stephen Hemminger > > > > --- > > > > drivers/scsi/storvsc_drv.c | 48 ++++------------------------------ > > > > ------------ > > > > 1 file changed, 4 insertions(+), 44 deletions(-) > > > > > > > > diff --git a/drivers/scsi/storvsc_drv.c > > > > b/drivers/scsi/storvsc_drv.c > > > > index 638e5f427c90..8cc241fc54b8 100644 > > > > --- a/drivers/scsi/storvsc_drv.c > > > > +++ b/drivers/scsi/storvsc_drv.c > > > > @@ -543,28 +543,6 @@ static void storvsc_host_scan(struct > > > > work_struct > > > > *work) > > > > kfree(wrk); > > > > } > > > > > > > > -static void storvsc_remove_lun(struct work_struct *work) > > > > -{ > > > > - struct storvsc_scan_work *wrk; > > > > - struct scsi_device *sdev; > > > > - > > > > - wrk = container_of(work, struct storvsc_scan_work, work); > > > > - if (!scsi_host_get(wrk->host)) > > > > - goto done; > > > > - > > > > - sdev = scsi_device_lookup(wrk->host, 0, wrk->tgt_id, wrk > > > > ->lun); > > > > - > > > > - if (sdev) { > > > > - scsi_remove_device(sdev); > > > > - scsi_device_put(sdev); > > > > - } > > > > - scsi_host_put(wrk->host); > > > > - > > > > -done: > > > > - kfree(wrk); > > > > -} > > > > - > > > > - > > > > /* > > > > * We can get incoming messages from the host that are not in > > > > response to > > > > * messages that we have sent out. An example of this would be > > > > messages > > > > @@ -955,8 +933,7 @@ static void storvsc_handle_error(struct > > > > vmscsi_request *vm_srb, > > > > } > > > > break; > > > > case SRB_STATUS_INVALID_LUN: > > > > - do_work = true; > > > > - process_err_fn = storvsc_remove_lun; > > > > + set_host_byte(scmnd, DID_NO_CONNECT); > > > > break; > > > > case SRB_STATUS_ABORTED: > > > > if (vm_srb->srb_status & > > > > SRB_STATUS_AUTOSENSE_VALID > > > > && > > > > @@ -1050,32 +1027,15 @@ static void storvsc_on_io_completion(struct > > > > storvsc_device *stor_device, > > > > > > > > stor_pkt = &request->vstor_packet; > > > > > > > > - /* > > > > - * The current SCSI handling on the host side does > > > > - * not correctly handle: > > > > - * INQUIRY command with page code parameter set to 0x80 > > > > - * MODE_SENSE command with cmd[2] == 0x1c > > > > - * > > > > - * Setup srb and scsi status so this won't be fatal. > > > > - * We do this so we can distinguish truly fatal failues > > > > - * (srb status == 0x4) and off-line the device in that > > > > case. > > > > - */ > > > > - > > > > - if ((stor_pkt->vm_srb.cdb[0] == INQUIRY) || > > > > - (stor_pkt->vm_srb.cdb[0] == MODE_SENSE)) { > > > > - vstor_packet->vm_srb.scsi_status = 0; > > > > - vstor_packet->vm_srb.srb_status = > > > > SRB_STATUS_SUCCESS; > > > > - } > > > > - > > > > - > > > > /* Copy over the status...etc */ > > > > stor_pkt->vm_srb.scsi_status = vstor_packet > > > > ->vm_srb.scsi_status; > > > > stor_pkt->vm_srb.srb_status = vstor_packet > > > > ->vm_srb.srb_status; > > > > stor_pkt->vm_srb.sense_info_length = > > > > vstor_packet->vm_srb.sense_info_length; > > > > > > > > - if (vstor_packet->vm_srb.scsi_status != 0 || > > > > - vstor_packet->vm_srb.srb_status != SRB_STATUS_SUCCESS) > > > > + if (stor_pkt->vm_srb.cdb[0] != INQUIRY && > > > > + (vstor_packet->vm_srb.scsi_status != 0 || > > > > + vstor_packet->vm_srb.srb_status != > > > > SRB_STATUS_SUCCESS)) > > > > storvsc_log(device, STORVSC_LOGGING_WARN, > > > > "cmd 0x%x scsi status 0x%x srb status > > > > 0x%x\n", > > > > stor_pkt->vm_srb.cdb[0], > > > > -- > > > > > > This patch gets rid of the ability to "hot remove" LUNs. I don't > > > think that can be part of any > > > solution. The INQUIRY hack I put in a long time ago was to deal with > > > host bugs on prior versions of > > > Windows server. WS2016 should not be trigerring this code. Stephen, > > > could you please test this patch - > > > a quick hack: > > > > > > From b97f24f224a71a6e745c42e5640045a553eb407c Mon Sep 17 00:00:00 > > > 2001 > > > From: K. Y. Srinivasan > > > Date: Sat, 4 Mar 2017 14:00:46 -0700 > > > Subject: [PATCH 1/1] scsi: storvsc: Fix a bug in LUN removal code > > > Reply-To: kys@microsoft.com > > > > > > Signed-off-by: K. Y. Srinivasan > > > --- > > > drivers/scsi/storvsc_drv.c | 13 +++++++++++++ > > > 1 files changed, 13 insertions(+), 0 deletions(-) > > > > > > diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c > > > index 05526b7..27eb682 100644 > > > --- a/drivers/scsi/storvsc_drv.c > > > +++ b/drivers/scsi/storvsc_drv.c > > > @@ -885,6 +885,7 @@ static void storvsc_handle_error(struct > > > vmscsi_request *vm_srb, > > > struct storvsc_scan_work *wrk; > > > void (*process_err_fn)(struct work_struct *work); > > > bool do_work = false; > > > + struct scsi_device *sdev; > > > > > > switch (SRB_STATUS(vm_srb->srb_status)) { > > > case SRB_STATUS_ERROR: > > > @@ -911,6 +912,18 @@ static void storvsc_handle_error(struct > > > vmscsi_request *vm_srb, > > > } > > > break; > > > case SRB_STATUS_INVALID_LUN: > > > + if (!scsi_host_get(host)) { > > > + set_host_byte(scmnd, DID_NO_CONNECT); > > > + break; > > > + } > > > + > > > + sdev = scsi_device_lookup(wrk->host, 0, wrk->tgt_id, > > > wrk->lun); > > > + > > > + if (!sdev) { > > > + set_host_byte(scmnd, DID_NO_CONNECT); > > > + break; > > > + } > > > + > > > > You're now getting two references (one to the host and one to the > > device) that you don't put either in error handling or in > > storvsc_remove_lun(). > > > > Probably you should eliminate the scsi_host_get and scsi_device_lookup > > in storvsc_remove_lun() (making it basically remove device put device > > put host) and add a host put in the !sdev if above. > > Yes; this was a quick hack to prove a theory. This should work (I hope); I will > cleanup and resend once > Stephen verifies. Stephen, Please test this patch. Have addressed the ref count issue that James pointed out. From 6d57fb68c40165e61d84b6766b2263747d5e241d Mon Sep 17 00:00:00 2001 From: K. Y. Srinivasan Date: Sat, 4 Mar 2017 15:57:26 -0700 Subject: [PATCH 1/1] scsi: storvsc: Fix a bug in LUN removal code Reply-To: kys@microsoft.com Signed-off-by: K. Y. Srinivasan --- drivers/scsi/storvsc_drv.c | 33 +++++++++++++++++++++++---------- 1 files changed, 23 insertions(+), 10 deletions(-) -- 1.7.1 > > K. Y > > > > James diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c index 05526b7..2bd132d 100644 --- a/drivers/scsi/storvsc_drv.c +++ b/drivers/scsi/storvsc_drv.c @@ -478,6 +478,7 @@ struct hv_host_device { struct storvsc_scan_work { struct work_struct work; struct Scsi_Host *host; + struct scsi_device *sdev; u8 lun; u8 tgt_id; }; @@ -531,24 +532,20 @@ static void storvsc_host_scan(struct work_struct *work) kfree(wrk); } +/* + * On Entry we have a reference on both the host and the device. + * Drop them here. + */ static void storvsc_remove_lun(struct work_struct *work) { struct storvsc_scan_work *wrk; - struct scsi_device *sdev; wrk = container_of(work, struct storvsc_scan_work, work); - if (!scsi_host_get(wrk->host)) - goto done; - - sdev = scsi_device_lookup(wrk->host, 0, wrk->tgt_id, wrk->lun); - if (sdev) { - scsi_remove_device(sdev); - scsi_device_put(sdev); - } + scsi_remove_device(wrk->sdev); + scsi_device_put(wrk->sdev); scsi_host_put(wrk->host); -done: kfree(wrk); } @@ -885,6 +882,7 @@ static void storvsc_handle_error(struct vmscsi_request *vm_srb, struct storvsc_scan_work *wrk; void (*process_err_fn)(struct work_struct *work); bool do_work = false; + struct scsi_device *sdev; switch (SRB_STATUS(vm_srb->srb_status)) { case SRB_STATUS_ERROR: @@ -911,9 +909,23 @@ static void storvsc_handle_error(struct vmscsi_request *vm_srb, } break; case SRB_STATUS_INVALID_LUN: + if (!scsi_host_get(host)) + goto host_not_known; + + sdev = scsi_device_lookup(wrk->host, 0, wrk->tgt_id, wrk->lun); + + if (!sdev) + goto lun_not_known; + do_work = true; process_err_fn = storvsc_remove_lun; break; + +lun_not_known: + scsi_host_put(host); +host_not_known: + set_host_byte(scmnd, DID_NO_CONNECT); + break; case SRB_STATUS_ABORTED: if (vm_srb->srb_status & SRB_STATUS_AUTOSENSE_VALID && (asc == 0x2a) && (ascq == 0x9)) { @@ -939,6 +951,7 @@ static void storvsc_handle_error(struct vmscsi_request *vm_srb, return; } + wrk->sdev = sdev; wrk->host = host; wrk->lun = vm_srb->lun; wrk->tgt_id = vm_srb->target_id;