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 is VERIFY(BYTCHK=1) and the equivalent NVMe command 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 block) 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. 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 | 478 +++++++++++++++++++++++++----------- include/linux/scatterlist.h | 33 ++- lib/scatterlist.c | 253 ++++++++++++++++--- 4 files changed, 596 insertions(+), 171 deletions(-) -- 2.37.3