From patchwork Thu Jan 28 02:22:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: KY Srinivasan X-Patchwork-Id: 8145451 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id F0D359F38B for ; Thu, 28 Jan 2016 00:47:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E40A620253 for ; Thu, 28 Jan 2016 00:47:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1612720219 for ; Thu, 28 Jan 2016 00:47:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967682AbcA1Aqd (ORCPT ); Wed, 27 Jan 2016 19:46:33 -0500 Received: from p3plsmtps2ded03.prod.phx3.secureserver.net ([208.109.80.60]:43721 "EHLO p3plsmtps2ded03.prod.phx3.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967650AbcA1AqW (ORCPT ); Wed, 27 Jan 2016 19:46:22 -0500 Received: from linuxonhyperv.com ([72.167.245.219]) by : HOSTING RELAY : with SMTP id Oaj6aBOjgdpLfOaj6aU7K3; Wed, 27 Jan 2016 17:46:21 -0700 x-originating-ip: 72.167.245.219 Received: by linuxonhyperv.com (Postfix, from userid 507) id 4CD5B1902AD; Wed, 27 Jan 2016 18:22:46 -0800 (PST) From: "K. Y. Srinivasan" To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, devel@linuxdriverproject.org, ohering@suse.com, jbottomley@parallels.com, hch@infradead.org, linux-scsi@vger.kernel.org, apw@canonical.com, vkuznets@redhat.com, jasowang@redhat.com, martin.petersen@oracle.com, hare@suse.de Cc: "K. Y. Srinivasan" Subject: [PATCH V2 2/2] scsi: storvsc: Use the specified target ID in device lookup Date: Wed, 27 Jan 2016 18:22:45 -0800 Message-Id: <1453947765-28764-2-git-send-email-kys@microsoft.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1453947765-28764-1-git-send-email-kys@microsoft.com> References: <1453947739-28725-1-git-send-email-kys@microsoft.com> <1453947765-28764-1-git-send-email-kys@microsoft.com> X-CMAE-Envelope: MS4wfJWDoTx1R7nbohfF01tV7v9AtKYeYZ2lMVi1KYDVfEnGBXIOaSoAjcjQox79SkFma58HiexLCfTeC65TJyXJX5vx9hjoiCFOGgK2XgEU6N0n4uZeZfJn XE97LN1bMLvvV26VYEjCVH4VobOydfGUmk/rBR+GUIxjmF6vVvfk0gYNptvnVwabmZvsEbVwjeAo4jpgduvwI8LBP03YZpFa+OyCQ5+J6KsHorPXGU87jaS3 aCmPUl0az8b8ar9Xh5EdZcVhhCXnLSTJ8TDvEfFDgeLUIiryUICnVdxK59s4fu9s1NBasaYcncJAJbxCF7qaVh45eZ+fe1mZtVDAVNqUIFHWWaduNtmzS0NF h4+9ph+rw8lQvp9eEFX7qKWCWS49PhZSgFEd8G3ypzGM7XPtlPpYVpT8Li6vKnTWNGN1Mm8RWUaISRH6uwttFJpS3dfirgGcw3zr+GD6Byi6XY1WFN/Vqesp +t7J/eByGZwBpYR6r3dwI2kmV/4Nf31IZLFGo6obqqndpK+ZbiGFcSpjmmt4DRvM3GxsYlulecNe9mLR9pmb+FNsh6jZcLTQEbl/3RDNP+zMqL+dYDt1l/mx K5E= Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The current code assumes that there is only one target in device lookup. Fix this bug. This will alow us to correctly handle hot reomoval of LUNs. Signed-off-by: K. Y. Srinivasan Reviewed-by: Alex Ng Tested-by: Vivek Yadav Reviewed-by: Johannes Thumshirn --- V2: Made lun and target_id unsigned 8 bit entities - Hannes Reinecke drivers/scsi/storvsc_drv.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c index 622f64a..132b168 100644 --- a/drivers/scsi/storvsc_drv.c +++ b/drivers/scsi/storvsc_drv.c @@ -478,19 +478,18 @@ struct hv_host_device { struct storvsc_scan_work { struct work_struct work; struct Scsi_Host *host; - uint lun; + u8 lun; + u8 tgt_id; }; static void storvsc_device_scan(struct work_struct *work) { struct storvsc_scan_work *wrk; - uint lun; struct scsi_device *sdev; wrk = container_of(work, struct storvsc_scan_work, work); - lun = wrk->lun; - sdev = scsi_device_lookup(wrk->host, 0, 0, lun); + sdev = scsi_device_lookup(wrk->host, 0, wrk->tgt_id, wrk->lun); if (!sdev) goto done; scsi_rescan_device(&sdev->sdev_gendev); @@ -541,7 +540,7 @@ static void storvsc_remove_lun(struct work_struct *work) if (!scsi_host_get(wrk->host)) goto done; - sdev = scsi_device_lookup(wrk->host, 0, 0, wrk->lun); + sdev = scsi_device_lookup(wrk->host, 0, wrk->tgt_id, wrk->lun); if (sdev) { scsi_remove_device(sdev); @@ -941,6 +940,7 @@ static void storvsc_handle_error(struct vmscsi_request *vm_srb, wrk->host = host; wrk->lun = vm_srb->lun; + wrk->tgt_id = vm_srb->target_id; INIT_WORK(&wrk->work, process_err_fn); schedule_work(&wrk->work); }