diff options
author | Andy Grover <agrover@redhat.com> | 2011-07-19 06:26:37 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2011-07-22 05:37:43 -0400 |
commit | 5951146dea1ac8ff2f177477c907084d63913cad (patch) | |
tree | 699cb7c498ca1799ae3e349cb4360171d9fa63e0 /drivers/target/tcm_fc | |
parent | f22c119683e73498d8126581a1be75e1b7a339a3 (diff) |
target: More core cleanups from AGrover (round 2)
This patch contains the squashed version of second round of target core
cleanups and simplifications and Andy and Co. It also contains a handful
of fixes to address bugs the original series and other minor cleanups.
Here is the condensed shortlog:
target: Remove unneeded casts to void*
target: Rename get_lun_for_{cmd,tmr} to lookup_{cmd,tmr}_lun
target: Make t_task a member of se_cmd, not a pointer
target: Handle functions returning "-2"
target: Use cmd->se_dev over cmd->se_lun->lun_se_dev
target: Embed qr in struct se_cmd
target: Replace embedded struct se_queue_req with a list_head
target: Rename list_heads that are nodes in struct se_cmd to "*_node"
target: Fold transport_device_setup_cmd() into lookup_{tmr,cmd}_lun()
target: Make t_mem_list and t_mem_list_bidi members of t_task
target: Add comment & cleanup transport_map_sg_to_mem()
target: Remove unneeded checks in transport_free_pages()
(Roland: Fix se_queue_req removal leftovers OOPs)
(nab: Fix transport_lookup_tmr_lun failure case)
(nab: Fix list_empty(&cmd->t_task.t_mem_bidi_list) inversion bugs)
Signed-off-by: Andy Grover <agrover@redhat.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target/tcm_fc')
-rw-r--r-- | drivers/target/tcm_fc/tfc_cmd.c | 26 | ||||
-rw-r--r-- | drivers/target/tcm_fc/tfc_conf.c | 2 | ||||
-rw-r--r-- | drivers/target/tcm_fc/tfc_io.c | 10 |
3 files changed, 18 insertions, 20 deletions
diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c index 19b2b9948314..6d9553bbba30 100644 --- a/drivers/target/tcm_fc/tfc_cmd.c +++ b/drivers/target/tcm_fc/tfc_cmd.c | |||
@@ -72,16 +72,16 @@ void ft_dump_cmd(struct ft_cmd *cmd, const char *caller) | |||
72 | caller, cmd, cmd->cdb); | 72 | caller, cmd, cmd->cdb); |
73 | printk(KERN_INFO "%s: cmd %p lun %d\n", caller, cmd, cmd->lun); | 73 | printk(KERN_INFO "%s: cmd %p lun %d\n", caller, cmd, cmd->lun); |
74 | 74 | ||
75 | task = se_cmd->t_task; | 75 | task = &se_cmd->t_task; |
76 | printk(KERN_INFO "%s: cmd %p task %p se_num %u buf %p len %u se_cmd_flags <0x%x>\n", | 76 | printk(KERN_INFO "%s: cmd %p task %p se_num %u buf %p len %u se_cmd_flags <0x%x>\n", |
77 | caller, cmd, task, task->t_tasks_se_num, | 77 | caller, cmd, task, task->t_tasks_se_num, |
78 | task->t_task_buf, se_cmd->data_length, se_cmd->se_cmd_flags); | 78 | task->t_task_buf, se_cmd->data_length, se_cmd->se_cmd_flags); |
79 | if (task->t_mem_list) | 79 | |
80 | list_for_each_entry(mem, task->t_mem_list, se_list) | 80 | list_for_each_entry(mem, &task->t_mem_list, se_list) |
81 | printk(KERN_INFO "%s: cmd %p mem %p page %p " | 81 | printk(KERN_INFO "%s: cmd %p mem %p page %p " |
82 | "len 0x%x off 0x%x\n", | 82 | "len 0x%x off 0x%x\n", |
83 | caller, cmd, mem, | 83 | caller, cmd, mem, |
84 | mem->se_page, mem->se_len, mem->se_off); | 84 | mem->se_page, mem->se_len, mem->se_off); |
85 | sp = cmd->seq; | 85 | sp = cmd->seq; |
86 | if (sp) { | 86 | if (sp) { |
87 | ep = fc_seq_exch(sp); | 87 | ep = fc_seq_exch(sp); |
@@ -262,9 +262,9 @@ int ft_write_pending(struct se_cmd *se_cmd) | |||
262 | * TCM/LIO target | 262 | * TCM/LIO target |
263 | */ | 263 | */ |
264 | transport_do_task_sg_chain(se_cmd); | 264 | transport_do_task_sg_chain(se_cmd); |
265 | cmd->sg = se_cmd->t_task->t_tasks_sg_chained; | 265 | cmd->sg = se_cmd->t_task.t_tasks_sg_chained; |
266 | cmd->sg_cnt = | 266 | cmd->sg_cnt = |
267 | se_cmd->t_task->t_tasks_sg_chained_no; | 267 | se_cmd->t_task.t_tasks_sg_chained_no; |
268 | } | 268 | } |
269 | if (cmd->sg && lport->tt.ddp_setup(lport, ep->xid, | 269 | if (cmd->sg && lport->tt.ddp_setup(lport, ep->xid, |
270 | cmd->sg, cmd->sg_cnt)) | 270 | cmd->sg, cmd->sg_cnt)) |
@@ -438,7 +438,7 @@ static void ft_send_tm(struct ft_cmd *cmd) | |||
438 | switch (fcp->fc_tm_flags) { | 438 | switch (fcp->fc_tm_flags) { |
439 | case FCP_TMF_LUN_RESET: | 439 | case FCP_TMF_LUN_RESET: |
440 | cmd->lun = scsilun_to_int((struct scsi_lun *)fcp->fc_lun); | 440 | cmd->lun = scsilun_to_int((struct scsi_lun *)fcp->fc_lun); |
441 | if (transport_get_lun_for_tmr(&cmd->se_cmd, cmd->lun) < 0) { | 441 | if (transport_lookup_tmr_lun(&cmd->se_cmd, cmd->lun) < 0) { |
442 | /* | 442 | /* |
443 | * Make sure to clean up newly allocated TMR request | 443 | * Make sure to clean up newly allocated TMR request |
444 | * since "unable to handle TMR request because failed | 444 | * since "unable to handle TMR request because failed |
@@ -637,7 +637,7 @@ static void ft_send_cmd(struct ft_cmd *cmd) | |||
637 | fc_seq_exch(cmd->seq)->lp->tt.seq_set_resp(cmd->seq, ft_recv_seq, cmd); | 637 | fc_seq_exch(cmd->seq)->lp->tt.seq_set_resp(cmd->seq, ft_recv_seq, cmd); |
638 | 638 | ||
639 | cmd->lun = scsilun_to_int((struct scsi_lun *)fcp->fc_lun); | 639 | cmd->lun = scsilun_to_int((struct scsi_lun *)fcp->fc_lun); |
640 | ret = transport_get_lun_for_cmd(&cmd->se_cmd, cmd->lun); | 640 | ret = transport_lookup_cmd_lun(&cmd->se_cmd, cmd->lun); |
641 | if (ret < 0) { | 641 | if (ret < 0) { |
642 | ft_dump_cmd(cmd, __func__); | 642 | ft_dump_cmd(cmd, __func__); |
643 | transport_send_check_condition_and_sense(&cmd->se_cmd, | 643 | transport_send_check_condition_and_sense(&cmd->se_cmd, |
@@ -650,13 +650,13 @@ static void ft_send_cmd(struct ft_cmd *cmd) | |||
650 | FT_IO_DBG("r_ctl %x alloc task ret %d\n", fh->fh_r_ctl, ret); | 650 | FT_IO_DBG("r_ctl %x alloc task ret %d\n", fh->fh_r_ctl, ret); |
651 | ft_dump_cmd(cmd, __func__); | 651 | ft_dump_cmd(cmd, __func__); |
652 | 652 | ||
653 | if (ret == -1) { | 653 | if (ret == -ENOMEM) { |
654 | transport_send_check_condition_and_sense(se_cmd, | 654 | transport_send_check_condition_and_sense(se_cmd, |
655 | TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE, 0); | 655 | TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE, 0); |
656 | transport_generic_free_cmd(se_cmd, 0, 1, 0); | 656 | transport_generic_free_cmd(se_cmd, 0, 1, 0); |
657 | return; | 657 | return; |
658 | } | 658 | } |
659 | if (ret == -2) { | 659 | if (ret == -EINVAL) { |
660 | if (se_cmd->se_cmd_flags & SCF_SCSI_RESERVATION_CONFLICT) | 660 | if (se_cmd->se_cmd_flags & SCF_SCSI_RESERVATION_CONFLICT) |
661 | ft_queue_status(se_cmd); | 661 | ft_queue_status(se_cmd); |
662 | else | 662 | else |
diff --git a/drivers/target/tcm_fc/tfc_conf.c b/drivers/target/tcm_fc/tfc_conf.c index 8c5067c65720..58e4745749db 100644 --- a/drivers/target/tcm_fc/tfc_conf.c +++ b/drivers/target/tcm_fc/tfc_conf.c | |||
@@ -331,7 +331,7 @@ static struct se_portal_group *ft_add_tpg( | |||
331 | transport_init_queue_obj(&tpg->qobj); | 331 | transport_init_queue_obj(&tpg->qobj); |
332 | 332 | ||
333 | ret = core_tpg_register(&ft_configfs->tf_ops, wwn, &tpg->se_tpg, | 333 | ret = core_tpg_register(&ft_configfs->tf_ops, wwn, &tpg->se_tpg, |
334 | (void *)tpg, TRANSPORT_TPG_TYPE_NORMAL); | 334 | tpg, TRANSPORT_TPG_TYPE_NORMAL); |
335 | if (ret < 0) { | 335 | if (ret < 0) { |
336 | kfree(tpg); | 336 | kfree(tpg); |
337 | return NULL; | 337 | return NULL; |
diff --git a/drivers/target/tcm_fc/tfc_io.c b/drivers/target/tcm_fc/tfc_io.c index 47efcfb9f4b8..f18af6e99b83 100644 --- a/drivers/target/tcm_fc/tfc_io.c +++ b/drivers/target/tcm_fc/tfc_io.c | |||
@@ -90,15 +90,14 @@ int ft_queue_data_in(struct se_cmd *se_cmd) | |||
90 | lport = ep->lp; | 90 | lport = ep->lp; |
91 | cmd->seq = lport->tt.seq_start_next(cmd->seq); | 91 | cmd->seq = lport->tt.seq_start_next(cmd->seq); |
92 | 92 | ||
93 | task = se_cmd->t_task; | 93 | task = &se_cmd->t_task; |
94 | BUG_ON(!task); | ||
95 | remaining = se_cmd->data_length; | 94 | remaining = se_cmd->data_length; |
96 | 95 | ||
97 | /* | 96 | /* |
98 | * Setup to use first mem list entry if any. | 97 | * Setup to use first mem list entry if any. |
99 | */ | 98 | */ |
100 | if (task->t_tasks_se_num) { | 99 | if (task->t_tasks_se_num) { |
101 | mem = list_first_entry(task->t_mem_list, | 100 | mem = list_first_entry(&task->t_mem_list, |
102 | struct se_mem, se_list); | 101 | struct se_mem, se_list); |
103 | mem_len = mem->se_len; | 102 | mem_len = mem->se_len; |
104 | mem_off = mem->se_off; | 103 | mem_off = mem->se_off; |
@@ -236,8 +235,7 @@ void ft_recv_write_data(struct ft_cmd *cmd, struct fc_frame *fp) | |||
236 | u32 f_ctl; | 235 | u32 f_ctl; |
237 | void *buf; | 236 | void *buf; |
238 | 237 | ||
239 | task = se_cmd->t_task; | 238 | task = &se_cmd->t_task; |
240 | BUG_ON(!task); | ||
241 | 239 | ||
242 | fh = fc_frame_header_get(fp); | 240 | fh = fc_frame_header_get(fp); |
243 | if (!(ntoh24(fh->fh_f_ctl) & FC_FC_REL_OFF)) | 241 | if (!(ntoh24(fh->fh_f_ctl) & FC_FC_REL_OFF)) |
@@ -315,7 +313,7 @@ void ft_recv_write_data(struct ft_cmd *cmd, struct fc_frame *fp) | |||
315 | * Setup to use first mem list entry if any. | 313 | * Setup to use first mem list entry if any. |
316 | */ | 314 | */ |
317 | if (task->t_tasks_se_num) { | 315 | if (task->t_tasks_se_num) { |
318 | mem = list_first_entry(task->t_mem_list, | 316 | mem = list_first_entry(&task->t_mem_list, |
319 | struct se_mem, se_list); | 317 | struct se_mem, se_list); |
320 | mem_len = mem->se_len; | 318 | mem_len = mem->se_len; |
321 | mem_off = mem->se_off; | 319 | mem_off = mem->se_off; |