public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Douglas Gilbert <dgilbert@interlog.com>
To: linux-scsi@vger.kernel.org
Cc: martin.petersen@oracle.com, jejb@linux.vnet.ibm.com,
	hare@suse.de, bvanassche@acm.org, bostroesser@gmail.com,
	jgg@ziepe.ca
Subject: [PATCH v2 0/5] scatterlist: add operations for scsi_debug
Date: Sat, 12 Nov 2022 14:49:34 -0500	[thread overview]
Message-ID: <20221112194939.4823-1-dgilbert@interlog.com> (raw)

The scsi_debug driver is essentially a ramdisk dressed up as a SCSI host
with one or more SCSI devices attached. Like all low level SCSI drivers,
the scsi_debug driver receives and provides data to the SCSI mid-level
(and the block layer) using scatterlists whose interface is found in
include/linux/scatterlist.h .

After trying kmalloc() then vmalloc() based storage for the scsi_debug
driver, it was found that certain SCSI commands can be optimized if
instead one or more scatterlists is used as its backing store. The
specific SCSI command that benefits the most is VERIFY(BYTCHK=1) whose
NVMe equivalent is COMPARE. These commands have data-out buffers
provided by an application that are compared by the storage device
with the LBA and count (of blocks) given in the command. In this
case the sgl_equal_sgl() function can be used instead of setting up
a temporary buffer.

The implementation of the more common SCSI READ and WRITE commands are
simplified by using the sgl_copy_sgl() function.

The first patch in this series removes an undocumented 4 GB limit in
the existing sgl_alloc_order() function.

In the final patch of this series, the scsi_debug driver uses the
new facilities in scatterlist to replace its vmalloc() backing store
with a sgl_alloc_order() based store. Also several loops based on
memcpy() and memcmp() are replaced by the new scatterlist copy
and 'equal' functions.

Changes since v1 (sent to linux-scsi list on 20221023)
  - in sgl_alloc_order() add check that order argument is less
    then MAX_ORDER; protects following call to round_up()
  - in sdeb_sgl_cmp_buf() within scsi_debug.c remove call to
    sg_miter_stop() as suggested by reviewer


Douglas Gilbert (5):
  sgl_alloc_order: remove 4 GiB limit
  scatterlist: add sgl_copy_sgl() function
  scatterlist: add sgl_equal_sgl() function
  scatterlist: add sgl_memset()
  scsi_debug: change store from vmalloc to sgl

 drivers/scsi/Kconfig        |   3 +-
 drivers/scsi/scsi_debug.c   | 442 ++++++++++++++++++++++++------------
 include/linux/scatterlist.h |  33 ++-
 lib/scatterlist.c           | 255 ++++++++++++++++++---
 4 files changed, 562 insertions(+), 171 deletions(-)

-- 
2.37.2


             reply	other threads:[~2022-11-12 19:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-12 19:49 Douglas Gilbert [this message]
2022-11-12 19:49 ` [PATCH v2 1/5] sgl_alloc_order: remove 4 GiB limit Douglas Gilbert
2022-11-15 20:33   ` Jason Gunthorpe
2022-11-16  0:20     ` Douglas Gilbert
2022-11-16  0:39       ` Jason Gunthorpe
2022-11-12 19:49 ` [PATCH v2 2/5] scatterlist: add sgl_copy_sgl() function Douglas Gilbert
2022-11-16  5:59   ` Christoph Hellwig
2022-11-12 19:49 ` [PATCH v2 3/5] scatterlist: add sgl_equal_sgl() function Douglas Gilbert
2022-11-12 19:49 ` [PATCH v2 4/5] scatterlist: add sgl_memset() Douglas Gilbert
2022-11-12 19:49 ` [PATCH v2 5/5] scsi_debug: change store from vmalloc to sgl Douglas Gilbert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221112194939.4823-1-dgilbert@interlog.com \
    --to=dgilbert@interlog.com \
    --cc=bostroesser@gmail.com \
    --cc=bvanassche@acm.org \
    --cc=hare@suse.de \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=jgg@ziepe.ca \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox