diff options
author | Nicholas Bellinger <nab@linux-iscsi.org> | 2011-11-23 00:41:54 -0500 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2011-12-14 06:42:08 -0500 |
commit | 4355a9110eeb2eaf1dd44fcab16ccbd1c8c5fad4 (patch) | |
tree | 6cfb4d1fc3cb5c71f67ab158ab41430cfe7a6e0c /drivers/target | |
parent | a63607855224702ea17e6016ecf3f7d544e83625 (diff) |
tcm_fc: Convert ft_send_work to use target_submit_cmd
This patch converts the main ft_send_work() I/O path to use
target_submit_cmd() with a single se_cmd->cmd_kref reference
that is released via the existing ft_check_stop_free() response
path callback.
It also makes ft_send_tm() use transport_init_se_cmd() and
target_get_sess_cmd() to also use single se_cmd->cmd_kref
reference.
Cc: Christoph Hellwig <hch@lst.de>
Cc: Kiran Patil <kiran.patil@intel.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target')
-rw-r--r-- | drivers/target/tcm_fc/tfc_cmd.c | 51 |
1 files changed, 13 insertions, 38 deletions
diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c index dbbbc8376d01..addc18f727ea 100644 --- a/drivers/target/tcm_fc/tfc_cmd.c +++ b/drivers/target/tcm_fc/tfc_cmd.c | |||
@@ -363,6 +363,11 @@ static void ft_send_tm(struct ft_cmd *cmd) | |||
363 | struct ft_sess *sess; | 363 | struct ft_sess *sess; |
364 | u8 tm_func; | 364 | u8 tm_func; |
365 | 365 | ||
366 | transport_init_se_cmd(&cmd->se_cmd, &ft_configfs->tf_ops, | ||
367 | cmd->sess->se_sess, 0, DMA_NONE, 0, | ||
368 | &cmd->ft_sense_buffer[0]); | ||
369 | target_get_sess_cmd(cmd->sess->se_sess, &cmd->se_cmd, false); | ||
370 | |||
366 | fcp = fc_frame_payload_get(cmd->req_frame, sizeof(*fcp)); | 371 | fcp = fc_frame_payload_get(cmd->req_frame, sizeof(*fcp)); |
367 | 372 | ||
368 | switch (fcp->fc_tm_flags) { | 373 | switch (fcp->fc_tm_flags) { |
@@ -416,7 +421,6 @@ static void ft_send_tm(struct ft_cmd *cmd) | |||
416 | sess = cmd->sess; | 421 | sess = cmd->sess; |
417 | transport_send_check_condition_and_sense(&cmd->se_cmd, | 422 | transport_send_check_condition_and_sense(&cmd->se_cmd, |
418 | cmd->se_cmd.scsi_sense_reason, 0); | 423 | cmd->se_cmd.scsi_sense_reason, 0); |
419 | transport_generic_free_cmd(&cmd->se_cmd, 0); | ||
420 | ft_sess_put(sess); | 424 | ft_sess_put(sess); |
421 | return; | 425 | return; |
422 | } | 426 | } |
@@ -532,7 +536,6 @@ static void ft_send_work(struct work_struct *work) | |||
532 | { | 536 | { |
533 | struct ft_cmd *cmd = container_of(work, struct ft_cmd, work); | 537 | struct ft_cmd *cmd = container_of(work, struct ft_cmd, work); |
534 | struct fc_frame_header *fh = fc_frame_header_get(cmd->req_frame); | 538 | struct fc_frame_header *fh = fc_frame_header_get(cmd->req_frame); |
535 | struct se_cmd *se_cmd; | ||
536 | struct fcp_cmnd *fcp; | 539 | struct fcp_cmnd *fcp; |
537 | int data_dir = 0; | 540 | int data_dir = 0; |
538 | u32 data_len; | 541 | u32 data_len; |
@@ -587,15 +590,6 @@ static void ft_send_work(struct work_struct *work) | |||
587 | data_len = ntohl(fcp->fc_dl); | 590 | data_len = ntohl(fcp->fc_dl); |
588 | cmd->cdb = fcp->fc_cdb; | 591 | cmd->cdb = fcp->fc_cdb; |
589 | } | 592 | } |
590 | |||
591 | se_cmd = &cmd->se_cmd; | ||
592 | /* | ||
593 | * Initialize struct se_cmd descriptor from target_core_mod | ||
594 | * infrastructure | ||
595 | */ | ||
596 | transport_init_se_cmd(se_cmd, &ft_configfs->tf_ops, cmd->sess->se_sess, | ||
597 | data_len, data_dir, task_attr, | ||
598 | &cmd->ft_sense_buffer[0]); | ||
599 | /* | 593 | /* |
600 | * Check for FCP task management flags | 594 | * Check for FCP task management flags |
601 | */ | 595 | */ |
@@ -603,39 +597,20 @@ static void ft_send_work(struct work_struct *work) | |||
603 | ft_send_tm(cmd); | 597 | ft_send_tm(cmd); |
604 | return; | 598 | return; |
605 | } | 599 | } |
606 | |||
607 | fc_seq_exch(cmd->seq)->lp->tt.seq_set_resp(cmd->seq, ft_recv_seq, cmd); | 600 | fc_seq_exch(cmd->seq)->lp->tt.seq_set_resp(cmd->seq, ft_recv_seq, cmd); |
608 | |||
609 | cmd->lun = scsilun_to_int((struct scsi_lun *)fcp->fc_lun); | 601 | cmd->lun = scsilun_to_int((struct scsi_lun *)fcp->fc_lun); |
610 | ret = transport_lookup_cmd_lun(&cmd->se_cmd, cmd->lun); | 602 | /* |
603 | * Use a single se_cmd->cmd_kref as we expect to release se_cmd | ||
604 | * directly from ft_check_stop_free callback in response path. | ||
605 | */ | ||
606 | ret = target_submit_cmd(&cmd->se_cmd, cmd->sess->se_sess, cmd->cdb, | ||
607 | &cmd->ft_sense_buffer[0], cmd->lun, data_len, | ||
608 | task_attr, data_dir, 0); | ||
609 | pr_debug("r_ctl %x alloc target_submit_cmd %d\n", fh->fh_r_ctl, ret); | ||
611 | if (ret < 0) { | 610 | if (ret < 0) { |
612 | ft_dump_cmd(cmd, __func__); | 611 | ft_dump_cmd(cmd, __func__); |
613 | transport_send_check_condition_and_sense(&cmd->se_cmd, | ||
614 | cmd->se_cmd.scsi_sense_reason, 0); | ||
615 | return; | ||
616 | } | ||
617 | |||
618 | ret = transport_generic_allocate_tasks(se_cmd, cmd->cdb); | ||
619 | |||
620 | pr_debug("r_ctl %x alloc task ret %d\n", fh->fh_r_ctl, ret); | ||
621 | ft_dump_cmd(cmd, __func__); | ||
622 | |||
623 | if (ret == -ENOMEM) { | ||
624 | transport_send_check_condition_and_sense(se_cmd, | ||
625 | TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE, 0); | ||
626 | transport_generic_free_cmd(se_cmd, 0); | ||
627 | return; | ||
628 | } | ||
629 | if (ret == -EINVAL) { | ||
630 | if (se_cmd->se_cmd_flags & SCF_SCSI_RESERVATION_CONFLICT) | ||
631 | ft_queue_status(se_cmd); | ||
632 | else | ||
633 | transport_send_check_condition_and_sense(se_cmd, | ||
634 | se_cmd->scsi_sense_reason, 0); | ||
635 | transport_generic_free_cmd(se_cmd, 0); | ||
636 | return; | 612 | return; |
637 | } | 613 | } |
638 | transport_handle_cdb_direct(se_cmd); | ||
639 | return; | 614 | return; |
640 | 615 | ||
641 | err: | 616 | err: |