RE: [RFC] hv_storvsc: error handling.

2017-03-04 Thread KY Srinivasan


> -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:j...@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 +, KY Srinivasan wrote:
> > >
> > > > -Original Message-
> > > > From: Stephen Hemminger [mailto:step...@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-
> > > > s...@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 

Re: [PATCH 11/20] lpfc: Fix eh_deadline setting for sli3 adapters.

2017-03-04 Thread Laurence Oberman


- Original Message -
> From: jsmart2...@gmail.com
> To: linux-scsi@vger.kernel.org, linux-n...@lists.infradead.org
> Cc: "James Smart" , "Dick Kennedy" 
> , "James Smart"
> 
> Sent: Saturday, March 4, 2017 12:30:31 PM
> Subject: [PATCH 11/20] lpfc: Fix eh_deadline setting for sli3 adapters.
> 
> From: James Smart 
> 
> A previous change unilaterally removed the hba reset entry point
> from the sli3 host template. This was done to allow tape devices
> being used for back up from being removed. Why was this done ?
> When there was non-responding device on the fabric, the error
> escalation policy would escalate to the reset handler. When the
> reset handler was called, it would reset the adapter, dropping
> link, thus logging out and terminating all i/o's - on any target.
> If there was a tape device on the same adapter that wasn't in
> error, it would kill the tape i/o's, effectively killing the
> tape device state.  With the reset point removed, the adapter
> reset avoided the fabric logout, allowing the other devices to
> continue to operate unaffected. A hack - yes. Hint: we really
> need a transport I_T nexus reset callback added to the eh process
> (in between the SCSI target reset and hba reset points), so a
> fc logout could occur to the one bad target only and stop the error
> escalation process.
> 
> This patch commonizes the approach so it can be used for sli3 and sli4
> adapters, but mandates the admin, via module parameter, specifically
> identify which adapters the resets are to be removed for. Additionally,
> bus_reset, which sends Target Reset TMFs to all targets, is also removed
> from the template as it too has the same effect as the adapter reset.
> 
> Signed-off-by: Dick Kennedy 
> Signed-off-by: James Smart 
> ---
>  drivers/scsi/lpfc/lpfc.h  |  1 +
>  drivers/scsi/lpfc/lpfc_attr.c |  6 +
>  drivers/scsi/lpfc/lpfc_crtn.h |  4 ++-
>  drivers/scsi/lpfc/lpfc_init.c | 61
>  ---
>  drivers/scsi/lpfc/lpfc_scsi.c |  3 +--
>  5 files changed, 69 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
> index de6cd57..763f32d 100644
> --- a/drivers/scsi/lpfc/lpfc.h
> +++ b/drivers/scsi/lpfc/lpfc.h
> @@ -99,6 +99,7 @@ struct lpfc_sli2_slim;
>  #define FC_MAX_ADPTMSG   64
>  
>  #define MAX_HBAEVT   32
> +#define MAX_HBAS_NO_RESET 16
>  
>  /* Number of MSI-X vectors the driver uses */
>  #define LPFC_MSIX_VECTORS2
> diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
> index 4114cf4..b741dcb 100644
> --- a/drivers/scsi/lpfc/lpfc_attr.c
> +++ b/drivers/scsi/lpfc/lpfc_attr.c
> @@ -3010,6 +3010,12 @@ MODULE_PARM_DESC(lpfc_poll, "FCP ring polling mode
> control:"
>  static DEVICE_ATTR(lpfc_poll, S_IRUGO | S_IWUSR,
>  lpfc_poll_show, lpfc_poll_store);
>  
> +int lpfc_no_hba_reset_cnt;
> +unsigned long lpfc_no_hba_reset[MAX_HBAS_NO_RESET] = {
> + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
> +module_param_array(lpfc_no_hba_reset, ulong, _no_hba_reset_cnt, 0444);
> +MODULE_PARM_DESC(lpfc_no_hba_reset, "WWPN of HBAs that should not be
> reset");
> +
>  LPFC_ATTR(sli_mode, 0, 0, 3,
>   "SLI mode selector:"
>   " 0 - auto (SLI-3 if supported),"
> diff --git a/drivers/scsi/lpfc/lpfc_crtn.h b/drivers/scsi/lpfc/lpfc_crtn.h
> index 843dd73..54e6ac4 100644
> --- a/drivers/scsi/lpfc/lpfc_crtn.h
> +++ b/drivers/scsi/lpfc/lpfc_crtn.h
> @@ -384,7 +384,7 @@ void lpfc_free_sysfs_attr(struct lpfc_vport *);
>  extern struct device_attribute *lpfc_hba_attrs[];
>  extern struct device_attribute *lpfc_vport_attrs[];
>  extern struct scsi_host_template lpfc_template;
> -extern struct scsi_host_template lpfc_template_s3;
> +extern struct scsi_host_template lpfc_template_no_hr;
>  extern struct scsi_host_template lpfc_template_nvme;
>  extern struct scsi_host_template lpfc_vport_template;
>  extern struct fc_function_template lpfc_transport_functions;
> @@ -554,3 +554,5 @@ void lpfc_nvme_abort_fcreq_cmpl(struct lpfc_hba *phba,
>   struct lpfc_wcqe_complete *abts_cmpl);
>  extern int lpfc_enable_nvmet_cnt;
>  extern unsigned long long lpfc_enable_nvmet[];
> +extern int lpfc_no_hba_reset_cnt;
> +extern unsigned long lpfc_no_hba_reset[];
> diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
> index b754887..ecb8e1c 100644
> --- a/drivers/scsi/lpfc/lpfc_init.c
> +++ b/drivers/scsi/lpfc/lpfc_init.c
> @@ -3555,6 +3555,44 @@ lpfc_sli4_scsi_sgl_update(struct lpfc_hba *phba)
>   return rc;
>  }
>  
> +static uint64_t
> +lpfc_get_wwpn(struct lpfc_hba *phba)
> +{
> + uint64_t wwn;
> + int rc;
> + LPFC_MBOXQ_t *mboxq;
> + MAILBOX_t *mb;
> +
> +
> + mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool,
> +

RE: [RFC] hv_storvsc: error handling.

2017-03-04 Thread KY Srinivasan


> -Original Message-
> From: James Bottomley [mailto:j...@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 +, KY Srinivasan wrote:
> >
> > > -Original Message-
> > > From: Stephen Hemminger [mailto:step...@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-
> > > s...@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 = >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 */
> > >   

Re: [RFC] hv_storvsc: error handling.

2017-03-04 Thread James Bottomley
On Sat, 2017-03-04 at 21:03 +, KY Srinivasan wrote:
> 
> > -Original Message-
> > From: Stephen Hemminger [mailto:step...@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-
> > s...@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 = >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 

RE: [RFC] hv_storvsc: error handling.

2017-03-04 Thread KY Srinivasan


> -Original Message-
> From: Stephen Hemminger [mailto:step...@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-
> s...@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 = >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 

Re: [bug report] scsi: lpfc: NVME Initiator: Merge into FC discovery

2017-03-04 Thread James Smart



On 2/27/2017 8:34 AM, Dan Carpenter wrote:

Hello James Smart,

This is a semi-automatic email about new static checker warnings.

The patch a0f2d3ef374f: "scsi: lpfc: NVME Initiator: Merge into FC
discovery" from Feb 12, 2017, leads to the following Smatch complaint:




Thanks.  Issues addressed in the lpfc patch set just posted.
see  http://marc.info/?l=linux-scsi=148864868315119=2

-- james



Re: [bug report] scsi: lpfc: NVME Target: Base modifications

2017-03-04 Thread James Smart



On 2/27/2017 8:48 AM, Dan Carpenter wrote:

Hello James Smart,

This is a semi-automatic email about new static checker warnings.

The patch f358dd0ca26c: "scsi: lpfc: NVME Target: Base modifications"
from Feb 12, 2017, leads to the following Smatch complaint:





Thanks.  Issues were addressed by patch from Colin King, and pushed in 
the lpfc patch set just posted.

see  http://marc.info/?l=linux-scsi=148864866415099=2

-- james


Re: [bug report] scsi: lpfc: NVME Initiator: Base modifications

2017-03-04 Thread James Smart



On 2/27/2017 7:55 AM, Dan Carpenter wrote:

Hello James Smart,

The patch 895427bd012c: "scsi: lpfc: NVME Initiator: Base
modifications" from Feb 12, 2017, leads to the following static
checker warning:




Thanks.  Issues addressed in the lpfc patch set just posted.
see  http://marc.info/?l=linux-scsi=148864868015116=2

-- james



Re: [bug report] scsi: lpfc: NVME Target: Receive buffer updates

2017-03-04 Thread James Smart



On 2/27/2017 8:44 AM, Dan Carpenter wrote:

Hello James Smart,

This is a semi-automatic email about new static checker warnings.

The patch 2d7dbc4c2775: "scsi: lpfc: NVME Target: Receive buffer
updates" from Feb 12, 2017, leads to the following Smatch complaint:




Thanks.  Issues were addressed by patch from Colin King, and pushed in 
the lpfc patch set just posted.

see http://marc.info/?l=linux-scsi=148864866515100=2

-- james


Re: [PATCH] scsi: lpfc: don't dereference dma_buf->iocbq before null check

2017-03-04 Thread James Smart

Looks good. I included it in the lpfc patch set just posted.

-- james


On 2/24/2017 6:09 AM, Colin King wrote:

From: Colin Ian King 

dma_buf->iocbq is being dereferenced immediately before it is
being null checked, so we have a potential null pointer dereference
bug.  Fix this by only dereferencing it only once we have passed
a null check on the pointer.

Detected by CoverityScan, CID#1411652 ("Dereference before null check")

Signed-off-by: Colin Ian King 
---
  drivers/scsi/lpfc/lpfc_mem.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/lpfc/lpfc_mem.c b/drivers/scsi/lpfc/lpfc_mem.c
index c61d8d6..5986c79 100644
--- a/drivers/scsi/lpfc/lpfc_mem.c
+++ b/drivers/scsi/lpfc/lpfc_mem.c
@@ -646,7 +646,6 @@ lpfc_sli4_nvmet_alloc(struct lpfc_hba *phba)
}
  
  	dma_buf->iocbq = lpfc_sli_get_iocbq(phba);

-   dma_buf->iocbq->iocb_flag = LPFC_IO_NVMET;
if (!dma_buf->iocbq) {
kfree(dma_buf->context);
pci_pool_free(phba->lpfc_drb_pool, dma_buf->dbuf.virt,
@@ -658,6 +657,7 @@ lpfc_sli4_nvmet_alloc(struct lpfc_hba *phba)
"2621 Ran out of nvmet iocb/WQEs\n");
return NULL;
}
+   dma_buf->iocbq->iocb_flag = LPFC_IO_NVMET;
nvmewqe = dma_buf->iocbq;
wqe = (union lpfc_wqe128 *)>wqe;
/* Initialize WQE */




Re: [PATCH] scsi: lpfc: fix missing spin_unlock on sql_list_lock

2017-03-04 Thread James Smart

Looks good. I included it in the lpfc patch set just posted.

-- james


On 2/24/2017 6:30 AM, Colin King wrote:

From: Colin Ian King 

In the case where sglq is null, the current code just returns without
unlocking the spinlock sql_list_lock. Fix this by breaking out of the
while loop and the exit path will then unlock and return NULL as was
the original intention.

Detected by CoverityScan, CID#1411635 ("Missing unlock")

Signed-off-by: Colin Ian King 
---
  drivers/scsi/lpfc/lpfc_sli.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 1fba5dc..40720bb 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -952,7 +952,7 @@ __lpfc_sli_get_els_sglq(struct lpfc_hba *phba, struct 
lpfc_iocbq *piocbq)
start_sglq = sglq;
while (!found) {
if (!sglq)
-   return NULL;
+   break;
if (ndlp && ndlp->active_rrqs_xri_bitmap &&
test_bit(sglq->sli4_lxritag,
ndlp->active_rrqs_xri_bitmap)) {




Re: [PATCH] scsi: lpfc: sanity check hrq is null before dereferencing it

2017-03-04 Thread James Smart

Looks good. I included it in the lpfc patch set just posted.

-- james


On 2/24/2017 5:56 AM, Colin King wrote:

From: Colin Ian King 

The sanity check for hrq should be moved to before the deference
of hrq to ensure we don't perform a null pointer deference.

Detected by CoverityScan, CID#1411650 ("Dereference before null check")

Signed-off-by: Colin Ian King 
---
  drivers/scsi/lpfc/lpfc_sli.c | 10 +-
  1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index e43e5e2..1fba5dc 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -15185,17 +15185,17 @@ lpfc_mrq_create(struct lpfc_hba *phba, struct 
lpfc_queue **hrqp,
drq = drqp[idx];
cq  = cqp[idx];
  
-		if (hrq->entry_count != drq->entry_count) {

-   status = -EINVAL;
-   goto out;
-   }
-
/* sanity check on queue memory */
if (!hrq || !drq || !cq) {
status = -ENODEV;
goto out;
}
  
+		if (hrq->entry_count != drq->entry_count) {

+   status = -EINVAL;
+   goto out;
+   }
+
if (idx == 0) {
bf_set(lpfc_mbx_rq_create_num_pages,
   _create->u.request,




Re: [PATCH] scsi: lpfc: remove redundant assignment of sgel

2017-03-04 Thread James Smart

Looks good. I included it in the lpfc patch set just posted.

-- james



On 2/24/2017 5:45 AM, Colin King wrote:

From: Colin Ian King 

In the NVMET_FCOP_RSP case, sgel is assigned but never used and
hence is redundant and can be removed.

Detected by CoverityScan, CID#1411658 ("Unused value")

Signed-off-by: Colin Ian King 
---
  drivers/scsi/lpfc/lpfc_nvmet.c | 1 -
  1 file changed, 1 deletion(-)

diff --git a/drivers/scsi/lpfc/lpfc_nvmet.c b/drivers/scsi/lpfc/lpfc_nvmet.c
index c421e17..e59a0a8 100644
--- a/drivers/scsi/lpfc/lpfc_nvmet.c
+++ b/drivers/scsi/lpfc/lpfc_nvmet.c
@@ -1445,7 +1445,6 @@ lpfc_nvmet_prep_fcp_wqe(struct lpfc_hba *phba,
  
  	case NVMET_FCOP_RSP:

/* Words 0 - 2 */
-   sgel = >sg[0];
physaddr = rsp->rspdma;
wqe->fcp_trsp.bde.tus.f.bdeFlags = BUFF_TYPE_BDE_64;
wqe->fcp_trsp.bde.tus.f.bdeSize = rsp->rsplen;




[PATCH 16/20] lpfc: remove dead sli3 nvme code

2017-03-04 Thread jsmart2021
From: James Smart 

Remove nvme teardown calls that should not be there on sli3 devices

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc_init.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 10c89e8..77d8840 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -10459,12 +10459,7 @@ lpfc_pci_remove_one_s3(struct pci_dev *pdev)
fc_remove_host(shost);
scsi_remove_host(shost);
 
-   /* Perform ndlp cleanup on the physical port.  The nvme and nvmet
-* localports are destroyed after to cleanup all transport memory.
-*/
lpfc_cleanup(vport);
-   lpfc_nvmet_destroy_targetport(phba);
-   lpfc_nvme_destroy_localport(vport);
 
/*
 * Bring down the SLI Layer. This step disable all interrupts,
-- 
2.5.0



[PATCH 14/20] lpfc: Rename LPFC_MAX_EQ_DELAY to LPFC_MAX_EQ_DELAY_EQID_CNT

2017-03-04 Thread jsmart2021
From: James Smart 

Without apriori understanding of what the define is, the name gives
a very different impression of what it is (a max delay value
for an EQ).  Rename the define so it reflects what it is: the number
of EQ IDs that can be set in one instance of the MODIFY_EQ_DELAY
mbx command.

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc_attr.c | 3 ++-
 drivers/scsi/lpfc/lpfc_hw4.h  | 4 ++--
 drivers/scsi/lpfc/lpfc_init.c | 7 ++-
 drivers/scsi/lpfc/lpfc_sli.c  | 5 -
 4 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index b741dcb..fbd3a56 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -4457,7 +4457,8 @@ lpfc_fcp_imax_store(struct device *dev, struct 
device_attribute *attr,
return -EINVAL;
 
phba->cfg_fcp_imax = (uint32_t)val;
-   for (i = 0; i < phba->io_channel_irqs; i++)
+
+   for (i = 0; i < phba->io_channel_irqs; i += LPFC_MAX_EQ_DELAY_EQID_CNT)
lpfc_modify_hba_eq_delay(phba, i);
 
return strlen(buf);
diff --git a/drivers/scsi/lpfc/lpfc_hw4.h b/drivers/scsi/lpfc/lpfc_hw4.h
index cfdb068..1527770 100644
--- a/drivers/scsi/lpfc/lpfc_hw4.h
+++ b/drivers/scsi/lpfc/lpfc_hw4.h
@@ -1001,7 +1001,7 @@ struct eq_delay_info {
uint32_t phase;
uint32_t delay_multi;
 };
-#defineLPFC_MAX_EQ_DELAY   8
+#defineLPFC_MAX_EQ_DELAY_EQID_CNT  8
 
 struct sgl_page_pairs {
uint32_t sgl_pg0_addr_lo;
@@ -1070,7 +1070,7 @@ struct lpfc_mbx_modify_eq_delay {
union {
struct {
uint32_t num_eq;
-   struct eq_delay_info eq[LPFC_MAX_EQ_DELAY];
+   struct eq_delay_info eq[LPFC_MAX_EQ_DELAY_EQID_CNT];
} request;
struct {
uint32_t word0;
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index ecb8e1c..10c89e8 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -8769,12 +8769,9 @@ lpfc_sli4_queue_setup(struct lpfc_hba *phba)
}
}
 
-   /*
-* Configure EQ delay multipier for interrupt coalescing using
-* MODIFY_EQ_DELAY for all EQs created, LPFC_MAX_EQ_DELAY at a time.
-*/
-   for (qidx = 0; qidx < io_channel; qidx += LPFC_MAX_EQ_DELAY)
+   for (qidx = 0; qidx < io_channel; qidx += LPFC_MAX_EQ_DELAY_EQID_CNT)
lpfc_modify_hba_eq_delay(phba, qidx);
+
return 0;
 
 out_destroy:
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 8a606d0..618cdac 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -1,3 +1,4 @@
+
 /***
  * This file is part of the Emulex Linux Device Driver for *
  * Fibre Channel Host Bus Adapters.*
@@ -13874,6 +13875,8 @@ lpfc_dual_chute_pci_bar_map(struct lpfc_hba *phba, 
uint16_t pci_barset)
  * @startq: The starting FCP EQ to modify
  *
  * This function sends an MODIFY_EQ_DELAY mailbox command to the HBA.
+ * The command allows up to LPFC_MAX_EQ_DELAY_EQID_CNT EQ ID's to be
+ * updated in one mailbox command.
  *
  * The @phba struct is used to send mailbox command to HBA. The @startq
  * is used to get the starting FCP EQ to change.
@@ -13926,7 +13929,7 @@ lpfc_modify_hba_eq_delay(struct lpfc_hba *phba, 
uint32_t startq)
eq_delay->u.request.eq[cnt].phase = 0;
eq_delay->u.request.eq[cnt].delay_multi = dmult;
cnt++;
-   if (cnt >= LPFC_MAX_EQ_DELAY)
+   if (cnt >= LPFC_MAX_EQ_DELAY_EQID_CNT)
break;
}
eq_delay->u.request.num_eq = cnt;
-- 
2.5.0



[PATCH 08/20] lpfc: Fix IO submission if WQ is full

2017-03-04 Thread jsmart2021
From: James Smart 

For both initiator and target: if WQ is full, return -EBUSY.

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc_nvme.c  | 2 +-
 drivers/scsi/lpfc/lpfc_nvmet.c | 5 -
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c
index bf3ccc5..e1bf31e 100644
--- a/drivers/scsi/lpfc/lpfc_nvme.c
+++ b/drivers/scsi/lpfc/lpfc_nvme.c
@@ -1310,7 +1310,7 @@ lpfc_nvme_fcp_io_submit(struct nvme_fc_local_port 
*pnvme_lport,
 "sid: x%x did: x%x oxid: x%x\n",
 ret, vport->fc_myDID, ndlp->nlp_DID,
 lpfc_ncmd->cur_iocbq.sli4_xritag);
-   ret = -EINVAL;
+   ret = -EBUSY;
goto out_free_nvme_buf;
}
 
diff --git a/drivers/scsi/lpfc/lpfc_nvmet.c b/drivers/scsi/lpfc/lpfc_nvmet.c
index 6c2221a..735e2ba 100644
--- a/drivers/scsi/lpfc/lpfc_nvmet.c
+++ b/drivers/scsi/lpfc/lpfc_nvmet.c
@@ -571,6 +571,7 @@ lpfc_nvmet_xmt_fcp_op(struct nvmet_fc_target_port *tgtport,
lpfc_printf_log(phba, KERN_ERR, LOG_NVME_IOERR,
"6102 Bad state IO x%x aborted\n",
ctxp->oxid);
+   rc = -ENXIO;
goto aerr;
}
 
@@ -580,6 +581,7 @@ lpfc_nvmet_xmt_fcp_op(struct nvmet_fc_target_port *tgtport,
lpfc_printf_log(phba, KERN_ERR, LOG_NVME_IOERR,
"6152 FCP Drop IO x%x: Prep\n",
ctxp->oxid);
+   rc = -ENXIO;
goto aerr;
}
 
@@ -618,8 +620,9 @@ lpfc_nvmet_xmt_fcp_op(struct nvmet_fc_target_port *tgtport,
ctxp->wqeq->hba_wqidx = 0;
nvmewqeq->context2 = NULL;
nvmewqeq->context3 = NULL;
+   rc = -EBUSY;
 aerr:
-   return -ENXIO;
+   return rc;
 }
 
 static void
-- 
2.5.0



[PATCH 06/20] lpfc: Fix RCTL value on NVME LS request and response

2017-03-04 Thread jsmart2021
From: James Smart 

NVME LS requests and responses had wrong R_CTL values.
Use the FC4 ELS Request and Response defines (defines badly
named, they are FC4 LS's) instead of the base ELS values.

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc_nvme.c  | 2 +-
 drivers/scsi/lpfc/lpfc_nvmet.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c
index 609a908..6346d4d 100644
--- a/drivers/scsi/lpfc/lpfc_nvme.c
+++ b/drivers/scsi/lpfc/lpfc_nvme.c
@@ -316,7 +316,7 @@ lpfc_nvme_gen_req(struct lpfc_vport *vport, struct 
lpfc_dmabuf *bmp,
bf_set(wqe_dfctl, >gen_req.wge_ctl, 0);
bf_set(wqe_si, >gen_req.wge_ctl, 1);
bf_set(wqe_la, >gen_req.wge_ctl, 1);
-   bf_set(wqe_rctl, >gen_req.wge_ctl, FC_RCTL_DD_UNSOL_CTL);
+   bf_set(wqe_rctl, >gen_req.wge_ctl, FC_RCTL_ELS4_REQ);
bf_set(wqe_type, >gen_req.wge_ctl, FC_TYPE_NVME);
 
/* Word 6 */
diff --git a/drivers/scsi/lpfc/lpfc_nvmet.c b/drivers/scsi/lpfc/lpfc_nvmet.c
index e59a0a8..6c2221a 100644
--- a/drivers/scsi/lpfc/lpfc_nvmet.c
+++ b/drivers/scsi/lpfc/lpfc_nvmet.c
@@ -1114,7 +1114,7 @@ lpfc_nvmet_prep_ls_wqe(struct lpfc_hba *phba,
bf_set(wqe_dfctl, >xmit_sequence.wge_ctl, 0);
bf_set(wqe_ls, >xmit_sequence.wge_ctl, 1);
bf_set(wqe_la, >xmit_sequence.wge_ctl, 0);
-   bf_set(wqe_rctl, >xmit_sequence.wge_ctl, FC_RCTL_DD_SOL_CTL);
+   bf_set(wqe_rctl, >xmit_sequence.wge_ctl, FC_RCTL_ELS4_REP);
bf_set(wqe_type, >xmit_sequence.wge_ctl, FC_TYPE_NVME);
 
/* Word 6 */
-- 
2.5.0



[PATCH 20/20] lpfc: revise version number to 11.2.0.10

2017-03-04 Thread jsmart2021
From: James Smart 

Revise lpfc version number to 11.2.0.10

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc_version.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/lpfc/lpfc_version.h b/drivers/scsi/lpfc/lpfc_version.h
index 86c6c9b..d4e95e2 100644
--- a/drivers/scsi/lpfc/lpfc_version.h
+++ b/drivers/scsi/lpfc/lpfc_version.h
@@ -20,7 +20,7 @@
  * included with this package. *
  ***/
 
-#define LPFC_DRIVER_VERSION "11.2.0.7"
+#define LPFC_DRIVER_VERSION "11.2.0.10"
 #define LPFC_DRIVER_NAME   "lpfc"
 
 /* Used for SLI 2/3 */
-- 
2.5.0



[PATCH 09/20] lpfc: Fix nvme allocation bug on failed nvme_fc_register_localport

2017-03-04 Thread jsmart2021
From: James Smart 

nvme bufs get allocated even when the registration fails.
Move allocation into the rsgistration success path.

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc_nvme.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c
index e1bf31e..26cde7c 100644
--- a/drivers/scsi/lpfc/lpfc_nvme.c
+++ b/drivers/scsi/lpfc/lpfc_nvme.c
@@ -2164,10 +2164,10 @@ lpfc_nvme_create_localport(struct lpfc_vport *vport)
lport->vport = vport;
INIT_LIST_HEAD(>rport_list);
vport->nvmei_support = 1;
+   len  = lpfc_new_nvme_buf(vport, phba->sli4_hba.nvme_xri_max);
+   vport->phba->total_nvme_bufs += len;
}
 
-   len  = lpfc_new_nvme_buf(vport, phba->sli4_hba.nvme_xri_max);
-   vport->phba->total_nvme_bufs += len;
return ret;
 }
 
-- 
2.5.0



[PATCH 18/20] lpfc: code cleanups in NVME initiator base

2017-03-04 Thread jsmart2021
From: James Smart 

This patch addresses the smatch issues identified by Dan Carpenter
in http://www.spinics.net/lists/linux-scsi/msg105663.html

The issues are:

drivers/scsi/lpfc/lpfc_hbadisc.c:316 lpfc_dev_loss_tmo_handler()
warn: we tested 'vport->load_flag & 2' before and it was 'false'

Action: removed item from test

drivers/scsi/lpfc/lpfc_hbadisc.c:701 lpfc_work_done()
warn: test_bit() takes a bit number

Action: changed definition so bit number

drivers/scsi/lpfc/lpfc_hbadisc.c:2206 lpfc_mbx_cmpl_fcf_scan_read_fcf_rec()
error: uninitialized symbol 'vlan_id'.
drivers/scsi/lpfc/lpfc_hbadisc.c:2582 lpfc_mbx_cmpl_fcf_rr_read_fcf_rec()
error: uninitialized symbol 'vlan_id'.
drivers/scsi/lpfc/lpfc_hbadisc.c:2683 lpfc_mbx_cmpl_read_fcf_rec() error:
uninitialized symbol 'vlan_id'.

Action: initilized value

drivers/scsi/lpfc/lpfc_hbadisc.c:4025 lpfc_register_remote_port()
error: we previously assumed 'rdata' could be null (see line 4023)

Action: refactored check block

drivers/scsi/lpfc/lpfc_hbadisc.c:4613 lpfc_sli4_dequeue_nport_iocbs()
error: double unlock 'irq:'

Action: removed inner irq reference

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc.h |  2 +-
 drivers/scsi/lpfc/lpfc_hbadisc.c | 17 +
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index 763f32d..257bbdd 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -105,7 +105,7 @@ struct lpfc_sli2_slim;
 #define LPFC_MSIX_VECTORS  2
 
 /* lpfc wait event data ready flag */
-#define LPFC_DATA_READY(1<<0)
+#define LPFC_DATA_READY0   /* bit 0 */
 
 /* queue dump line buffer size */
 #define LPFC_LBUF_SZ   128
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index b940092..b0c4060 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -313,8 +313,7 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp)
 ndlp->nlp_state, ndlp->nlp_rpi);
}
 
-   if (!(vport->load_flag & FC_UNLOADING) &&
-   !(ndlp->nlp_flag & NLP_DELAY_TMO) &&
+   if (!(ndlp->nlp_flag & NLP_DELAY_TMO) &&
!(ndlp->nlp_flag & NLP_NPR_2B_DISC) &&
(ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) &&
(ndlp->nlp_state != NLP_STE_REG_LOGIN_ISSUE) &&
@@ -2175,7 +2174,7 @@ lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba 
*phba, LPFC_MBOXQ_t *mboxq)
uint32_t boot_flag, addr_mode;
uint16_t fcf_index, next_fcf_index;
struct lpfc_fcf_rec *fcf_rec = NULL;
-   uint16_t vlan_id;
+   uint16_t vlan_id = LPFC_FCOE_NULL_VID;
bool select_new_fcf;
int rc;
 
@@ -4022,9 +4021,11 @@ lpfc_register_remote_port(struct lpfc_vport *vport, 
struct lpfc_nodelist *ndlp)
rdata = rport->dd_data;
/* break the link before dropping the ref */
ndlp->rport = NULL;
-   if (rdata && rdata->pnode == ndlp)
-   lpfc_nlp_put(ndlp);
-   rdata->pnode = NULL;
+   if (rdata) {
+   if (rdata->pnode == ndlp)
+   lpfc_nlp_put(ndlp);
+   rdata->pnode = NULL;
+   }
/* drop reference for earlier registeration */
put_device(>dev);
}
@@ -4608,9 +4609,9 @@ lpfc_sli4_dequeue_nport_iocbs(struct lpfc_hba *phba,
pring = qp->pring;
if (!pring)
continue;
-   spin_lock_irq(>ring_lock);
+   spin_lock(>ring_lock);
__lpfc_dequeue_nport_iocbs(phba, ndlp, pring, dequeue_list);
-   spin_unlock_irq(>ring_lock);
+   spin_unlock(>ring_lock);
}
spin_unlock_irq(>hbalock);
 }
-- 
2.5.0



[PATCH 07/20] lpfc: Fix NVME CMD IU byte swapped word 1 problem

2017-03-04 Thread jsmart2021
From: James Smart 

Word 1 in NVME CMD IU appears byte swapped from value placed in WQE
Should be Big Endian value in WQE word 16

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc_nvme.c | 17 -
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c
index 6346d4d..bf3ccc5 100644
--- a/drivers/scsi/lpfc/lpfc_nvme.c
+++ b/drivers/scsi/lpfc/lpfc_nvme.c
@@ -620,15 +620,15 @@ lpfc_nvme_adj_fcp_sgls(struct lpfc_vport *vport,
 * Embed the payload in the last half of the WQE
 * WQE words 16-30 get the NVME CMD IU payload
 *
-* WQE Word 16 is already setup with flags
-* WQE words 17-19 get payload Words 2-4
+* WQE words 16-19 get payload Words 1-4
 * WQE words 20-21 get payload Words 6-7
 * WQE words 22-29 get payload Words 16-23
 */
-   wptr = >words[17];  /* WQE ptr */
+   wptr = >words[16];  /* WQE ptr */
dptr = (uint32_t *)nCmd->cmdaddr;  /* payload ptr */
-   dptr += 2;  /* Skip Words 0-1 in payload */
+   dptr++; /* Skip Word 0 in payload */
 
+   *wptr++ = *dptr++;  /* Word 1 */
*wptr++ = *dptr++;  /* Word 2 */
*wptr++ = *dptr++;  /* Word 3 */
*wptr++ = *dptr++;  /* Word 4 */
@@ -978,9 +978,6 @@ lpfc_nvme_prep_io_cmd(struct lpfc_vport *vport,
bf_set(wqe_cmd_type, >generic.wqe_com,
   NVME_WRITE_CMD);
 
-   /* Word 16 */
-   wqe->words[16] = LPFC_NVME_EMBED_WRITE;
-
phba->fc4NvmeOutputRequests++;
} else {
/* Word 7 */
@@ -1002,9 +999,6 @@ lpfc_nvme_prep_io_cmd(struct lpfc_vport *vport,
bf_set(wqe_cmd_type, >generic.wqe_com,
   NVME_READ_CMD);
 
-   /* Word 16 */
-   wqe->words[16] = LPFC_NVME_EMBED_READ;
-
phba->fc4NvmeInputRequests++;
}
} else {
@@ -1026,9 +1020,6 @@ lpfc_nvme_prep_io_cmd(struct lpfc_vport *vport,
/* Word 11 */
bf_set(wqe_cmd_type, >generic.wqe_com, NVME_READ_CMD);
 
-   /* Word 16 */
-   wqe->words[16] = LPFC_NVME_EMBED_CMD;
-
phba->fc4NvmeControlRequests++;
}
/*
-- 
2.5.0



[PATCH 11/20] lpfc: Fix eh_deadline setting for sli3 adapters.

2017-03-04 Thread jsmart2021
From: James Smart 

A previous change unilaterally removed the hba reset entry point
from the sli3 host template. This was done to allow tape devices
being used for back up from being removed. Why was this done ?
When there was non-responding device on the fabric, the error
escalation policy would escalate to the reset handler. When the
reset handler was called, it would reset the adapter, dropping
link, thus logging out and terminating all i/o's - on any target.
If there was a tape device on the same adapter that wasn't in
error, it would kill the tape i/o's, effectively killing the
tape device state.  With the reset point removed, the adapter
reset avoided the fabric logout, allowing the other devices to
continue to operate unaffected. A hack - yes. Hint: we really
need a transport I_T nexus reset callback added to the eh process
(in between the SCSI target reset and hba reset points), so a
fc logout could occur to the one bad target only and stop the error
escalation process.

This patch commonizes the approach so it can be used for sli3 and sli4
adapters, but mandates the admin, via module parameter, specifically
identify which adapters the resets are to be removed for. Additionally,
bus_reset, which sends Target Reset TMFs to all targets, is also removed
from the template as it too has the same effect as the adapter reset.

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc.h  |  1 +
 drivers/scsi/lpfc/lpfc_attr.c |  6 +
 drivers/scsi/lpfc/lpfc_crtn.h |  4 ++-
 drivers/scsi/lpfc/lpfc_init.c | 61 ---
 drivers/scsi/lpfc/lpfc_scsi.c |  3 +--
 5 files changed, 69 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index de6cd57..763f32d 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -99,6 +99,7 @@ struct lpfc_sli2_slim;
 #define FC_MAX_ADPTMSG 64
 
 #define MAX_HBAEVT 32
+#define MAX_HBAS_NO_RESET 16
 
 /* Number of MSI-X vectors the driver uses */
 #define LPFC_MSIX_VECTORS  2
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 4114cf4..b741dcb 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -3010,6 +3010,12 @@ MODULE_PARM_DESC(lpfc_poll, "FCP ring polling mode 
control:"
 static DEVICE_ATTR(lpfc_poll, S_IRUGO | S_IWUSR,
   lpfc_poll_show, lpfc_poll_store);
 
+int lpfc_no_hba_reset_cnt;
+unsigned long lpfc_no_hba_reset[MAX_HBAS_NO_RESET] = {
+   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+module_param_array(lpfc_no_hba_reset, ulong, _no_hba_reset_cnt, 0444);
+MODULE_PARM_DESC(lpfc_no_hba_reset, "WWPN of HBAs that should not be reset");
+
 LPFC_ATTR(sli_mode, 0, 0, 3,
"SLI mode selector:"
" 0 - auto (SLI-3 if supported),"
diff --git a/drivers/scsi/lpfc/lpfc_crtn.h b/drivers/scsi/lpfc/lpfc_crtn.h
index 843dd73..54e6ac4 100644
--- a/drivers/scsi/lpfc/lpfc_crtn.h
+++ b/drivers/scsi/lpfc/lpfc_crtn.h
@@ -384,7 +384,7 @@ void lpfc_free_sysfs_attr(struct lpfc_vport *);
 extern struct device_attribute *lpfc_hba_attrs[];
 extern struct device_attribute *lpfc_vport_attrs[];
 extern struct scsi_host_template lpfc_template;
-extern struct scsi_host_template lpfc_template_s3;
+extern struct scsi_host_template lpfc_template_no_hr;
 extern struct scsi_host_template lpfc_template_nvme;
 extern struct scsi_host_template lpfc_vport_template;
 extern struct fc_function_template lpfc_transport_functions;
@@ -554,3 +554,5 @@ void lpfc_nvme_abort_fcreq_cmpl(struct lpfc_hba *phba,
struct lpfc_wcqe_complete *abts_cmpl);
 extern int lpfc_enable_nvmet_cnt;
 extern unsigned long long lpfc_enable_nvmet[];
+extern int lpfc_no_hba_reset_cnt;
+extern unsigned long lpfc_no_hba_reset[];
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index b754887..ecb8e1c 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -3555,6 +3555,44 @@ lpfc_sli4_scsi_sgl_update(struct lpfc_hba *phba)
return rc;
 }
 
+static uint64_t
+lpfc_get_wwpn(struct lpfc_hba *phba)
+{
+   uint64_t wwn;
+   int rc;
+   LPFC_MBOXQ_t *mboxq;
+   MAILBOX_t *mb;
+
+
+   mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool,
+   GFP_KERNEL);
+   if (!mboxq)
+   return (uint64_t)-1;
+
+   /* First get WWN of HBA instance */
+   lpfc_read_nv(phba, mboxq);
+   rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL);
+   if (rc != MBX_SUCCESS) {
+   lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
+   "6019 Mailbox failed , mbxCmd x%x "
+   "READ_NV, mbxStatus x%x\n",
+   bf_get(lpfc_mqe_command, >u.mqe),
+   bf_get(lpfc_mqe_status, >u.mqe));

[PATCH 12/20] lpfc: add transport eh_timed_out reference

2017-03-04 Thread jsmart2021
From: James Smart 

Christoph's prior patch missed the template for the sli3 adapters,
which is now the "no host reset" template. Add the transport
eh_timed_out handler to the no host reset template

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc_scsi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index bcfd6d6..54fd0c8 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -5959,6 +5959,7 @@ struct scsi_host_template lpfc_template_no_hr = {
.proc_name  = LPFC_DRIVER_NAME,
.info   = lpfc_info,
.queuecommand   = lpfc_queuecommand,
+   .eh_timed_out   = fc_eh_timed_out,
.eh_abort_handler   = lpfc_abort_handler,
.eh_device_reset_handler = lpfc_device_reset_handler,
.eh_target_reset_handler = lpfc_target_reset_handler,
-- 
2.5.0



[PATCH 04/20] scsi: lpfc: fix missing spin_unlock on sql_list_lock

2017-03-04 Thread jsmart2021
From: James Smart 

From: Colin Ian King 

In the case where sglq is null, the current code just returns without
unlocking the spinlock sql_list_lock. Fix this by breaking out of the
while loop and the exit path will then unlock and return NULL as was
the original intention.

Detected by CoverityScan, CID#1411635 ("Missing unlock")

Signed-off-by: Colin Ian King 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc_sli.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 562a528..7389c13 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -952,7 +952,7 @@ __lpfc_sli_get_els_sglq(struct lpfc_hba *phba, struct 
lpfc_iocbq *piocbq)
start_sglq = sglq;
while (!found) {
if (!sglq)
-   return NULL;
+   break;
if (ndlp && ndlp->active_rrqs_xri_bitmap &&
test_bit(sglq->sli4_lxritag,
ndlp->active_rrqs_xri_bitmap)) {
-- 
2.5.0



[PATCH 15/20] lpfc: correct double print

2017-03-04 Thread jsmart2021
From: James Smart 

Correct a merge error that had debug data printed twice for the
same element

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc_debugfs.c | 22 --
 1 file changed, 22 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
index 9f4798e..913eed82 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.c
+++ b/drivers/scsi/lpfc/lpfc_debugfs.c
@@ -3653,17 +3653,6 @@ lpfc_idiag_queacc_write(struct file *file, const char 
__user *buf,
idiag.ptr_private = phba->sli4_hba.nvmels_cq;
goto pass_check;
}
-   /* NVME LS complete queue */
-   if (phba->sli4_hba.nvmels_cq &&
-   phba->sli4_hba.nvmels_cq->queue_id == queid) {
-   /* Sanity check */
-   rc = lpfc_idiag_que_param_check(
-   phba->sli4_hba.nvmels_cq, index, count);
-   if (rc)
-   goto error_out;
-   idiag.ptr_private = phba->sli4_hba.nvmels_cq;
-   goto pass_check;
-   }
/* FCP complete queue */
if (phba->sli4_hba.fcp_cq) {
for (qidx = 0; qidx < phba->cfg_fcp_io_channel;
@@ -3738,17 +3727,6 @@ lpfc_idiag_queacc_write(struct file *file, const char 
__user *buf,
idiag.ptr_private = phba->sli4_hba.nvmels_wq;
goto pass_check;
}
-   /* NVME LS work queue */
-   if (phba->sli4_hba.nvmels_wq &&
-   phba->sli4_hba.nvmels_wq->queue_id == queid) {
-   /* Sanity check */
-   rc = lpfc_idiag_que_param_check(
-   phba->sli4_hba.nvmels_wq, index, count);
-   if (rc)
-   goto error_out;
-   idiag.ptr_private = phba->sli4_hba.nvmels_wq;
-   goto pass_check;
-   }
/* FCP work queue */
if (phba->sli4_hba.fcp_wq) {
for (qidx = 0; qidx < phba->cfg_fcp_io_channel;
-- 
2.5.0



[PATCH 13/20] lpfc: Rework lpfc Kconfig for NVME options

2017-03-04 Thread jsmart2021
From: James Smart 

Reworked Kconfig so that lfpc only requires the scsi stack.
NVME Initiator and NVME Target support can be enabled if
the other NVMe subsystems have been enabled.

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/Kconfig   | 19 ---
 drivers/scsi/lpfc/lpfc_nvme.c  | 18 +++---
 drivers/scsi/lpfc/lpfc_nvmet.c | 10 ++
 3 files changed, 41 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 230043c..4bf55b5 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -1241,19 +1241,32 @@ config SCSI_LPFC
tristate "Emulex LightPulse Fibre Channel Support"
depends on PCI && SCSI
depends on SCSI_FC_ATTRS
-   depends on NVME_FC && NVME_TARGET_FC
select CRC_T10DIF
-   help
+   ---help---
   This lpfc driver supports the Emulex LightPulse
   Family of Fibre Channel PCI host adapters.
 
 config SCSI_LPFC_DEBUG_FS
bool "Emulex LightPulse Fibre Channel debugfs Support"
depends on SCSI_LPFC && DEBUG_FS
-   help
+   ---help---
  This makes debugging information from the lpfc driver
  available via the debugfs filesystem.
 
+config LPFC_NVME_INITIATOR
+   bool "Emulex LightPulse Fibre Channel NVME Initiator Support"
+   depends on SCSI_LPFC && NVME_FC
+   ---help---
+ This enables NVME Initiator support in the Emulex lpfc driver.
+
+config LPFC_NVME_TARGET
+   bool "Emulex LightPulse Fibre Channel NVME Initiator Support"
+   depends on SCSI_LPFC && NVME_TARGET_FC
+   ---help---
+ This enables NVME Target support in the Emulex lpfc driver.
+ Target enablement must still be enabled on a per adapter
+ basis by module parameters.
+
 config SCSI_SIM710
tristate "Simple 53c710 SCSI support (Compaq, NCR machines)"
depends on (EISA || MCA) && SCSI
diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c
index b9012fe..0a4c190 100644
--- a/drivers/scsi/lpfc/lpfc_nvme.c
+++ b/drivers/scsi/lpfc/lpfc_nvme.c
@@ -2127,11 +2127,12 @@ lpfc_release_nvme_buf(struct lpfc_hba *phba, struct 
lpfc_nvme_buf *lpfc_ncmd)
 int
 lpfc_nvme_create_localport(struct lpfc_vport *vport)
 {
+   int ret = 0;
struct lpfc_hba  *phba = vport->phba;
struct nvme_fc_port_info nfcp_info;
struct nvme_fc_local_port *localport;
struct lpfc_nvme_lport *lport;
-   int len, ret = 0;
+   int len;
 
/* Initialize this localport instance.  The vport wwn usage ensures
 * that NPIV is accounted for.
@@ -2148,8 +2149,12 @@ lpfc_nvme_create_localport(struct lpfc_vport *vport)
/* localport is allocated from the stack, but the registration
 * call allocates heap memory as well as the private area.
 */
+#ifdef CONFIG_LPFC_NVME_INITIATOR
ret = nvme_fc_register_localport(_info, _nvme_template,
 >phba->pcidev->dev, );
+#else
+   ret = -ENOMEM;
+#endif
if (!ret) {
lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME | LOG_NVME_DISC,
 "6005 Successfully registered local "
@@ -2185,6 +2190,7 @@ lpfc_nvme_create_localport(struct lpfc_vport *vport)
 void
 lpfc_nvme_destroy_localport(struct lpfc_vport *vport)
 {
+#ifdef CONFIG_LPFC_NVME_INITIATOR
struct nvme_fc_local_port *localport;
struct lpfc_nvme_lport *lport;
struct lpfc_nvme_rport *rport = NULL, *rport_next = NULL;
@@ -2200,7 +2206,6 @@ lpfc_nvme_destroy_localport(struct lpfc_vport *vport)
lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME,
 "6011 Destroying NVME localport %p\n",
 localport);
-
list_for_each_entry_safe(rport, rport_next, >rport_list, list) {
/* The last node ref has to get released now before the rport
 * private memory area is released by the transport.
@@ -2214,6 +2219,7 @@ lpfc_nvme_destroy_localport(struct lpfc_vport *vport)
 "6008 rport fail destroy %x\n", ret);
wait_for_completion_timeout(>rport_unreg_done, 5);
}
+
/* lport's rport list is clear.  Unregister
 * lport and release resources.
 */
@@ -2237,6 +2243,7 @@ lpfc_nvme_destroy_localport(struct lpfc_vport *vport)
 "Failed, status x%x\n",
 ret);
}
+#endif
 }
 
 void
@@ -2267,6 +2274,7 @@ lpfc_nvme_update_localport(struct lpfc_vport *vport)
 int
 lpfc_nvme_register_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
 {
+#ifdef CONFIG_LPFC_NVME_INITIATOR
int ret = 0;
struct nvme_fc_local_port *localport;
struct lpfc_nvme_lport *lport;
@@ -2340,7 +2348,6 @@ lpfc_nvme_register_port(struct 

[PATCH 19/20] lpfc: code cleanups in NVME initiator discovery

2017-03-04 Thread jsmart2021
From: James Smart 

This patch addresses the smatch issues identified by Dan Carpenter
in http://www.spinics.net/lists/linux-scsi/msg105665.html

The issues are:

drivers/scsi/lpfc/lpfc_ct.c:943 lpfc_cmpl_ct_cmd_gft_id()
error: we previously assumed 'ndlp' could be null (see line 928)

Action: moved under if check

drivers/scsi/lpfc/lpfc_nvmet.c:1694 lpfc_nvmet_unsol_issue_abort()
error: we previously assumed 'ndlp' could be null (see line 1690)

Action: conditionalized arg in printf stmt

drivers/scsi/lpfc/lpfc_nvmet.c:1792 lpfc_nvmet_sol_fcp_issue_abort()
error: we previously assumed 'ndlp' could be null (see line 1788)

Action: conditionalized arg in printf stmt

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc_ct.c| 2 +-
 drivers/scsi/lpfc/lpfc_nvmet.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
index c22bb3f..d3e9af9 100644
--- a/drivers/scsi/lpfc/lpfc_ct.c
+++ b/drivers/scsi/lpfc/lpfc_ct.c
@@ -939,8 +939,8 @@ lpfc_cmpl_ct_cmd_gft_id(struct lpfc_hba *phba, struct 
lpfc_iocbq *cmdiocb,
 "FC4 x%08x, Data: x%08x x%08x\n",
 ndlp, did, ndlp->nlp_fc4_type,
 FC_TYPE_FCP, FC_TYPE_NVME);
+   ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
}
-   ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
lpfc_nlp_set_state(vport, ndlp, NLP_STE_PRLI_ISSUE);
lpfc_issue_els_prli(vport, ndlp, 0);
} else
diff --git a/drivers/scsi/lpfc/lpfc_nvmet.c b/drivers/scsi/lpfc/lpfc_nvmet.c
index a69ca6e..b7739a5 100644
--- a/drivers/scsi/lpfc/lpfc_nvmet.c
+++ b/drivers/scsi/lpfc/lpfc_nvmet.c
@@ -1720,7 +1720,7 @@ lpfc_nvmet_unsol_issue_abort(struct lpfc_hba *phba,
atomic_inc(>xmt_abort_rsp_error);
lpfc_printf_log(phba, KERN_WARNING, LOG_NVME_ABTS,
"6134 Drop ABTS - wrong NDLP state x%x.\n",
-   ndlp->nlp_state);
+   (ndlp) ? ndlp->nlp_state : NLP_STE_MAX_STATE);
 
/* No failure to an ABTS request. */
return 0;
@@ -1818,7 +1818,7 @@ lpfc_nvmet_sol_fcp_issue_abort(struct lpfc_hba *phba,
atomic_inc(>xmt_abort_rsp_error);
lpfc_printf_log(phba, KERN_WARNING, LOG_NVME_ABTS,
"6160 Drop ABTS - wrong NDLP state x%x.\n",
-   ndlp->nlp_state);
+   (ndlp) ? ndlp->nlp_state : NLP_STE_MAX_STATE);
 
/* No failure to an ABTS request. */
return 0;
-- 
2.5.0



[PATCH 17/20] lpfc: correct rdp diag portnames

2017-03-04 Thread jsmart2021
From: James Smart 

NVME merge reverted diag port names to the physical port.
They should be the vport.

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc_els.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index d260a13..d9c61d0 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -5177,15 +5177,15 @@ lpfc_rdp_res_speed(struct fc_rdp_port_speed_desc *desc, 
struct lpfc_hba *phba)
 
 static uint32_t
 lpfc_rdp_res_diag_port_names(struct fc_rdp_port_name_desc *desc,
-   struct lpfc_hba *phba)
+   struct lpfc_vport *vport)
 {
 
desc->tag = cpu_to_be32(RDP_PORT_NAMES_DESC_TAG);
 
-   memcpy(desc->port_names.wwnn, phba->wwnn,
+   memcpy(desc->port_names.wwnn, >fc_nodename,
sizeof(desc->port_names.wwnn));
 
-   memcpy(desc->port_names.wwpn, phba->wwpn,
+   memcpy(desc->port_names.wwpn, >fc_portname,
sizeof(desc->port_names.wwpn));
 
desc->length = cpu_to_be32(sizeof(desc->port_names));
@@ -5279,7 +5279,7 @@ lpfc_els_rdp_cmpl(struct lpfc_hba *phba, struct 
lpfc_rdp_context *rdp_context,
len += lpfc_rdp_res_link_error((struct fc_rdp_link_error_status_desc *)
   (len + pcmd), _context->link_stat);
len += lpfc_rdp_res_diag_port_names((struct fc_rdp_port_name_desc *)
-(len + pcmd), phba);
+(len + pcmd), vport);
len += lpfc_rdp_res_attach_port_names((struct fc_rdp_port_name_desc *)
(len + pcmd), vport, ndlp);
len += lpfc_rdp_res_fec_desc((struct fc_fec_rdp_desc *)(len + pcmd),
-- 
2.5.0



[PATCH 00/20] lpfc: Update lpfc to revision 11.2.0.10

2017-03-04 Thread jsmart2021
From: James Smart 

This set of patches are mainly cleanups and fixes to the large
nvme post that was recently integrated. It includes a patch to
break the mandate for both NVME and SCSI subystems.

James Smart (20):
  scsi: lpfc: remove redundant assignment of sgel
  scsi: lpfc: sanity check hrq is null before dereferencing it
  scsi: lpfc: don't dereference dma_buf->iocbq before null check
  scsi: lpfc: fix missing spin_unlock on sql_list_lock
  lpfc: Fix crash during Hardware error recovery on SLI3 adapters
  lpfc: Fix RCTL value on NVME LS request and response
  lpfc: Fix NVME CMD IU byte swapped word 1 problem
  lpfc: Fix IO submission if WQ is full
  lpfc: Fix nvme allocation bug on failed nvme_fc_register_localport
  lpfc: add NVME exchange aborts
  lpfc: Fix eh_deadline setting for sli3 adapters.
  lpfc: add transport eh_timed_out reference
  lpfc: Rework lpfc Kconfig for NVME options
  lpfc: Rename LPFC_MAX_EQ_DELAY to LPFC_MAX_EQ_DELAY_EQID_CNT
  lpfc: correct double print
  lpfc: remove dead sli3 nvme code
  lpfc: correct rdp diag portnames
  lpfc: code cleanups in NVME initiator base
  lpfc: code cleanups in NVME initiator discovery
  lpfc: revise version number to 11.2.0.10

 drivers/scsi/Kconfig |  19 +--
 drivers/scsi/lpfc/lpfc.h |   4 +-
 drivers/scsi/lpfc/lpfc_attr.c|   9 +++-
 drivers/scsi/lpfc/lpfc_crtn.h|   4 +-
 drivers/scsi/lpfc/lpfc_ct.c  |   2 +-
 drivers/scsi/lpfc/lpfc_debugfs.c |  22 
 drivers/scsi/lpfc/lpfc_els.c |  22 +---
 drivers/scsi/lpfc/lpfc_hbadisc.c |  19 ---
 drivers/scsi/lpfc/lpfc_hw4.h |   4 +-
 drivers/scsi/lpfc/lpfc_init.c|  80 -
 drivers/scsi/lpfc/lpfc_mem.c |   2 +-
 drivers/scsi/lpfc/lpfc_nvme.c| 107 ++-
 drivers/scsi/lpfc/lpfc_nvme.h|   1 +
 drivers/scsi/lpfc/lpfc_nvmet.c   |  43 +---
 drivers/scsi/lpfc/lpfc_scsi.c|   4 +-
 drivers/scsi/lpfc/lpfc_sli.c |  68 +
 drivers/scsi/lpfc/lpfc_sli4.h|   6 +++
 drivers/scsi/lpfc/lpfc_version.h |   2 +-
 18 files changed, 312 insertions(+), 106 deletions(-)

-- 
2.5.0



[PATCH 10/20] lpfc: add NVME exchange aborts

2017-03-04 Thread jsmart2021
From: James Smart 

previous code did little more than log a message.

This patch adds abort path support, modeled after the SCSI code paths.
Currently addresses only the initiator path. Target path under
development, but stubbed out.

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc.h |  1 +
 drivers/scsi/lpfc/lpfc_hbadisc.c |  2 ++
 drivers/scsi/lpfc/lpfc_init.c|  7 +
 drivers/scsi/lpfc/lpfc_nvme.c| 64 
 drivers/scsi/lpfc/lpfc_nvme.h|  1 +
 drivers/scsi/lpfc/lpfc_nvmet.c   | 21 +++--
 drivers/scsi/lpfc/lpfc_sli.c | 51 ++--
 drivers/scsi/lpfc/lpfc_sli4.h|  6 
 8 files changed, 143 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index 0bba2e3..de6cd57 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -692,6 +692,7 @@ struct lpfc_hba {
 * capability
 */
 #define HBA_NVME_IOQ_FLUSH  0x8 /* NVME IO queues flushed. */
+#define NVME_XRI_ABORT_EVENT   0x10
 
uint32_t fcp_ring_in_use; /* When polling test if intr-hndlr active*/
struct lpfc_dmabuf slim2p;
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index 194a14d..b940092 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -641,6 +641,8 @@ lpfc_work_done(struct lpfc_hba *phba)
lpfc_handle_rrq_active(phba);
if (phba->hba_flag & FCP_XRI_ABORT_EVENT)
lpfc_sli4_fcp_xri_abort_event_proc(phba);
+   if (phba->hba_flag & NVME_XRI_ABORT_EVENT)
+   lpfc_sli4_nvme_xri_abort_event_proc(phba);
if (phba->hba_flag & ELS_XRI_ABORT_EVENT)
lpfc_sli4_els_xri_abort_event_proc(phba);
if (phba->hba_flag & ASYNC_EVENT)
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 0ee429d..b754887 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -5736,6 +5736,8 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba)
/* Initialize the Abort nvme buffer list used by driver */
spin_lock_init(>sli4_hba.abts_nvme_buf_list_lock);
INIT_LIST_HEAD(>sli4_hba.lpfc_abts_nvme_buf_list);
+   /* Fast-path XRI aborted CQ Event work queue list */
+   INIT_LIST_HEAD(>sli4_hba.sp_nvme_xri_aborted_work_queue);
}
 
/* This abort list used by worker thread */
@@ -8973,6 +8975,11 @@ lpfc_sli4_cq_event_release_all(struct lpfc_hba *phba)
/* Pending ELS XRI abort events */
list_splice_init(>sli4_hba.sp_els_xri_aborted_work_queue,
 );
+   if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) {
+   /* Pending NVME XRI abort events */
+   list_splice_init(>sli4_hba.sp_nvme_xri_aborted_work_queue,
+);
+   }
/* Pending asynnc events */
list_splice_init(>sli4_hba.sp_asynce_work_queue,
 );
diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c
index 26cde7c..b9012fe 100644
--- a/drivers/scsi/lpfc/lpfc_nvme.c
+++ b/drivers/scsi/lpfc/lpfc_nvme.c
@@ -1277,6 +1277,7 @@ lpfc_nvme_fcp_io_submit(struct nvme_fc_local_port 
*pnvme_lport,
pnvme_fcreq->private = (void *)lpfc_ncmd;
lpfc_ncmd->nvmeCmd = pnvme_fcreq;
lpfc_ncmd->nrport = rport;
+   lpfc_ncmd->ndlp = ndlp;
lpfc_ncmd->start_time = jiffies;
 
lpfc_nvme_prep_io_cmd(vport, lpfc_ncmd, ndlp);
@@ -1812,10 +1813,10 @@ lpfc_post_nvme_sgl_list(struct lpfc_hba *phba,
pdma_phys_sgl1, cur_xritag);
if (status) {
/* failure, put on abort nvme list */
-   lpfc_ncmd->exch_busy = 1;
+   lpfc_ncmd->flags |= LPFC_SBUF_XBUSY;
} else {
/* success, put on NVME buffer list */
-   lpfc_ncmd->exch_busy = 0;
+   lpfc_ncmd->flags &= ~LPFC_SBUF_XBUSY;
lpfc_ncmd->status = IOSTAT_SUCCESS;
num_posted++;
}
@@ -1845,10 +1846,10 @@ lpfc_post_nvme_sgl_list(struct lpfc_hba *phba,
 struct lpfc_nvme_buf, list);
if (status) {
/* failure, put on abort nvme list */
-   lpfc_ncmd->exch_busy = 1;

[PATCH 02/20] scsi: lpfc: sanity check hrq is null before dereferencing it

2017-03-04 Thread jsmart2021
From: James Smart 

From: Colin Ian King 

The sanity check for hrq should be moved to before the deference
of hrq to ensure we don't perform a null pointer deference.

Detected by CoverityScan, CID#1411650 ("Dereference before null check")

Signed-off-by: Colin Ian King 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc_sli.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index d8d8693..562a528 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -15185,17 +15185,17 @@ lpfc_mrq_create(struct lpfc_hba *phba, struct 
lpfc_queue **hrqp,
drq = drqp[idx];
cq  = cqp[idx];
 
-   if (hrq->entry_count != drq->entry_count) {
-   status = -EINVAL;
-   goto out;
-   }
-
/* sanity check on queue memory */
if (!hrq || !drq || !cq) {
status = -ENODEV;
goto out;
}
 
+   if (hrq->entry_count != drq->entry_count) {
+   status = -EINVAL;
+   goto out;
+   }
+
if (idx == 0) {
bf_set(lpfc_mbx_rq_create_num_pages,
   _create->u.request,
-- 
2.5.0



[PATCH 03/20] scsi: lpfc: don't dereference dma_buf->iocbq before null check

2017-03-04 Thread jsmart2021
From: James Smart 

From: Colin Ian King 

dma_buf->iocbq is being dereferenced immediately before it is
being null checked, so we have a potential null pointer dereference
bug.  Fix this by only dereferencing it only once we have passed
a null check on the pointer.

Detected by CoverityScan, CID#1411652 ("Dereference before null check")

Signed-off-by: Colin Ian King 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc_mem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/lpfc/lpfc_mem.c b/drivers/scsi/lpfc/lpfc_mem.c
index c61d8d6..5986c79 100644
--- a/drivers/scsi/lpfc/lpfc_mem.c
+++ b/drivers/scsi/lpfc/lpfc_mem.c
@@ -646,7 +646,6 @@ lpfc_sli4_nvmet_alloc(struct lpfc_hba *phba)
}
 
dma_buf->iocbq = lpfc_sli_get_iocbq(phba);
-   dma_buf->iocbq->iocb_flag = LPFC_IO_NVMET;
if (!dma_buf->iocbq) {
kfree(dma_buf->context);
pci_pool_free(phba->lpfc_drb_pool, dma_buf->dbuf.virt,
@@ -658,6 +657,7 @@ lpfc_sli4_nvmet_alloc(struct lpfc_hba *phba)
"2621 Ran out of nvmet iocb/WQEs\n");
return NULL;
}
+   dma_buf->iocbq->iocb_flag = LPFC_IO_NVMET;
nvmewqe = dma_buf->iocbq;
wqe = (union lpfc_wqe128 *)>wqe;
/* Initialize WQE */
-- 
2.5.0



[PATCH 05/20] lpfc: Fix crash during Hardware error recovery on SLI3 adapters

2017-03-04 Thread jsmart2021
From: James Smart 

if REG_VPI fails, the driver was incorrectly issuing INIT_VFI
(a SLI4 command) on a SLI3 adapter.

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc_els.c | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 2d26440..d260a13 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -8371,11 +8371,17 @@ lpfc_cmpl_reg_new_vport(struct lpfc_hba *phba, 
LPFC_MBOXQ_t *pmb)
spin_lock_irq(shost->host_lock);
vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;
spin_unlock_irq(shost->host_lock);
-   if (vport->port_type == LPFC_PHYSICAL_PORT
-   && !(vport->fc_flag & FC_LOGO_RCVD_DID_CHNG))
-   lpfc_issue_init_vfi(vport);
-   else
+   if (mb->mbxStatus == MBX_NOT_FINISHED)
+   break;
+   if ((vport->port_type == LPFC_PHYSICAL_PORT) &&
+   !(vport->fc_flag & FC_LOGO_RCVD_DID_CHNG)) {
+   if (phba->sli_rev == LPFC_SLI_REV4)
+   lpfc_issue_init_vfi(vport);
+   else
+   lpfc_initial_flogi(vport);
+   } else {
lpfc_initial_fdisc(vport);
+   }
break;
}
} else {
-- 
2.5.0



[PATCH 01/20] scsi: lpfc: remove redundant assignment of sgel

2017-03-04 Thread jsmart2021
From: James Smart 

From: Colin Ian King 

In the NVMET_FCOP_RSP case, sgel is assigned but never used and
hence is redundant and can be removed.

Detected by CoverityScan, CID#1411658 ("Unused value")

Signed-off-by: Colin Ian King 
Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/lpfc_nvmet.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/scsi/lpfc/lpfc_nvmet.c b/drivers/scsi/lpfc/lpfc_nvmet.c
index c421e17..e59a0a8 100644
--- a/drivers/scsi/lpfc/lpfc_nvmet.c
+++ b/drivers/scsi/lpfc/lpfc_nvmet.c
@@ -1445,7 +1445,6 @@ lpfc_nvmet_prep_fcp_wqe(struct lpfc_hba *phba,
 
case NVMET_FCOP_RSP:
/* Words 0 - 2 */
-   sgel = >sg[0];
physaddr = rsp->rspdma;
wqe->fcp_trsp.bde.tus.f.bdeFlags = BUFF_TYPE_BDE_64;
wqe->fcp_trsp.bde.tus.f.bdeSize = rsp->rsplen;
-- 
2.5.0



Re: [RFC] hv_storvsc: error handling.

2017-03-04 Thread Hannes Reinecke

On 03/04/2017 01:50 AM, Stephen Hemminger wrote:

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 = >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],

I really do wonder; according to the comments above the wrong error 
handling really only affects inquiry VPD page 0x80 and MODE_SENSE page 
0x1c. So why do we need to blank out _every_ inquiry?
Wouldn't it far better to check _what_ goes wrong when asking for page 
0x80, and fix up things correctly?


Cheers,

Hannes
--
Dr. Hannes Reinecke   zSeries & Storage
h...@suse.de  +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)


[PATCH] scsi: qedf: Fix defective logging format and argument mismatches

2017-03-04 Thread Joe Perches
Add __printf compiler verification of format and arguments.
Fix fallout.

Signed-off-by: Joe Perches 
---
 drivers/scsi/qedf/qedf_dbg.h | 13 -
 drivers/scsi/qedf/qedf_fip.c |  2 +-
 drivers/scsi/qedf/qedf_io.c  |  4 ++--
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/qedf/qedf_dbg.h b/drivers/scsi/qedf/qedf_dbg.h
index 23bd70628a2f..7d173f48a81e 100644
--- a/drivers/scsi/qedf/qedf_dbg.h
+++ b/drivers/scsi/qedf/qedf_dbg.h
@@ -81,14 +81,17 @@ struct qedf_dbg_ctx {
 #define QEDF_INFO(pdev, level, fmt, ...)   \
qedf_dbg_info(pdev, __func__, __LINE__, level, fmt, \
  ## __VA_ARGS__)
-
-extern void qedf_dbg_err(struct qedf_dbg_ctx *qedf, const char *func, u32 line,
+__printf(4, 5)
+void qedf_dbg_err(struct qedf_dbg_ctx *qedf, const char *func, u32 line,
  const char *fmt, ...);
-extern void qedf_dbg_warn(struct qedf_dbg_ctx *qedf, const char *func, u32 
line,
+__printf(4, 5)
+void qedf_dbg_warn(struct qedf_dbg_ctx *qedf, const char *func, u32 line,
   const char *, ...);
-extern void qedf_dbg_notice(struct qedf_dbg_ctx *qedf, const char *func,
+__printf(4, 5)
+void qedf_dbg_notice(struct qedf_dbg_ctx *qedf, const char *func,
u32 line, const char *, ...);
-extern void qedf_dbg_info(struct qedf_dbg_ctx *qedf, const char *func, u32 
line,
+__printf(5, 6)
+void qedf_dbg_info(struct qedf_dbg_ctx *qedf, const char *func, u32 line,
  u32 info, const char *fmt, ...);
 
 /* GRC Dump related defines */
diff --git a/drivers/scsi/qedf/qedf_fip.c b/drivers/scsi/qedf/qedf_fip.c
index 868d423380d1..ed58b9104f58 100644
--- a/drivers/scsi/qedf/qedf_fip.c
+++ b/drivers/scsi/qedf/qedf_fip.c
@@ -203,7 +203,7 @@ void qedf_fip_recv(struct qedf_ctx *qedf, struct sk_buff 
*skb)
case FIP_DT_MAC:
mp = (struct fip_mac_desc *)desc;
QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_LL2,
-   "fd_mac=%pM.\n", __func__, mp->fd_mac);
+   "fd_mac=%pM\n", mp->fd_mac);
ether_addr_copy(cvl_mac, mp->fd_mac);
break;
case FIP_DT_NAME:
diff --git a/drivers/scsi/qedf/qedf_io.c b/drivers/scsi/qedf/qedf_io.c
index ee0dcf9d3aba..46debe5034af 100644
--- a/drivers/scsi/qedf/qedf_io.c
+++ b/drivers/scsi/qedf/qedf_io.c
@@ -1342,7 +1342,7 @@ void qedf_scsi_completion(struct qedf_ctx *qedf, struct 
fcoe_cqe *cqe,
} else {
refcount = kref_read(_req->refcount);
QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_IO,
-   "%d:0:%d:%d xid=0x%0x op=0x%02x "
+   "%d:0:%d:%lld xid=0x%0x op=0x%02x "
"lba=%02x%02x%02x%02x cdb_status=%d "
"fcp_resid=0x%x refcount=%d.\n",
qedf->lport->host->host_no, sc_cmd->device->id,
@@ -1426,7 +1426,7 @@ void qedf_scsi_done(struct qedf_ctx *qedf, struct 
qedf_ioreq *io_req,
 
sc_cmd->result = result << 16;
refcount = kref_read(_req->refcount);
-   QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_IO, "%d:0:%d:%d: Completing "
+   QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_IO, "%d:0:%d:%lld: Completing "
"sc_cmd=%p result=0x%08x op=0x%02x lba=0x%02x%02x%02x%02x, "
"allowed=%d retries=%d refcount=%d.\n",
qedf->lport->host->host_no, sc_cmd->device->id,
-- 
2.10.0.rc2.1.g053435c