Re: [PATCH v2 0/6] scsi: fix scsi_cmd::cmd_len

Douglas Gilbert
2022-04-11T15:06:25Z

On 2022-04-11 01:03, Christoph Hellwig wrote:
> This still misses any good explanation of why we want all this.

Advantages:
- undoes regression in ce70fd9a551af, that is:
- cdb_len > 32 no longer allowed (visible to the user space), undone
- but we still have this one:
- prior to lk5.18 sizeof(scsi_cmnd::cmnd) is that of a
pointer but >= lk5.18 sizeof(scsi_cmnd::cmnd) is 32 (or 16)
- makes all scsi_cmnd objects 16 bytes smaller
- hides the poorly named dtor for scsi_cmnd objects (blk_mq_free_request)
within a more intuitively named inline: scsi_free_cmnd
- scsi_free_cmnd() allows other cleanups to be hooked, like the one
proposed to free the long CDB heap, if used
- supplies three access functions for manipulating CDBs.
scsi_cmnd_set_cdb() removes the need for memset()s and cdb[n]=0 code,
and setting scsi_cmnd::cmd_len when ULDs and LLDs are building CDBs
- allows scsi_cmnd::cmnd to be renamed scsi_cmnd::__cdb in the future
to encourage the use of those access functions
- patches to code accessing scsi_cmnd::cmnd change the name of a SCSI
CDB (a byte array) to 'cdb' rather than the confusing terms: 'cmnd'
or 'cmd'

Disadvantages:
- burdens each access to a CDB with (scsi_cmnd::flags & SCMD_LONG_CDB)
check
- LLDs that want to fetch 32 byte CDBs (or longer) need to use the
scsi_cmnd_get_cdb() access function. For CDB lengths <= 16 bytes
they can continue to access scsi_cmnd::cmnd directly