Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1642688

RE: [PATCH] scsi: zero per-cmd driver data for each MQ I/O

From Long Li <longli@microsoft.com>
Newsgroups linux.kernel
Subject RE: [PATCH] scsi: zero per-cmd driver data for each MQ I/O
Date 2017-05-16 19:40 +0200
Message-ID <tHOBX-6g-1@gated-at.bofh.it> (permalink)
References <tHxKN-6h6-5@gated-at.bofh.it> <tHydP-6FF-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw



> -----Original Message-----
> From: Bart Van Assche [mailto:Bart.VanAssche@sandisk.com]
> Sent: Monday, May 15, 2017 5:01 PM
> To: jejb@linux.vnet.ibm.com; linux-scsi@vger.kernel.org; linux-
> kernel@vger.kernel.org; Long Li <longli@microsoft.com>;
> martin.petersen@oracle.com
> Cc: Stephen Hemminger <sthemmin@microsoft.com>; KY Srinivasan
> <kys@microsoft.com>
> Subject: Re: [PATCH] scsi: zero per-cmd driver data for each MQ I/O
> 
> On Mon, 2017-05-15 at 23:32 +0000, Long Li wrote:
> > Thanks for looking! Yes this is for chasing a bug.
> >
> > With the patch, we also zero the private data used by lower layer
> > driver, in addition to the private data in scsi_cmnd.
> 
> Hello Long,
> 
> What bug did you encounter, with which combination of ULP (sd?) and LLD SCSI
> driver(s) and for which request type (REQ_OP_*)? You will have to mention
> that information in the patch description anyway if you want your patch to get
> accepted.
> 
> If the bug that you encountered only occurs with a single LLD, would it be
> possible to implement a fix by modifying the LLD instead of the SCSI core?

The bug I encounter is that in hv_storvsc (a LLD), sometime we are getting stale data in the private driver data memory allocated by SCSI. As a LLD, we expect the memory allocated by SCSI to be zeroed. If not we may send unexpected commands to the device.

A little background on private data: In LLD's scsi_host_template, the driver may optionally ask SCSI to allocate its private driver memory for each command, by specifying cmd_size. This memory is allocated at the end of scsi_cmnd by SCSI. Later when SCSI queues a command, the LLD can use scsi_cmd_priv to get its private data.

hv_storvsc doesn't clear its private data before use. I'm not sure about other LLD drivers. Although it's possible to fix it in LLD not SCSI core, I think that is not the ideal place to do it. Whoever is allocating the SCSI command should also zero it.

There is a similar patch that fixed a similar issue for non-MQ case:
commit ee5242360424b9b967454e9183767323d10cf985

I'm sorry I should have put more details in the patch. 

> 
> Thanks,
> 
> Bart.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

RE: [PATCH] scsi: zero per-cmd driver data for each MQ I/O Long Li <longli@microsoft.com> - 2017-05-16 01:40 +0200
  Re: [PATCH] scsi: zero per-cmd driver data for each MQ I/O Bart Van Assche <Bart.VanAssche@sandisk.com> - 2017-05-16 02:10 +0200
    RE: [PATCH] scsi: zero per-cmd driver data for each MQ I/O Long Li <longli@microsoft.com> - 2017-05-16 19:40 +0200
      Re: [PATCH] scsi: zero per-cmd driver data for each MQ I/O Bart Van Assche <Bart.VanAssche@sandisk.com> - 2017-05-18 01:10 +0200
        Re: [PATCH] scsi: zero per-cmd driver data for each MQ I/O Christoph Hellwig <hch@infradead.org> - 2017-05-18 09:00 +0200
          RE: [PATCH] scsi: zero per-cmd driver data for each MQ I/O KY Srinivasan <kys@microsoft.com> - 2017-05-18 15:30 +0200
          Re: [PATCH] scsi: zero per-cmd driver data for each MQ I/O Bart Van Assche <Bart.VanAssche@sandisk.com> - 2017-05-18 18:00 +0200
            RE: [PATCH] scsi: zero per-cmd driver data for each MQ I/O Long Li <longli@microsoft.com> - 2017-05-18 18:50 +0200

csiph-web