diff options
author | Roland Dreier <roland@purestorage.com> | 2012-08-15 17:35:25 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2012-09-17 20:12:58 -0400 |
commit | 9c58b7ddd70dd7bfaac4ca87131f36d10aaba441 (patch) | |
tree | 2796f11c283904cef9b38f543e31fed3fea565c7 /drivers/target/iscsi/iscsi_target.c | |
parent | 2ed772b7b9df0f459308b3cbececc0136076d09e (diff) |
target: Simplify fabric sense data length handling
Every fabric driver has to supply a se_tfo->set_fabric_sense_len()
method, just so iSCSI can return an offset of 2. However, every fabric
driver is already allocating a sense buffer and passing it into the
target core, either via transport_init_se_cmd() or target_submit_cmd().
So instead of having iSCSI pass the start of its sense buffer into the
core and then later tell the core to skip the first 2 bytes, it seems
easier for iSCSI just to do the offset of 2 when it passes the sense
buffer into the core. Then we can drop the se_tfo->set_fabric_sense_len()
everywhere, and just add a couple of lines of code to iSCSI to set the
sense data length to the beginning of the buffer right before it sends
it over the network.
(nab: Remove .set_fabric_sense_len usage from tcm_qla2xxx_npiv_ops +
change transport_get_sense_buffer to follow v3.6-rc6 code w/o
->set_fabric_sense_len usage)
Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target/iscsi/iscsi_target.c')
-rw-r--r-- | drivers/target/iscsi/iscsi_target.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 97c0f78c3c9c..9cfdeedaadb6 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c | |||
@@ -953,7 +953,7 @@ done: | |||
953 | */ | 953 | */ |
954 | transport_init_se_cmd(&cmd->se_cmd, &lio_target_fabric_configfs->tf_ops, | 954 | transport_init_se_cmd(&cmd->se_cmd, &lio_target_fabric_configfs->tf_ops, |
955 | conn->sess->se_sess, hdr->data_length, cmd->data_direction, | 955 | conn->sess->se_sess, hdr->data_length, cmd->data_direction, |
956 | sam_task_attr, &cmd->sense_buffer[0]); | 956 | sam_task_attr, cmd->sense_buffer + 2); |
957 | 957 | ||
958 | pr_debug("Got SCSI Command, ITT: 0x%08x, CmdSN: 0x%08x," | 958 | pr_debug("Got SCSI Command, ITT: 0x%08x, CmdSN: 0x%08x," |
959 | " ExpXferLen: %u, Length: %u, CID: %hu\n", hdr->itt, | 959 | " ExpXferLen: %u, Length: %u, CID: %hu\n", hdr->itt, |
@@ -1700,7 +1700,7 @@ static int iscsit_handle_task_mgt_cmd( | |||
1700 | transport_init_se_cmd(&cmd->se_cmd, | 1700 | transport_init_se_cmd(&cmd->se_cmd, |
1701 | &lio_target_fabric_configfs->tf_ops, | 1701 | &lio_target_fabric_configfs->tf_ops, |
1702 | conn->sess->se_sess, 0, DMA_NONE, | 1702 | conn->sess->se_sess, 0, DMA_NONE, |
1703 | MSG_SIMPLE_TAG, &cmd->sense_buffer[0]); | 1703 | MSG_SIMPLE_TAG, cmd->sense_buffer + 2); |
1704 | 1704 | ||
1705 | switch (function) { | 1705 | switch (function) { |
1706 | case ISCSI_TM_FUNC_ABORT_TASK: | 1706 | case ISCSI_TM_FUNC_ABORT_TASK: |
@@ -3092,15 +3092,18 @@ static int iscsit_send_status( | |||
3092 | if (cmd->se_cmd.sense_buffer && | 3092 | if (cmd->se_cmd.sense_buffer && |
3093 | ((cmd->se_cmd.se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) || | 3093 | ((cmd->se_cmd.se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) || |
3094 | (cmd->se_cmd.se_cmd_flags & SCF_EMULATED_TASK_SENSE))) { | 3094 | (cmd->se_cmd.se_cmd_flags & SCF_EMULATED_TASK_SENSE))) { |
3095 | put_unaligned_be16(cmd->se_cmd.scsi_sense_length, cmd->sense_buffer); | ||
3096 | cmd->se_cmd.scsi_sense_length += sizeof (__be16); | ||
3097 | |||
3095 | padding = -(cmd->se_cmd.scsi_sense_length) & 3; | 3098 | padding = -(cmd->se_cmd.scsi_sense_length) & 3; |
3096 | hton24(hdr->dlength, cmd->se_cmd.scsi_sense_length); | 3099 | hton24(hdr->dlength, cmd->se_cmd.scsi_sense_length); |
3097 | iov[iov_count].iov_base = cmd->se_cmd.sense_buffer; | 3100 | iov[iov_count].iov_base = cmd->sense_buffer; |
3098 | iov[iov_count++].iov_len = | 3101 | iov[iov_count++].iov_len = |
3099 | (cmd->se_cmd.scsi_sense_length + padding); | 3102 | (cmd->se_cmd.scsi_sense_length + padding); |
3100 | tx_size += cmd->se_cmd.scsi_sense_length; | 3103 | tx_size += cmd->se_cmd.scsi_sense_length; |
3101 | 3104 | ||
3102 | if (padding) { | 3105 | if (padding) { |
3103 | memset(cmd->se_cmd.sense_buffer + | 3106 | memset(cmd->sense_buffer + |
3104 | cmd->se_cmd.scsi_sense_length, 0, padding); | 3107 | cmd->se_cmd.scsi_sense_length, 0, padding); |
3105 | tx_size += padding; | 3108 | tx_size += padding; |
3106 | pr_debug("Adding %u bytes of padding to" | 3109 | pr_debug("Adding %u bytes of padding to" |
@@ -3109,7 +3112,7 @@ static int iscsit_send_status( | |||
3109 | 3112 | ||
3110 | if (conn->conn_ops->DataDigest) { | 3113 | if (conn->conn_ops->DataDigest) { |
3111 | iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, | 3114 | iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, |
3112 | cmd->se_cmd.sense_buffer, | 3115 | cmd->sense_buffer, |
3113 | (cmd->se_cmd.scsi_sense_length + padding), | 3116 | (cmd->se_cmd.scsi_sense_length + padding), |
3114 | 0, NULL, (u8 *)&cmd->data_crc); | 3117 | 0, NULL, (u8 *)&cmd->data_crc); |
3115 | 3118 | ||