diff options
author | Christoph Hellwig <hch@infradead.org> | 2012-04-23 11:35:33 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2012-05-06 18:11:14 -0400 |
commit | 6bb35e009b656b36f7985057822c5fbf53ea75b7 (patch) | |
tree | 31384150dbd2828ee72a0802efb23692511f032f /drivers/target/target_core_cdb.c | |
parent | bd31377878868a47b2d2e6f570fb0cace828555b (diff) |
target: replace ->execute_task with ->execute_cmd
Make CDB emulation work on commands instead of tasks again as a preparation
of removing tasks completely.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target/target_core_cdb.c')
-rw-r--r-- | drivers/target/target_core_cdb.c | 64 |
1 files changed, 22 insertions, 42 deletions
diff --git a/drivers/target/target_core_cdb.c b/drivers/target/target_core_cdb.c index 8e6b91d0380d..22cf44cf43ac 100644 --- a/drivers/target/target_core_cdb.c +++ b/drivers/target/target_core_cdb.c | |||
@@ -601,9 +601,8 @@ target_emulate_evpd_00(struct se_cmd *cmd, unsigned char *buf) | |||
601 | return 0; | 601 | return 0; |
602 | } | 602 | } |
603 | 603 | ||
604 | int target_emulate_inquiry(struct se_task *task) | 604 | int target_emulate_inquiry(struct se_cmd *cmd) |
605 | { | 605 | { |
606 | struct se_cmd *cmd = task->task_se_cmd; | ||
607 | struct se_device *dev = cmd->se_dev; | 606 | struct se_device *dev = cmd->se_dev; |
608 | struct se_portal_group *tpg = cmd->se_lun->lun_sep->sep_tpg; | 607 | struct se_portal_group *tpg = cmd->se_lun->lun_sep->sep_tpg; |
609 | unsigned char *buf, *map_buf; | 608 | unsigned char *buf, *map_buf; |
@@ -667,16 +666,13 @@ out: | |||
667 | } | 666 | } |
668 | transport_kunmap_data_sg(cmd); | 667 | transport_kunmap_data_sg(cmd); |
669 | 668 | ||
670 | if (!ret) { | 669 | if (!ret) |
671 | task->task_scsi_status = GOOD; | 670 | target_complete_cmd(cmd, GOOD); |
672 | transport_complete_task(task, 1); | ||
673 | } | ||
674 | return ret; | 671 | return ret; |
675 | } | 672 | } |
676 | 673 | ||
677 | int target_emulate_readcapacity(struct se_task *task) | 674 | int target_emulate_readcapacity(struct se_cmd *cmd) |
678 | { | 675 | { |
679 | struct se_cmd *cmd = task->task_se_cmd; | ||
680 | struct se_device *dev = cmd->se_dev; | 676 | struct se_device *dev = cmd->se_dev; |
681 | unsigned char *buf; | 677 | unsigned char *buf; |
682 | unsigned long long blocks_long = dev->transport->get_blocks(dev); | 678 | unsigned long long blocks_long = dev->transport->get_blocks(dev); |
@@ -700,14 +696,12 @@ int target_emulate_readcapacity(struct se_task *task) | |||
700 | 696 | ||
701 | transport_kunmap_data_sg(cmd); | 697 | transport_kunmap_data_sg(cmd); |
702 | 698 | ||
703 | task->task_scsi_status = GOOD; | 699 | target_complete_cmd(cmd, GOOD); |
704 | transport_complete_task(task, 1); | ||
705 | return 0; | 700 | return 0; |
706 | } | 701 | } |
707 | 702 | ||
708 | int target_emulate_readcapacity_16(struct se_task *task) | 703 | int target_emulate_readcapacity_16(struct se_cmd *cmd) |
709 | { | 704 | { |
710 | struct se_cmd *cmd = task->task_se_cmd; | ||
711 | struct se_device *dev = cmd->se_dev; | 705 | struct se_device *dev = cmd->se_dev; |
712 | unsigned char *buf; | 706 | unsigned char *buf; |
713 | unsigned long long blocks = dev->transport->get_blocks(dev); | 707 | unsigned long long blocks = dev->transport->get_blocks(dev); |
@@ -735,8 +729,7 @@ int target_emulate_readcapacity_16(struct se_task *task) | |||
735 | 729 | ||
736 | transport_kunmap_data_sg(cmd); | 730 | transport_kunmap_data_sg(cmd); |
737 | 731 | ||
738 | task->task_scsi_status = GOOD; | 732 | target_complete_cmd(cmd, GOOD); |
739 | transport_complete_task(task, 1); | ||
740 | return 0; | 733 | return 0; |
741 | } | 734 | } |
742 | 735 | ||
@@ -875,9 +868,8 @@ target_modesense_dpofua(unsigned char *buf, int type) | |||
875 | } | 868 | } |
876 | } | 869 | } |
877 | 870 | ||
878 | int target_emulate_modesense(struct se_task *task) | 871 | int target_emulate_modesense(struct se_cmd *cmd) |
879 | { | 872 | { |
880 | struct se_cmd *cmd = task->task_se_cmd; | ||
881 | struct se_device *dev = cmd->se_dev; | 873 | struct se_device *dev = cmd->se_dev; |
882 | char *cdb = cmd->t_task_cdb; | 874 | char *cdb = cmd->t_task_cdb; |
883 | unsigned char *rbuf; | 875 | unsigned char *rbuf; |
@@ -950,14 +942,12 @@ int target_emulate_modesense(struct se_task *task) | |||
950 | memcpy(rbuf, buf, offset); | 942 | memcpy(rbuf, buf, offset); |
951 | transport_kunmap_data_sg(cmd); | 943 | transport_kunmap_data_sg(cmd); |
952 | 944 | ||
953 | task->task_scsi_status = GOOD; | 945 | target_complete_cmd(cmd, GOOD); |
954 | transport_complete_task(task, 1); | ||
955 | return 0; | 946 | return 0; |
956 | } | 947 | } |
957 | 948 | ||
958 | int target_emulate_request_sense(struct se_task *task) | 949 | int target_emulate_request_sense(struct se_cmd *cmd) |
959 | { | 950 | { |
960 | struct se_cmd *cmd = task->task_se_cmd; | ||
961 | unsigned char *cdb = cmd->t_task_cdb; | 951 | unsigned char *cdb = cmd->t_task_cdb; |
962 | unsigned char *buf; | 952 | unsigned char *buf; |
963 | u8 ua_asc = 0, ua_ascq = 0; | 953 | u8 ua_asc = 0, ua_ascq = 0; |
@@ -1011,8 +1001,7 @@ int target_emulate_request_sense(struct se_task *task) | |||
1011 | 1001 | ||
1012 | end: | 1002 | end: |
1013 | transport_kunmap_data_sg(cmd); | 1003 | transport_kunmap_data_sg(cmd); |
1014 | task->task_scsi_status = GOOD; | 1004 | target_complete_cmd(cmd, GOOD); |
1015 | transport_complete_task(task, 1); | ||
1016 | return 0; | 1005 | return 0; |
1017 | } | 1006 | } |
1018 | 1007 | ||
@@ -1020,9 +1009,8 @@ end: | |||
1020 | * Used for TCM/IBLOCK and TCM/FILEIO for block/blk-lib.c level discard support. | 1009 | * Used for TCM/IBLOCK and TCM/FILEIO for block/blk-lib.c level discard support. |
1021 | * Note this is not used for TCM/pSCSI passthrough | 1010 | * Note this is not used for TCM/pSCSI passthrough |
1022 | */ | 1011 | */ |
1023 | int target_emulate_unmap(struct se_task *task) | 1012 | int target_emulate_unmap(struct se_cmd *cmd) |
1024 | { | 1013 | { |
1025 | struct se_cmd *cmd = task->task_se_cmd; | ||
1026 | struct se_device *dev = cmd->se_dev; | 1014 | struct se_device *dev = cmd->se_dev; |
1027 | unsigned char *buf, *ptr = NULL; | 1015 | unsigned char *buf, *ptr = NULL; |
1028 | unsigned char *cdb = &cmd->t_task_cdb[0]; | 1016 | unsigned char *cdb = &cmd->t_task_cdb[0]; |
@@ -1069,10 +1057,8 @@ int target_emulate_unmap(struct se_task *task) | |||
1069 | 1057 | ||
1070 | err: | 1058 | err: |
1071 | transport_kunmap_data_sg(cmd); | 1059 | transport_kunmap_data_sg(cmd); |
1072 | if (!ret) { | 1060 | if (!ret) |
1073 | task->task_scsi_status = GOOD; | 1061 | target_complete_cmd(cmd, GOOD); |
1074 | transport_complete_task(task, 1); | ||
1075 | } | ||
1076 | return ret; | 1062 | return ret; |
1077 | } | 1063 | } |
1078 | 1064 | ||
@@ -1080,9 +1066,8 @@ err: | |||
1080 | * Used for TCM/IBLOCK and TCM/FILEIO for block/blk-lib.c level discard support. | 1066 | * Used for TCM/IBLOCK and TCM/FILEIO for block/blk-lib.c level discard support. |
1081 | * Note this is not used for TCM/pSCSI passthrough | 1067 | * Note this is not used for TCM/pSCSI passthrough |
1082 | */ | 1068 | */ |
1083 | int target_emulate_write_same(struct se_task *task) | 1069 | int target_emulate_write_same(struct se_cmd *cmd) |
1084 | { | 1070 | { |
1085 | struct se_cmd *cmd = task->task_se_cmd; | ||
1086 | struct se_device *dev = cmd->se_dev; | 1071 | struct se_device *dev = cmd->se_dev; |
1087 | sector_t range; | 1072 | sector_t range; |
1088 | sector_t lba = cmd->t_task_lba; | 1073 | sector_t lba = cmd->t_task_lba; |
@@ -1121,30 +1106,25 @@ int target_emulate_write_same(struct se_task *task) | |||
1121 | return ret; | 1106 | return ret; |
1122 | } | 1107 | } |
1123 | 1108 | ||
1124 | task->task_scsi_status = GOOD; | 1109 | target_complete_cmd(cmd, GOOD); |
1125 | transport_complete_task(task, 1); | ||
1126 | return 0; | 1110 | return 0; |
1127 | } | 1111 | } |
1128 | 1112 | ||
1129 | int target_emulate_synchronize_cache(struct se_task *task) | 1113 | int target_emulate_synchronize_cache(struct se_cmd *cmd) |
1130 | { | 1114 | { |
1131 | struct se_device *dev = task->task_se_cmd->se_dev; | 1115 | if (!cmd->se_dev->transport->do_sync_cache) { |
1132 | struct se_cmd *cmd = task->task_se_cmd; | ||
1133 | |||
1134 | if (!dev->transport->do_sync_cache) { | ||
1135 | pr_err("SYNCHRONIZE_CACHE emulation not supported" | 1116 | pr_err("SYNCHRONIZE_CACHE emulation not supported" |
1136 | " for: %s\n", dev->transport->name); | 1117 | " for: %s\n", cmd->se_dev->transport->name); |
1137 | cmd->scsi_sense_reason = TCM_UNSUPPORTED_SCSI_OPCODE; | 1118 | cmd->scsi_sense_reason = TCM_UNSUPPORTED_SCSI_OPCODE; |
1138 | return -ENOSYS; | 1119 | return -ENOSYS; |
1139 | } | 1120 | } |
1140 | 1121 | ||
1141 | dev->transport->do_sync_cache(task); | 1122 | cmd->se_dev->transport->do_sync_cache(cmd); |
1142 | return 0; | 1123 | return 0; |
1143 | } | 1124 | } |
1144 | 1125 | ||
1145 | int target_emulate_noop(struct se_task *task) | 1126 | int target_emulate_noop(struct se_cmd *cmd) |
1146 | { | 1127 | { |
1147 | task->task_scsi_status = GOOD; | 1128 | target_complete_cmd(cmd, GOOD); |
1148 | transport_complete_task(task, 1); | ||
1149 | return 0; | 1129 | return 0; |
1150 | } | 1130 | } |