aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2012-05-20 11:59:17 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2012-07-16 20:28:40 -0400
commit3d6d72014f16967ca92765040be30f022c5952e6 (patch)
treeca4a3028d770ceab2b42fedca07e78d6d90a06b2 /drivers/target
parent1fd032ee10d2816c947f5d5b9abda95e728f0a8f (diff)
target: move transport_generic_prepare_cdb into pscsi
The virtual drivers don't need to clear cdb fields they never look at, so move this code into the pscsi backend. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target')
-rw-r--r--drivers/target/target_core_pscsi.c26
-rw-r--r--drivers/target/target_core_transport.c29
2 files changed, 26 insertions, 29 deletions
diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
index 099c59d31b1..9a776cc03d6 100644
--- a/drivers/target/target_core_pscsi.c
+++ b/drivers/target/target_core_pscsi.c
@@ -1022,6 +1022,30 @@ fail:
1022 return -ENOMEM; 1022 return -ENOMEM;
1023} 1023}
1024 1024
1025/*
1026 * Clear a lun set in the cdb if the initiator talking to use spoke
1027 * and old standards version, as we can't assume the underlying device
1028 * won't choke up on it.
1029 */
1030static inline void pscsi_clear_cdb_lun(unsigned char *cdb)
1031{
1032 switch (cdb[0]) {
1033 case READ_10: /* SBC - RDProtect */
1034 case READ_12: /* SBC - RDProtect */
1035 case READ_16: /* SBC - RDProtect */
1036 case SEND_DIAGNOSTIC: /* SPC - SELF-TEST Code */
1037 case VERIFY: /* SBC - VRProtect */
1038 case VERIFY_16: /* SBC - VRProtect */
1039 case WRITE_VERIFY: /* SBC - VRProtect */
1040 case WRITE_VERIFY_12: /* SBC - VRProtect */
1041 case MAINTENANCE_IN: /* SPC - Parameter Data Format for SA RTPG */
1042 break;
1043 default:
1044 cdb[1] &= 0x1f; /* clear logical unit number */
1045 break;
1046 }
1047}
1048
1025static int pscsi_parse_cdb(struct se_cmd *cmd) 1049static int pscsi_parse_cdb(struct se_cmd *cmd)
1026{ 1050{
1027 unsigned char *cdb = cmd->t_task_cdb; 1051 unsigned char *cdb = cmd->t_task_cdb;
@@ -1034,6 +1058,8 @@ static int pscsi_parse_cdb(struct se_cmd *cmd)
1034 return -EINVAL; 1058 return -EINVAL;
1035 } 1059 }
1036 1060
1061 pscsi_clear_cdb_lun(cdb);
1062
1037 /* 1063 /*
1038 * For REPORT LUNS we always need to emulate the respone, and for everything 1064 * For REPORT LUNS we always need to emulate the respone, and for everything
1039 * related to persistent reservations and ALUA we might optionally use our 1065 * related to persistent reservations and ALUA we might optionally use our
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 3a7fe21e4d2..7cfb519a83f 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -1315,34 +1315,6 @@ out:
1315} 1315}
1316EXPORT_SYMBOL(transport_add_device_to_core_hba); 1316EXPORT_SYMBOL(transport_add_device_to_core_hba);
1317 1317
1318/* transport_generic_prepare_cdb():
1319 *
1320 * Since the Initiator sees iSCSI devices as LUNs, the SCSI CDB will
1321 * contain the iSCSI LUN in bits 7-5 of byte 1 as per SAM-2.
1322 * The point of this is since we are mapping iSCSI LUNs to
1323 * SCSI Target IDs having a non-zero LUN in the CDB will throw the
1324 * devices and HBAs for a loop.
1325 */
1326static inline void transport_generic_prepare_cdb(
1327 unsigned char *cdb)
1328{
1329 switch (cdb[0]) {
1330 case READ_10: /* SBC - RDProtect */
1331 case READ_12: /* SBC - RDProtect */
1332 case READ_16: /* SBC - RDProtect */
1333 case SEND_DIAGNOSTIC: /* SPC - SELF-TEST Code */
1334 case VERIFY: /* SBC - VRProtect */
1335 case VERIFY_16: /* SBC - VRProtect */
1336 case WRITE_VERIFY: /* SBC - VRProtect */
1337 case WRITE_VERIFY_12: /* SBC - VRProtect */
1338 case MAINTENANCE_IN: /* SPC - Parameter Data Format for SA RTPG */
1339 break;
1340 default:
1341 cdb[1] &= 0x1f; /* clear logical unit number */
1342 break;
1343 }
1344}
1345
1346int target_cmd_size_check(struct se_cmd *cmd, unsigned int size) 1318int target_cmd_size_check(struct se_cmd *cmd, unsigned int size)
1347{ 1319{
1348 struct se_device *dev = cmd->se_dev; 1320 struct se_device *dev = cmd->se_dev;
@@ -1471,7 +1443,6 @@ int target_setup_cmd_from_cdb(
1471 unsigned long flags; 1443 unsigned long flags;
1472 int ret; 1444 int ret;
1473 1445
1474 transport_generic_prepare_cdb(cdb);
1475 /* 1446 /*
1476 * Ensure that the received CDB is less than the max (252 + 8) bytes 1447 * Ensure that the received CDB is less than the max (252 + 8) bytes
1477 * for VARIABLE_LENGTH_CMD 1448 * for VARIABLE_LENGTH_CMD