mbox series

[V2,00/15] scsi: use sg helper to operate sgl

Message ID 20190613071335.5679-1-ming.lei@redhat.com (mailing list archive)
Headers show
Series scsi: use sg helper to operate sgl | expand

Message

Ming Lei June 13, 2019, 7:13 a.m. UTC
Hi,

Most of drivers use sg helpers to operate sgl, however there is
still a few drivers which operate sgl directly, this way can't
work in case of chained sgl.

So convert them to use sg helper.

There are two types of scsi SGL uses:

1) operate on scsi_sglist(scmd) directly, then one local variable of
'struct scatterlist *' is involved, so the following coccinelle semantic
patch is developed for finding this type of direct sgl uses:

	https://marc.info/?l=linux-scsi&m=156031374809852&w=2

2) scsi_sglist(scmd) is stored to cmd->SCp.buffer and the SGL is used
via cmd->SCp.buffer. Simple 'grep SCp.buffer' is used for finding SGL
direct uses, fortunately only the following drivers uses SCp.buffer to
store SGL:

	NCR5380, aha152x, arm/, imm, pcmcia, ppa and wd33c93

And arm/ is already ready to handle chained SGL.

The 1st 9 patches are for handling type #1, and the other 6 patches
for handling type #2.

V2:
	- use coccinelle semantic patch for finding direct sgl uses from
	scsi command(9 drivers found)
	- run 'git grep -E "SCp.buffer"' to find direct sgl uses
	from SCp.buffer(6 drivers are found)

Finn Thain (1):
  NCR5380: Support chained sg lists

Ming Lei (14):
  scsi: vmw_pscsi: use sg helper to operate sgl
  scsi: advansys: use sg helper to operate sgl
  scsi: lpfc: use sg helper to operate sgl
  scsi: mvumi: use sg helper to operate sgl
  scsi: ipr: use sg helper to operate sgl
  scsi: pmcraid: use sg helper to operate sgl
  usb: image: microtek: use sg helper to operate sgl
  staging: unisys: visorhba: use sg helper to operate sgl
  s390: zfcp_fc: use sg helper to operate sgl
  scsi: aha152x: use sg helper to operate sgl
  scsi: imm: use sg helper to operate sgl
  scsi: pcmcia: nsp_cs: use sg helper to operate sgl
  scsi: ppa: use sg helper to operate sgl
  scsi: wd33c93: use sg helper to operate sgl

 drivers/s390/scsi/zfcp_fc.c                   |  4 +-
 drivers/scsi/NCR5380.c                        | 41 ++++++++-----------
 drivers/scsi/advansys.c                       |  2 +-
 drivers/scsi/aha152x.c                        | 29 ++++++++-----
 drivers/scsi/imm.c                            |  2 +-
 drivers/scsi/ipr.c                            | 28 +++++++------
 drivers/scsi/lpfc/lpfc_nvmet.c                |  3 +-
 drivers/scsi/mvumi.c                          |  9 ++--
 drivers/scsi/pcmcia/nsp_cs.c                  |  4 +-
 drivers/scsi/pmcraid.c                        | 12 +++---
 drivers/scsi/ppa.c                            |  2 +-
 drivers/scsi/vmw_pvscsi.c                     |  2 +-
 drivers/scsi/wd33c93.c                        |  2 +-
 .../staging/unisys/visorhba/visorhba_main.c   |  9 ++--
 drivers/usb/image/microtek.c                  | 20 ++++-----
 drivers/usb/image/microtek.h                  |  2 +-
 16 files changed, 85 insertions(+), 86 deletions(-)

Comments

James Bottomley June 13, 2019, 4:42 p.m. UTC | #1
On Thu, 2019-06-13 at 15:13 +0800, Ming Lei wrote:
> Hi,
> 
> Most of drivers use sg helpers to operate sgl, however there is
> still a few drivers which operate sgl directly, this way can't
> work in case of chained sgl.

This isn't a useful explanation of the issue you make it sound like a
bug, which it isn't: it's a change of behaviour we'd like to introduce
in SCSI.  Please reword the explanation more along the lines of

---
Scsi MQ makes a large static allocation for the first scatter gather
list chunk for the driver to use.  This is a performance headache we'd
like to fix by reducing the size of the allocation to a 2 element
array.  Doing this will break the current guarantee that any driver
using SG_ALL doesn't need to use the scatterlist iterators and can get
away with directly dereferencing the array.  Thus we need to update all
drivers to use the scatterlist iterators and remove direct indexing of
the scatterlist array before reducing the initial scatterlist
allocation size in SCSI.
---

Which explains what we're trying to do and why.

In particular changelogs like this

> The current way isn't safe for chained sgl, so use sgl helper to
> operate sgl.

Are just plain wrong:  They were perfectly safe until you altered the
conditions for using non-chained sgls.  Please use the above
explanation in the patches, abbreviated if you like, so all recipients
know why this needs doing and that it isn't an existing bug.

James
Ming Lei June 14, 2019, 12:52 a.m. UTC | #2
On Thu, Jun 13, 2019 at 09:42:51AM -0700, James Bottomley wrote:
> On Thu, 2019-06-13 at 15:13 +0800, Ming Lei wrote:
> > Hi,
> > 
> > Most of drivers use sg helpers to operate sgl, however there is
> > still a few drivers which operate sgl directly, this way can't
> > work in case of chained sgl.
> 
> This isn't a useful explanation of the issue you make it sound like a
> bug, which it isn't: it's a change of behaviour we'd like to introduce
> in SCSI.  Please reword the explanation more along the lines of
> 
> ---
> Scsi MQ makes a large static allocation for the first scatter gather
> list chunk for the driver to use.  This is a performance headache we'd
> like to fix by reducing the size of the allocation to a 2 element
> array.  Doing this will break the current guarantee that any driver
> using SG_ALL doesn't need to use the scatterlist iterators and can get
> away with directly dereferencing the array.  Thus we need to update all
> drivers to use the scatterlist iterators and remove direct indexing of
> the scatterlist array before reducing the initial scatterlist
> allocation size in SCSI.
> ---
> 
> Which explains what we're trying to do and why.
> 
> In particular changelogs like this
> 
> > The current way isn't safe for chained sgl, so use sgl helper to
> > operate sgl.
> 
> Are just plain wrong:  They were perfectly safe until you altered the
> conditions for using non-chained sgls.  Please use the above
> explanation in the patches, abbreviated if you like, so all recipients
> know why this needs doing and that it isn't an existing bug.

OK, will update with the above commit log in V3.

Thanks,
Ming