Re: [PATCH V2 2/2] scsi: storvsc: Use the specified target ID in device lookup
From: Johannes Thumshirn
Date: Thu Jan 28 2016 - 03:30:06 EST
On Wed, Jan 27, 2016 at 06:22:45PM -0800, K. Y. Srinivasan wrote:
> 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 <kys@xxxxxxxxxxxxx>
> Reviewed-by: Alex Ng <alexng@xxxxxxxxxxxxx>
> Tested-by: Vivek Yadav <vyadav@xxxxxxxxxxxxx>
> ---
> V2: Made lun and target_id unsigned 8 bit entities - Hannes Reinecke <hare@xxxxxxx>
>
> 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);
> }
> --
> 1.7.4.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Reviewed-by: Johannes Thumshirn <jthumshirn@xxxxxxx>
--
Johannes Thumshirn Storage
jthumshirn@xxxxxxx +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850