Skip to contentSkip to conversation

Split SCSI header files

PATCH Superseded Bart Van Assche 2 participants 3 messages Apr 5, 2015 – Apr 7, 2015

Subsystems (2)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Split SCSI header files

Move the constants that are used by both initiator and target drivers into the new header file <scsi/scsi_proto.h>. Move the functions that are used by both subsystems into <scsi/scsi_lib.h>. Rename drivers/scsi/scsi_lib.c into scsi_ini_lib.c. This change will allow to modify the SCSI target code such that the initiator SCSI header files are no longer included. Note: the SCSI target driver patch is available for review at
https://github.com/bvanassche/linux/commit/092c3cf236ae35a460dead9423fae8f210ee2345.

Cc Nicholas Bellinger <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc Hannes Reinecke <[email protected]>

---

v2: dropped scsi_lun.h and introduced scsi_lib.h.

 drivers/scsi/Makefile             |    3 +-
 drivers/scsi/scsi.c               |   46 -
 drivers/scsi/scsi_ini_lib.c       | 3145 ++++++++++++++++++++++++++++++++++++
 drivers/scsi/scsi_lib.c           | 3200 +------------------------------------
 drivers/scsi/scsi_scan.c          |   62 -
 include/scsi/scsi.h               |  291 +---
 include/scsi/scsi_cmnd.h          |   17 -
 include/scsi/scsi_device.h        |    2 -
 include/scsi/scsi_lib.h           |   33 +
 include/scsi/scsi_proto.h         |  299 ++++
 include/target/target_core_base.h |    5 +-
 11 files changed, 3565 insertions(+), 3538 deletions(-)
 create mode 100644 drivers/scsi/scsi_ini_lib.c
 create mode 100644 include/scsi/scsi_lib.h
 create mode 100644 include/scsi/scsi_proto.h
drivers/scsi/Makefile +2 -1
index dee160a..ecd2a63 100644
@@ -160,7 +160,8 @@ obj-$(CONFIG_SCSI_OSD_INITIATOR) += osd/
 # This goes last, so that "real" scsi devices probe earlier
 obj-$(CONFIG_SCSI_DEBUG)	+= scsi_debug.o
 scsi_mod-y			+= scsi.o hosts.o scsi_ioctl.o \
-				   scsicam.o scsi_error.o scsi_lib.o
+				   scsicam.o scsi_error.o scsi_ini_lib.o \
+				   scsi_lib.o
 scsi_mod-$(CONFIG_SCSI_CONSTANTS) += constants.o
 scsi_mod-$(CONFIG_SCSI_DMA)	+= scsi_lib_dma.o
 scsi_mod-y			+= scsi_scan.o scsi_sysfs.o scsi_devinfo.o
drivers/scsi/scsi.c +0 -46

52 lines not on this page · raw message

drivers/scsi/scsi_ini_lib.c new file +3145 -0

2,939 lines not on this page · raw message

drivers/scsi/scsi_lib.c +81 -3119

3,200 lines not on this page · raw message

drivers/scsi/scsi_scan.c +0 -62

62 lines not on this page · raw message

include/scsi/scsi.h +3 -288

291 lines not on this page · raw message

include/scsi/scsi_cmnd.h +0 -17
index 9fc1aec..3416b70 100644

Lines of this file are not shown. View the raw message.

include/scsi/scsi_device.h +0 -2
index a4c9336..ae84b22 100644

Lines of this file are not shown. View the raw message.

include/scsi/scsi_lib.h new file +33 -0
new file mode 100644
index 0000000..239536d

Lines of this file are not shown. View the raw message.

include/scsi/scsi_proto.h new file +299 -0

299 lines not on this page · raw message

include/target/target_core_base.h +2 -3
index 672150b..ce71e7f 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.1.4

Part of the diff is not shown here. View the raw message.

#1 lore raw
Quoted 2 lines · Bart Van Assche

Move the constants that are used by both initiator and target drivers into the new header file <scsi/scsi_proto.h>.

This part looks mostly good, and I would prefer this to be a patch on it's own. One little nitpick below.

Quoted 6 lines

Move the
functions that are used by both subsystems into <scsi/scsi_lib.h>. Rename drivers/scsi/scsi_lib.c into scsi_ini_lib.c. This change will allow to modify the SCSI target code such that the initiator SCSI header files are no longer included. Note: the SCSI target driver patch is available for review at

I don't really like renaming the file that has most of the initiator side SCSI code that way. If we really have to rename it in some way I'd suggest just merging it into scsi.c as we call forth and back between the two all the time.

Maybe we can use scsi_common.c/h/.ko to avoid these moves, although I'd prefer to just duplicate this tiny amount of code.

Quoted 6 lines
include/scsi/scsi_proto.h new file +6 -0
+/*
+ * MAX_COMMAND_SIZE is:
+ * The longest fixed-length SCSI CDB as per the SCSI standard.
+ * fixed-length means: commands that their size can be determined
+ * by their opcode and the CDB does not carry a length specifier, (unlike
+ * the VARIABLE_LENGTH_CMD(0x7f) command). This is actually not exactly

include/scsi/scsi_proto.h line 195

Quoted 10 lines
include/scsi/scsi_proto.h new file +10 -0
+ * true and the SCSI standard also defines extended commands and
+ * vendor specific commands that can be bigger than 16 bytes. The kernel
+ * will support these using the same infrastructure used for VARLEN CDB's.
+ * So in effect MAX_COMMAND_SIZE means the maximum size command scsi-ml
+ * supports without specifying a cmd_len by ULD's
+ */
+#define MAX_COMMAND_SIZE 16
+#if (MAX_COMMAND_SIZE > BLK_MAX_CDB)
+# error MAX_COMMAND_SIZE can not be bigger than BLK_MAX_CDB
+#endif

This clearly is a limitation of the Linux SCSI initiator, so having it in the _proto.h header seems like a bad idea. For now I'd suggest to keep it where it is, but an additional patch to remove MAX_COMMAND_SIZE and use BLK_MAX_CDB everywhere would be even better.

include/target/target_core_base.h line 24

Quoted 10 lines
include/target/target_core_base.h +2 -3
@@ -19,9 +19,8 @@
 /*
  * By default we use 32-byte CDBs in TCM Core and subsystem plugin code.
  *
- * Note that both include/scsi/scsi_cmnd.h:MAX_COMMAND_SIZE and
- * include/linux/blkdev.h:BLOCK_MAX_CDB as of v2.6.36-rc4 still use
- * 16-byte CDBs by default and require an extra allocation for
+ * Note that both MAX_COMMAND_SIZE and BLOCK_MAX_CDB as of v4.0-rc1 still
+ * use 16-byte CDBs by default and require an extra allocation for
  * 32-byte CDBs to because of legacy issues.

This comment is incorrect. There aren't any legacy issues, we just decided to handle > 16 byte CDBs in the slow path. I'd suggest you remove this sentence (and the next one) entirely instead of trying to fix it up.

#2 lore raw
Quoted 8 lines · Christoph Hellwig
Quoted 6 lines · Bart Van Assche

Move the
functions that are used by both subsystems into <scsi/scsi_lib.h>. Rename drivers/scsi/scsi_lib.c into scsi_ini_lib.c. This change will allow to modify the SCSI target code such that the initiator SCSI header files are no longer included. Note: the SCSI target driver patch is available for review at

Quoted 7 lines

I don't really like renaming the file that has most of the initiator side SCSI code that way. If we really have to rename it in some way I'd suggest just merging it into scsi.c as we call forth and back between the two all the time.

Maybe we can use scsi_common.c/h/.ko to avoid these moves, although I'd prefer to just duplicate this tiny amount of code.

Hello Christoph,

Sorry but duplicating code is not really something that makes me enthusiast ... But I will address all your other comments, including using the names scsi_common.c/.h.

Bart.