Skip to content

Commit 9c58b7d

Browse files
rolanddNicholas Bellinger
authored andcommitted
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>
1 parent 2ed772b commit 9c58b7d

13 files changed

Lines changed: 79 additions & 163 deletions

File tree

‎Documentation/target/tcm_mod_builder.py‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,6 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
402402
buf += " .queue_data_in = " + fabric_mod_name + "_queue_data_in,\n"
403403
buf += " .queue_status = " + fabric_mod_name + "_queue_status,\n"
404404
buf += " .queue_tm_rsp = " + fabric_mod_name + "_queue_tm_rsp,\n"
405-
buf += " .set_fabric_sense_len = " + fabric_mod_name + "_set_fabric_sense_len,\n"
406405
buf += " .is_state_remove = " + fabric_mod_name + "_is_state_remove,\n"
407406
buf += " /*\n"
408407
buf += " * Setup function pointers for generic logic in target_core_fabric_configfs.c\n"
@@ -905,13 +904,6 @@ def tcm_mod_dump_fabric_ops(proto_ident, fabric_mod_dir_var, fabric_mod_name):
905904
buf += "}\n\n"
906905
bufi += "int " + fabric_mod_name + "_queue_tm_rsp(struct se_cmd *);\n"
907906

908-
if re.search('set_fabric_sense_len\)\(', fo):
909-
buf += "u16 " + fabric_mod_name + "_set_fabric_sense_len(struct se_cmd *se_cmd, u32 sense_length)\n"
910-
buf += "{\n"
911-
buf += " return 0;\n"
912-
buf += "}\n\n"
913-
bufi += "u16 " + fabric_mod_name + "_set_fabric_sense_len(struct se_cmd *, u32);\n"
914-
915907
if re.search('is_state_remove\)\(', fo):
916908
buf += "int " + fabric_mod_name + "_is_state_remove(struct se_cmd *se_cmd)\n"
917909
buf += "{\n"

‎drivers/infiniband/ulp/srpt/ib_srpt.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3564,11 +3564,6 @@ static int srpt_get_tcm_cmd_state(struct se_cmd *se_cmd)
35643564
return srpt_get_cmd_state(ioctx);
35653565
}
35663566

3567-
static u16 srpt_set_fabric_sense_len(struct se_cmd *cmd, u32 sense_length)
3568-
{
3569-
return 0;
3570-
}
3571-
35723567
/**
35733568
* srpt_parse_i_port_id() - Parse an initiator port ID.
35743569
* @name: ASCII representation of a 128-bit initiator port ID.
@@ -3948,7 +3943,6 @@ static struct target_core_fabric_ops srpt_template = {
39483943
.queue_data_in = srpt_queue_response,
39493944
.queue_status = srpt_queue_status,
39503945
.queue_tm_rsp = srpt_queue_response,
3951-
.set_fabric_sense_len = srpt_set_fabric_sense_len,
39523946
/*
39533947
* Setup function pointers for generic logic in
39543948
* target_core_fabric_configfs.c

‎drivers/scsi/qla2xxx/tcm_qla2xxx.c‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -735,12 +735,6 @@ static int tcm_qla2xxx_queue_tm_rsp(struct se_cmd *se_cmd)
735735
return 0;
736736
}
737737

738-
static u16 tcm_qla2xxx_set_fabric_sense_len(struct se_cmd *se_cmd,
739-
u32 sense_length)
740-
{
741-
return 0;
742-
}
743-
744738
/* Local pointer to allocated TCM configfs fabric module */
745739
struct target_fabric_configfs *tcm_qla2xxx_fabric_configfs;
746740
struct target_fabric_configfs *tcm_qla2xxx_npiv_fabric_configfs;
@@ -1686,7 +1680,6 @@ static struct target_core_fabric_ops tcm_qla2xxx_ops = {
16861680
.queue_data_in = tcm_qla2xxx_queue_data_in,
16871681
.queue_status = tcm_qla2xxx_queue_status,
16881682
.queue_tm_rsp = tcm_qla2xxx_queue_tm_rsp,
1689-
.set_fabric_sense_len = tcm_qla2xxx_set_fabric_sense_len,
16901683
/*
16911684
* Setup function pointers for generic logic in
16921685
* target_core_fabric_configfs.c
@@ -1734,7 +1727,6 @@ static struct target_core_fabric_ops tcm_qla2xxx_npiv_ops = {
17341727
.queue_data_in = tcm_qla2xxx_queue_data_in,
17351728
.queue_status = tcm_qla2xxx_queue_status,
17361729
.queue_tm_rsp = tcm_qla2xxx_queue_tm_rsp,
1737-
.set_fabric_sense_len = tcm_qla2xxx_set_fabric_sense_len,
17381730
/*
17391731
* Setup function pointers for generic logic in
17401732
* target_core_fabric_configfs.c

‎drivers/target/iscsi/iscsi_target.c‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ static int iscsit_handle_scsi_cmd(
953953
*/
954954
transport_init_se_cmd(&cmd->se_cmd, &lio_target_fabric_configfs->tf_ops,
955955
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);
957957

958958
pr_debug("Got SCSI Command, ITT: 0x%08x, CmdSN: 0x%08x,"
959959
" ExpXferLen: %u, Length: %u, CID: %hu\n", hdr->itt,
@@ -1700,7 +1700,7 @@ static int iscsit_handle_task_mgt_cmd(
17001700
transport_init_se_cmd(&cmd->se_cmd,
17011701
&lio_target_fabric_configfs->tf_ops,
17021702
conn->sess->se_sess, 0, DMA_NONE,
1703-
MSG_SIMPLE_TAG, &cmd->sense_buffer[0]);
1703+
MSG_SIMPLE_TAG, cmd->sense_buffer + 2);
17041704

17051705
switch (function) {
17061706
case ISCSI_TM_FUNC_ABORT_TASK:
@@ -3092,15 +3092,18 @@ static int iscsit_send_status(
30923092
if (cmd->se_cmd.sense_buffer &&
30933093
((cmd->se_cmd.se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) ||
30943094
(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+
30953098
padding = -(cmd->se_cmd.scsi_sense_length) & 3;
30963099
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;
30983101
iov[iov_count++].iov_len =
30993102
(cmd->se_cmd.scsi_sense_length + padding);
31003103
tx_size += cmd->se_cmd.scsi_sense_length;
31013104

31023105
if (padding) {
3103-
memset(cmd->se_cmd.sense_buffer +
3106+
memset(cmd->sense_buffer +
31043107
cmd->se_cmd.scsi_sense_length, 0, padding);
31053108
tx_size += padding;
31063109
pr_debug("Adding %u bytes of padding to"
@@ -3109,7 +3112,7 @@ static int iscsit_send_status(
31093112

31103113
if (conn->conn_ops->DataDigest) {
31113114
iscsit_do_crypto_hash_buf(&conn->conn_tx_hash,
3112-
cmd->se_cmd.sense_buffer,
3115+
cmd->sense_buffer,
31133116
(cmd->se_cmd.scsi_sense_length + padding),
31143117
0, NULL, (u8 *)&cmd->data_crc);
31153118

‎drivers/target/iscsi/iscsi_target_configfs.c‎

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,21 +1542,6 @@ static int lio_queue_status(struct se_cmd *se_cmd)
15421542
return 0;
15431543
}
15441544

1545-
static u16 lio_set_fabric_sense_len(struct se_cmd *se_cmd, u32 sense_length)
1546-
{
1547-
unsigned char *buffer = se_cmd->sense_buffer;
1548-
/*
1549-
* From RFC-3720 10.4.7. Data Segment - Sense and Response Data Segment
1550-
* 16-bit SenseLength.
1551-
*/
1552-
buffer[0] = ((sense_length >> 8) & 0xff);
1553-
buffer[1] = (sense_length & 0xff);
1554-
/*
1555-
* Return two byte offset into allocated sense_buffer.
1556-
*/
1557-
return 2;
1558-
}
1559-
15601545
static int lio_queue_tm_rsp(struct se_cmd *se_cmd)
15611546
{
15621547
struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
@@ -1740,7 +1725,6 @@ int iscsi_target_register_configfs(void)
17401725
fabric->tf_ops.queue_data_in = &lio_queue_data_in;
17411726
fabric->tf_ops.queue_status = &lio_queue_status;
17421727
fabric->tf_ops.queue_tm_rsp = &lio_queue_tm_rsp;
1743-
fabric->tf_ops.set_fabric_sense_len = &lio_set_fabric_sense_len;
17441728
/*
17451729
* Setup function pointers for generic logic in target_core_fabric_configfs.c
17461730
*/

‎drivers/target/loopback/tcm_loop.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -846,11 +846,6 @@ static int tcm_loop_queue_tm_rsp(struct se_cmd *se_cmd)
846846
return 0;
847847
}
848848

849-
static u16 tcm_loop_set_fabric_sense_len(struct se_cmd *se_cmd, u32 sense_length)
850-
{
851-
return 0;
852-
}
853-
854849
static char *tcm_loop_dump_proto_id(struct tcm_loop_hba *tl_hba)
855850
{
856851
switch (tl_hba->tl_proto_id) {
@@ -1368,7 +1363,6 @@ static int tcm_loop_register_configfs(void)
13681363
fabric->tf_ops.queue_data_in = &tcm_loop_queue_data_in;
13691364
fabric->tf_ops.queue_status = &tcm_loop_queue_status;
13701365
fabric->tf_ops.queue_tm_rsp = &tcm_loop_queue_tm_rsp;
1371-
fabric->tf_ops.set_fabric_sense_len = &tcm_loop_set_fabric_sense_len;
13721366

13731367
/*
13741368
* Setup function pointers for generic logic in target_core_fabric_configfs.c

‎drivers/target/sbp/sbp_target.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1847,11 +1847,6 @@ static int sbp_queue_tm_rsp(struct se_cmd *se_cmd)
18471847
return 0;
18481848
}
18491849

1850-
static u16 sbp_set_fabric_sense_len(struct se_cmd *se_cmd, u32 sense_length)
1851-
{
1852-
return 0;
1853-
}
1854-
18551850
static int sbp_check_stop_free(struct se_cmd *se_cmd)
18561851
{
18571852
struct sbp_target_request *req = container_of(se_cmd,
@@ -2529,7 +2524,6 @@ static struct target_core_fabric_ops sbp_ops = {
25292524
.queue_data_in = sbp_queue_data_in,
25302525
.queue_status = sbp_queue_status,
25312526
.queue_tm_rsp = sbp_queue_tm_rsp,
2532-
.set_fabric_sense_len = sbp_set_fabric_sense_len,
25332527
.check_stop_free = sbp_check_stop_free,
25342528

25352529
.fabric_make_wwn = sbp_make_tport,

‎drivers/target/target_core_configfs.c‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,10 +457,6 @@ static int target_fabric_tf_ops_check(
457457
pr_err("Missing tfo->queue_tm_rsp()\n");
458458
return -EINVAL;
459459
}
460-
if (!tfo->set_fabric_sense_len) {
461-
pr_err("Missing tfo->set_fabric_sense_len()\n");
462-
return -EINVAL;
463-
}
464460
/*
465461
* We at least require tfo->fabric_make_wwn(), tfo->fabric_drop_wwn()
466462
* tfo->fabric_make_tpg() and tfo->fabric_drop_tpg() in

0 commit comments

Comments
 (0)