diff options
| author | Christoph Hellwig <hch@lst.de> | 2011-09-13 17:09:01 -0400 |
|---|---|---|
| committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2011-10-23 23:20:38 -0400 |
| commit | 82f1c8a4e7739eae9f1c32c2c419efdc19b8af41 (patch) | |
| tree | e4b9141c59cbc1402b96fb34003205fe90d362df | |
| parent | e6a2573f1f5d66f0456c433afdfc63f33fdf9008 (diff) | |
target: push session reinstatement out of transport_generic_free_cmd
Push session reinstatement out of transport_generic_free_cmd into the only
caller that actually needs it. Clean up transport_generic_free_cmd a bit,
and remove the useless comment. I'd love to add a more useful kerneldoc
comment for it, but as this point I'm still a bit confused in where it
stands in the command release stack.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
| -rw-r--r-- | drivers/target/iscsi/iscsi_target.c | 2 | ||||
| -rw-r--r-- | drivers/target/loopback/tcm_loop.c | 4 | ||||
| -rw-r--r-- | drivers/target/target_core_transport.c | 37 | ||||
| -rw-r--r-- | drivers/target/tcm_fc/tfc_cmd.c | 12 | ||||
| -rw-r--r-- | include/target/target_core_transport.h | 2 |
5 files changed, 23 insertions, 34 deletions
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 6a4ea29c2f36..7dc2cfe9431c 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c | |||
| @@ -3547,7 +3547,7 @@ get_immediate: | |||
| 3547 | iscsit_release_cmd(cmd); | 3547 | iscsit_release_cmd(cmd); |
| 3548 | else | 3548 | else |
| 3549 | transport_generic_free_cmd(&cmd->se_cmd, | 3549 | transport_generic_free_cmd(&cmd->se_cmd, |
| 3550 | 1, 0); | 3550 | 1); |
| 3551 | goto get_immediate; | 3551 | goto get_immediate; |
| 3552 | case ISTATE_SEND_NOPIN_WANT_RESPONSE: | 3552 | case ISTATE_SEND_NOPIN_WANT_RESPONSE: |
| 3553 | spin_unlock_bh(&cmd->istate_lock); | 3553 | spin_unlock_bh(&cmd->istate_lock); |
diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index aa2d67997235..f0e701d27bd1 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c | |||
| @@ -200,7 +200,7 @@ static void tcm_loop_check_stop_free(struct se_cmd *se_cmd) | |||
| 200 | * Release the struct se_cmd, which will make a callback to release | 200 | * Release the struct se_cmd, which will make a callback to release |
| 201 | * struct tcm_loop_cmd * in tcm_loop_deallocate_core_cmd() | 201 | * struct tcm_loop_cmd * in tcm_loop_deallocate_core_cmd() |
| 202 | */ | 202 | */ |
| 203 | transport_generic_free_cmd(se_cmd, 0, 0); | 203 | transport_generic_free_cmd(se_cmd, 0); |
| 204 | } | 204 | } |
| 205 | 205 | ||
| 206 | static void tcm_loop_release_cmd(struct se_cmd *se_cmd) | 206 | static void tcm_loop_release_cmd(struct se_cmd *se_cmd) |
| @@ -388,7 +388,7 @@ static int tcm_loop_device_reset(struct scsi_cmnd *sc) | |||
| 388 | SUCCESS : FAILED; | 388 | SUCCESS : FAILED; |
| 389 | release: | 389 | release: |
| 390 | if (se_cmd) | 390 | if (se_cmd) |
| 391 | transport_generic_free_cmd(se_cmd, 1, 0); | 391 | transport_generic_free_cmd(se_cmd, 1); |
| 392 | else | 392 | else |
| 393 | kmem_cache_free(tcm_loop_cmd_cache, tl_cmd); | 393 | kmem_cache_free(tcm_loop_cmd_cache, tl_cmd); |
| 394 | kfree(tl_tmr); | 394 | kfree(tl_tmr); |
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 4f21b88b85b1..db2f8987a046 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c | |||
| @@ -4331,42 +4331,25 @@ void transport_release_cmd(struct se_cmd *cmd) | |||
| 4331 | } | 4331 | } |
| 4332 | EXPORT_SYMBOL(transport_release_cmd); | 4332 | EXPORT_SYMBOL(transport_release_cmd); |
| 4333 | 4333 | ||
| 4334 | /* transport_generic_free_cmd(): | 4334 | bool transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks) |
| 4335 | * | ||
| 4336 | * Called from processing frontend to release storage engine resources | ||
| 4337 | */ | ||
| 4338 | void transport_generic_free_cmd( | ||
| 4339 | struct se_cmd *cmd, | ||
| 4340 | int wait_for_tasks, | ||
| 4341 | int session_reinstatement) | ||
| 4342 | { | 4335 | { |
| 4343 | if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD)) | 4336 | if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD)) |
| 4344 | transport_release_cmd(cmd); | 4337 | transport_release_cmd(cmd); |
| 4345 | else { | 4338 | else { |
| 4346 | core_dec_lacl_count(cmd->se_sess->se_node_acl, cmd); | 4339 | core_dec_lacl_count(cmd->se_sess->se_node_acl, cmd); |
| 4347 | 4340 | ||
| 4348 | if (cmd->se_lun) { | 4341 | if (cmd->se_lun) |
| 4349 | #if 0 | ||
| 4350 | pr_debug("cmd: %p ITT: 0x%08x contains" | ||
| 4351 | " cmd->se_lun\n", cmd, | ||
| 4352 | cmd->se_tfo->get_task_tag(cmd)); | ||
| 4353 | #endif | ||
| 4354 | transport_lun_remove_cmd(cmd); | 4342 | transport_lun_remove_cmd(cmd); |
| 4355 | } | ||
| 4356 | 4343 | ||
| 4357 | if (wait_for_tasks && cmd->transport_wait_for_tasks) | 4344 | if (wait_for_tasks && cmd->transport_wait_for_tasks) |
| 4358 | cmd->transport_wait_for_tasks(cmd, 0, 0); | 4345 | cmd->transport_wait_for_tasks(cmd, 0, 0); |
| 4359 | 4346 | ||
| 4360 | transport_free_dev_tasks(cmd); | 4347 | transport_free_dev_tasks(cmd); |
| 4361 | 4348 | ||
| 4362 | if (!transport_put_cmd(cmd) && session_reinstatement) { | 4349 | return transport_put_cmd(cmd); |
| 4363 | unsigned long flags; | ||
| 4364 | |||
| 4365 | spin_lock_irqsave(&cmd->t_state_lock, flags); | ||
| 4366 | transport_all_task_dev_remove_state(cmd); | ||
| 4367 | spin_unlock_irqrestore(&cmd->t_state_lock, flags); | ||
| 4368 | } | ||
| 4369 | } | 4350 | } |
| 4351 | |||
| 4352 | return true; | ||
| 4370 | } | 4353 | } |
| 4371 | EXPORT_SYMBOL(transport_generic_free_cmd); | 4354 | EXPORT_SYMBOL(transport_generic_free_cmd); |
| 4372 | 4355 | ||
| @@ -4631,7 +4614,13 @@ remove: | |||
| 4631 | if (!remove_cmd) | 4614 | if (!remove_cmd) |
| 4632 | return; | 4615 | return; |
| 4633 | 4616 | ||
| 4634 | transport_generic_free_cmd(cmd, 0, session_reinstatement); | 4617 | if (!transport_generic_free_cmd(cmd, 0) && session_reinstatement) { |
| 4618 | unsigned long flags; | ||
| 4619 | |||
| 4620 | spin_lock_irqsave(&cmd->t_state_lock, flags); | ||
| 4621 | transport_all_task_dev_remove_state(cmd); | ||
| 4622 | spin_unlock_irqrestore(&cmd->t_state_lock, flags); | ||
| 4623 | } | ||
| 4635 | } | 4624 | } |
| 4636 | 4625 | ||
| 4637 | static int transport_get_sense_codes( | 4626 | static int transport_get_sense_codes( |
| @@ -5181,7 +5170,7 @@ get_cmd: | |||
| 5181 | transport_put_cmd(cmd); | 5170 | transport_put_cmd(cmd); |
| 5182 | break; | 5171 | break; |
| 5183 | case TRANSPORT_FREE_CMD_INTR: | 5172 | case TRANSPORT_FREE_CMD_INTR: |
| 5184 | transport_generic_free_cmd(cmd, 0, 0); | 5173 | transport_generic_free_cmd(cmd, 0); |
| 5185 | break; | 5174 | break; |
| 5186 | case TRANSPORT_PROCESS_TMR: | 5175 | case TRANSPORT_PROCESS_TMR: |
| 5187 | transport_generic_do_tmr(cmd); | 5176 | transport_generic_do_tmr(cmd); |
diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c index c2d148d80cf7..7f2ee5a0ed79 100644 --- a/drivers/target/tcm_fc/tfc_cmd.c +++ b/drivers/target/tcm_fc/tfc_cmd.c | |||
| @@ -114,7 +114,7 @@ void ft_release_cmd(struct se_cmd *se_cmd) | |||
| 114 | 114 | ||
| 115 | void ft_check_stop_free(struct se_cmd *se_cmd) | 115 | void ft_check_stop_free(struct se_cmd *se_cmd) |
| 116 | { | 116 | { |
| 117 | transport_generic_free_cmd(se_cmd, 0, 0); | 117 | transport_generic_free_cmd(se_cmd, 0); |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | /* | 120 | /* |
| @@ -269,7 +269,7 @@ static void ft_recv_seq(struct fc_seq *sp, struct fc_frame *fp, void *arg) | |||
| 269 | /* XXX need to find cmd if queued */ | 269 | /* XXX need to find cmd if queued */ |
| 270 | cmd->se_cmd.t_state = TRANSPORT_REMOVE; | 270 | cmd->se_cmd.t_state = TRANSPORT_REMOVE; |
| 271 | cmd->seq = NULL; | 271 | cmd->seq = NULL; |
| 272 | transport_generic_free_cmd(&cmd->se_cmd, 0, 0); | 272 | transport_generic_free_cmd(&cmd->se_cmd, 0); |
| 273 | return; | 273 | return; |
| 274 | } | 274 | } |
| 275 | 275 | ||
| @@ -287,7 +287,7 @@ static void ft_recv_seq(struct fc_seq *sp, struct fc_frame *fp, void *arg) | |||
| 287 | __func__, fh->fh_r_ctl); | 287 | __func__, fh->fh_r_ctl); |
| 288 | ft_invl_hw_context(cmd); | 288 | ft_invl_hw_context(cmd); |
| 289 | fc_frame_free(fp); | 289 | fc_frame_free(fp); |
| 290 | transport_generic_free_cmd(&cmd->se_cmd, 0, 0); | 290 | transport_generic_free_cmd(&cmd->se_cmd, 0); |
| 291 | break; | 291 | break; |
| 292 | } | 292 | } |
| 293 | } | 293 | } |
| @@ -420,7 +420,7 @@ static void ft_send_tm(struct ft_cmd *cmd) | |||
| 420 | sess = cmd->sess; | 420 | sess = cmd->sess; |
| 421 | transport_send_check_condition_and_sense(&cmd->se_cmd, | 421 | transport_send_check_condition_and_sense(&cmd->se_cmd, |
| 422 | cmd->se_cmd.scsi_sense_reason, 0); | 422 | cmd->se_cmd.scsi_sense_reason, 0); |
| 423 | transport_generic_free_cmd(&cmd->se_cmd, 0, 0); | 423 | transport_generic_free_cmd(&cmd->se_cmd, 0); |
| 424 | ft_sess_put(sess); | 424 | ft_sess_put(sess); |
| 425 | return; | 425 | return; |
| 426 | } | 426 | } |
| @@ -627,7 +627,7 @@ static void ft_send_work(struct work_struct *work) | |||
| 627 | if (ret == -ENOMEM) { | 627 | if (ret == -ENOMEM) { |
| 628 | transport_send_check_condition_and_sense(se_cmd, | 628 | transport_send_check_condition_and_sense(se_cmd, |
| 629 | TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE, 0); | 629 | TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE, 0); |
| 630 | transport_generic_free_cmd(se_cmd, 0, 0); | 630 | transport_generic_free_cmd(se_cmd, 0); |
| 631 | return; | 631 | return; |
| 632 | } | 632 | } |
| 633 | if (ret == -EINVAL) { | 633 | if (ret == -EINVAL) { |
| @@ -636,7 +636,7 @@ static void ft_send_work(struct work_struct *work) | |||
| 636 | else | 636 | else |
| 637 | transport_send_check_condition_and_sense(se_cmd, | 637 | transport_send_check_condition_and_sense(se_cmd, |
| 638 | se_cmd->scsi_sense_reason, 0); | 638 | se_cmd->scsi_sense_reason, 0); |
| 639 | transport_generic_free_cmd(se_cmd, 0, 0); | 639 | transport_generic_free_cmd(se_cmd, 0); |
| 640 | return; | 640 | return; |
| 641 | } | 641 | } |
| 642 | transport_handle_cdb_direct(se_cmd); | 642 | transport_handle_cdb_direct(se_cmd); |
diff --git a/include/target/target_core_transport.h b/include/target/target_core_transport.h index 99a671e0f9da..a113129fa22e 100644 --- a/include/target/target_core_transport.h +++ b/include/target/target_core_transport.h | |||
| @@ -184,7 +184,7 @@ extern int transport_check_aborted_status(struct se_cmd *, int); | |||
| 184 | extern int transport_send_check_condition_and_sense(struct se_cmd *, u8, int); | 184 | extern int transport_send_check_condition_and_sense(struct se_cmd *, u8, int); |
| 185 | extern void transport_send_task_abort(struct se_cmd *); | 185 | extern void transport_send_task_abort(struct se_cmd *); |
| 186 | extern void transport_release_cmd(struct se_cmd *); | 186 | extern void transport_release_cmd(struct se_cmd *); |
| 187 | extern void transport_generic_free_cmd(struct se_cmd *, int, int); | 187 | extern bool transport_generic_free_cmd(struct se_cmd *, int); |
| 188 | extern void transport_generic_wait_for_cmds(struct se_cmd *, int); | 188 | extern void transport_generic_wait_for_cmds(struct se_cmd *, int); |
| 189 | extern int transport_init_task_sg(struct se_task *, struct se_mem *, u32); | 189 | extern int transport_init_task_sg(struct se_task *, struct se_mem *, u32); |
| 190 | extern int transport_map_mem_to_sg(struct se_task *, struct list_head *, | 190 | extern int transport_map_mem_to_sg(struct se_task *, struct list_head *, |
