public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/6] scsi: fix scsi_cmd::cmd_len
@ 2022-04-10 17:36 Douglas Gilbert
  2022-04-10 17:36 ` [PATCH v2 1/6] scsi_cmnd: reinstate support for cmd_len > 32 Douglas Gilbert
                   ` (6 more replies)
  0 siblings, 7 replies; 12+ messages in thread
From: Douglas Gilbert @ 2022-04-10 17:36 UTC (permalink / raw)
  To: linux-scsi; +Cc: martin.petersen, jejb, hare, bvanassche, hch

As described in the first patch of this set, commit ce70fd9a551af
reduced the maximum size of any SCSI commands (CDB length) to
32 bytes. It was previously larger in struct scsi_request which
has now (lk 5.18.0-rc1) been removed.

Use a slightly different scheme than before to support CDB lengths
greater than 16 bytes. Three access function are added, one for read
access, one for writable access that doesn't increase the cdb length,
and the third for create/write access to the CDB held inside a
scsi_cmnd object. This reduces the size of struct scsi_cmnd by 16
bytes.

A scsi_cmnd object is always paired with a struct request object
that immediately precedes it. To note this pairing the new comments
refer to a scsi_cmnd "sub-object". Prior to this patch the
constructor/destructor naming was confusing:
   - scsi_alloc_request() to create a pair
   - blk_mq_free_request() to destruct a pair

Add a new destructor function:
   scsi_free_cmnd(struct scsi_cmnd *scmd)

to make this a bit clearer. Also scsi_free_cmnd() will free up a
pointer to a long cdb buffer on the heap, if one is present.

These changes have been applied to SCSI mid-level and the upper
level drivers (ULDs, e.g. sd). Only one low level driver (LLD)
has been updated: scsi_debug. The rest of the LLDs can continue
to use scsi_cmnd::cmnd directly _unless_ they wish to support
CDB lengths > 16 bytes; in that case they should use
scsi_cmnd_get_cdb().

This patchset is against lk 5.18.0-rc1 and also applies cleanly
to MKP's 5.19/scsi-queue branch.

Changes since the first revision:
  - introduce a new SCSI_MAX_RUN_TIME_8BIT_CDB_LEN define for the
    case where hp->cmd_len is an 8 bit quantity. This addresses a
    kernel test robot report on patch 1 sent 20220408
  - take up Bart's suggestion to reduce
    SCSI_MAX_COMPILE_TIME_CDB_LEN to 16, hence shaving 16 bytes
    off the size of struct scsi_cmnd
  - introduce scsi_cmnd_get_changeable_cdb() access function for
    the case when the code wants to change some bytes in an
    existing cdb but not increase its size
  - add a broad description of how struct scsi_cmnd fits into
    overall architecture, tweak some other comments
  - further work on the sr and stex ULDs
 

Douglas Gilbert (6):
  scsi_cmnd: reinstate support for cmd_len > 32
  sd, sd_zbc: use scsi_cmnd cdb access functions
  sg: reinstate cmd_len > 32
  bsg: allow cmd_len > 32
  scsi_debug: reinstate cmd_len > 32
  st,sr,stex: use scsi_cmnd cdb access functions

 drivers/scsi/scsi_bsg.c     |  22 +-
 drivers/scsi/scsi_debug.c   | 410 +++++++++++++++++++-----------------
 drivers/scsi/scsi_debugfs.c |   3 +-
 drivers/scsi/scsi_error.c   |  76 ++++---
 drivers/scsi/scsi_ioctl.c   |  21 +-
 drivers/scsi/scsi_lib.c     |  75 ++++++-
 drivers/scsi/scsi_logging.c |  11 +-
 drivers/scsi/sd.c           | 176 +++++++++-------
 drivers/scsi/sd_zbc.c       |  12 +-
 drivers/scsi/sg.c           |  23 +-
 drivers/scsi/sr.c           |  40 ++--
 drivers/scsi/st.c           |  12 +-
 drivers/scsi/stex.c         |  22 +-
 include/scsi/scsi_cmnd.h    | 116 ++++++++--
 include/scsi/scsi_eh.h      |   6 +-
 15 files changed, 623 insertions(+), 402 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-04-19  3:27 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-10 17:36 [PATCH v2 0/6] scsi: fix scsi_cmd::cmd_len Douglas Gilbert
2022-04-10 17:36 ` [PATCH v2 1/6] scsi_cmnd: reinstate support for cmd_len > 32 Douglas Gilbert
2022-04-10 17:36 ` [PATCH v2 2/6] sd, sd_zbc: use scsi_cmnd cdb access functions Douglas Gilbert
2022-04-10 17:36 ` [PATCH v2 3/6] sg: reinstate cmd_len > 32 Douglas Gilbert
2022-04-10 17:36 ` [PATCH v2 4/6] bsg: allow " Douglas Gilbert
2022-04-10 17:36 ` [PATCH v2 5/6] scsi_debug: reinstate " Douglas Gilbert
2022-04-10 17:36 ` [PATCH v2 6/6] st,sr,stex: use scsi_cmnd cdb access functions Douglas Gilbert
2022-04-11  5:03 ` [PATCH v2 0/6] scsi: fix scsi_cmd::cmd_len Christoph Hellwig
2022-04-11 15:06   ` Douglas Gilbert
2022-04-11 15:52     ` Christoph Hellwig
2022-04-12  3:05       ` Douglas Gilbert
2022-04-19  3:26         ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox