All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] Split SCSI header files
@ 2015-04-07 12:32 Bart Van Assche
  2015-04-07 12:33 ` [PATCH v3 1/4] " Bart Van Assche
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Bart Van Assche @ 2015-04-07 12:32 UTC (permalink / raw)
  To: James Bottomley
  Cc: Christoph Hellwig, Nicholas A. Bellinger, Hannes Reinecke,
	Mike Christie, linux-scsi, target-devel

Move the constants and functions that are used by both initiator and 
target code to new header files such that the target code does no longer 
have to include initiator header files.

Changes in v3 of this series compared to v2:
- Renamed scsi_lib.h into scsi_common.h.
- Added a patch for replacing MAX_COMMAND_SIZE with BLK_MAX_CDB.
- Added a patch that minimizes the include directives in target code.

Changes in v2 of this series compared to v1:
- Dropped the scsi_lun.h header file and introduced scsi_lib.h.

The patches in this series are:
0001-Split-SCSI-header-files.patch
0002-Replace-MAX_COMMAND_SIZE-with-BLK_MAX_CDB.patch
0003-target-Correct-a-comment.patch
0004-target-Minimize-SCSI-header-include-directives.patch

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

* [PATCH v3 1/4] Split SCSI header files
  2015-04-07 12:32 [PATCH v3] Split SCSI header files Bart Van Assche
@ 2015-04-07 12:33 ` Bart Van Assche
  2015-04-07 12:33 ` [PATCH v3 2/4] Replace MAX_COMMAND_SIZE with BLK_MAX_CDB Bart Van Assche
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Bart Van Assche @ 2015-04-07 12:33 UTC (permalink / raw)
  To: James Bottomley
  Cc: Christoph Hellwig, Nicholas A. Bellinger, Hannes Reinecke,
	Mike Christie, linux-scsi, target-devel

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_common.c/.h.
This change will allow to remove the initiator SCSI header
include directives from most SCSI target source files in a later
patch.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Nicholas Bellinger <nab@linux-iscsi.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Mike Christie <michaelc@cs.wisc.edu>
---
 drivers/scsi/Makefile      |   1 +
 drivers/scsi/scsi.c        |  46 -------
 drivers/scsi/scsi_common.c | 178 +++++++++++++++++++++++++++
 drivers/scsi/scsi_error.c  |  64 ----------
 drivers/scsi/scsi_scan.c   |  62 ----------
 include/scsi/scsi.h        | 291 +--------------------------------------------
 include/scsi/scsi_common.h |  64 ++++++++++
 include/scsi/scsi_device.h |   2 -
 include/scsi/scsi_eh.h     |  31 -----
 include/scsi/scsi_proto.h  | 281 +++++++++++++++++++++++++++++++++++++++++++
 10 files changed, 527 insertions(+), 493 deletions(-)
 create mode 100644 drivers/scsi/scsi_common.c
 create mode 100644 include/scsi/scsi_common.h
 create mode 100644 include/scsi/scsi_proto.h

diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index dee160a..ee4517b 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -161,6 +161,7 @@ obj-$(CONFIG_SCSI_OSD_INITIATOR) += osd/
 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
+scsi_mod-y			+= scsi_common.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
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index c9c3b57..6322d10 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -98,52 +98,6 @@ EXPORT_SYMBOL(scsi_sd_probe_domain);
 ASYNC_DOMAIN_EXCLUSIVE(scsi_sd_pm_domain);
 EXPORT_SYMBOL(scsi_sd_pm_domain);
 
-/* NB: These are exposed through /proc/scsi/scsi and form part of the ABI.
- * You may not alter any existing entry (although adding new ones is
- * encouraged once assigned by ANSI/INCITS T10
- */
-static const char *const scsi_device_types[] = {
-	"Direct-Access    ",
-	"Sequential-Access",
-	"Printer          ",
-	"Processor        ",
-	"WORM             ",
-	"CD-ROM           ",
-	"Scanner          ",
-	"Optical Device   ",
-	"Medium Changer   ",
-	"Communications   ",
-	"ASC IT8          ",
-	"ASC IT8          ",
-	"RAID             ",
-	"Enclosure        ",
-	"Direct-Access-RBC",
-	"Optical card     ",
-	"Bridge controller",
-	"Object storage   ",
-	"Automation/Drive ",
-	"Security Manager ",
-	"Direct-Access-ZBC",
-};
-
-/**
- * scsi_device_type - Return 17 char string indicating device type.
- * @type: type number to look up
- */
-
-const char * scsi_device_type(unsigned type)
-{
-	if (type == 0x1e)
-		return "Well-known LUN   ";
-	if (type == 0x1f)
-		return "No Device        ";
-	if (type >= ARRAY_SIZE(scsi_device_types))
-		return "Unknown          ";
-	return scsi_device_types[type];
-}
-
-EXPORT_SYMBOL(scsi_device_type);
-
 struct scsi_host_cmd_pool {
 	struct kmem_cache	*cmd_slab;
 	struct kmem_cache	*sense_slab;
diff --git a/drivers/scsi/scsi_common.c b/drivers/scsi/scsi_common.c
new file mode 100644
index 0000000..2ff0922
--- /dev/null
+++ b/drivers/scsi/scsi_common.c
@@ -0,0 +1,178 @@
+/*
+ * SCSI functions used by both the initiator and the target code.
+ */
+
+#include <linux/bug.h>
+#include <linux/kernel.h>
+#include <linux/string.h>
+#include <scsi/scsi_common.h>
+
+/* NB: These are exposed through /proc/scsi/scsi and form part of the ABI.
+ * You may not alter any existing entry (although adding new ones is
+ * encouraged once assigned by ANSI/INCITS T10
+ */
+static const char *const scsi_device_types[] = {
+	"Direct-Access    ",
+	"Sequential-Access",
+	"Printer          ",
+	"Processor        ",
+	"WORM             ",
+	"CD-ROM           ",
+	"Scanner          ",
+	"Optical Device   ",
+	"Medium Changer   ",
+	"Communications   ",
+	"ASC IT8          ",
+	"ASC IT8          ",
+	"RAID             ",
+	"Enclosure        ",
+	"Direct-Access-RBC",
+	"Optical card     ",
+	"Bridge controller",
+	"Object storage   ",
+	"Automation/Drive ",
+	"Security Manager ",
+	"Direct-Access-ZBC",
+};
+
+/**
+ * scsi_device_type - Return 17 char string indicating device type.
+ * @type: type number to look up
+ */
+const char *scsi_device_type(unsigned type)
+{
+	if (type == 0x1e)
+		return "Well-known LUN   ";
+	if (type == 0x1f)
+		return "No Device        ";
+	if (type >= ARRAY_SIZE(scsi_device_types))
+		return "Unknown          ";
+	return scsi_device_types[type];
+}
+EXPORT_SYMBOL(scsi_device_type);
+
+/**
+ * scsilun_to_int - convert a scsi_lun to an int
+ * @scsilun:	struct scsi_lun to be converted.
+ *
+ * Description:
+ *     Convert @scsilun from a struct scsi_lun to a four byte host byte-ordered
+ *     integer, and return the result. The caller must check for
+ *     truncation before using this function.
+ *
+ * Notes:
+ *     For a description of the LUN format, post SCSI-3 see the SCSI
+ *     Architecture Model, for SCSI-3 see the SCSI Controller Commands.
+ *
+ *     Given a struct scsi_lun of: d2 04 0b 03 00 00 00 00, this function
+ *     returns the integer: 0x0b03d204
+ *
+ *     This encoding will return a standard integer LUN for LUNs smaller
+ *     than 256, which typically use a single level LUN structure with
+ *     addressing method 0.
+ */
+u64 scsilun_to_int(struct scsi_lun *scsilun)
+{
+	int i;
+	u64 lun;
+
+	lun = 0;
+	for (i = 0; i < sizeof(lun); i += 2)
+		lun = lun | (((u64)scsilun->scsi_lun[i] << ((i + 1) * 8)) |
+			     ((u64)scsilun->scsi_lun[i + 1] << (i * 8)));
+	return lun;
+}
+EXPORT_SYMBOL(scsilun_to_int);
+
+/**
+ * int_to_scsilun - reverts an int into a scsi_lun
+ * @lun:        integer to be reverted
+ * @scsilun:	struct scsi_lun to be set.
+ *
+ * Description:
+ *     Reverts the functionality of the scsilun_to_int, which packed
+ *     an 8-byte lun value into an int. This routine unpacks the int
+ *     back into the lun value.
+ *
+ * Notes:
+ *     Given an integer : 0x0b03d204,  this function returns a
+ *     struct scsi_lun of: d2 04 0b 03 00 00 00 00
+ *
+ */
+void int_to_scsilun(u64 lun, struct scsi_lun *scsilun)
+{
+	int i;
+
+	memset(scsilun->scsi_lun, 0, sizeof(scsilun->scsi_lun));
+
+	for (i = 0; i < sizeof(lun); i += 2) {
+		scsilun->scsi_lun[i] = (lun >> 8) & 0xFF;
+		scsilun->scsi_lun[i+1] = lun & 0xFF;
+		lun = lun >> 16;
+	}
+}
+EXPORT_SYMBOL(int_to_scsilun);
+
+/**
+ * scsi_normalize_sense - normalize main elements from either fixed or
+ *			descriptor sense data format into a common format.
+ *
+ * @sense_buffer:	byte array containing sense data returned by device
+ * @sb_len:		number of valid bytes in sense_buffer
+ * @sshdr:		pointer to instance of structure that common
+ *			elements are written to.
+ *
+ * Notes:
+ *	The "main elements" from sense data are: response_code, sense_key,
+ *	asc, ascq and additional_length (only for descriptor format).
+ *
+ *	Typically this function can be called after a device has
+ *	responded to a SCSI command with the CHECK_CONDITION status.
+ *
+ * Return value:
+ *	true if valid sense data information found, else false;
+ */
+bool scsi_normalize_sense(const u8 *sense_buffer, int sb_len,
+			  struct scsi_sense_hdr *sshdr)
+{
+	if (!sense_buffer || !sb_len)
+		return false;
+
+	memset(sshdr, 0, sizeof(struct scsi_sense_hdr));
+
+	sshdr->response_code = (sense_buffer[0] & 0x7f);
+
+	if (!scsi_sense_valid(sshdr))
+		return false;
+
+	if (sshdr->response_code >= 0x72) {
+		/*
+		 * descriptor format
+		 */
+		if (sb_len > 1)
+			sshdr->sense_key = (sense_buffer[1] & 0xf);
+		if (sb_len > 2)
+			sshdr->asc = sense_buffer[2];
+		if (sb_len > 3)
+			sshdr->ascq = sense_buffer[3];
+		if (sb_len > 7)
+			sshdr->additional_length = sense_buffer[7];
+	} else {
+		/*
+		 * fixed format
+		 */
+		if (sb_len > 2)
+			sshdr->sense_key = (sense_buffer[2] & 0xf);
+		if (sb_len > 7) {
+			sb_len = (sb_len < (sense_buffer[7] + 8)) ?
+					 sb_len : (sense_buffer[7] + 8);
+			if (sb_len > 12)
+				sshdr->asc = sense_buffer[12];
+			if (sb_len > 13)
+				sshdr->ascq = sense_buffer[13];
+		}
+	}
+
+	return true;
+}
+EXPORT_SYMBOL(scsi_normalize_sense);
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 4cdaffc..b79bbea 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -2398,70 +2398,6 @@ out_put_autopm_host:
 }
 EXPORT_SYMBOL(scsi_ioctl_reset);
 
-/**
- * scsi_normalize_sense - normalize main elements from either fixed or
- *			descriptor sense data format into a common format.
- *
- * @sense_buffer:	byte array containing sense data returned by device
- * @sb_len:		number of valid bytes in sense_buffer
- * @sshdr:		pointer to instance of structure that common
- *			elements are written to.
- *
- * Notes:
- *	The "main elements" from sense data are: response_code, sense_key,
- *	asc, ascq and additional_length (only for descriptor format).
- *
- *	Typically this function can be called after a device has
- *	responded to a SCSI command with the CHECK_CONDITION status.
- *
- * Return value:
- *	true if valid sense data information found, else false;
- */
-bool scsi_normalize_sense(const u8 *sense_buffer, int sb_len,
-			  struct scsi_sense_hdr *sshdr)
-{
-	if (!sense_buffer || !sb_len)
-		return false;
-
-	memset(sshdr, 0, sizeof(struct scsi_sense_hdr));
-
-	sshdr->response_code = (sense_buffer[0] & 0x7f);
-
-	if (!scsi_sense_valid(sshdr))
-		return false;
-
-	if (sshdr->response_code >= 0x72) {
-		/*
-		 * descriptor format
-		 */
-		if (sb_len > 1)
-			sshdr->sense_key = (sense_buffer[1] & 0xf);
-		if (sb_len > 2)
-			sshdr->asc = sense_buffer[2];
-		if (sb_len > 3)
-			sshdr->ascq = sense_buffer[3];
-		if (sb_len > 7)
-			sshdr->additional_length = sense_buffer[7];
-	} else {
-		/*
-		 * fixed format
-		 */
-		if (sb_len > 2)
-			sshdr->sense_key = (sense_buffer[2] & 0xf);
-		if (sb_len > 7) {
-			sb_len = (sb_len < (sense_buffer[7] + 8)) ?
-					 sb_len : (sense_buffer[7] + 8);
-			if (sb_len > 12)
-				sshdr->asc = sense_buffer[12];
-			if (sb_len > 13)
-				sshdr->ascq = sense_buffer[13];
-		}
-	}
-
-	return true;
-}
-EXPORT_SYMBOL(scsi_normalize_sense);
-
 bool scsi_command_normalize_sense(const struct scsi_cmnd *cmd,
 				  struct scsi_sense_hdr *sshdr)
 {
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 9c0a520..202369b 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -1263,68 +1263,6 @@ static void scsi_sequential_lun_scan(struct scsi_target *starget,
 }
 
 /**
- * scsilun_to_int - convert a scsi_lun to an int
- * @scsilun:	struct scsi_lun to be converted.
- *
- * Description:
- *     Convert @scsilun from a struct scsi_lun to a four byte host byte-ordered
- *     integer, and return the result. The caller must check for
- *     truncation before using this function.
- *
- * Notes:
- *     For a description of the LUN format, post SCSI-3 see the SCSI
- *     Architecture Model, for SCSI-3 see the SCSI Controller Commands.
- *
- *     Given a struct scsi_lun of: d2 04 0b 03 00 00 00 00, this function
- *     returns the integer: 0x0b03d204
- *
- *     This encoding will return a standard integer LUN for LUNs smaller
- *     than 256, which typically use a single level LUN structure with
- *     addressing method 0.
- **/
-u64 scsilun_to_int(struct scsi_lun *scsilun)
-{
-	int i;
-	u64 lun;
-
-	lun = 0;
-	for (i = 0; i < sizeof(lun); i += 2)
-		lun = lun | (((u64)scsilun->scsi_lun[i] << ((i + 1) * 8)) |
-			     ((u64)scsilun->scsi_lun[i + 1] << (i * 8)));
-	return lun;
-}
-EXPORT_SYMBOL(scsilun_to_int);
-
-/**
- * int_to_scsilun - reverts an int into a scsi_lun
- * @lun:        integer to be reverted
- * @scsilun:	struct scsi_lun to be set.
- *
- * Description:
- *     Reverts the functionality of the scsilun_to_int, which packed
- *     an 8-byte lun value into an int. This routine unpacks the int
- *     back into the lun value.
- *
- * Notes:
- *     Given an integer : 0x0b03d204,  this function returns a
- *     struct scsi_lun of: d2 04 0b 03 00 00 00 00
- *
- **/
-void int_to_scsilun(u64 lun, struct scsi_lun *scsilun)
-{
-	int i;
-
-	memset(scsilun->scsi_lun, 0, sizeof(scsilun->scsi_lun));
-
-	for (i = 0; i < sizeof(lun); i += 2) {
-		scsilun->scsi_lun[i] = (lun >> 8) & 0xFF;
-		scsilun->scsi_lun[i+1] = lun & 0xFF;
-		lun = lun >> 16;
-	}
-}
-EXPORT_SYMBOL(int_to_scsilun);
-
-/**
  * scsi_report_lun_scan - Scan using SCSI REPORT LUN results
  * @starget: which target
  * @bflags: Zero or a mix of BLIST_NOLUN, BLIST_REPORTLUN2, or BLIST_NOREPORTLUN
diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
index d0a66aa..e0a3398 100644
--- a/include/scsi/scsi.h
+++ b/include/scsi/scsi.h
@@ -1,9 +1,6 @@
 /*
  * This header file contains public constants and structures used by
- * the scsi code for linux.
- *
- * For documentation on the OPCODES, MESSAGES, and SENSE values,
- * please consult the SCSI standard.
+ * the SCSI initiator code.
  */
 #ifndef _SCSI_SCSI_H
 #define _SCSI_SCSI_H
@@ -11,6 +8,8 @@
 #include <linux/types.h>
 #include <linux/scatterlist.h>
 #include <linux/kernel.h>
+#include <scsi/scsi_common.h>
+#include <scsi/scsi_proto.h>
 
 struct scsi_cmnd;
 
@@ -49,187 +48,6 @@ enum scsi_timeouts {
  */
 #define SCAN_WILD_CARD	~0
 
-/*
- *      SCSI opcodes
- */
-
-#define TEST_UNIT_READY       0x00
-#define REZERO_UNIT           0x01
-#define REQUEST_SENSE         0x03
-#define FORMAT_UNIT           0x04
-#define READ_BLOCK_LIMITS     0x05
-#define REASSIGN_BLOCKS       0x07
-#define INITIALIZE_ELEMENT_STATUS 0x07
-#define READ_6                0x08
-#define WRITE_6               0x0a
-#define SEEK_6                0x0b
-#define READ_REVERSE          0x0f
-#define WRITE_FILEMARKS       0x10
-#define SPACE                 0x11
-#define INQUIRY               0x12
-#define RECOVER_BUFFERED_DATA 0x14
-#define MODE_SELECT           0x15
-#define RESERVE               0x16
-#define RELEASE               0x17
-#define COPY                  0x18
-#define ERASE                 0x19
-#define MODE_SENSE            0x1a
-#define START_STOP            0x1b
-#define RECEIVE_DIAGNOSTIC    0x1c
-#define SEND_DIAGNOSTIC       0x1d
-#define ALLOW_MEDIUM_REMOVAL  0x1e
-
-#define READ_FORMAT_CAPACITIES 0x23
-#define SET_WINDOW            0x24
-#define READ_CAPACITY         0x25
-#define READ_10               0x28
-#define WRITE_10              0x2a
-#define SEEK_10               0x2b
-#define POSITION_TO_ELEMENT   0x2b
-#define WRITE_VERIFY          0x2e
-#define VERIFY                0x2f
-#define SEARCH_HIGH           0x30
-#define SEARCH_EQUAL          0x31
-#define SEARCH_LOW            0x32
-#define SET_LIMITS            0x33
-#define PRE_FETCH             0x34
-#define READ_POSITION         0x34
-#define SYNCHRONIZE_CACHE     0x35
-#define LOCK_UNLOCK_CACHE     0x36
-#define READ_DEFECT_DATA      0x37
-#define MEDIUM_SCAN           0x38
-#define COMPARE               0x39
-#define COPY_VERIFY           0x3a
-#define WRITE_BUFFER          0x3b
-#define READ_BUFFER           0x3c
-#define UPDATE_BLOCK          0x3d
-#define READ_LONG             0x3e
-#define WRITE_LONG            0x3f
-#define CHANGE_DEFINITION     0x40
-#define WRITE_SAME            0x41
-#define UNMAP		      0x42
-#define READ_TOC              0x43
-#define READ_HEADER           0x44
-#define GET_EVENT_STATUS_NOTIFICATION 0x4a
-#define LOG_SELECT            0x4c
-#define LOG_SENSE             0x4d
-#define XDWRITEREAD_10        0x53
-#define MODE_SELECT_10        0x55
-#define RESERVE_10            0x56
-#define RELEASE_10            0x57
-#define MODE_SENSE_10         0x5a
-#define PERSISTENT_RESERVE_IN 0x5e
-#define PERSISTENT_RESERVE_OUT 0x5f
-#define VARIABLE_LENGTH_CMD   0x7f
-#define REPORT_LUNS           0xa0
-#define SECURITY_PROTOCOL_IN  0xa2
-#define MAINTENANCE_IN        0xa3
-#define MAINTENANCE_OUT       0xa4
-#define MOVE_MEDIUM           0xa5
-#define EXCHANGE_MEDIUM       0xa6
-#define READ_12               0xa8
-#define SERVICE_ACTION_OUT_12 0xa9
-#define WRITE_12              0xaa
-#define READ_MEDIA_SERIAL_NUMBER 0xab /* Obsolete with SPC-2 */
-#define SERVICE_ACTION_IN_12  0xab
-#define WRITE_VERIFY_12       0xae
-#define VERIFY_12	      0xaf
-#define SEARCH_HIGH_12        0xb0
-#define SEARCH_EQUAL_12       0xb1
-#define SEARCH_LOW_12         0xb2
-#define SECURITY_PROTOCOL_OUT 0xb5
-#define READ_ELEMENT_STATUS   0xb8
-#define SEND_VOLUME_TAG       0xb6
-#define WRITE_LONG_2          0xea
-#define EXTENDED_COPY         0x83
-#define RECEIVE_COPY_RESULTS  0x84
-#define ACCESS_CONTROL_IN     0x86
-#define ACCESS_CONTROL_OUT    0x87
-#define READ_16               0x88
-#define COMPARE_AND_WRITE     0x89
-#define WRITE_16              0x8a
-#define READ_ATTRIBUTE        0x8c
-#define WRITE_ATTRIBUTE	      0x8d
-#define VERIFY_16	      0x8f
-#define SYNCHRONIZE_CACHE_16  0x91
-#define WRITE_SAME_16	      0x93
-#define SERVICE_ACTION_BIDIRECTIONAL 0x9d
-#define SERVICE_ACTION_IN_16  0x9e
-#define SERVICE_ACTION_OUT_16 0x9f
-/* values for service action in */
-#define	SAI_READ_CAPACITY_16  0x10
-#define SAI_GET_LBA_STATUS    0x12
-#define SAI_REPORT_REFERRALS  0x13
-/* values for VARIABLE_LENGTH_CMD service action codes
- * see spc4r17 Section D.3.5, table D.7 and D.8 */
-#define VLC_SA_RECEIVE_CREDENTIAL 0x1800
-/* values for maintenance in */
-#define MI_REPORT_IDENTIFYING_INFORMATION 0x05
-#define MI_REPORT_TARGET_PGS  0x0a
-#define MI_REPORT_ALIASES     0x0b
-#define MI_REPORT_SUPPORTED_OPERATION_CODES 0x0c
-#define MI_REPORT_SUPPORTED_TASK_MANAGEMENT_FUNCTIONS 0x0d
-#define MI_REPORT_PRIORITY    0x0e
-#define MI_REPORT_TIMESTAMP   0x0f
-#define MI_MANAGEMENT_PROTOCOL_IN 0x10
-/* value for MI_REPORT_TARGET_PGS ext header */
-#define MI_EXT_HDR_PARAM_FMT  0x20
-/* values for maintenance out */
-#define MO_SET_IDENTIFYING_INFORMATION 0x06
-#define MO_SET_TARGET_PGS     0x0a
-#define MO_CHANGE_ALIASES     0x0b
-#define MO_SET_PRIORITY       0x0e
-#define MO_SET_TIMESTAMP      0x0f
-#define MO_MANAGEMENT_PROTOCOL_OUT 0x10
-/* values for variable length command */
-#define XDREAD_32	      0x03
-#define XDWRITE_32	      0x04
-#define XPWRITE_32	      0x06
-#define XDWRITEREAD_32	      0x07
-#define READ_32		      0x09
-#define VERIFY_32	      0x0a
-#define WRITE_32	      0x0b
-#define WRITE_SAME_32	      0x0d
-
-/* Values for T10/04-262r7 */
-#define	ATA_16		      0x85	/* 16-byte pass-thru */
-#define	ATA_12		      0xa1	/* 12-byte pass-thru */
-
-/* Vendor specific CDBs start here */
-#define VENDOR_SPECIFIC_CDB 0xc0
-
-/*
- *	SCSI command lengths
- */
-
-#define SCSI_MAX_VARLEN_CDB_SIZE 260
-
-/* defined in T10 SCSI Primary Commands-2 (SPC2) */
-struct scsi_varlen_cdb_hdr {
-	__u8 opcode;        /* opcode always == VARIABLE_LENGTH_CMD */
-	__u8 control;
-	__u8 misc[5];
-	__u8 additional_cdb_length;         /* total cdb length - 8 */
-	__be16 service_action;
-	/* service specific data follows */
-};
-
-static inline unsigned
-scsi_varlen_cdb_length(const void *hdr)
-{
-	return ((struct scsi_varlen_cdb_hdr *)hdr)->additional_cdb_length + 8;
-}
-
-extern const unsigned char scsi_command_size_tbl[8];
-#define COMMAND_SIZE(opcode) scsi_command_size_tbl[((opcode) >> 5) & 7]
-
-static inline unsigned
-scsi_command_size(const unsigned char *cmnd)
-{
-	return (cmnd[0] == VARIABLE_LENGTH_CMD) ?
-		scsi_varlen_cdb_length(cmnd) : COMMAND_SIZE(cmnd[0]);
-}
-
 #ifdef CONFIG_ACPI
 struct acpi_bus_type;
 
@@ -240,22 +58,6 @@ extern void
 scsi_unregister_acpi_bus_type(struct acpi_bus_type *bus);
 #endif
 
-/*
- *  SCSI Architecture Model (SAM) Status codes. Taken from SAM-3 draft
- *  T10/1561-D Revision 4 Draft dated 7th November 2002.
- */
-#define SAM_STAT_GOOD            0x00
-#define SAM_STAT_CHECK_CONDITION 0x02
-#define SAM_STAT_CONDITION_MET   0x04
-#define SAM_STAT_BUSY            0x08
-#define SAM_STAT_INTERMEDIATE    0x10
-#define SAM_STAT_INTERMEDIATE_CONDITION_MET 0x14
-#define SAM_STAT_RESERVATION_CONFLICT 0x18
-#define SAM_STAT_COMMAND_TERMINATED 0x22	/* obsolete in SAM-3 */
-#define SAM_STAT_TASK_SET_FULL   0x28
-#define SAM_STAT_ACA_ACTIVE      0x30
-#define SAM_STAT_TASK_ABORTED    0x40
-
 /** scsi_status_is_good - check the status return.
  *
  * @status: the status passed up from the driver (including host and
@@ -279,86 +81,6 @@ static inline int scsi_status_is_good(int status)
 		(status == SAM_STAT_COMMAND_TERMINATED));
 }
 
-/*
- *  Status codes. These are deprecated as they are shifted 1 bit right
- *  from those found in the SCSI standards. This causes confusion for
- *  applications that are ported to several OSes. Prefer SAM Status codes
- *  above.
- */
-
-#define GOOD                 0x00
-#define CHECK_CONDITION      0x01
-#define CONDITION_GOOD       0x02
-#define BUSY                 0x04
-#define INTERMEDIATE_GOOD    0x08
-#define INTERMEDIATE_C_GOOD  0x0a
-#define RESERVATION_CONFLICT 0x0c
-#define COMMAND_TERMINATED   0x11
-#define QUEUE_FULL           0x14
-#define ACA_ACTIVE           0x18
-#define TASK_ABORTED         0x20
-
-#define STATUS_MASK          0xfe
-
-/*
- *  SENSE KEYS
- */
-
-#define NO_SENSE            0x00
-#define RECOVERED_ERROR     0x01
-#define NOT_READY           0x02
-#define MEDIUM_ERROR        0x03
-#define HARDWARE_ERROR      0x04
-#define ILLEGAL_REQUEST     0x05
-#define UNIT_ATTENTION      0x06
-#define DATA_PROTECT        0x07
-#define BLANK_CHECK         0x08
-#define COPY_ABORTED        0x0a
-#define ABORTED_COMMAND     0x0b
-#define VOLUME_OVERFLOW     0x0d
-#define MISCOMPARE          0x0e
-
-
-/*
- *  DEVICE TYPES
- *  Please keep them in 0x%02x format for $MODALIAS to work
- */
-
-#define TYPE_DISK           0x00
-#define TYPE_TAPE           0x01
-#define TYPE_PRINTER        0x02
-#define TYPE_PROCESSOR      0x03    /* HP scanners use this */
-#define TYPE_WORM           0x04    /* Treated as ROM by our system */
-#define TYPE_ROM            0x05
-#define TYPE_SCANNER        0x06
-#define TYPE_MOD            0x07    /* Magneto-optical disk - 
-				     * - treated as TYPE_DISK */
-#define TYPE_MEDIUM_CHANGER 0x08
-#define TYPE_COMM           0x09    /* Communications device */
-#define TYPE_RAID           0x0c
-#define TYPE_ENCLOSURE      0x0d    /* Enclosure Services Device */
-#define TYPE_RBC	    0x0e
-#define TYPE_OSD            0x11
-#define TYPE_ZBC            0x14
-#define TYPE_WLUN           0x1e    /* well-known logical unit */
-#define TYPE_NO_LUN         0x7f
-
-/* SCSI protocols; these are taken from SPC-3 section 7.5 */
-enum scsi_protocol {
-	SCSI_PROTOCOL_FCP = 0,	/* Fibre Channel */
-	SCSI_PROTOCOL_SPI = 1,	/* parallel SCSI */
-	SCSI_PROTOCOL_SSA = 2,	/* Serial Storage Architecture - Obsolete */
-	SCSI_PROTOCOL_SBP = 3,	/* firewire */
-	SCSI_PROTOCOL_SRP = 4,	/* Infiniband RDMA */
-	SCSI_PROTOCOL_ISCSI = 5,
-	SCSI_PROTOCOL_SAS = 6,
-	SCSI_PROTOCOL_ADT = 7,	/* Media Changers */
-	SCSI_PROTOCOL_ATA = 8,
-	SCSI_PROTOCOL_UNSPEC = 0xf, /* No specific protocol */
-};
-
-/* Returns a human-readable name for the device */
-extern const char * scsi_device_type(unsigned type);
 
 /*
  * standard mode-select header prepended to all mode-select commands
@@ -380,13 +102,6 @@ struct ccs_modesel_head {
 };
 
 /*
- * ScsiLun: 8 byte LUN.
- */
-struct scsi_lun {
-	__u8 scsi_lun[8];
-};
-
-/*
  * The Well Known LUNS (SAM-3) in our int representation of a LUN
  */
 #define SCSI_W_LUN_BASE 0xc100
diff --git a/include/scsi/scsi_common.h b/include/scsi/scsi_common.h
new file mode 100644
index 0000000..676b03b
--- /dev/null
+++ b/include/scsi/scsi_common.h
@@ -0,0 +1,64 @@
+/*
+ * Functions used by both the SCSI initiator code and the SCSI target code.
+ */
+
+#ifndef _SCSI_COMMON_H_
+#define _SCSI_COMMON_H_
+
+#include <linux/types.h>
+#include <scsi/scsi_proto.h>
+
+static inline unsigned
+scsi_varlen_cdb_length(const void *hdr)
+{
+	return ((struct scsi_varlen_cdb_hdr *)hdr)->additional_cdb_length + 8;
+}
+
+extern const unsigned char scsi_command_size_tbl[8];
+#define COMMAND_SIZE(opcode) scsi_command_size_tbl[((opcode) >> 5) & 7]
+
+static inline unsigned
+scsi_command_size(const unsigned char *cmnd)
+{
+	return (cmnd[0] == VARIABLE_LENGTH_CMD) ?
+		scsi_varlen_cdb_length(cmnd) : COMMAND_SIZE(cmnd[0]);
+}
+
+/* Returns a human-readable name for the device */
+extern const char *scsi_device_type(unsigned type);
+
+extern void int_to_scsilun(u64, struct scsi_lun *);
+extern u64 scsilun_to_int(struct scsi_lun *);
+
+/*
+ * This is a slightly modified SCSI sense "descriptor" format header.
+ * The addition is to allow the 0x70 and 0x71 response codes. The idea
+ * is to place the salient data from either "fixed" or "descriptor" sense
+ * format into one structure to ease application processing.
+ *
+ * The original sense buffer should be kept around for those cases
+ * in which more information is required (e.g. the LBA of a MEDIUM ERROR).
+ */
+struct scsi_sense_hdr {		/* See SPC-3 section 4.5 */
+	u8 response_code;	/* permit: 0x0, 0x70, 0x71, 0x72, 0x73 */
+	u8 sense_key;
+	u8 asc;
+	u8 ascq;
+	u8 byte4;
+	u8 byte5;
+	u8 byte6;
+	u8 additional_length;	/* always 0 for fixed sense format */
+};
+
+static inline bool scsi_sense_valid(const struct scsi_sense_hdr *sshdr)
+{
+	if (!sshdr)
+		return false;
+
+	return (sshdr->response_code & 0x70) == 0x70;
+}
+
+extern bool scsi_normalize_sense(const u8 *sense_buffer, int sb_len,
+				 struct scsi_sense_hdr *sshdr);
+
+#endif /* _SCSI_COMMON_H_ */
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index a4c9336..ae84b22 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -413,8 +413,6 @@ extern void scsi_target_reap(struct scsi_target *);
 extern void scsi_target_block(struct device *);
 extern void scsi_target_unblock(struct device *, enum scsi_device_state);
 extern void scsi_remove_target(struct device *);
-extern void int_to_scsilun(u64, struct scsi_lun *);
-extern u64 scsilun_to_int(struct scsi_lun *);
 extern const char *scsi_device_state_name(enum scsi_device_state);
 extern int scsi_is_sdev_device(const struct device *);
 extern int scsi_is_target_device(const struct device *);
diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h
index 1e1421b..8d1d7fa 100644
--- a/include/scsi/scsi_eh.h
+++ b/include/scsi/scsi_eh.h
@@ -7,43 +7,12 @@
 struct scsi_device;
 struct Scsi_Host;
 
-/*
- * This is a slightly modified SCSI sense "descriptor" format header.
- * The addition is to allow the 0x70 and 0x71 response codes. The idea
- * is to place the salient data from either "fixed" or "descriptor" sense
- * format into one structure to ease application processing.
- *
- * The original sense buffer should be kept around for those cases
- * in which more information is required (e.g. the LBA of a MEDIUM ERROR).
- */
-struct scsi_sense_hdr {		/* See SPC-3 section 4.5 */
-	u8 response_code;	/* permit: 0x0, 0x70, 0x71, 0x72, 0x73 */
-	u8 sense_key;
-	u8 asc;
-	u8 ascq;
-	u8 byte4;
-	u8 byte5;
-	u8 byte6;
-	u8 additional_length;	/* always 0 for fixed sense format */
-};
-
-static inline bool scsi_sense_valid(const struct scsi_sense_hdr *sshdr)
-{
-	if (!sshdr)
-		return false;
-
-	return (sshdr->response_code & 0x70) == 0x70;
-}
-
-
 extern void scsi_eh_finish_cmd(struct scsi_cmnd *scmd,
 			       struct list_head *done_q);
 extern void scsi_eh_flush_done_q(struct list_head *done_q);
 extern void scsi_report_bus_reset(struct Scsi_Host *, int);
 extern void scsi_report_device_reset(struct Scsi_Host *, int, int);
 extern int scsi_block_when_processing_errors(struct scsi_device *);
-extern bool scsi_normalize_sense(const u8 *sense_buffer, int sb_len,
-				 struct scsi_sense_hdr *sshdr);
 extern bool scsi_command_normalize_sense(const struct scsi_cmnd *cmd,
 					 struct scsi_sense_hdr *sshdr);
 
diff --git a/include/scsi/scsi_proto.h b/include/scsi/scsi_proto.h
new file mode 100644
index 0000000..a9fbf1b
--- /dev/null
+++ b/include/scsi/scsi_proto.h
@@ -0,0 +1,281 @@
+/*
+ * This header file contains public constants and structures used by
+ * both the SCSI initiator and the SCSI target code.
+ *
+ * For documentation on the OPCODES, MESSAGES, and SENSE values,
+ * please consult the SCSI standard.
+ */
+
+#ifndef _SCSI_PROTO_H_
+#define _SCSI_PROTO_H_
+
+#include <linux/types.h>
+
+/*
+ *      SCSI opcodes
+ */
+
+#define TEST_UNIT_READY       0x00
+#define REZERO_UNIT           0x01
+#define REQUEST_SENSE         0x03
+#define FORMAT_UNIT           0x04
+#define READ_BLOCK_LIMITS     0x05
+#define REASSIGN_BLOCKS       0x07
+#define INITIALIZE_ELEMENT_STATUS 0x07
+#define READ_6                0x08
+#define WRITE_6               0x0a
+#define SEEK_6                0x0b
+#define READ_REVERSE          0x0f
+#define WRITE_FILEMARKS       0x10
+#define SPACE                 0x11
+#define INQUIRY               0x12
+#define RECOVER_BUFFERED_DATA 0x14
+#define MODE_SELECT           0x15
+#define RESERVE               0x16
+#define RELEASE               0x17
+#define COPY                  0x18
+#define ERASE                 0x19
+#define MODE_SENSE            0x1a
+#define START_STOP            0x1b
+#define RECEIVE_DIAGNOSTIC    0x1c
+#define SEND_DIAGNOSTIC       0x1d
+#define ALLOW_MEDIUM_REMOVAL  0x1e
+
+#define READ_FORMAT_CAPACITIES 0x23
+#define SET_WINDOW            0x24
+#define READ_CAPACITY         0x25
+#define READ_10               0x28
+#define WRITE_10              0x2a
+#define SEEK_10               0x2b
+#define POSITION_TO_ELEMENT   0x2b
+#define WRITE_VERIFY          0x2e
+#define VERIFY                0x2f
+#define SEARCH_HIGH           0x30
+#define SEARCH_EQUAL          0x31
+#define SEARCH_LOW            0x32
+#define SET_LIMITS            0x33
+#define PRE_FETCH             0x34
+#define READ_POSITION         0x34
+#define SYNCHRONIZE_CACHE     0x35
+#define LOCK_UNLOCK_CACHE     0x36
+#define READ_DEFECT_DATA      0x37
+#define MEDIUM_SCAN           0x38
+#define COMPARE               0x39
+#define COPY_VERIFY           0x3a
+#define WRITE_BUFFER          0x3b
+#define READ_BUFFER           0x3c
+#define UPDATE_BLOCK          0x3d
+#define READ_LONG             0x3e
+#define WRITE_LONG            0x3f
+#define CHANGE_DEFINITION     0x40
+#define WRITE_SAME            0x41
+#define UNMAP		      0x42
+#define READ_TOC              0x43
+#define READ_HEADER           0x44
+#define GET_EVENT_STATUS_NOTIFICATION 0x4a
+#define LOG_SELECT            0x4c
+#define LOG_SENSE             0x4d
+#define XDWRITEREAD_10        0x53
+#define MODE_SELECT_10        0x55
+#define RESERVE_10            0x56
+#define RELEASE_10            0x57
+#define MODE_SENSE_10         0x5a
+#define PERSISTENT_RESERVE_IN 0x5e
+#define PERSISTENT_RESERVE_OUT 0x5f
+#define VARIABLE_LENGTH_CMD   0x7f
+#define REPORT_LUNS           0xa0
+#define SECURITY_PROTOCOL_IN  0xa2
+#define MAINTENANCE_IN        0xa3
+#define MAINTENANCE_OUT       0xa4
+#define MOVE_MEDIUM           0xa5
+#define EXCHANGE_MEDIUM       0xa6
+#define READ_12               0xa8
+#define SERVICE_ACTION_OUT_12 0xa9
+#define WRITE_12              0xaa
+#define READ_MEDIA_SERIAL_NUMBER 0xab /* Obsolete with SPC-2 */
+#define SERVICE_ACTION_IN_12  0xab
+#define WRITE_VERIFY_12       0xae
+#define VERIFY_12	      0xaf
+#define SEARCH_HIGH_12        0xb0
+#define SEARCH_EQUAL_12       0xb1
+#define SEARCH_LOW_12         0xb2
+#define SECURITY_PROTOCOL_OUT 0xb5
+#define READ_ELEMENT_STATUS   0xb8
+#define SEND_VOLUME_TAG       0xb6
+#define WRITE_LONG_2          0xea
+#define EXTENDED_COPY         0x83
+#define RECEIVE_COPY_RESULTS  0x84
+#define ACCESS_CONTROL_IN     0x86
+#define ACCESS_CONTROL_OUT    0x87
+#define READ_16               0x88
+#define COMPARE_AND_WRITE     0x89
+#define WRITE_16              0x8a
+#define READ_ATTRIBUTE        0x8c
+#define WRITE_ATTRIBUTE	      0x8d
+#define VERIFY_16	      0x8f
+#define SYNCHRONIZE_CACHE_16  0x91
+#define WRITE_SAME_16	      0x93
+#define SERVICE_ACTION_BIDIRECTIONAL 0x9d
+#define SERVICE_ACTION_IN_16  0x9e
+#define SERVICE_ACTION_OUT_16 0x9f
+/* values for service action in */
+#define	SAI_READ_CAPACITY_16  0x10
+#define SAI_GET_LBA_STATUS    0x12
+#define SAI_REPORT_REFERRALS  0x13
+/* values for VARIABLE_LENGTH_CMD service action codes
+ * see spc4r17 Section D.3.5, table D.7 and D.8 */
+#define VLC_SA_RECEIVE_CREDENTIAL 0x1800
+/* values for maintenance in */
+#define MI_REPORT_IDENTIFYING_INFORMATION 0x05
+#define MI_REPORT_TARGET_PGS  0x0a
+#define MI_REPORT_ALIASES     0x0b
+#define MI_REPORT_SUPPORTED_OPERATION_CODES 0x0c
+#define MI_REPORT_SUPPORTED_TASK_MANAGEMENT_FUNCTIONS 0x0d
+#define MI_REPORT_PRIORITY    0x0e
+#define MI_REPORT_TIMESTAMP   0x0f
+#define MI_MANAGEMENT_PROTOCOL_IN 0x10
+/* value for MI_REPORT_TARGET_PGS ext header */
+#define MI_EXT_HDR_PARAM_FMT  0x20
+/* values for maintenance out */
+#define MO_SET_IDENTIFYING_INFORMATION 0x06
+#define MO_SET_TARGET_PGS     0x0a
+#define MO_CHANGE_ALIASES     0x0b
+#define MO_SET_PRIORITY       0x0e
+#define MO_SET_TIMESTAMP      0x0f
+#define MO_MANAGEMENT_PROTOCOL_OUT 0x10
+/* values for variable length command */
+#define XDREAD_32	      0x03
+#define XDWRITE_32	      0x04
+#define XPWRITE_32	      0x06
+#define XDWRITEREAD_32	      0x07
+#define READ_32		      0x09
+#define VERIFY_32	      0x0a
+#define WRITE_32	      0x0b
+#define WRITE_SAME_32	      0x0d
+
+/* Values for T10/04-262r7 */
+#define	ATA_16		      0x85	/* 16-byte pass-thru */
+#define	ATA_12		      0xa1	/* 12-byte pass-thru */
+
+/* Vendor specific CDBs start here */
+#define VENDOR_SPECIFIC_CDB 0xc0
+
+/*
+ *	SCSI command lengths
+ */
+
+#define SCSI_MAX_VARLEN_CDB_SIZE 260
+
+/* defined in T10 SCSI Primary Commands-2 (SPC2) */
+struct scsi_varlen_cdb_hdr {
+	__u8 opcode;        /* opcode always == VARIABLE_LENGTH_CMD */
+	__u8 control;
+	__u8 misc[5];
+	__u8 additional_cdb_length;         /* total cdb length - 8 */
+	__be16 service_action;
+	/* service specific data follows */
+};
+
+/*
+ *  SCSI Architecture Model (SAM) Status codes. Taken from SAM-3 draft
+ *  T10/1561-D Revision 4 Draft dated 7th November 2002.
+ */
+#define SAM_STAT_GOOD            0x00
+#define SAM_STAT_CHECK_CONDITION 0x02
+#define SAM_STAT_CONDITION_MET   0x04
+#define SAM_STAT_BUSY            0x08
+#define SAM_STAT_INTERMEDIATE    0x10
+#define SAM_STAT_INTERMEDIATE_CONDITION_MET 0x14
+#define SAM_STAT_RESERVATION_CONFLICT 0x18
+#define SAM_STAT_COMMAND_TERMINATED 0x22	/* obsolete in SAM-3 */
+#define SAM_STAT_TASK_SET_FULL   0x28
+#define SAM_STAT_ACA_ACTIVE      0x30
+#define SAM_STAT_TASK_ABORTED    0x40
+
+/*
+ *  Status codes. These are deprecated as they are shifted 1 bit right
+ *  from those found in the SCSI standards. This causes confusion for
+ *  applications that are ported to several OSes. Prefer SAM Status codes
+ *  above.
+ */
+
+#define GOOD                 0x00
+#define CHECK_CONDITION      0x01
+#define CONDITION_GOOD       0x02
+#define BUSY                 0x04
+#define INTERMEDIATE_GOOD    0x08
+#define INTERMEDIATE_C_GOOD  0x0a
+#define RESERVATION_CONFLICT 0x0c
+#define COMMAND_TERMINATED   0x11
+#define QUEUE_FULL           0x14
+#define ACA_ACTIVE           0x18
+#define TASK_ABORTED         0x20
+
+#define STATUS_MASK          0xfe
+
+/*
+ *  SENSE KEYS
+ */
+
+#define NO_SENSE            0x00
+#define RECOVERED_ERROR     0x01
+#define NOT_READY           0x02
+#define MEDIUM_ERROR        0x03
+#define HARDWARE_ERROR      0x04
+#define ILLEGAL_REQUEST     0x05
+#define UNIT_ATTENTION      0x06
+#define DATA_PROTECT        0x07
+#define BLANK_CHECK         0x08
+#define COPY_ABORTED        0x0a
+#define ABORTED_COMMAND     0x0b
+#define VOLUME_OVERFLOW     0x0d
+#define MISCOMPARE          0x0e
+
+
+/*
+ *  DEVICE TYPES
+ *  Please keep them in 0x%02x format for $MODALIAS to work
+ */
+
+#define TYPE_DISK           0x00
+#define TYPE_TAPE           0x01
+#define TYPE_PRINTER        0x02
+#define TYPE_PROCESSOR      0x03    /* HP scanners use this */
+#define TYPE_WORM           0x04    /* Treated as ROM by our system */
+#define TYPE_ROM            0x05
+#define TYPE_SCANNER        0x06
+#define TYPE_MOD            0x07    /* Magneto-optical disk -
+				     * - treated as TYPE_DISK */
+#define TYPE_MEDIUM_CHANGER 0x08
+#define TYPE_COMM           0x09    /* Communications device */
+#define TYPE_RAID           0x0c
+#define TYPE_ENCLOSURE      0x0d    /* Enclosure Services Device */
+#define TYPE_RBC	    0x0e
+#define TYPE_OSD            0x11
+#define TYPE_ZBC            0x14
+#define TYPE_WLUN           0x1e    /* well-known logical unit */
+#define TYPE_NO_LUN         0x7f
+
+/* SCSI protocols; these are taken from SPC-3 section 7.5 */
+enum scsi_protocol {
+	SCSI_PROTOCOL_FCP = 0,	/* Fibre Channel */
+	SCSI_PROTOCOL_SPI = 1,	/* parallel SCSI */
+	SCSI_PROTOCOL_SSA = 2,	/* Serial Storage Architecture - Obsolete */
+	SCSI_PROTOCOL_SBP = 3,	/* firewire */
+	SCSI_PROTOCOL_SRP = 4,	/* Infiniband RDMA */
+	SCSI_PROTOCOL_ISCSI = 5,
+	SCSI_PROTOCOL_SAS = 6,
+	SCSI_PROTOCOL_ADT = 7,	/* Media Changers */
+	SCSI_PROTOCOL_ATA = 8,
+	SCSI_PROTOCOL_UNSPEC = 0xf, /* No specific protocol */
+};
+
+/*
+ * ScsiLun: 8 byte LUN.
+ */
+struct scsi_lun {
+	__u8 scsi_lun[8];
+};
+
+
+#endif /* _SCSI_PROTO_H_ */
-- 
2.1.4


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

* [PATCH v3 2/4] Replace MAX_COMMAND_SIZE with BLK_MAX_CDB
  2015-04-07 12:32 [PATCH v3] Split SCSI header files Bart Van Assche
  2015-04-07 12:33 ` [PATCH v3 1/4] " Bart Van Assche
@ 2015-04-07 12:33 ` Bart Van Assche
  2015-04-07 12:33 ` [PATCH v3 3/4] target: Correct a comment Bart Van Assche
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Bart Van Assche @ 2015-04-07 12:33 UTC (permalink / raw)
  To: James Bottomley
  Cc: Christoph Hellwig, Nicholas A. Bellinger, Hannes Reinecke,
	Mike Christie, linux-scsi, target-devel

Since the two constants MAX_COMMAND_SIZE and BLK_MAX_CDB have
the same meaning, replace MAX_COMMAND_SIZE with BLK_MAX_CDB.

This patch has been generated by removing the MAX_COMMAND_SIZE
definition manually from <scsi/scsi_cmnd.h> and also from
drivers/usb/gadget/function/storage_common.h. The other changes
in this patch have been generated with the help of the following
command:

sed -i.orig 's/\([^a-zA-Z_]\)MAX_COMMAND_SIZE/\1BLK_MAX_CDB/g' $(git grep -lw MAX_COMMAND_SIZE)

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Nicholas Bellinger <nab@linux-iscsi.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Mike Christie <michaelc@cs.wisc.edu>
---
 drivers/ata/libata-scsi.c                    |  4 +-
 drivers/block/cciss_scsi.c                   |  2 +-
 drivers/scsi/53c700.c                        |  8 +--
 drivers/scsi/53c700.h                        |  2 +-
 drivers/scsi/gdth.c                          |  6 +-
 drivers/scsi/gdth_proc.c                     |  4 +-
 drivers/scsi/hpsa.c                          |  2 +-
 drivers/scsi/isci/init.c                     |  2 +-
 drivers/scsi/mvumi.c                         | 10 +--
 drivers/scsi/mvumi.h                         |  2 +-
 drivers/scsi/osst.c                          | 96 ++++++++++++++--------------
 drivers/scsi/osst.h                          |  2 +-
 drivers/scsi/qla1280.c                       |  2 +-
 drivers/scsi/scsi_ioctl.c                    |  4 +-
 drivers/scsi/scsi_scan.c                     |  6 +-
 drivers/scsi/st.c                            | 52 +++++++--------
 drivers/scsi/st.h                            |  2 +-
 drivers/target/target_core_pscsi.c           | 12 ++--
 drivers/usb/gadget/function/f_mass_storage.c |  4 +-
 drivers/usb/gadget/function/storage_common.h |  3 -
 drivers/usb/storage/cypress_atacb.c          |  4 +-
 include/scsi/scsi_cmnd.h                     | 17 -----
 22 files changed, 113 insertions(+), 133 deletions(-)

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index b061ba2..1ae14a7 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -483,7 +483,7 @@ static int ata_get_identity(struct ata_port *ap, struct scsi_device *sdev,
 int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)
 {
 	int rc = 0;
-	u8 scsi_cmd[MAX_COMMAND_SIZE];
+	u8 scsi_cmd[BLK_MAX_CDB];
 	u8 args[4], *argbuf = NULL, *sensebuf = NULL;
 	int argsize = 0;
 	enum dma_data_direction data_dir;
@@ -592,7 +592,7 @@ error:
 int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg)
 {
 	int rc = 0;
-	u8 scsi_cmd[MAX_COMMAND_SIZE];
+	u8 scsi_cmd[BLK_MAX_CDB];
 	u8 args[7], *sensebuf = NULL;
 	int cmd_result;
 
diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c
index ecd845c..5cf43db 100644
--- a/drivers/block/cciss_scsi.c
+++ b/drivers/block/cciss_scsi.c
@@ -856,7 +856,7 @@ cciss_scsi_detect(ctlr_info_t *h)
 	sh->this_id = SELF_SCSI_ID;  
 	sh->can_queue = cciss_tape_cmds;
 	sh->sg_tablesize = h->maxsgentries;
-	sh->max_cmd_len = MAX_COMMAND_SIZE;
+	sh->max_cmd_len = BLK_MAX_CDB;
 	sh->max_sectors = h->cciss_max_sectors;
 
 	((struct cciss_scsi_adapter_data_t *) 
diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c
index 82abfce..da19099 100644
--- a/drivers/scsi/53c700.c
+++ b/drivers/scsi/53c700.c
@@ -595,7 +595,7 @@ NCR_700_scsi_done(struct NCR_700_Host_Parameters *hostdata,
 			(struct NCR_700_command_slot *)SCp->host_scribble;
 
 		dma_unmap_single(hostdata->dev, slot->pCmd,
-				 MAX_COMMAND_SIZE, DMA_TO_DEVICE);
+				 BLK_MAX_CDB, DMA_TO_DEVICE);
 		if (slot->flags == NCR_700_FLAG_AUTOSENSE) {
 			char *cmnd = NCR_700_get_sense_cmnd(SCp->device);
 
@@ -997,7 +997,7 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp,
 				 * here */
 				NCR_700_unmap(hostdata, SCp, slot);
 				dma_unmap_single(hostdata->dev, slot->pCmd,
-						 MAX_COMMAND_SIZE,
+						 BLK_MAX_CDB,
 						 DMA_TO_DEVICE);
 
 				cmnd[0] = REQUEST_SENSE;
@@ -1017,7 +1017,7 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp,
 				cmnd[8] = SCp->cmd_len;
 				SCp->cmd_len = 6; /* command length for
 						   * REQUEST_SENSE */
-				slot->pCmd = dma_map_single(hostdata->dev, cmnd, MAX_COMMAND_SIZE, DMA_TO_DEVICE);
+				slot->pCmd = dma_map_single(hostdata->dev, cmnd, BLK_MAX_CDB, DMA_TO_DEVICE);
 				slot->dma_handle = dma_map_single(hostdata->dev, SCp->sense_buffer, SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE);
 				slot->SG[0].ins = bS_to_host(SCRIPT_MOVE_DATA_IN | SCSI_SENSE_BUFFERSIZE);
 				slot->SG[0].pAddr = bS_to_host(slot->dma_handle);
@@ -1895,7 +1895,7 @@ NCR_700_queuecommand_lck(struct scsi_cmnd *SCp, void (*done)(struct scsi_cmnd *)
 	}
 	slot->resume_offset = 0;
 	slot->pCmd = dma_map_single(hostdata->dev, SCp->cmnd,
-				    MAX_COMMAND_SIZE, DMA_TO_DEVICE);
+				    BLK_MAX_CDB, DMA_TO_DEVICE);
 	NCR_700_start_command(SCp);
 	return 0;
 }
diff --git a/drivers/scsi/53c700.h b/drivers/scsi/53c700.h
index e06bdfe..dd06fb7 100644
--- a/drivers/scsi/53c700.h
+++ b/drivers/scsi/53c700.h
@@ -80,7 +80,7 @@ struct NCR_700_Device_Parameters {
 	/* space for creating a request sense command. Really, except
 	 * for the annoying SCSI-2 requirement for LUN information in
 	 * cmnd[1], this could be in static storage */
-	unsigned char cmnd[MAX_COMMAND_SIZE];
+	unsigned char cmnd[BLK_MAX_CDB];
 	__u8	depth;
 };
 
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index 71e1380..455bb6c 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -4472,7 +4472,7 @@ static int gdth_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
     gdth_ha_str *ha; 
     Scsi_Cmnd *scp;
     unsigned long flags;
-    char cmnd[MAX_COMMAND_SIZE];   
+    char cmnd[BLK_MAX_CDB];   
     void __user *argp = (void __user *)arg;
 
     memset(cmnd, 0xff, 12);
@@ -4632,8 +4632,8 @@ static void gdth_flush(gdth_ha_str *ha)
 {
     int             i;
     gdth_cmd_str    gdtcmd;
-    char            cmnd[MAX_COMMAND_SIZE];   
-    memset(cmnd, 0xff, MAX_COMMAND_SIZE);
+    char            cmnd[BLK_MAX_CDB];   
+    memset(cmnd, 0xff, BLK_MAX_CDB);
 
     TRACE2(("gdth_flush() hanum %d\n", ha->hanum));
 
diff --git a/drivers/scsi/gdth_proc.c b/drivers/scsi/gdth_proc.c
index e66e997..88bfe50 100644
--- a/drivers/scsi/gdth_proc.c
+++ b/drivers/scsi/gdth_proc.c
@@ -32,7 +32,7 @@ static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer,
     gdth_cpar_str   *pcpar;
     u64         paddr;
 
-    char            cmnd[MAX_COMMAND_SIZE];
+    char            cmnd[BLK_MAX_CDB];
     memset(cmnd, 0xff, 12);
     memset(&gdtcmd, 0, sizeof(gdth_cmd_str));
 
@@ -157,7 +157,7 @@ int gdth_show_info(struct seq_file *m, struct Scsi_Host *host)
     gdth_defcnt_str *pdef;
     gdth_cdrinfo_str *pcdi;
     gdth_hget_str *phg;
-    char cmnd[MAX_COMMAND_SIZE];
+    char cmnd[BLK_MAX_CDB];
 
     gdtcmd = kmalloc(sizeof(*gdtcmd), GFP_KERNEL);
     estr = kmalloc(sizeof(*estr), GFP_KERNEL);
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index a1cfbd3..5179d9e 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -4249,7 +4249,7 @@ static int hpsa_register_scsi(struct ctlr_info *h)
 	sh->n_io_port = 0;
 	sh->this_id = -1;
 	sh->max_channel = 3;
-	sh->max_cmd_len = MAX_COMMAND_SIZE;
+	sh->max_cmd_len = BLK_MAX_CDB;
 	sh->max_lun = HPSA_MAX_LUN;
 	sh->max_id = HPSA_MAX_LUN;
 	sh->can_queue = h->nr_cmds -
diff --git a/drivers/scsi/isci/init.c b/drivers/scsi/isci/init.c
index cd41b63..e0c9d07 100644
--- a/drivers/scsi/isci/init.c
+++ b/drivers/scsi/isci/init.c
@@ -595,7 +595,7 @@ static struct isci_host *isci_host_alloc(struct pci_dev *pdev, int id)
 
 	shost->max_id = ~0;
 	shost->max_lun = ~0;
-	shost->max_cmd_len = MAX_COMMAND_SIZE;
+	shost->max_cmd_len = BLK_MAX_CDB;
 
 	err = scsi_add_host(shost, &pdev->dev);
 	if (err)
diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c
index 3e6b866..93689c3 100644
--- a/drivers/scsi/mvumi.c
+++ b/drivers/scsi/mvumi.c
@@ -818,8 +818,8 @@ get_cmd:	cmd = mvumi_create_internal_cmd(mhba, 0);
 		frame->device_id = device_id;
 		frame->cmd_flag = CMD_FLAG_NON_DATA;
 		frame->data_transfer_length = 0;
-		frame->cdb_length = MAX_COMMAND_SIZE;
-		memset(frame->cdb, 0, MAX_COMMAND_SIZE);
+		frame->cdb_length = BLK_MAX_CDB;
+		memset(frame->cdb, 0, BLK_MAX_CDB);
 		frame->cdb[0] = SCSI_CMD_MARVELL_SPECIFIC;
 		frame->cdb[1] = CDB_CORE_MODULE;
 		frame->cdb[2] = CDB_CORE_SHUTDOWN;
@@ -1748,9 +1748,9 @@ static int mvumi_get_event(struct mvumi_hba *mhba, unsigned char msg)
 	frame->device_id = 0;
 	frame->cmd_flag = CMD_FLAG_DATA_IN;
 	frame->req_function = CL_FUN_SCSI_CMD;
-	frame->cdb_length = MAX_COMMAND_SIZE;
+	frame->cdb_length = BLK_MAX_CDB;
 	frame->data_transfer_length = sizeof(struct mvumi_event_req);
-	memset(frame->cdb, 0, MAX_COMMAND_SIZE);
+	memset(frame->cdb, 0, BLK_MAX_CDB);
 	frame->cdb[0] = APICDB0_EVENT;
 	frame->cdb[1] = msg;
 	mvumi_issue_blocked_cmd(mhba, cmd);
@@ -2450,7 +2450,7 @@ static int mvumi_io_attach(struct mvumi_hba *mhba)
 	host->max_sectors = mhba->max_transfer_size / 512;
 	host->cmd_per_lun = (mhba->max_io - 1) ? (mhba->max_io - 1) : 1;
 	host->max_id = mhba->max_target_id;
-	host->max_cmd_len = MAX_COMMAND_SIZE;
+	host->max_cmd_len = BLK_MAX_CDB;
 	host->transportt = &mvumi_transport_template;
 
 	ret = scsi_add_host(host, &mhba->pdev->dev);
diff --git a/drivers/scsi/mvumi.h b/drivers/scsi/mvumi.h
index 41f1687..712d456 100644
--- a/drivers/scsi/mvumi.h
+++ b/drivers/scsi/mvumi.h
@@ -285,7 +285,7 @@ struct mvumi_msg_frame {
 	u32 data_transfer_length;
 	u16 request_id;
 	u16 reserved1;
-	u8 cdb[MAX_COMMAND_SIZE];
+	u8 cdb[BLK_MAX_CDB];
 	u32 payload[1];
 };
 
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index 5033223..4c60352 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -749,7 +749,7 @@ err_out:
 static int osst_wait_ready(struct osst_tape * STp, struct osst_request ** aSRpnt,
 				 unsigned timeout, int initial_delay)
 {
-	unsigned char		cmd[MAX_COMMAND_SIZE];
+	unsigned char		cmd[BLK_MAX_CDB];
 	struct osst_request   * SRpnt;
 	unsigned long		startwait = jiffies;
 #if DEBUG
@@ -762,7 +762,7 @@ static int osst_wait_ready(struct osst_tape * STp, struct osst_request ** aSRpnt
 	if (initial_delay > 0)
 		msleep(jiffies_to_msecs(initial_delay));
 
-	memset(cmd, 0, MAX_COMMAND_SIZE);
+	memset(cmd, 0, BLK_MAX_CDB);
 	cmd[0] = TEST_UNIT_READY;
 
 	SRpnt = osst_do_scsi(*aSRpnt, STp, cmd, 0, DMA_NONE, STp->timeout, MAX_RETRIES, 1);
@@ -783,7 +783,7 @@ static int osst_wait_ready(struct osst_tape * STp, struct osst_request ** aSRpnt
 #endif
 	    msleep(100);
 
-	    memset(cmd, 0, MAX_COMMAND_SIZE);
+	    memset(cmd, 0, BLK_MAX_CDB);
 	    cmd[0] = TEST_UNIT_READY;
 
 	    SRpnt = osst_do_scsi(SRpnt, STp, cmd, 0, DMA_NONE, STp->timeout, MAX_RETRIES, 1);
@@ -813,7 +813,7 @@ static int osst_wait_ready(struct osst_tape * STp, struct osst_request ** aSRpnt
  */
 static int osst_wait_for_medium(struct osst_tape * STp, struct osst_request ** aSRpnt, unsigned timeout)
 {
-	unsigned char		cmd[MAX_COMMAND_SIZE];
+	unsigned char		cmd[BLK_MAX_CDB];
 	struct osst_request   * SRpnt;
 	unsigned long		startwait = jiffies;
 #if DEBUG
@@ -823,7 +823,7 @@ static int osst_wait_for_medium(struct osst_tape * STp, struct osst_request ** a
 	printk(OSST_DEB_MSG "%s:D: Reached onstream wait for medium\n", name);
 #endif
 
-	memset(cmd, 0, MAX_COMMAND_SIZE);
+	memset(cmd, 0, BLK_MAX_CDB);
 	cmd[0] = TEST_UNIT_READY;
 
 	SRpnt = osst_do_scsi(*aSRpnt, STp, cmd, 0, DMA_NONE, STp->timeout, MAX_RETRIES, 1);
@@ -841,7 +841,7 @@ static int osst_wait_for_medium(struct osst_tape * STp, struct osst_request ** a
 #endif
 	    msleep(100);
 
-	    memset(cmd, 0, MAX_COMMAND_SIZE);
+	    memset(cmd, 0, BLK_MAX_CDB);
 	    cmd[0] = TEST_UNIT_READY;
 
 	    SRpnt = osst_do_scsi(SRpnt, STp, cmd, 0, DMA_NONE, STp->timeout, MAX_RETRIES, 1);
@@ -882,7 +882,7 @@ static int osst_position_tape_and_confirm(struct osst_tape * STp, struct osst_re
  */
 static int osst_flush_drive_buffer(struct osst_tape * STp, struct osst_request ** aSRpnt)
 {
-	unsigned char		cmd[MAX_COMMAND_SIZE];
+	unsigned char		cmd[BLK_MAX_CDB];
 	struct osst_request   * SRpnt;
 	int			result = 0;
 	int			delay  = OSST_WAIT_WRITE_COMPLETE;
@@ -892,7 +892,7 @@ static int osst_flush_drive_buffer(struct osst_tape * STp, struct osst_request *
 	printk(OSST_DEB_MSG "%s:D: Reached onstream flush drive buffer (write filemark)\n", name);
 #endif
 
-	memset(cmd, 0, MAX_COMMAND_SIZE);
+	memset(cmd, 0, BLK_MAX_CDB);
 	cmd[0] = WRITE_FILEMARKS;
 	cmd[1] = 1;
 
@@ -972,7 +972,7 @@ static int osst_wait_frame(struct osst_tape * STp, struct osst_request ** aSRpnt
 static int osst_recover_wait_frame(struct osst_tape * STp, struct osst_request ** aSRpnt, int writing)
 {
 	struct osst_request   * SRpnt;
-	unsigned char		cmd[MAX_COMMAND_SIZE];
+	unsigned char		cmd[BLK_MAX_CDB];
 	unsigned long   	startwait = jiffies;
 	int			retval    = 1;
         char		      * name      = tape_name(STp);
@@ -984,7 +984,7 @@ static int osst_recover_wait_frame(struct osst_tape * STp, struct osst_request *
 
 		/* write zero fm then read pos - if shows write error, try to recover - if no progress, wait */
 
-		memset(cmd, 0, MAX_COMMAND_SIZE);
+		memset(cmd, 0, BLK_MAX_CDB);
 		cmd[0] = WRITE_FILEMARKS;
 		cmd[1] = 1;
 		SRpnt = osst_do_scsi(*aSRpnt, STp, cmd, 0, DMA_NONE, STp->timeout,
@@ -1001,7 +1001,7 @@ static int osst_recover_wait_frame(struct osst_tape * STp, struct osst_request *
 			schedule_timeout_interruptible(HZ / OSST_POLL_PER_SEC);
 
 			STp->buffer->b_data = mybuf; STp->buffer->buffer_size = 24;
-			memset(cmd, 0, MAX_COMMAND_SIZE);
+			memset(cmd, 0, BLK_MAX_CDB);
 			cmd[0] = READ_POSITION;
 
 			SRpnt = osst_do_scsi(SRpnt, STp, cmd, 20, DMA_FROM_DEVICE, STp->timeout,
@@ -1029,7 +1029,7 @@ static int osst_recover_wait_frame(struct osst_tape * STp, struct osst_request *
  */
 static int osst_read_frame(struct osst_tape * STp, struct osst_request ** aSRpnt, int timeout)
 {
-	unsigned char		cmd[MAX_COMMAND_SIZE];
+	unsigned char		cmd[BLK_MAX_CDB];
 	struct osst_request   * SRpnt;
 	int			retval = 0;
 #if DEBUG
@@ -1041,7 +1041,7 @@ static int osst_read_frame(struct osst_tape * STp, struct osst_request ** aSRpnt
 		if (osst_wait_frame (STp, aSRpnt, STp->first_frame_position, 0, timeout))
 			retval = osst_recover_wait_frame(STp, aSRpnt, 0);
 
-	memset(cmd, 0, MAX_COMMAND_SIZE);
+	memset(cmd, 0, BLK_MAX_CDB);
 	cmd[0] = READ_6;
 	cmd[1] = 1;
 	cmd[4] = 1;
@@ -1102,7 +1102,7 @@ static int osst_initiate_read(struct osst_tape * STp, struct osst_request ** aSR
 {
 	struct st_partstat    * STps   = &(STp->ps[STp->partition]);
 	struct osst_request   * SRpnt  ;
-	unsigned char		cmd[MAX_COMMAND_SIZE];
+	unsigned char		cmd[BLK_MAX_CDB];
 	int			retval = 0;
 	char		      * name   = tape_name(STp);
 
@@ -1119,7 +1119,7 @@ static int osst_initiate_read(struct osst_tape * STp, struct osst_request ** aSR
 		 *      Issue a read 0 command to get the OnStream drive
                  *      read frames into its buffer.
 		 */
-		memset(cmd, 0, MAX_COMMAND_SIZE);
+		memset(cmd, 0, BLK_MAX_CDB);
 		cmd[0] = READ_6;
 		cmd[1] = 1;
 
@@ -1471,7 +1471,7 @@ static int osst_read_back_buffer_and_rewrite(struct osst_tape * STp, struct osst
 {
 	struct osst_request   * SRpnt = * aSRpnt;
 	unsigned char	      * buffer, * p;
-	unsigned char		cmd[MAX_COMMAND_SIZE];
+	unsigned char		cmd[BLK_MAX_CDB];
 	int			flag, new_frame, i;
 	int			nframes          = STp->cur_frames;
 	int			blks_per_frame   = ntohs(STp->buffer->aux->dat.dat_list[0].blk_cnt);
@@ -1501,7 +1501,7 @@ static int osst_read_back_buffer_and_rewrite(struct osst_tape * STp, struct osst
 #endif
 	for (i = 0, p = buffer; i < nframes; i++, p += OS_DATA_SIZE) {
 
-		memset(cmd, 0, MAX_COMMAND_SIZE);
+		memset(cmd, 0, BLK_MAX_CDB);
 		cmd[0] = 0x3C;		/* Buffer Read           */
 		cmd[1] = 6;		/* Retrieve Faulty Block */
 		cmd[7] = 32768 >> 8;
@@ -1567,7 +1567,7 @@ static int osst_read_back_buffer_and_rewrite(struct osst_tape * STp, struct osst
 		osst_init_aux(STp, STp->buffer->aux->frame_type, frame_seq_number+i,
 			       	logical_blk_num + i*blks_per_frame,
 			       	ntohl(STp->buffer->aux->dat.dat_list[0].blk_sz), blks_per_frame);
-		memset(cmd, 0, MAX_COMMAND_SIZE);
+		memset(cmd, 0, BLK_MAX_CDB);
 		cmd[0] = WRITE_6;
 		cmd[1] = 1;
 		cmd[4] = 1;
@@ -1592,7 +1592,7 @@ static int osst_read_back_buffer_and_rewrite(struct osst_tape * STp, struct osst
 #if DEBUG
 				printk(OSST_DEB_MSG "%s:D: Check re-write successful\n", name);
 #endif
-				memset(cmd, 0, MAX_COMMAND_SIZE);
+				memset(cmd, 0, BLK_MAX_CDB);
 				cmd[0] = WRITE_FILEMARKS;
 				cmd[1] = 1;
 				SRpnt = osst_do_scsi(SRpnt, STp, cmd, 0, DMA_NONE,
@@ -1607,7 +1607,7 @@ static int osst_read_back_buffer_and_rewrite(struct osst_tape * STp, struct osst
 				flag = STp->buffer->syscall_result;
 				while ( !flag && time_before(jiffies, startwait + 60*HZ) ) {
 
-					memset(cmd, 0, MAX_COMMAND_SIZE);
+					memset(cmd, 0, BLK_MAX_CDB);
 					cmd[0] = TEST_UNIT_READY;
 
 					SRpnt = osst_do_scsi(SRpnt, STp, cmd, 0, DMA_NONE, STp->timeout,
@@ -1667,7 +1667,7 @@ static int osst_read_back_buffer_and_rewrite(struct osst_tape * STp, struct osst
 static int osst_reposition_and_retry(struct osst_tape * STp, struct osst_request ** aSRpnt,
 					unsigned int frame, unsigned int skip, int pending)
 {
-	unsigned char		cmd[MAX_COMMAND_SIZE];
+	unsigned char		cmd[BLK_MAX_CDB];
 	struct osst_request   * SRpnt;
 	char		      * name      = tape_name(STp);
 	int			expected  = 0;
@@ -1707,7 +1707,7 @@ static int osst_reposition_and_retry(struct osst_tape * STp, struct osst_request
 		}
 		if (pending && STp->cur_frames < 50) {
 
-			memset(cmd, 0, MAX_COMMAND_SIZE);
+			memset(cmd, 0, BLK_MAX_CDB);
 			cmd[0] = WRITE_6;
 			cmd[1] = 1;
 			cmd[4] = 1;
@@ -2152,11 +2152,11 @@ static int osst_space_over_filemarks_forward_fast(struct osst_tape * STp, struct
 #if DEBUG
 static void osst_set_retries(struct osst_tape * STp, struct osst_request ** aSRpnt, int retries)
 {
-	unsigned char		cmd[MAX_COMMAND_SIZE];
+	unsigned char		cmd[BLK_MAX_CDB];
 	struct osst_request   * SRpnt  = * aSRpnt;
 	char		      * name   = tape_name(STp);
 
-	memset(cmd, 0, MAX_COMMAND_SIZE);
+	memset(cmd, 0, BLK_MAX_CDB);
 	cmd[0] = MODE_SELECT;
 	cmd[1] = 0x10;
 	cmd[4] = NUMBER_RETRIES_PAGE_LENGTH + MODE_HEADER_LENGTH;
@@ -2682,7 +2682,7 @@ static unsigned int osst_parse_firmware_rev (const char * str)
  */
 static int osst_configure_onstream(struct osst_tape *STp, struct osst_request ** aSRpnt)
 {
-	unsigned char                  cmd[MAX_COMMAND_SIZE];
+	unsigned char                  cmd[BLK_MAX_CDB];
 	char                         * name = tape_name(STp);
 	struct osst_request          * SRpnt = * aSRpnt;
 	osst_mode_parameter_header_t * header;
@@ -2707,7 +2707,7 @@ static int osst_configure_onstream(struct osst_tape *STp, struct osst_request **
 	 * Configure 32.5KB (data+aux) frame size.
          * Get the current frame size from the block size mode page
 	 */
-	memset(cmd, 0, MAX_COMMAND_SIZE);
+	memset(cmd, 0, BLK_MAX_CDB);
 	cmd[0] = MODE_SENSE;
 	cmd[1] = 8;
 	cmd[2] = BLOCK_SIZE_PAGE;
@@ -2745,7 +2745,7 @@ static int osst_configure_onstream(struct osst_tape *STp, struct osst_request **
 	bs->record32 = 0;
 	bs->record32_5 = 1;
 
-	memset(cmd, 0, MAX_COMMAND_SIZE);
+	memset(cmd, 0, BLK_MAX_CDB);
 	cmd[0] = MODE_SELECT;
 	cmd[1] = 0x10;
 	cmd[4] = BLOCK_SIZE_PAGE_LENGTH + MODE_HEADER_LENGTH;
@@ -2771,7 +2771,7 @@ static int osst_configure_onstream(struct osst_tape *STp, struct osst_request **
 	 * Set vendor name to 'LIN4' for "Linux support version 4".
 	 */
 
-	memset(cmd, 0, MAX_COMMAND_SIZE);
+	memset(cmd, 0, BLK_MAX_CDB);
 	cmd[0] = MODE_SELECT;
 	cmd[1] = 0x10;
 	cmd[4] = VENDOR_IDENT_PAGE_LENGTH + MODE_HEADER_LENGTH;
@@ -2799,7 +2799,7 @@ static int osst_configure_onstream(struct osst_tape *STp, struct osst_request **
 	    return (-EIO);
 	}
 
-	memset(cmd, 0, MAX_COMMAND_SIZE);
+	memset(cmd, 0, BLK_MAX_CDB);
 	cmd[0] = MODE_SENSE;
 	cmd[1] = 8;
 	cmd[2] = CAPABILITIES_PAGE;
@@ -2819,7 +2819,7 @@ static int osst_configure_onstream(struct osst_tape *STp, struct osst_request **
 
 	drive_buffer_size = ntohs(cp->buffer_size) / 2;
 
-	memset(cmd, 0, MAX_COMMAND_SIZE);
+	memset(cmd, 0, BLK_MAX_CDB);
 	cmd[0] = MODE_SENSE;
 	cmd[1] = 8;
 	cmd[2] = TAPE_PARAMTR_PAGE;
@@ -2882,7 +2882,7 @@ static int cross_eof(struct osst_tape *STp, struct osst_request ** aSRpnt, int f
 
 static int osst_get_frame_position(struct osst_tape *STp, struct osst_request ** aSRpnt)
 {
-	unsigned char		scmd[MAX_COMMAND_SIZE];
+	unsigned char		scmd[BLK_MAX_CDB];
 	struct osst_request   * SRpnt;
 	int			result = 0;
 	char    	      * name   = tape_name(STp);
@@ -2895,7 +2895,7 @@ static int osst_get_frame_position(struct osst_tape *STp, struct osst_request **
 
 	if (STp->ready != ST_READY) return (-EIO);
 
-	memset (scmd, 0, MAX_COMMAND_SIZE);
+	memset (scmd, 0, BLK_MAX_CDB);
 	scmd[0] = READ_POSITION;
 
 	STp->buffer->b_data = mybuf; STp->buffer->buffer_size = 24;
@@ -2916,7 +2916,7 @@ static int osst_get_frame_position(struct osst_tape *STp, struct osst_request **
 		if (result == -EIO) {	/* re-read position - this needs to preserve media errors */
 			unsigned char mysense[16];
 			memcpy (mysense, SRpnt->sense, 16);
-			memset (scmd, 0, MAX_COMMAND_SIZE);
+			memset (scmd, 0, BLK_MAX_CDB);
 			scmd[0] = READ_POSITION;
 			STp->buffer->b_data = mybuf; STp->buffer->buffer_size = 24;
 			SRpnt = osst_do_scsi(SRpnt, STp, scmd, 20, DMA_FROM_DEVICE,
@@ -2966,7 +2966,7 @@ static int osst_get_frame_position(struct osst_tape *STp, struct osst_request **
 /* Set the tape block */
 static int osst_set_frame_position(struct osst_tape *STp, struct osst_request ** aSRpnt, int ppos, int skip)
 {
-	unsigned char		scmd[MAX_COMMAND_SIZE];
+	unsigned char		scmd[BLK_MAX_CDB];
 	struct osst_request   * SRpnt;
 	struct st_partstat    * STps;
 	int			result = 0;
@@ -2988,7 +2988,7 @@ static int osst_set_frame_position(struct osst_tape *STp, struct osst_request **
 		if (debugging)
 			printk(OSST_DEB_MSG "%s:D: Setting ppos to %d.\n", name, pp);
 #endif
-		memset (scmd, 0, MAX_COMMAND_SIZE);
+		memset (scmd, 0, BLK_MAX_CDB);
 		scmd[0] = SEEK_10;
 		scmd[1] = 1;
 		scmd[3] = (pp >> 24);
@@ -3053,7 +3053,7 @@ static int osst_flush_write_buffer(struct osst_tape *STp, struct osst_request **
 {
 	int			offset, transfer, blks = 0;
 	int			result = 0;
-	unsigned char		cmd[MAX_COMMAND_SIZE];
+	unsigned char		cmd[BLK_MAX_CDB];
 	struct osst_request   * SRpnt = *aSRpnt;
 	struct st_partstat    * STps;
 	char		      * name = tape_name(STp);
@@ -3100,7 +3100,7 @@ static int osst_flush_write_buffer(struct osst_tape *STp, struct osst_request **
 			if (osst_wait_frame (STp, aSRpnt, STp->first_frame_position, -50, 120))
 				result = osst_recover_wait_frame(STp, aSRpnt, 1);
 
-		memset(cmd, 0, MAX_COMMAND_SIZE);
+		memset(cmd, 0, BLK_MAX_CDB);
 		cmd[0] = WRITE_6;
 		cmd[1] = 1;
 		cmd[4] = 1;
@@ -3243,7 +3243,7 @@ static int osst_flush_buffer(struct osst_tape * STp, struct osst_request ** aSRp
 
 static int osst_write_frame(struct osst_tape * STp, struct osst_request ** aSRpnt, int synchronous)
 {
-	unsigned char		cmd[MAX_COMMAND_SIZE];
+	unsigned char		cmd[BLK_MAX_CDB];
 	struct osst_request   * SRpnt;
 	int			blks;
 #if DEBUG
@@ -3276,7 +3276,7 @@ static int osst_write_frame(struct osst_tape * STp, struct osst_request ** aSRpn
 	STp->ps[STp->partition].rw = ST_WRITING;
 	STp->write_type            = OS_WRITE_DATA;
 			
-	memset(cmd, 0, MAX_COMMAND_SIZE);
+	memset(cmd, 0, BLK_MAX_CDB);
 	cmd[0]   = WRITE_6;
 	cmd[1]   = 1;
 	cmd[4]   = 1;						/* one frame at a time... */
@@ -4058,7 +4058,7 @@ static int osst_int_ioctl(struct osst_tape * STp, struct osst_request ** aSRpnt,
 	long			ltmp;
 	int			i, ioctl_result;
 	int			chg_eof = 1;
-	unsigned char		cmd[MAX_COMMAND_SIZE];
+	unsigned char		cmd[BLK_MAX_CDB];
 	struct osst_request   * SRpnt = * aSRpnt;
 	struct st_partstat    * STps;
 	int			fileno, blkno, at_sm, frame_seq_numbr, logical_blk_num;
@@ -4079,7 +4079,7 @@ static int osst_int_ioctl(struct osst_tape * STp, struct osst_request ** aSRpnt,
 	frame_seq_numbr = STp->frame_seq_number;
 	logical_blk_num = STp->logical_blk_num;
 
-	memset(cmd, 0, MAX_COMMAND_SIZE);
+	memset(cmd, 0, BLK_MAX_CDB);
 	switch (cmd_in) {
 	 case MTFSFM:
 		chg_eof = 0; /* Changed from the FSF after this */
@@ -4441,7 +4441,7 @@ static int __os_scsi_tape_open(struct inode * inode, struct file * filp)
 {
 	unsigned short	      flags;
 	int		      i, b_size, new_session = 0, retval = 0;
-	unsigned char	      cmd[MAX_COMMAND_SIZE];
+	unsigned char	      cmd[BLK_MAX_CDB];
 	struct osst_request * SRpnt = NULL;
 	struct osst_tape    * STp;
 	struct st_modedef   * STm;
@@ -4542,7 +4542,7 @@ static int __os_scsi_tape_open(struct inode * inode, struct file * filp)
 	STp->nbr_waits = STp->nbr_finished = 0;
 #endif
 
-	memset (cmd, 0, MAX_COMMAND_SIZE);
+	memset (cmd, 0, BLK_MAX_CDB);
 	cmd[0] = TEST_UNIT_READY;
 
 	SRpnt = osst_do_scsi(NULL, STp, cmd, 0, DMA_NONE, STp->timeout, MAX_RETRIES, 1);
@@ -4561,7 +4561,7 @@ static int __os_scsi_tape_open(struct inode * inode, struct file * filp)
 			goto err_out;
 		}
 		if (SRpnt->sense[13] == 2) {	/* initialize command required (LOAD) */
-			memset (cmd, 0, MAX_COMMAND_SIZE);
+			memset (cmd, 0, BLK_MAX_CDB);
         		cmd[0] = START_STOP;
 			cmd[1] = 1;
 			cmd[4] = 1;
@@ -4579,7 +4579,7 @@ static int __os_scsi_tape_open(struct inode * inode, struct file * filp)
 
 		for (i=0; i < 10; i++) {
 
-			memset (cmd, 0, MAX_COMMAND_SIZE);
+			memset (cmd, 0, BLK_MAX_CDB);
 			cmd[0] = TEST_UNIT_READY;
 
 			SRpnt = osst_do_scsi(SRpnt, STp, cmd, 0, DMA_NONE,
@@ -4613,7 +4613,7 @@ static int __os_scsi_tape_open(struct inode * inode, struct file * filp)
 	if (!STp->buffer->syscall_result && STp->header_ok &&
 	    !SRpnt->result && SRpnt->sense[0] == 0) {
 
-		memset(cmd, 0, MAX_COMMAND_SIZE);
+		memset(cmd, 0, BLK_MAX_CDB);
 		cmd[0] = MODE_SENSE;
 		cmd[1] = 8;
 		cmd[2] = VENDOR_IDENT_PAGE;
@@ -4665,7 +4665,7 @@ static int __os_scsi_tape_open(struct inode * inode, struct file * filp)
 	if ((STp->buffer)->syscall_result != 0 &&   /* in all error conditions except no medium */ 
 	    (SRpnt->sense[2] != 2 || SRpnt->sense[12] != 0x3A) ) {
 
-		memset(cmd, 0, MAX_COMMAND_SIZE);
+		memset(cmd, 0, BLK_MAX_CDB);
 		cmd[0] = MODE_SELECT;
 		cmd[1] = 0x10;
 		cmd[4] = 4 + MODE_HEADER_LENGTH;
@@ -4688,7 +4688,7 @@ static int __os_scsi_tape_open(struct inode * inode, struct file * filp)
 
 		for (i=0; i < 10; i++) {
 
-			memset (cmd, 0, MAX_COMMAND_SIZE);
+			memset (cmd, 0, BLK_MAX_CDB);
 			cmd[0] = TEST_UNIT_READY;
 
 			SRpnt = osst_do_scsi(SRpnt, STp, cmd, 0, DMA_NONE,
diff --git a/drivers/scsi/osst.h b/drivers/scsi/osst.h
index b4fea98..a49d0fa 100644
--- a/drivers/scsi/osst.h
+++ b/drivers/scsi/osst.h
@@ -630,7 +630,7 @@ struct osst_tape {
 
 /* scsi tape command */
 struct osst_request {
-	unsigned char cmd[MAX_COMMAND_SIZE];
+	unsigned char cmd[BLK_MAX_CDB];
 	unsigned char sense[SCSI_SENSE_BUFFERSIZE];
 	int result;
 	struct osst_tape *stp;
diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
index c68a66e..383344d 100644
--- a/drivers/scsi/qla1280.c
+++ b/drivers/scsi/qla1280.c
@@ -2853,7 +2853,7 @@ qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp)
 		cmd->cmnd[0], (long)CMD_HANDLE(sp->cmd));
 	dprintk(2, "             bus %i, target %i, lun %i\n",
 		SCSI_BUS_32(cmd), SCSI_TCN_32(cmd), SCSI_LUN_32(cmd));
-	qla1280_dump_buffer(2, cmd->cmnd, MAX_COMMAND_SIZE);
+	qla1280_dump_buffer(2, cmd->cmnd, BLK_MAX_CDB);
 
 	/*
 	 * Build command packet.
diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c
index c4f7b56..aa501d8 100644
--- a/drivers/scsi/scsi_ioctl.c
+++ b/drivers/scsi/scsi_ioctl.c
@@ -138,7 +138,7 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd,
 
 int scsi_set_medium_removal(struct scsi_device *sdev, char state)
 {
-	char scsi_cmd[MAX_COMMAND_SIZE];
+	char scsi_cmd[BLK_MAX_CDB];
 	int ret;
 
 	if (!sdev->removable || !sdev->lockable)
@@ -198,7 +198,7 @@ static int scsi_ioctl_get_pci(struct scsi_device *sdev, void __user *arg)
  */
 int scsi_ioctl(struct scsi_device *sdev, int cmd, void __user *arg)
 {
-	char scsi_cmd[MAX_COMMAND_SIZE];
+	char scsi_cmd[BLK_MAX_CDB];
 
 	/* Check for deprecated ioctls ... all the ioctls which don't
 	 * follow the new unique numbering scheme are deprecated */
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 202369b..085d139 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -179,7 +179,7 @@ int scsi_complete_async_scans(void)
 static void scsi_unlock_floptical(struct scsi_device *sdev,
 				  unsigned char *result)
 {
-	unsigned char scsi_cmd[MAX_COMMAND_SIZE];
+	unsigned char scsi_cmd[BLK_MAX_CDB];
 
 	sdev_printk(KERN_NOTICE, sdev, "unlocking floptical drive\n");
 	scsi_cmd[0] = MODE_SENSE;
@@ -558,7 +558,7 @@ static void sanitize_inquiry_string(unsigned char *s, int len)
 static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
 			  int result_len, int *bflags)
 {
-	unsigned char scsi_cmd[MAX_COMMAND_SIZE];
+	unsigned char scsi_cmd[BLK_MAX_CDB];
 	int first_inquiry_len, try_inquiry_len, next_inquiry_len;
 	int response_len = 0;
 	int pass, count, result;
@@ -1286,7 +1286,7 @@ static int scsi_report_lun_scan(struct scsi_target *starget, int bflags,
 				int rescan)
 {
 	char devname[64];
-	unsigned char scsi_cmd[MAX_COMMAND_SIZE];
+	unsigned char scsi_cmd[BLK_MAX_CDB];
 	unsigned int length;
 	u64 lun;
 	unsigned int num_luns;
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 9a1c342..de46b86 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -670,7 +670,7 @@ static int write_behind_check(struct scsi_tape * STp)
 static int cross_eof(struct scsi_tape * STp, int forward)
 {
 	struct st_request *SRpnt;
-	unsigned char cmd[MAX_COMMAND_SIZE];
+	unsigned char cmd[BLK_MAX_CDB];
 
 	cmd[0] = SPACE;
 	cmd[1] = 0x01;		/* Space FileMarks */
@@ -707,7 +707,7 @@ static int st_flush_write_buffer(struct scsi_tape * STp)
 {
 	int transfer, blks;
 	int result;
-	unsigned char cmd[MAX_COMMAND_SIZE];
+	unsigned char cmd[BLK_MAX_CDB];
 	struct st_request *SRpnt;
 	struct st_partstat *STps;
 
@@ -721,7 +721,7 @@ static int st_flush_write_buffer(struct scsi_tape * STp)
 		transfer = STp->buffer->buffer_bytes;
 		DEBC_printk(STp, "Flushing %d bytes.\n", transfer);
 
-		memset(cmd, 0, MAX_COMMAND_SIZE);
+		memset(cmd, 0, BLK_MAX_CDB);
 		cmd[0] = WRITE_6;
 		cmd[1] = 1;
 		blks = transfer / STp->block_size;
@@ -912,14 +912,14 @@ static int test_ready(struct scsi_tape *STp, int do_wait)
 {
 	int attentions, waits, max_wait, scode;
 	int retval = CHKRES_READY, new_session = 0;
-	unsigned char cmd[MAX_COMMAND_SIZE];
+	unsigned char cmd[BLK_MAX_CDB];
 	struct st_request *SRpnt = NULL;
 	struct st_cmdstatus *cmdstatp = &STp->buffer->cmdstat;
 
 	max_wait = do_wait ? ST_BLOCK_SECONDS : 0;
 
 	for (attentions=waits=0; ; ) {
-		memset((void *) &cmd[0], 0, MAX_COMMAND_SIZE);
+		memset((void *) &cmd[0], 0, BLK_MAX_CDB);
 		cmd[0] = TEST_UNIT_READY;
 		SRpnt = st_do_scsi(SRpnt, STp, cmd, 0, DMA_NONE,
 				   STp->long_timeout, MAX_READY_RETRIES, 1);
@@ -985,7 +985,7 @@ static int test_ready(struct scsi_tape *STp, int do_wait)
 static int check_tape(struct scsi_tape *STp, struct file *filp)
 {
 	int i, retval, new_session = 0, do_wait;
-	unsigned char cmd[MAX_COMMAND_SIZE], saved_cleaning;
+	unsigned char cmd[BLK_MAX_CDB], saved_cleaning;
 	unsigned short st_flags = filp->f_flags;
 	struct st_request *SRpnt = NULL;
 	struct st_modedef *STm;
@@ -1051,7 +1051,7 @@ static int check_tape(struct scsi_tape *STp, struct file *filp)
 	if (STp->omit_blklims)
 		STp->min_block = STp->max_block = (-1);
 	else {
-		memset((void *) &cmd[0], 0, MAX_COMMAND_SIZE);
+		memset((void *) &cmd[0], 0, BLK_MAX_CDB);
 		cmd[0] = READ_BLOCK_LIMITS;
 
 		SRpnt = st_do_scsi(SRpnt, STp, cmd, 6, DMA_FROM_DEVICE,
@@ -1077,7 +1077,7 @@ static int check_tape(struct scsi_tape *STp, struct file *filp)
 		}
 	}
 
-	memset((void *) &cmd[0], 0, MAX_COMMAND_SIZE);
+	memset((void *) &cmd[0], 0, BLK_MAX_CDB);
 	cmd[0] = MODE_SENSE;
 	cmd[4] = 12;
 
@@ -1286,7 +1286,7 @@ static int st_open(struct inode *inode, struct file *filp)
 static int st_flush(struct file *filp, fl_owner_t id)
 {
 	int result = 0, result2;
-	unsigned char cmd[MAX_COMMAND_SIZE];
+	unsigned char cmd[BLK_MAX_CDB];
 	struct st_request *SRpnt;
 	struct scsi_tape *STp = filp->private_data;
 	struct st_modedef *STm = &(STp->modes[STp->current_mode]);
@@ -1322,7 +1322,7 @@ static int st_flush(struct file *filp, fl_owner_t id)
 		DEBC_printk(STp, "Async write waits %d, finished %d.\n",
 			    STp->nbr_waits, STp->nbr_finished);
 #endif
-		memset(cmd, 0, MAX_COMMAND_SIZE);
+		memset(cmd, 0, BLK_MAX_CDB);
 		cmd[0] = WRITE_FILEMARKS;
 		if (STp->immediate_filemark)
 			cmd[1] = 1;
@@ -1570,7 +1570,7 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
 	ssize_t retval;
 	int undone, retry_eot = 0, scode;
 	int async_write;
-	unsigned char cmd[MAX_COMMAND_SIZE];
+	unsigned char cmd[BLK_MAX_CDB];
 	const char __user *b_point;
 	struct st_request *SRpnt = NULL;
 	struct scsi_tape *STp = filp->private_data;
@@ -1659,7 +1659,7 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
 
 	total = count;
 
-	memset(cmd, 0, MAX_COMMAND_SIZE);
+	memset(cmd, 0, BLK_MAX_CDB);
 	cmd[0] = WRITE_6;
 	cmd[1] = (STp->block_size != 0);
 
@@ -1846,7 +1846,7 @@ static long read_tape(struct scsi_tape *STp, long count,
 		      struct st_request ** aSRpnt)
 {
 	int transfer, blks, bytes;
-	unsigned char cmd[MAX_COMMAND_SIZE];
+	unsigned char cmd[BLK_MAX_CDB];
 	struct st_request *SRpnt;
 	struct st_modedef *STm;
 	struct st_partstat *STps;
@@ -1877,7 +1877,7 @@ static long read_tape(struct scsi_tape *STp, long count,
 		}
 	}
 
-	memset(cmd, 0, MAX_COMMAND_SIZE);
+	memset(cmd, 0, BLK_MAX_CDB);
 	cmd[0] = READ_6;
 	cmd[1] = (STp->block_size != 0);
 	if (!cmd[1] && STp->sili)
@@ -2418,10 +2418,10 @@ static int st_set_options(struct scsi_tape *STp, long options)
    parameter, if necessary. */
 static int read_mode_page(struct scsi_tape *STp, int page, int omit_block_descs)
 {
-	unsigned char cmd[MAX_COMMAND_SIZE];
+	unsigned char cmd[BLK_MAX_CDB];
 	struct st_request *SRpnt;
 
-	memset(cmd, 0, MAX_COMMAND_SIZE);
+	memset(cmd, 0, BLK_MAX_CDB);
 	cmd[0] = MODE_SENSE;
 	if (omit_block_descs)
 		cmd[1] = MODE_SENSE_OMIT_BDESCS;
@@ -2444,11 +2444,11 @@ static int read_mode_page(struct scsi_tape *STp, int page, int omit_block_descs)
 static int write_mode_page(struct scsi_tape *STp, int page, int slow)
 {
 	int pgo;
-	unsigned char cmd[MAX_COMMAND_SIZE];
+	unsigned char cmd[BLK_MAX_CDB];
 	struct st_request *SRpnt;
 	int timeout;
 
-	memset(cmd, 0, MAX_COMMAND_SIZE);
+	memset(cmd, 0, BLK_MAX_CDB);
 	cmd[0] = MODE_SELECT;
 	cmd[1] = MODE_SELECT_PAGE_FORMAT;
 	pgo = MODE_HEADER_LENGTH + (STp->buffer)->b_data[MH_OFF_BDESCS_LENGTH];
@@ -2544,7 +2544,7 @@ static int st_compression(struct scsi_tape * STp, int state)
 static int do_load_unload(struct scsi_tape *STp, struct file *filp, int load_code)
 {
 	int retval = (-EIO), timeout;
-	unsigned char cmd[MAX_COMMAND_SIZE];
+	unsigned char cmd[BLK_MAX_CDB];
 	struct st_partstat *STps;
 	struct st_request *SRpnt;
 
@@ -2555,7 +2555,7 @@ static int do_load_unload(struct scsi_tape *STp, struct file *filp, int load_cod
 			return (-EIO);
 	}
 
-	memset(cmd, 0, MAX_COMMAND_SIZE);
+	memset(cmd, 0, BLK_MAX_CDB);
 	cmd[0] = START_STOP;
 	if (load_code)
 		cmd[4] |= 1;
@@ -2643,7 +2643,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
 	long ltmp;
 	int ioctl_result;
 	int chg_eof = 1;
-	unsigned char cmd[MAX_COMMAND_SIZE];
+	unsigned char cmd[BLK_MAX_CDB];
 	struct st_request *SRpnt;
 	struct st_partstat *STps;
 	int fileno, blkno, at_sm, undone;
@@ -2662,7 +2662,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
 	blkno = STps->drv_block;
 	at_sm = STps->at_sm;
 
-	memset(cmd, 0, MAX_COMMAND_SIZE);
+	memset(cmd, 0, BLK_MAX_CDB);
 	switch (cmd_in) {
 	case MTFSFM:
 		chg_eof = 0;	/* Changed from the FSF after this */
@@ -3046,13 +3046,13 @@ static int get_location(struct scsi_tape *STp, unsigned int *block, int *partiti
 			int logical)
 {
 	int result;
-	unsigned char scmd[MAX_COMMAND_SIZE];
+	unsigned char scmd[BLK_MAX_CDB];
 	struct st_request *SRpnt;
 
 	if (STp->ready != ST_READY)
 		return (-EIO);
 
-	memset(scmd, 0, MAX_COMMAND_SIZE);
+	memset(scmd, 0, BLK_MAX_CDB);
 	if ((STp->device)->scsi_level < SCSI_2) {
 		scmd[0] = QFA_REQUEST_BLOCK;
 		scmd[4] = 3;
@@ -3109,7 +3109,7 @@ static int set_location(struct scsi_tape *STp, unsigned int block, int partition
 	int result, p;
 	unsigned int blk;
 	int timeout;
-	unsigned char scmd[MAX_COMMAND_SIZE];
+	unsigned char scmd[BLK_MAX_CDB];
 	struct st_request *SRpnt;
 
 	if (STp->ready != ST_READY)
@@ -3138,7 +3138,7 @@ static int set_location(struct scsi_tape *STp, unsigned int block, int partition
 		}
 	}
 
-	memset(scmd, 0, MAX_COMMAND_SIZE);
+	memset(scmd, 0, BLK_MAX_CDB);
 	if ((STp->device)->scsi_level < SCSI_2) {
 		scmd[0] = QFA_SEEK_BLOCK;
 		scmd[2] = (block >> 16);
diff --git a/drivers/scsi/st.h b/drivers/scsi/st.h
index f3eee0f..3e45170 100644
--- a/drivers/scsi/st.h
+++ b/drivers/scsi/st.h
@@ -24,7 +24,7 @@ struct scsi_tape;
 
 /* scsi tape command */
 struct st_request {
-	unsigned char cmd[MAX_COMMAND_SIZE];
+	unsigned char cmd[BLK_MAX_CDB];
 	unsigned char sense[SCSI_SENSE_BUFFERSIZE];
 	int result;
 	struct scsi_tape *stp;
diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
index f6c954c..39e2b03 100644
--- a/drivers/target/target_core_pscsi.c
+++ b/drivers/target/target_core_pscsi.c
@@ -153,14 +153,14 @@ static int pscsi_pmode_enable_hba(struct se_hba *hba, unsigned long mode_flag)
 static void pscsi_tape_read_blocksize(struct se_device *dev,
 		struct scsi_device *sdev)
 {
-	unsigned char cdb[MAX_COMMAND_SIZE], *buf;
+	unsigned char cdb[BLK_MAX_CDB], *buf;
 	int ret;
 
 	buf = kzalloc(12, GFP_KERNEL);
 	if (!buf)
 		return;
 
-	memset(cdb, 0, MAX_COMMAND_SIZE);
+	memset(cdb, 0, BLK_MAX_CDB);
 	cdb[0] = MODE_SENSE;
 	cdb[4] = 0x0c; /* 12 bytes */
 
@@ -201,14 +201,14 @@ pscsi_set_inquiry_info(struct scsi_device *sdev, struct t10_wwn *wwn)
 static int
 pscsi_get_inquiry_vpd_serial(struct scsi_device *sdev, struct t10_wwn *wwn)
 {
-	unsigned char cdb[MAX_COMMAND_SIZE], *buf;
+	unsigned char cdb[BLK_MAX_CDB], *buf;
 	int ret;
 
 	buf = kzalloc(INQUIRY_VPD_SERIAL_LEN, GFP_KERNEL);
 	if (!buf)
 		return -ENOMEM;
 
-	memset(cdb, 0, MAX_COMMAND_SIZE);
+	memset(cdb, 0, BLK_MAX_CDB);
 	cdb[0] = INQUIRY;
 	cdb[1] = 0x01; /* Query VPD */
 	cdb[2] = 0x80; /* Unit Serial Number */
@@ -236,7 +236,7 @@ static void
 pscsi_get_inquiry_vpd_device_ident(struct scsi_device *sdev,
 		struct t10_wwn *wwn)
 {
-	unsigned char cdb[MAX_COMMAND_SIZE], *buf, *page_83;
+	unsigned char cdb[BLK_MAX_CDB], *buf, *page_83;
 	int ident_len, page_len, off = 4, ret;
 	struct t10_vpd *vpd;
 
@@ -244,7 +244,7 @@ pscsi_get_inquiry_vpd_device_ident(struct scsi_device *sdev,
 	if (!buf)
 		return;
 
-	memset(cdb, 0, MAX_COMMAND_SIZE);
+	memset(cdb, 0, BLK_MAX_CDB);
 	cdb[0] = INQUIRY;
 	cdb[1] = 0x01; /* Query VPD */
 	cdb[2] = 0x83; /* Device Identifier */
diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c
index 811929c..05b7439 100644
--- a/drivers/usb/gadget/function/f_mass_storage.c
+++ b/drivers/usb/gadget/function/f_mass_storage.c
@@ -277,7 +277,7 @@ struct fsg_common {
 	unsigned int		fsg_num_buffers;
 
 	int			cmnd_size;
-	u8			cmnd[MAX_COMMAND_SIZE];
+	u8			cmnd[BLK_MAX_CDB];
 
 	unsigned int		nluns;
 	unsigned int		lun;
@@ -2132,7 +2132,7 @@ static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh)
 
 	/* Is the CBW meaningful? */
 	if (cbw->Lun >= FSG_MAX_LUNS || cbw->Flags & ~US_BULK_FLAG_IN ||
-			cbw->Length <= 0 || cbw->Length > MAX_COMMAND_SIZE) {
+			cbw->Length <= 0 || cbw->Length > BLK_MAX_CDB) {
 		DBG(fsg, "non-meaningful CBW: lun = %u, flags = 0x%x, "
 				"cmdlen %u\n",
 				cbw->Lun, cbw->Flags, cbw->Length);
diff --git a/drivers/usb/gadget/function/storage_common.h b/drivers/usb/gadget/function/storage_common.h
index 70c8914..45d3b87 100644
--- a/drivers/usb/gadget/function/storage_common.h
+++ b/drivers/usb/gadget/function/storage_common.h
@@ -65,9 +65,6 @@ do {									\
 
 #endif /* DUMP_MSGS */
 
-/* Length of a SCSI Command Data Block */
-#define MAX_COMMAND_SIZE	16
-
 /* SCSI Sense Key/Additional Sense Code/ASC Qualifier values */
 #define SS_NO_SENSE				0
 #define SS_COMMUNICATION_FAILURE		0x040800
diff --git a/drivers/usb/storage/cypress_atacb.c b/drivers/usb/storage/cypress_atacb.c
index 8514a2d..d29808d 100644
--- a/drivers/usb/storage/cypress_atacb.c
+++ b/drivers/usb/storage/cypress_atacb.c
@@ -82,7 +82,7 @@ static struct us_unusual_dev cypress_unusual_dev_list[] = {
  */
 static void cypress_atacb_passthrough(struct scsi_cmnd *srb, struct us_data *us)
 {
-	unsigned char save_cmnd[MAX_COMMAND_SIZE];
+	unsigned char save_cmnd[BLK_MAX_CDB];
 
 	if (likely(srb->cmnd[0] != ATA_16 && srb->cmnd[0] != ATA_12)) {
 		usb_stor_transparent_scsi_command(srb, us);
@@ -90,7 +90,7 @@ static void cypress_atacb_passthrough(struct scsi_cmnd *srb, struct us_data *us)
 	}
 
 	memcpy(save_cmnd, srb->cmnd, sizeof(save_cmnd));
-	memset(srb->cmnd, 0, MAX_COMMAND_SIZE);
+	memset(srb->cmnd, 0, BLK_MAX_CDB);
 
 	/* check if we support the command */
 	if (save_cmnd[1] >> 5) /* MULTIPLE_COUNT */
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index 9fc1aec..3416b70 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -14,23 +14,6 @@ struct scsi_driver;
 
 #include <scsi/scsi_device.h>
 
-/*
- * 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
- * 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
-
 struct scsi_data_buffer {
 	struct sg_table table;
 	unsigned length;
-- 
2.1.4


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

* [PATCH v3 3/4] target: Correct a comment
  2015-04-07 12:32 [PATCH v3] Split SCSI header files Bart Van Assche
  2015-04-07 12:33 ` [PATCH v3 1/4] " Bart Van Assche
  2015-04-07 12:33 ` [PATCH v3 2/4] Replace MAX_COMMAND_SIZE with BLK_MAX_CDB Bart Van Assche
@ 2015-04-07 12:33 ` Bart Van Assche
  2015-04-07 12:34 ` [PATCH v3 4/4] target: Minimize SCSI header #include directives Bart Van Assche
  2015-04-13  9:44 ` [PATCH v3] Split SCSI header files Christoph Hellwig
  4 siblings, 0 replies; 6+ messages in thread
From: Bart Van Assche @ 2015-04-07 12:33 UTC (permalink / raw)
  To: James Bottomley
  Cc: Christoph Hellwig, Nicholas A. Bellinger, Hannes Reinecke,
	Mike Christie, linux-scsi, target-devel

Correct the comment above the definition of TCM_MAX_COMMAND_SIZE.
A quote from Christoph:

    There aren't any legacy issues, we just decided to handle >
    16 byte CDBs in the slow path.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Nicholas Bellinger <nab@linux-iscsi.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Mike Christie <michaelc@cs.wisc.edu>
---
 include/target/target_core_base.h | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index 672150b..7a6e55f 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -17,16 +17,8 @@
 /* Don't raise above 511 or REPORT_LUNS needs to handle >1 page */
 #define TRANSPORT_MAX_LUNS_PER_TPG		256
 /*
- * 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
- * 32-byte CDBs to because of legacy issues.
- *
- * Within TCM Core there are no such legacy limitiations, so we go ahead
- * use 32-byte CDBs by default and use include/scsi/scsi.h:scsi_command_size()
- * within all TCM Core and subsystem plugin code.
+ * Maximum size of a CDB that can be stored in se_cmd without allocating
+ * memory dynamically for the CDB.
  */
 #define TCM_MAX_COMMAND_SIZE			32
 /*
-- 
2.1.4


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

* [PATCH v3 4/4] target: Minimize SCSI header #include directives
  2015-04-07 12:32 [PATCH v3] Split SCSI header files Bart Van Assche
                   ` (2 preceding siblings ...)
  2015-04-07 12:33 ` [PATCH v3 3/4] target: Correct a comment Bart Van Assche
@ 2015-04-07 12:34 ` Bart Van Assche
  2015-04-13  9:44 ` [PATCH v3] Split SCSI header files Christoph Hellwig
  4 siblings, 0 replies; 6+ messages in thread
From: Bart Van Assche @ 2015-04-07 12:34 UTC (permalink / raw)
  To: James Bottomley
  Cc: Christoph Hellwig, Nicholas A. Bellinger, Hannes Reinecke,
	Mike Christie, linux-scsi, target-devel

Only include SCSI initiator header files in target code that needs
these header files, namely the SCSI pass-through code and the tcm_loop
driver. Change SCSI_SENSE_BUFFERSIZE into TRANSPORT_SENSE_BUFFER in
target code because the former is intended for initiator code and the
latter for target code.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Nicholas Bellinger <nab@linux-iscsi.org>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Mike Christie <michaelc@cs.wisc.edu>
---
 Documentation/target/tcm_mod_builder.py    | 7 ++-----
 drivers/infiniband/ulp/srpt/ib_srpt.c      | 1 +
 drivers/infiniband/ulp/srpt/ib_srpt.h      | 2 +-
 drivers/target/iscsi/iscsi_target.c        | 2 +-
 drivers/target/iscsi/iscsi_target_device.c | 1 -
 drivers/target/iscsi/iscsi_target_tmr.c    | 2 +-
 drivers/target/sbp/sbp_target.c            | 2 +-
 drivers/target/target_core_alua.c          | 3 +--
 drivers/target/target_core_device.c        | 4 ++--
 drivers/target/target_core_fabric_lib.c    | 2 --
 drivers/target/target_core_file.c          | 3 +--
 drivers/target/target_core_iblock.c        | 3 +--
 drivers/target/target_core_pr.c            | 3 +--
 drivers/target/target_core_pscsi.c         | 2 --
 drivers/target/target_core_pscsi.h         | 6 +++---
 drivers/target/target_core_rd.c            | 3 +--
 drivers/target/target_core_sbc.c           | 2 +-
 drivers/target/target_core_spc.c           | 3 ++-
 drivers/target/target_core_stat.c          | 3 ---
 drivers/target/target_core_tmr.c           | 2 --
 drivers/target/target_core_tpg.c           | 3 +--
 drivers/target/target_core_transport.c     | 4 +---
 drivers/target/target_core_ua.c            | 3 +--
 drivers/target/target_core_user.c          | 5 +++--
 drivers/target/target_core_xcopy.c         | 3 +--
 drivers/target/tcm_fc/tfc_cmd.c            | 4 ----
 drivers/target/tcm_fc/tfc_conf.c           | 4 ----
 drivers/target/tcm_fc/tfc_io.c             | 4 ----
 drivers/target/tcm_fc/tfc_sess.c           | 4 ----
 drivers/usb/gadget/legacy/tcm_usb_gadget.c | 1 -
 drivers/usb/gadget/legacy/tcm_usb_gadget.h | 1 -
 drivers/vhost/scsi.c                       | 3 ++-
 drivers/xen/xen-scsiback.c                 | 5 +----
 include/target/iscsi/iscsi_target_core.h   | 1 -
 include/target/target_core_base.h          | 3 +--
 include/trace/events/target.h              | 2 +-
 36 files changed, 32 insertions(+), 74 deletions(-)

diff --git a/Documentation/target/tcm_mod_builder.py b/Documentation/target/tcm_mod_builder.py
index 2b47704..cd9d124 100755
--- a/Documentation/target/tcm_mod_builder.py
+++ b/Documentation/target/tcm_mod_builder.py
@@ -558,11 +558,8 @@ def tcm_mod_dump_fabric_ops(proto_ident, fabric_mod_dir_var, fabric_mod_name):
 	buf += "#include <linux/string.h>\n"
 	buf += "#include <linux/ctype.h>\n"
 	buf += "#include <asm/unaligned.h>\n"
-	buf += "#include <scsi/scsi.h>\n"
-	buf += "#include <scsi/scsi_host.h>\n"
-	buf += "#include <scsi/scsi_device.h>\n"
-	buf += "#include <scsi/scsi_cmnd.h>\n"
-	buf += "#include <scsi/libfc.h>\n\n"
+	buf += "#include <scsi/scsi_common.h>\n"
+	buf += "#include <scsi/scsi_proto.h>\n"
 	buf += "#include <target/target_core_base.h>\n"
 	buf += "#include <target/target_core_fabric.h>\n"
 	buf += "#include <target/target_core_configfs.h>\n\n"
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
index 6e0a477..e95145a 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -41,6 +41,7 @@
 #include <linux/string.h>
 #include <linux/delay.h>
 #include <linux/atomic.h>
+#include <scsi/scsi_proto.h>
 #include <scsi/scsi_tcq.h>
 #include <target/configfs_macros.h>
 #include <target/target_core_base.h>
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.h b/drivers/infiniband/ulp/srpt/ib_srpt.h
index 3dae156..d85c0c2 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.h
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.h
@@ -245,7 +245,7 @@ struct srpt_send_ioctx {
 	u8			n_rdma;
 	u8			n_rbuf;
 	bool			queue_status_only;
-	u8			sense_data[SCSI_SENSE_BUFFERSIZE];
+	u8			sense_data[TRANSPORT_SENSE_BUFFER];
 };
 
 /**
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index 2accb6e..168ac7d 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -23,7 +23,7 @@
 #include <linux/module.h>
 #include <linux/idr.h>
 #include <asm/unaligned.h>
-#include <scsi/scsi_device.h>
+#include <scsi/scsi_proto.h>
 #include <scsi/iscsi_proto.h>
 #include <scsi/scsi_tcq.h>
 #include <target/target_core_base.h>
diff --git a/drivers/target/iscsi/iscsi_target_device.c b/drivers/target/iscsi/iscsi_target_device.c
index 34c3cd1..5fabcd3 100644
--- a/drivers/target/iscsi/iscsi_target_device.c
+++ b/drivers/target/iscsi/iscsi_target_device.c
@@ -17,7 +17,6 @@
  * GNU General Public License for more details.
  ******************************************************************************/
 
-#include <scsi/scsi_device.h>
 #include <target/target_core_base.h>
 #include <target/target_core_fabric.h>
 
diff --git a/drivers/target/iscsi/iscsi_target_tmr.c b/drivers/target/iscsi/iscsi_target_tmr.c
index b0224a7..fe9a582 100644
--- a/drivers/target/iscsi/iscsi_target_tmr.c
+++ b/drivers/target/iscsi/iscsi_target_tmr.c
@@ -17,7 +17,7 @@
  ******************************************************************************/
 
 #include <asm/unaligned.h>
-#include <scsi/scsi_device.h>
+#include <scsi/scsi_proto.h>
 #include <scsi/iscsi_proto.h>
 #include <target/target_core_base.h>
 #include <target/target_core_fabric.h>
diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
index 9512af6..30aecb9 100644
--- a/drivers/target/sbp/sbp_target.c
+++ b/drivers/target/sbp/sbp_target.c
@@ -30,7 +30,7 @@
 #include <linux/ctype.h>
 #include <linux/firewire.h>
 #include <linux/firewire-constants.h>
-#include <scsi/scsi.h>
+#include <scsi/scsi_proto.h>
 #include <scsi/scsi_tcq.h>
 #include <target/target_core_base.h>
 #include <target/target_core_backend.h>
diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c
index 75cbde1..29904a9 100644
--- a/drivers/target/target_core_alua.c
+++ b/drivers/target/target_core_alua.c
@@ -28,8 +28,7 @@
 #include <linux/configfs.h>
 #include <linux/export.h>
 #include <linux/file.h>
-#include <scsi/scsi.h>
-#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_proto.h>
 #include <asm/unaligned.h>
 
 #include <target/target_core_base.h>
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index 79b4ec3..4015cbd 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -35,8 +35,8 @@
 #include <linux/export.h>
 #include <net/sock.h>
 #include <net/tcp.h>
-#include <scsi/scsi.h>
-#include <scsi/scsi_device.h>
+#include <scsi/scsi_common.h>
+#include <scsi/scsi_proto.h>
 
 #include <target/target_core_base.h>
 #include <target/target_core_backend.h>
diff --git a/drivers/target/target_core_fabric_lib.c b/drivers/target/target_core_fabric_lib.c
index 35bfe77..fdf31ef 100644
--- a/drivers/target/target_core_fabric_lib.c
+++ b/drivers/target/target_core_fabric_lib.c
@@ -29,8 +29,6 @@
 #include <linux/ctype.h>
 #include <linux/spinlock.h>
 #include <linux/export.h>
-#include <scsi/scsi.h>
-#include <scsi/scsi_cmnd.h>
 
 #include <target/target_core_base.h>
 #include <target/target_core_fabric.h>
diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c
index 44620fb..23e4152 100644
--- a/drivers/target/target_core_file.c
+++ b/drivers/target/target_core_file.c
@@ -31,8 +31,7 @@
 #include <linux/spinlock.h>
 #include <linux/module.h>
 #include <linux/falloc.h>
-#include <scsi/scsi.h>
-#include <scsi/scsi_host.h>
+#include <scsi/scsi_proto.h>
 #include <asm/unaligned.h>
 
 #include <target/target_core_base.h>
diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c
index d4a4b0f..d862711 100644
--- a/drivers/target/target_core_iblock.c
+++ b/drivers/target/target_core_iblock.c
@@ -35,8 +35,7 @@
 #include <linux/genhd.h>
 #include <linux/file.h>
 #include <linux/module.h>
-#include <scsi/scsi.h>
-#include <scsi/scsi_host.h>
+#include <scsi/scsi_proto.h>
 #include <asm/unaligned.h>
 
 #include <target/target_core_base.h>
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index 2de6fb8..2fc16b8 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -28,8 +28,7 @@
 #include <linux/spinlock.h>
 #include <linux/list.h>
 #include <linux/file.h>
-#include <scsi/scsi.h>
-#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_proto.h>
 #include <asm/unaligned.h>
 
 #include <target/target_core_base.h>
diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
index 39e2b03..98e64a2 100644
--- a/drivers/target/target_core_pscsi.c
+++ b/drivers/target/target_core_pscsi.c
@@ -36,9 +36,7 @@
 #include <linux/module.h>
 #include <asm/unaligned.h>
 
-#include <scsi/scsi.h>
 #include <scsi/scsi_device.h>
-#include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_tcq.h>
 
diff --git a/drivers/target/target_core_pscsi.h b/drivers/target/target_core_pscsi.h
index 1bd757d..8fee9b0 100644
--- a/drivers/target/target_core_pscsi.h
+++ b/drivers/target/target_core_pscsi.h
@@ -16,13 +16,13 @@
 #define PS_TIMEOUT_OTHER	(500*HZ)
 
 #include <linux/device.h>
-#include <scsi/scsi_driver.h>
-#include <scsi/scsi_device.h>
 #include <linux/kref.h>
 #include <linux/kobject.h>
 
+struct scsi_device;
+
 struct pscsi_plugin_task {
-	unsigned char pscsi_sense[SCSI_SENSE_BUFFERSIZE];
+	unsigned char pscsi_sense[TRANSPORT_SENSE_BUFFER];
 	int	pscsi_direction;
 	int	pscsi_result;
 	u32	pscsi_resid;
diff --git a/drivers/target/target_core_rd.c b/drivers/target/target_core_rd.c
index 98e83ac..0a03597 100644
--- a/drivers/target/target_core_rd.c
+++ b/drivers/target/target_core_rd.c
@@ -29,8 +29,7 @@
 #include <linux/timer.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
-#include <scsi/scsi.h>
-#include <scsi/scsi_host.h>
+#include <scsi/scsi_proto.h>
 
 #include <target/target_core_base.h>
 #include <target/target_core_backend.h>
diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c
index 3e72974..95defa7 100644
--- a/drivers/target/target_core_sbc.c
+++ b/drivers/target/target_core_sbc.c
@@ -25,7 +25,7 @@
 #include <linux/ratelimit.h>
 #include <linux/crc-t10dif.h>
 #include <asm/unaligned.h>
-#include <scsi/scsi.h>
+#include <scsi/scsi_proto.h>
 #include <scsi/scsi_tcq.h>
 
 #include <target/target_core_base.h>
diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
index 6c8bd6b..9ebae02 100644
--- a/drivers/target/target_core_spc.c
+++ b/drivers/target/target_core_spc.c
@@ -24,7 +24,8 @@
 #include <linux/module.h>
 #include <asm/unaligned.h>
 
-#include <scsi/scsi.h>
+#include <scsi/scsi_proto.h>
+#include <scsi/scsi_common.h>
 #include <scsi/scsi_tcq.h>
 
 #include <target/target_core_base.h>
diff --git a/drivers/target/target_core_stat.c b/drivers/target/target_core_stat.c
index 0353899..40f6c13 100644
--- a/drivers/target/target_core_stat.c
+++ b/drivers/target/target_core_stat.c
@@ -33,9 +33,6 @@
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/configfs.h>
-#include <scsi/scsi.h>
-#include <scsi/scsi_device.h>
-#include <scsi/scsi_host.h>
 
 #include <target/target_core_base.h>
 #include <target/target_core_backend.h>
diff --git a/drivers/target/target_core_tmr.c b/drivers/target/target_core_tmr.c
index fa5e157..e0201c9 100644
--- a/drivers/target/target_core_tmr.c
+++ b/drivers/target/target_core_tmr.c
@@ -27,8 +27,6 @@
 #include <linux/spinlock.h>
 #include <linux/list.h>
 #include <linux/export.h>
-#include <scsi/scsi.h>
-#include <scsi/scsi_cmnd.h>
 
 #include <target/target_core_base.h>
 #include <target/target_core_backend.h>
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c
index 0696de9..3ec3a3f 100644
--- a/drivers/target/target_core_tpg.c
+++ b/drivers/target/target_core_tpg.c
@@ -32,8 +32,7 @@
 #include <linux/export.h>
 #include <net/sock.h>
 #include <net/tcp.h>
-#include <scsi/scsi.h>
-#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_proto.h>
 
 #include <target/target_core_base.h>
 #include <target/target_core_backend.h>
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index ac3cbab..7f36556 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -37,9 +37,7 @@
 #include <asm/unaligned.h>
 #include <net/sock.h>
 #include <net/tcp.h>
-#include <scsi/scsi.h>
-#include <scsi/scsi_cmnd.h>
-#include <scsi/scsi_tcq.h>
+#include <scsi/scsi_proto.h>
 
 #include <target/target_core_base.h>
 #include <target/target_core_backend.h>
diff --git a/drivers/target/target_core_ua.c b/drivers/target/target_core_ua.c
index 1738b16..e44cc94 100644
--- a/drivers/target/target_core_ua.c
+++ b/drivers/target/target_core_ua.c
@@ -25,8 +25,7 @@
 
 #include <linux/slab.h>
 #include <linux/spinlock.h>
-#include <scsi/scsi.h>
-#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_proto.h>
 
 #include <target/target_core_base.h>
 #include <target/target_core_fabric.h>
diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index 1a1bcf7..2a291ba 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -19,12 +19,13 @@
 #include <linux/spinlock.h>
 #include <linux/module.h>
 #include <linux/idr.h>
+#include <linux/kernel.h>
 #include <linux/timer.h>
 #include <linux/parser.h>
-#include <scsi/scsi.h>
-#include <scsi/scsi_host.h>
 #include <linux/uio_driver.h>
 #include <net/genetlink.h>
+#include <scsi/scsi_common.h>
+#include <scsi/scsi_proto.h>
 #include <target/target_core_base.h>
 #include <target/target_core_fabric.h>
 #include <target/target_core_backend.h>
diff --git a/drivers/target/target_core_xcopy.c b/drivers/target/target_core_xcopy.c
index 33ac39b..409ad9a 100644
--- a/drivers/target/target_core_xcopy.c
+++ b/drivers/target/target_core_xcopy.c
@@ -25,8 +25,7 @@
 #include <linux/spinlock.h>
 #include <linux/list.h>
 #include <linux/configfs.h>
-#include <scsi/scsi.h>
-#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_proto.h>
 #include <asm/unaligned.h>
 
 #include <target/target_core_base.h>
diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c
index edcafa4..1bf78e7 100644
--- a/drivers/target/tcm_fc/tfc_cmd.c
+++ b/drivers/target/tcm_fc/tfc_cmd.c
@@ -30,10 +30,6 @@
 #include <linux/hash.h>
 #include <linux/percpu_ida.h>
 #include <asm/unaligned.h>
-#include <scsi/scsi.h>
-#include <scsi/scsi_host.h>
-#include <scsi/scsi_device.h>
-#include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_tcq.h>
 #include <scsi/libfc.h>
 #include <scsi/fc_encode.h>
diff --git a/drivers/target/tcm_fc/tfc_conf.c b/drivers/target/tcm_fc/tfc_conf.c
index efdcb96..2536846 100644
--- a/drivers/target/tcm_fc/tfc_conf.c
+++ b/drivers/target/tcm_fc/tfc_conf.c
@@ -34,10 +34,6 @@
 #include <linux/kernel.h>
 #include <linux/ctype.h>
 #include <asm/unaligned.h>
-#include <scsi/scsi.h>
-#include <scsi/scsi_host.h>
-#include <scsi/scsi_device.h>
-#include <scsi/scsi_cmnd.h>
 #include <scsi/libfc.h>
 
 #include <target/target_core_base.h>
diff --git a/drivers/target/tcm_fc/tfc_io.c b/drivers/target/tcm_fc/tfc_io.c
index 583e755..fe585d1 100644
--- a/drivers/target/tcm_fc/tfc_io.c
+++ b/drivers/target/tcm_fc/tfc_io.c
@@ -39,10 +39,6 @@
 #include <linux/hash.h>
 #include <linux/ratelimit.h>
 #include <asm/unaligned.h>
-#include <scsi/scsi.h>
-#include <scsi/scsi_host.h>
-#include <scsi/scsi_device.h>
-#include <scsi/scsi_cmnd.h>
 #include <scsi/libfc.h>
 #include <scsi/fc_encode.h>
 
diff --git a/drivers/target/tcm_fc/tfc_sess.c b/drivers/target/tcm_fc/tfc_sess.c
index ccee7e3..f2a616d 100644
--- a/drivers/target/tcm_fc/tfc_sess.c
+++ b/drivers/target/tcm_fc/tfc_sess.c
@@ -32,10 +32,6 @@
 #include <linux/rculist.h>
 #include <linux/kref.h>
 #include <asm/unaligned.h>
-#include <scsi/scsi.h>
-#include <scsi/scsi_host.h>
-#include <scsi/scsi_device.h>
-#include <scsi/scsi_cmnd.h>
 #include <scsi/libfc.h>
 
 #include <target/target_core_base.h>
diff --git a/drivers/usb/gadget/legacy/tcm_usb_gadget.c b/drivers/usb/gadget/legacy/tcm_usb_gadget.c
index 6e0a019..889623c 100644
--- a/drivers/usb/gadget/legacy/tcm_usb_gadget.c
+++ b/drivers/usb/gadget/legacy/tcm_usb_gadget.c
@@ -16,7 +16,6 @@
 #include <linux/usb/composite.h>
 #include <linux/usb/gadget.h>
 #include <linux/usb/storage.h>
-#include <scsi/scsi.h>
 #include <scsi/scsi_tcq.h>
 #include <target/target_core_base.h>
 #include <target/target_core_fabric.h>
diff --git a/drivers/usb/gadget/legacy/tcm_usb_gadget.h b/drivers/usb/gadget/legacy/tcm_usb_gadget.h
index 8289219..9fb3544 100644
--- a/drivers/usb/gadget/legacy/tcm_usb_gadget.h
+++ b/drivers/usb/gadget/legacy/tcm_usb_gadget.h
@@ -6,7 +6,6 @@
 #include <linux/usb/composite.h>
 #include <linux/usb/uas.h>
 #include <linux/usb/storage.h>
-#include <scsi/scsi.h>
 #include <target/target_core_base.h>
 #include <target/target_core_fabric.h>
 
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index 71df240..694843f 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -37,7 +37,8 @@
 #include <linux/fs.h>
 #include <linux/miscdevice.h>
 #include <asm/unaligned.h>
-#include <scsi/scsi.h>
+#include <scsi/scsi_common.h>
+#include <scsi/scsi_proto.h>
 #include <target/target_core_base.h>
 #include <target/target_core_fabric.h>
 #include <target/target_core_fabric_configfs.h>
diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c
index 42bd55a..4796854 100644
--- a/drivers/xen/xen-scsiback.c
+++ b/drivers/xen/xen-scsiback.c
@@ -47,10 +47,7 @@
 
 #include <generated/utsrelease.h>
 
-#include <scsi/scsi.h>
-#include <scsi/scsi_dbg.h>
-#include <scsi/scsi_eh.h>
-#include <scsi/scsi_tcq.h>
+#include <scsi/scsi_host.h> /* SG_ALL */
 
 #include <target/target_core_base.h>
 #include <target/target_core_fabric.h>
diff --git a/include/target/iscsi/iscsi_target_core.h b/include/target/iscsi/iscsi_target_core.h
index d3583d3..9d98498 100644
--- a/include/target/iscsi/iscsi_target_core.h
+++ b/include/target/iscsi/iscsi_target_core.h
@@ -5,7 +5,6 @@
 #include <linux/configfs.h>
 #include <net/sock.h>
 #include <net/tcp.h>
-#include <scsi/scsi_cmnd.h>
 #include <scsi/iscsi_proto.h>
 #include <target/target_core_base.h>
 
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index 7a6e55f..bc6e6fa 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -6,7 +6,6 @@
 #include <linux/dma-mapping.h>
 #include <linux/blkdev.h>
 #include <linux/percpu_ida.h>
-#include <scsi/scsi_cmnd.h>
 #include <net/sock.h>
 #include <net/tcp.h>
 
@@ -25,7 +24,7 @@
  * From include/scsi/scsi_cmnd.h:SCSI_SENSE_BUFFERSIZE, currently
  * defined 96, but the real limit is 252 (or 260 including the header)
  */
-#define TRANSPORT_SENSE_BUFFER			SCSI_SENSE_BUFFERSIZE
+#define TRANSPORT_SENSE_BUFFER			96
 /* Used by transport_send_check_condition_and_sense() */
 #define SPC_SENSE_KEY_OFFSET			2
 #define SPC_ADD_SENSE_LEN_OFFSET		7
diff --git a/include/trace/events/target.h b/include/trace/events/target.h
index 04c3c6e..50fea66 100644
--- a/include/trace/events/target.h
+++ b/include/trace/events/target.h
@@ -6,7 +6,7 @@
 
 #include <linux/tracepoint.h>
 #include <linux/trace_seq.h>
-#include <scsi/scsi.h>
+#include <scsi/scsi_proto.h>
 #include <scsi/scsi_tcq.h>
 #include <target/target_core_base.h>
 
-- 
2.1.4


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

* Re: [PATCH v3] Split SCSI header files
  2015-04-07 12:32 [PATCH v3] Split SCSI header files Bart Van Assche
                   ` (3 preceding siblings ...)
  2015-04-07 12:34 ` [PATCH v3 4/4] target: Minimize SCSI header #include directives Bart Van Assche
@ 2015-04-13  9:44 ` Christoph Hellwig
  4 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2015-04-13  9:44 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: James Bottomley, Christoph Hellwig, Nicholas A. Bellinger,
	Hannes Reinecke, Mike Christie, linux-scsi, target-devel

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

although I think patch 1 really should be split into two: one just
for the proto.h move, and one for the common module.

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

end of thread, other threads:[~2015-04-13  9:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-07 12:32 [PATCH v3] Split SCSI header files Bart Van Assche
2015-04-07 12:33 ` [PATCH v3 1/4] " Bart Van Assche
2015-04-07 12:33 ` [PATCH v3 2/4] Replace MAX_COMMAND_SIZE with BLK_MAX_CDB Bart Van Assche
2015-04-07 12:33 ` [PATCH v3 3/4] target: Correct a comment Bart Van Assche
2015-04-07 12:34 ` [PATCH v3 4/4] target: Minimize SCSI header #include directives Bart Van Assche
2015-04-13  9:44 ` [PATCH v3] Split SCSI header files Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.