Commit 6bb35e00 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Nicholas Bellinger

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: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent bd313778
...@@ -59,9 +59,8 @@ struct t10_alua_lu_gp *default_lu_gp; ...@@ -59,9 +59,8 @@ struct t10_alua_lu_gp *default_lu_gp;
* *
* See spc4r17 section 6.27 * See spc4r17 section 6.27
*/ */
int target_emulate_report_target_port_groups(struct se_task *task) int target_emulate_report_target_port_groups(struct se_cmd *cmd)
{ {
struct se_cmd *cmd = task->task_se_cmd;
struct se_subsystem_dev *su_dev = cmd->se_dev->se_sub_dev; struct se_subsystem_dev *su_dev = cmd->se_dev->se_sub_dev;
struct se_port *port; struct se_port *port;
struct t10_alua_tg_pt_gp *tg_pt_gp; struct t10_alua_tg_pt_gp *tg_pt_gp;
...@@ -166,8 +165,7 @@ int target_emulate_report_target_port_groups(struct se_task *task) ...@@ -166,8 +165,7 @@ int target_emulate_report_target_port_groups(struct se_task *task)
transport_kunmap_data_sg(cmd); transport_kunmap_data_sg(cmd);
task->task_scsi_status = GOOD; target_complete_cmd(cmd, GOOD);
transport_complete_task(task, 1);
return 0; return 0;
} }
...@@ -176,9 +174,8 @@ int target_emulate_report_target_port_groups(struct se_task *task) ...@@ -176,9 +174,8 @@ int target_emulate_report_target_port_groups(struct se_task *task)
* *
* See spc4r17 section 6.35 * See spc4r17 section 6.35
*/ */
int target_emulate_set_target_port_groups(struct se_task *task) int target_emulate_set_target_port_groups(struct se_cmd *cmd)
{ {
struct se_cmd *cmd = task->task_se_cmd;
struct se_device *dev = cmd->se_dev; struct se_device *dev = cmd->se_dev;
struct se_subsystem_dev *su_dev = dev->se_sub_dev; struct se_subsystem_dev *su_dev = dev->se_sub_dev;
struct se_port *port, *l_port = cmd->se_lun->lun_sep; struct se_port *port, *l_port = cmd->se_lun->lun_sep;
...@@ -351,8 +348,7 @@ int target_emulate_set_target_port_groups(struct se_task *task) ...@@ -351,8 +348,7 @@ int target_emulate_set_target_port_groups(struct se_task *task)
out: out:
transport_kunmap_data_sg(cmd); transport_kunmap_data_sg(cmd);
task->task_scsi_status = GOOD; target_complete_cmd(cmd, GOOD);
transport_complete_task(task, 1);
return 0; return 0;
} }
......
...@@ -66,8 +66,8 @@ extern struct kmem_cache *t10_alua_lu_gp_mem_cache; ...@@ -66,8 +66,8 @@ extern struct kmem_cache *t10_alua_lu_gp_mem_cache;
extern struct kmem_cache *t10_alua_tg_pt_gp_cache; extern struct kmem_cache *t10_alua_tg_pt_gp_cache;
extern struct kmem_cache *t10_alua_tg_pt_gp_mem_cache; extern struct kmem_cache *t10_alua_tg_pt_gp_mem_cache;
extern int target_emulate_report_target_port_groups(struct se_task *); extern int target_emulate_report_target_port_groups(struct se_cmd *);
extern int target_emulate_set_target_port_groups(struct se_task *); extern int target_emulate_set_target_port_groups(struct se_cmd *);
extern int core_alua_check_nonop_delay(struct se_cmd *); extern int core_alua_check_nonop_delay(struct se_cmd *);
extern int core_alua_do_port_transition(struct t10_alua_tg_pt_gp *, extern int core_alua_do_port_transition(struct t10_alua_tg_pt_gp *,
struct se_device *, struct se_port *, struct se_device *, struct se_port *,
......
...@@ -601,9 +601,8 @@ target_emulate_evpd_00(struct se_cmd *cmd, unsigned char *buf) ...@@ -601,9 +601,8 @@ target_emulate_evpd_00(struct se_cmd *cmd, unsigned char *buf)
return 0; return 0;
} }
int target_emulate_inquiry(struct se_task *task) int target_emulate_inquiry(struct se_cmd *cmd)
{ {
struct se_cmd *cmd = task->task_se_cmd;
struct se_device *dev = cmd->se_dev; struct se_device *dev = cmd->se_dev;
struct se_portal_group *tpg = cmd->se_lun->lun_sep->sep_tpg; struct se_portal_group *tpg = cmd->se_lun->lun_sep->sep_tpg;
unsigned char *buf, *map_buf; unsigned char *buf, *map_buf;
...@@ -667,16 +666,13 @@ int target_emulate_inquiry(struct se_task *task) ...@@ -667,16 +666,13 @@ int target_emulate_inquiry(struct se_task *task)
} }
transport_kunmap_data_sg(cmd); transport_kunmap_data_sg(cmd);
if (!ret) { if (!ret)
task->task_scsi_status = GOOD; target_complete_cmd(cmd, GOOD);
transport_complete_task(task, 1);
}
return ret; return ret;
} }
int target_emulate_readcapacity(struct se_task *task) int target_emulate_readcapacity(struct se_cmd *cmd)
{ {
struct se_cmd *cmd = task->task_se_cmd;
struct se_device *dev = cmd->se_dev; struct se_device *dev = cmd->se_dev;
unsigned char *buf; unsigned char *buf;
unsigned long long blocks_long = dev->transport->get_blocks(dev); unsigned long long blocks_long = dev->transport->get_blocks(dev);
...@@ -700,14 +696,12 @@ int target_emulate_readcapacity(struct se_task *task) ...@@ -700,14 +696,12 @@ int target_emulate_readcapacity(struct se_task *task)
transport_kunmap_data_sg(cmd); transport_kunmap_data_sg(cmd);
task->task_scsi_status = GOOD; target_complete_cmd(cmd, GOOD);
transport_complete_task(task, 1);
return 0; return 0;
} }
int target_emulate_readcapacity_16(struct se_task *task) int target_emulate_readcapacity_16(struct se_cmd *cmd)
{ {
struct se_cmd *cmd = task->task_se_cmd;
struct se_device *dev = cmd->se_dev; struct se_device *dev = cmd->se_dev;
unsigned char *buf; unsigned char *buf;
unsigned long long blocks = dev->transport->get_blocks(dev); unsigned long long blocks = dev->transport->get_blocks(dev);
...@@ -735,8 +729,7 @@ int target_emulate_readcapacity_16(struct se_task *task) ...@@ -735,8 +729,7 @@ int target_emulate_readcapacity_16(struct se_task *task)
transport_kunmap_data_sg(cmd); transport_kunmap_data_sg(cmd);
task->task_scsi_status = GOOD; target_complete_cmd(cmd, GOOD);
transport_complete_task(task, 1);
return 0; return 0;
} }
...@@ -875,9 +868,8 @@ target_modesense_dpofua(unsigned char *buf, int type) ...@@ -875,9 +868,8 @@ target_modesense_dpofua(unsigned char *buf, int type)
} }
} }
int target_emulate_modesense(struct se_task *task) int target_emulate_modesense(struct se_cmd *cmd)
{ {
struct se_cmd *cmd = task->task_se_cmd;
struct se_device *dev = cmd->se_dev; struct se_device *dev = cmd->se_dev;
char *cdb = cmd->t_task_cdb; char *cdb = cmd->t_task_cdb;
unsigned char *rbuf; unsigned char *rbuf;
...@@ -950,14 +942,12 @@ int target_emulate_modesense(struct se_task *task) ...@@ -950,14 +942,12 @@ int target_emulate_modesense(struct se_task *task)
memcpy(rbuf, buf, offset); memcpy(rbuf, buf, offset);
transport_kunmap_data_sg(cmd); transport_kunmap_data_sg(cmd);
task->task_scsi_status = GOOD; target_complete_cmd(cmd, GOOD);
transport_complete_task(task, 1);
return 0; return 0;
} }
int target_emulate_request_sense(struct se_task *task) int target_emulate_request_sense(struct se_cmd *cmd)
{ {
struct se_cmd *cmd = task->task_se_cmd;
unsigned char *cdb = cmd->t_task_cdb; unsigned char *cdb = cmd->t_task_cdb;
unsigned char *buf; unsigned char *buf;
u8 ua_asc = 0, ua_ascq = 0; u8 ua_asc = 0, ua_ascq = 0;
...@@ -1011,8 +1001,7 @@ int target_emulate_request_sense(struct se_task *task) ...@@ -1011,8 +1001,7 @@ int target_emulate_request_sense(struct se_task *task)
end: end:
transport_kunmap_data_sg(cmd); transport_kunmap_data_sg(cmd);
task->task_scsi_status = GOOD; target_complete_cmd(cmd, GOOD);
transport_complete_task(task, 1);
return 0; return 0;
} }
...@@ -1020,9 +1009,8 @@ int target_emulate_request_sense(struct se_task *task) ...@@ -1020,9 +1009,8 @@ int target_emulate_request_sense(struct se_task *task)
* Used for TCM/IBLOCK and TCM/FILEIO for block/blk-lib.c level discard support. * Used for TCM/IBLOCK and TCM/FILEIO for block/blk-lib.c level discard support.
* Note this is not used for TCM/pSCSI passthrough * Note this is not used for TCM/pSCSI passthrough
*/ */
int target_emulate_unmap(struct se_task *task) int target_emulate_unmap(struct se_cmd *cmd)
{ {
struct se_cmd *cmd = task->task_se_cmd;
struct se_device *dev = cmd->se_dev; struct se_device *dev = cmd->se_dev;
unsigned char *buf, *ptr = NULL; unsigned char *buf, *ptr = NULL;
unsigned char *cdb = &cmd->t_task_cdb[0]; unsigned char *cdb = &cmd->t_task_cdb[0];
...@@ -1069,10 +1057,8 @@ int target_emulate_unmap(struct se_task *task) ...@@ -1069,10 +1057,8 @@ int target_emulate_unmap(struct se_task *task)
err: err:
transport_kunmap_data_sg(cmd); transport_kunmap_data_sg(cmd);
if (!ret) { if (!ret)
task->task_scsi_status = GOOD; target_complete_cmd(cmd, GOOD);
transport_complete_task(task, 1);
}
return ret; return ret;
} }
...@@ -1080,9 +1066,8 @@ int target_emulate_unmap(struct se_task *task) ...@@ -1080,9 +1066,8 @@ int target_emulate_unmap(struct se_task *task)
* Used for TCM/IBLOCK and TCM/FILEIO for block/blk-lib.c level discard support. * Used for TCM/IBLOCK and TCM/FILEIO for block/blk-lib.c level discard support.
* Note this is not used for TCM/pSCSI passthrough * Note this is not used for TCM/pSCSI passthrough
*/ */
int target_emulate_write_same(struct se_task *task) int target_emulate_write_same(struct se_cmd *cmd)
{ {
struct se_cmd *cmd = task->task_se_cmd;
struct se_device *dev = cmd->se_dev; struct se_device *dev = cmd->se_dev;
sector_t range; sector_t range;
sector_t lba = cmd->t_task_lba; sector_t lba = cmd->t_task_lba;
...@@ -1121,30 +1106,25 @@ int target_emulate_write_same(struct se_task *task) ...@@ -1121,30 +1106,25 @@ int target_emulate_write_same(struct se_task *task)
return ret; return ret;
} }
task->task_scsi_status = GOOD; target_complete_cmd(cmd, GOOD);
transport_complete_task(task, 1);
return 0; return 0;
} }
int target_emulate_synchronize_cache(struct se_task *task) int target_emulate_synchronize_cache(struct se_cmd *cmd)
{ {
struct se_device *dev = task->task_se_cmd->se_dev; if (!cmd->se_dev->transport->do_sync_cache) {
struct se_cmd *cmd = task->task_se_cmd;
if (!dev->transport->do_sync_cache) {
pr_err("SYNCHRONIZE_CACHE emulation not supported" pr_err("SYNCHRONIZE_CACHE emulation not supported"
" for: %s\n", dev->transport->name); " for: %s\n", cmd->se_dev->transport->name);
cmd->scsi_sense_reason = TCM_UNSUPPORTED_SCSI_OPCODE; cmd->scsi_sense_reason = TCM_UNSUPPORTED_SCSI_OPCODE;
return -ENOSYS; return -ENOSYS;
} }
dev->transport->do_sync_cache(task); cmd->se_dev->transport->do_sync_cache(cmd);
return 0; return 0;
} }
int target_emulate_noop(struct se_task *task) int target_emulate_noop(struct se_cmd *cmd)
{ {
task->task_scsi_status = GOOD; target_complete_cmd(cmd, GOOD);
transport_complete_task(task, 1);
return 0; return 0;
} }
...@@ -643,9 +643,8 @@ void core_dev_unexport( ...@@ -643,9 +643,8 @@ void core_dev_unexport(
lun->lun_se_dev = NULL; lun->lun_se_dev = NULL;
} }
int target_report_luns(struct se_task *se_task) int target_report_luns(struct se_cmd *se_cmd)
{ {
struct se_cmd *se_cmd = se_task->task_se_cmd;
struct se_dev_entry *deve; struct se_dev_entry *deve;
struct se_session *se_sess = se_cmd->se_sess; struct se_session *se_sess = se_cmd->se_sess;
unsigned char *buf; unsigned char *buf;
...@@ -696,8 +695,7 @@ int target_report_luns(struct se_task *se_task) ...@@ -696,8 +695,7 @@ int target_report_luns(struct se_task *se_task)
buf[3] = (lun_count & 0xff); buf[3] = (lun_count & 0xff);
transport_kunmap_data_sg(se_cmd); transport_kunmap_data_sg(se_cmd);
se_task->task_scsi_status = GOOD; target_complete_cmd(se_cmd, GOOD);
transport_complete_task(se_task, 1);
return 0; return 0;
} }
......
...@@ -356,9 +356,8 @@ static int fd_do_writev(struct se_task *task) ...@@ -356,9 +356,8 @@ static int fd_do_writev(struct se_task *task)
return 1; return 1;
} }
static void fd_emulate_sync_cache(struct se_task *task) static void fd_emulate_sync_cache(struct se_cmd *cmd)
{ {
struct se_cmd *cmd = task->task_se_cmd;
struct se_device *dev = cmd->se_dev; struct se_device *dev = cmd->se_dev;
struct fd_dev *fd_dev = dev->dev_ptr; struct fd_dev *fd_dev = dev->dev_ptr;
int immed = (cmd->t_task_cdb[1] & 0x2); int immed = (cmd->t_task_cdb[1] & 0x2);
......
...@@ -304,9 +304,8 @@ static void iblock_end_io_flush(struct bio *bio, int err) ...@@ -304,9 +304,8 @@ static void iblock_end_io_flush(struct bio *bio, int err)
* Implement SYCHRONIZE CACHE. Note that we can't handle lba ranges and must * Implement SYCHRONIZE CACHE. Note that we can't handle lba ranges and must
* always flush the whole cache. * always flush the whole cache.
*/ */
static void iblock_emulate_sync_cache(struct se_task *task) static void iblock_emulate_sync_cache(struct se_cmd *cmd)
{ {
struct se_cmd *cmd = task->task_se_cmd;
struct iblock_dev *ib_dev = cmd->se_dev->dev_ptr; struct iblock_dev *ib_dev = cmd->se_dev->dev_ptr;
int immed = (cmd->t_task_cdb[1] & 0x2); int immed = (cmd->t_task_cdb[1] & 0x2);
struct bio *bio; struct bio *bio;
......
...@@ -5,15 +5,15 @@ ...@@ -5,15 +5,15 @@
extern struct t10_alua_lu_gp *default_lu_gp; extern struct t10_alua_lu_gp *default_lu_gp;
/* target_core_cdb.c */ /* target_core_cdb.c */
int target_emulate_inquiry(struct se_task *task); int target_emulate_inquiry(struct se_cmd *cmd);
int target_emulate_readcapacity(struct se_task *task); int target_emulate_readcapacity(struct se_cmd *cmd);
int target_emulate_readcapacity_16(struct se_task *task); int target_emulate_readcapacity_16(struct se_cmd *cmd);
int target_emulate_modesense(struct se_task *task); int target_emulate_modesense(struct se_cmd *cmd);
int target_emulate_request_sense(struct se_task *task); int target_emulate_request_sense(struct se_cmd *cmd);
int target_emulate_unmap(struct se_task *task); int target_emulate_unmap(struct se_cmd *cmd);
int target_emulate_write_same(struct se_task *task); int target_emulate_write_same(struct se_cmd *cmd);
int target_emulate_synchronize_cache(struct se_task *task); int target_emulate_synchronize_cache(struct se_cmd *cmd);
int target_emulate_noop(struct se_task *task); int target_emulate_noop(struct se_cmd *cmd);
/* target_core_device.c */ /* target_core_device.c */
struct se_dev_entry *core_get_se_deve_from_rtpi(struct se_node_acl *, u16); struct se_dev_entry *core_get_se_deve_from_rtpi(struct se_node_acl *, u16);
...@@ -28,7 +28,7 @@ int core_dev_export(struct se_device *, struct se_portal_group *, ...@@ -28,7 +28,7 @@ int core_dev_export(struct se_device *, struct se_portal_group *,
struct se_lun *); struct se_lun *);
void core_dev_unexport(struct se_device *, struct se_portal_group *, void core_dev_unexport(struct se_device *, struct se_portal_group *,
struct se_lun *); struct se_lun *);
int target_report_luns(struct se_task *); int target_report_luns(struct se_cmd *);
void se_release_device_for_hba(struct se_device *); void se_release_device_for_hba(struct se_device *);
void se_release_vpd_for_dev(struct se_device *); void se_release_vpd_for_dev(struct se_device *);
int se_free_virtual_device(struct se_device *, struct se_hba *); int se_free_virtual_device(struct se_device *, struct se_hba *);
......
...@@ -193,9 +193,8 @@ static int target_check_scsi2_reservation_conflict(struct se_cmd *cmd) ...@@ -193,9 +193,8 @@ static int target_check_scsi2_reservation_conflict(struct se_cmd *cmd)
return 0; return 0;
} }
int target_scsi2_reservation_release(struct se_task *task) int target_scsi2_reservation_release(struct se_cmd *cmd)
{ {
struct se_cmd *cmd = task->task_se_cmd;
struct se_device *dev = cmd->se_dev; struct se_device *dev = cmd->se_dev;
struct se_session *sess = cmd->se_sess; struct se_session *sess = cmd->se_sess;
struct se_portal_group *tpg = sess->se_tpg; struct se_portal_group *tpg = sess->se_tpg;
...@@ -234,16 +233,13 @@ int target_scsi2_reservation_release(struct se_task *task) ...@@ -234,16 +233,13 @@ int target_scsi2_reservation_release(struct se_task *task)
out_unlock: out_unlock:
spin_unlock(&dev->dev_reservation_lock); spin_unlock(&dev->dev_reservation_lock);
out: out:
if (!ret) { if (!ret)
task->task_scsi_status = GOOD; target_complete_cmd(cmd, GOOD);
transport_complete_task(task, 1);
}
return ret; return ret;
} }
int target_scsi2_reservation_reserve(struct se_task *task) int target_scsi2_reservation_reserve(struct se_cmd *cmd)
{ {
struct se_cmd *cmd = task->task_se_cmd;
struct se_device *dev = cmd->se_dev; struct se_device *dev = cmd->se_dev;
struct se_session *sess = cmd->se_sess; struct se_session *sess = cmd->se_sess;
struct se_portal_group *tpg = sess->se_tpg; struct se_portal_group *tpg = sess->se_tpg;
...@@ -304,10 +300,8 @@ int target_scsi2_reservation_reserve(struct se_task *task) ...@@ -304,10 +300,8 @@ int target_scsi2_reservation_reserve(struct se_task *task)
out_unlock: out_unlock:
spin_unlock(&dev->dev_reservation_lock); spin_unlock(&dev->dev_reservation_lock);
out: out:
if (!ret) { if (!ret)
task->task_scsi_status = GOOD; target_complete_cmd(cmd, GOOD);
transport_complete_task(task, 1);
}
return ret; return ret;
} }
...@@ -3798,9 +3792,8 @@ static unsigned long long core_scsi3_extract_reservation_key(unsigned char *cdb) ...@@ -3798,9 +3792,8 @@ static unsigned long long core_scsi3_extract_reservation_key(unsigned char *cdb)
/* /*
* See spc4r17 section 6.14 Table 170 * See spc4r17 section 6.14 Table 170
*/ */
int target_scsi3_emulate_pr_out(struct se_task *task) int target_scsi3_emulate_pr_out(struct se_cmd *cmd)
{ {
struct se_cmd *cmd = task->task_se_cmd;
unsigned char *cdb = &cmd->t_task_cdb[0]; unsigned char *cdb = &cmd->t_task_cdb[0];
unsigned char *buf; unsigned char *buf;
u64 res_key, sa_res_key; u64 res_key, sa_res_key;
...@@ -3940,10 +3933,8 @@ int target_scsi3_emulate_pr_out(struct se_task *task) ...@@ -3940,10 +3933,8 @@ int target_scsi3_emulate_pr_out(struct se_task *task)
} }
out: out:
if (!ret) { if (!ret)
task->task_scsi_status = GOOD; target_complete_cmd(cmd, GOOD);
transport_complete_task(task, 1);
}
return ret; return ret;
} }
...@@ -4298,9 +4289,8 @@ static int core_scsi3_pri_read_full_status(struct se_cmd *cmd) ...@@ -4298,9 +4289,8 @@ static int core_scsi3_pri_read_full_status(struct se_cmd *cmd)
return 0; return 0;
} }
int target_scsi3_emulate_pr_in(struct se_task *task) int target_scsi3_emulate_pr_in(struct se_cmd *cmd)
{ {
struct se_cmd *cmd = task->task_se_cmd;
int ret; int ret;
/* /*
...@@ -4341,10 +4331,8 @@ int target_scsi3_emulate_pr_in(struct se_task *task) ...@@ -4341,10 +4331,8 @@ int target_scsi3_emulate_pr_in(struct se_task *task)
break; break;
} }
if (!ret) { if (!ret)
task->task_scsi_status = GOOD; target_complete_cmd(cmd, GOOD);
transport_complete_task(task, 1);
}
return ret; return ret;
} }
......
...@@ -47,8 +47,8 @@ extern struct kmem_cache *t10_pr_reg_cache; ...@@ -47,8 +47,8 @@ extern struct kmem_cache *t10_pr_reg_cache;
extern int core_pr_dump_initiator_port(struct t10_pr_registration *, extern int core_pr_dump_initiator_port(struct t10_pr_registration *,
char *, u32); char *, u32);
extern int target_scsi2_reservation_release(struct se_task *task); extern int target_scsi2_reservation_release(struct se_cmd *);
extern int target_scsi2_reservation_reserve(struct se_task *task); extern int target_scsi2_reservation_reserve(struct se_cmd *);
extern int core_scsi3_alloc_aptpl_registration( extern int core_scsi3_alloc_aptpl_registration(
struct t10_reservation *, u64, struct t10_reservation *, u64,
unsigned char *, unsigned char *, u32, unsigned char *, unsigned char *, u32,
...@@ -61,8 +61,8 @@ extern void core_scsi3_free_pr_reg_from_nacl(struct se_device *, ...@@ -61,8 +61,8 @@ extern void core_scsi3_free_pr_reg_from_nacl(struct se_device *,
extern void core_scsi3_free_all_registrations(struct se_device *); extern void core_scsi3_free_all_registrations(struct se_device *);
extern unsigned char *core_scsi3_pr_dump_type(int); extern unsigned char *core_scsi3_pr_dump_type(int);
extern int target_scsi3_emulate_pr_in(struct se_task *task); extern int target_scsi3_emulate_pr_in(struct se_cmd *);
extern int target_scsi3_emulate_pr_out(struct se_task *task); extern int target_scsi3_emulate_pr_out(struct se_cmd *);
extern int core_setup_reservations(struct se_device *, int); extern int core_setup_reservations(struct se_device *, int);
#endif /* TARGET_CORE_PR_H */ #endif /* TARGET_CORE_PR_H */
...@@ -772,6 +772,16 @@ void transport_complete_task(struct se_task *task, int success) ...@@ -772,6 +772,16 @@ void transport_complete_task(struct se_task *task, int success)
} }
EXPORT_SYMBOL(transport_complete_task); EXPORT_SYMBOL(transport_complete_task);
void target_complete_cmd(struct se_cmd *cmd, u8 scsi_status)
{
struct se_task *task = list_entry(cmd->t_task_list.next,
struct se_task, t_list);
task->task_scsi_status = scsi_status;
transport_complete_task(task, scsi_status == GOOD);
}
EXPORT_SYMBOL(target_complete_cmd);
/* /*
* Called by transport_add_tasks_from_cmd() once a struct se_cmd's * Called by transport_add_tasks_from_cmd() once a struct se_cmd's
* struct se_task list are ready to be added to the active execution list * struct se_task list are ready to be added to the active execution list
...@@ -2233,8 +2243,8 @@ static int __transport_execute_tasks(struct se_device *dev, struct se_cmd *new_c ...@@ -2233,8 +2243,8 @@ static int __transport_execute_tasks(struct se_device *dev, struct se_cmd *new_c
spin_unlock_irqrestore(&cmd->t_state_lock, flags); spin_unlock_irqrestore(&cmd->t_state_lock, flags);
if (cmd->execute_task) if (cmd->execute_cmd)
error = cmd->execute_task(task); error = cmd->execute_cmd(cmd);
else else
error = dev->transport->do_task(task); error = dev->transport->do_task(task);
if (error != 0) { if (error != 0) {
...@@ -2804,7 +2814,7 @@ static int transport_generic_cmd_sequencer( ...@@ -2804,7 +2814,7 @@ static int transport_generic_cmd_sequencer(
if (target_check_write_same_discard(&cdb[10], dev) < 0) if (target_check_write_same_discard(&cdb[10], dev) < 0)
goto out_unsupported_cdb; goto out_unsupported_cdb;
if (!passthrough) if (!passthrough)
cmd->execute_task = target_emulate_write_same; cmd->execute_cmd = target_emulate_write_same;
break; break;
default: default:
pr_err("VARIABLE_LENGTH_CMD service action" pr_err("VARIABLE_LENGTH_CMD service action"
...@@ -2820,7 +2830,7 @@ static int transport_generic_cmd_sequencer( ...@@ -2820,7 +2830,7 @@ static int transport_generic_cmd_sequencer(
*/ */
if (cdb[1] == MI_REPORT_TARGET_PGS && if (cdb[1] == MI_REPORT_TARGET_PGS &&
su_dev->t10_alua.alua_type == SPC3_ALUA_EMULATED) { su_dev->t10_alua.alua_type == SPC3_ALUA_EMULATED) {
cmd->execute_task = cmd->execute_cmd =
target_emulate_report_target_port_groups; target_emulate_report_target_port_groups;
} }
size = (cdb[6] << 24) | (cdb[7] << 16) | size = (cdb[6] << 24) | (cdb[7] << 16) |
...@@ -2843,13 +2853,13 @@ static int transport_generic_cmd_sequencer( ...@@ -2843,13 +2853,13 @@ static int transport_generic_cmd_sequencer(
size = cdb[4]; size = cdb[4];
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB; cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
if (!passthrough) if (!passthrough)
cmd->execute_task = target_emulate_modesense; cmd->execute_cmd = target_emulate_modesense;
break; break;
case MODE_SENSE_10: case MODE_SENSE_10:
size = (cdb[7] << 8) + cdb[8]; size = (cdb[7] << 8) + cdb[8];
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB; cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
if (!passthrough) if (!passthrough)
cmd->execute_task = target_emulate_modesense; cmd->execute_cmd = target_emulate_modesense;
break; break;
case GPCMD_READ_BUFFER_CAPACITY: case GPCMD_READ_BUFFER_CAPACITY:
case GPCMD_SEND_OPC: case GPCMD_SEND_OPC:
...@@ -2871,13 +2881,13 @@ static int transport_generic_cmd_sequencer( ...@@ -2871,13 +2881,13 @@ static int transport_generic_cmd_sequencer(
break; break;
case PERSISTENT_RESERVE_IN: case PERSISTENT_RESERVE_IN:
if (su_dev->t10_pr.res_type == SPC3_PERSISTENT_RESERVATIONS) if (su_dev->t10_pr.res_type == SPC3_PERSISTENT_RESERVATIONS)
cmd->execute_task = target_scsi3_emulate_pr_in; cmd->execute_cmd = target_scsi3_emulate_pr_in;
size = (cdb[7] << 8) + cdb[8]; size = (cdb[7] << 8) + cdb[8];
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB; cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
break; break;
case PERSISTENT_RESERVE_OUT: case PERSISTENT_RESERVE_OUT:
if (su_dev->t10_pr.res_type == SPC3_PERSISTENT_RESERVATIONS) if (su_dev->t10_pr.res_type == SPC3_PERSISTENT_RESERVATIONS)
cmd->execute_task = target_scsi3_emulate_pr_out; cmd->execute_cmd = target_scsi3_emulate_pr_out;
size = (cdb[7] << 8) + cdb[8]; size = (cdb[7] << 8) + cdb[8];
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB; cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
break; break;
...@@ -2898,7 +2908,7 @@ static int transport_generic_cmd_sequencer( ...@@ -2898,7 +2908,7 @@ static int transport_generic_cmd_sequencer(
*/ */
if (cdb[1] == MO_SET_TARGET_PGS && if (cdb[1] == MO_SET_TARGET_PGS &&
su_dev->t10_alua.alua_type == SPC3_ALUA_EMULATED) { su_dev->t10_alua.alua_type == SPC3_ALUA_EMULATED) {
cmd->execute_task = cmd->execute_cmd =
target_emulate_set_target_port_groups; target_emulate_set_target_port_groups;
} }
...@@ -2920,7 +2930,7 @@ static int transport_generic_cmd_sequencer( ...@@ -2920,7 +2930,7 @@ static int transport_generic_cmd_sequencer(
cmd->sam_task_attr = MSG_HEAD_TAG; cmd->sam_task_attr = MSG_HEAD_TAG;
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB; cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
if (!passthrough) if (!passthrough)
cmd->execute_task = target_emulate_inquiry; cmd->execute_cmd = target_emulate_inquiry;
break; break;
case READ_BUFFER: case READ_BUFFER:
size = (cdb[6] << 16) + (cdb[7] << 8) + cdb[8]; size = (cdb[6] << 16) + (cdb[7] << 8) + cdb[8];
...@@ -2930,7 +2940,7 @@ static int transport_generic_cmd_sequencer( ...@@ -2930,7 +2940,7 @@ static int transport_generic_cmd_sequencer(
size = READ_CAP_LEN; size = READ_CAP_LEN;
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB; cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
if (!passthrough) if (!passthrough)
cmd->execute_task = target_emulate_readcapacity; cmd->execute_cmd = target_emulate_readcapacity;
break; break;
case READ_MEDIA_SERIAL_NUMBER: case READ_MEDIA_SERIAL_NUMBER:
case SECURITY_PROTOCOL_IN: case SECURITY_PROTOCOL_IN:
...@@ -2942,7 +2952,7 @@ static int transport_generic_cmd_sequencer( ...@@ -2942,7 +2952,7 @@ static int transport_generic_cmd_sequencer(
switch (cmd->t_task_cdb[1] & 0x1f) { switch (cmd->t_task_cdb[1] & 0x1f) {
case SAI_READ_CAPACITY_16: case SAI_READ_CAPACITY_16:
if (!passthrough) if (!passthrough)
cmd->execute_task = cmd->execute_cmd =
target_emulate_readcapacity_16; target_emulate_readcapacity_16;
break; break;
default: default:
...@@ -2985,7 +2995,7 @@ static int transport_generic_cmd_sequencer( ...@@ -2985,7 +2995,7 @@ static int transport_generic_cmd_sequencer(
size = cdb[4]; size = cdb[4];
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB; cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
if (!passthrough) if (!passthrough)
cmd->execute_task = target_emulate_request_sense; cmd->execute_cmd = target_emulate_request_sense;
break; break;
case READ_ELEMENT_STATUS: case READ_ELEMENT_STATUS:
size = 65536 * cdb[7] + 256 * cdb[8] + cdb[9]; size = 65536 * cdb[7] + 256 * cdb[8] + cdb[9];
...@@ -3014,7 +3024,7 @@ static int transport_generic_cmd_sequencer( ...@@ -3014,7 +3024,7 @@ static int transport_generic_cmd_sequencer(
* emulation disabled. * emulation disabled.
*/ */
if (su_dev->t10_pr.res_type != SPC_PASSTHROUGH) if (su_dev->t10_pr.res_type != SPC_PASSTHROUGH)
cmd->execute_task = target_scsi2_reservation_reserve; cmd->execute_cmd = target_scsi2_reservation_reserve;
cmd->se_cmd_flags |= SCF_SCSI_NON_DATA_CDB; cmd->se_cmd_flags |= SCF_SCSI_NON_DATA_CDB;
break; break;
case RELEASE: case RELEASE:
...@@ -3029,7 +3039,7 @@ static int transport_generic_cmd_sequencer( ...@@ -3029,7 +3039,7 @@ static int transport_generic_cmd_sequencer(
size = cmd->data_length; size = cmd->data_length;
if (su_dev->t10_pr.res_type != SPC_PASSTHROUGH) if (su_dev->t10_pr.res_type != SPC_PASSTHROUGH)
cmd->execute_task = target_scsi2_reservation_release; cmd->execute_cmd = target_scsi2_reservation_release;
cmd->se_cmd_flags |= SCF_SCSI_NON_DATA_CDB; cmd->se_cmd_flags |= SCF_SCSI_NON_DATA_CDB;
break; break;
case SYNCHRONIZE_CACHE: case SYNCHRONIZE_CACHE:
...@@ -3061,13 +3071,13 @@ static int transport_generic_cmd_sequencer( ...@@ -3061,13 +3071,13 @@ static int transport_generic_cmd_sequencer(
if (transport_cmd_get_valid_sectors(cmd) < 0) if (transport_cmd_get_valid_sectors(cmd) < 0)
goto out_invalid_cdb_field; goto out_invalid_cdb_field;
} }
cmd->execute_task = target_emulate_synchronize_cache; cmd->execute_cmd = target_emulate_synchronize_cache;
break; break;
case UNMAP: case UNMAP:
size = get_unaligned_be16(&cdb[7]); size = get_unaligned_be16(&cdb[7]);
cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB; cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
if (!passthrough) if (!passthrough)
cmd->execute_task = target_emulate_unmap; cmd->execute_cmd = target_emulate_unmap;
break; break;
case WRITE_SAME_16: case WRITE_SAME_16:
sectors = transport_get_sectors_16(cdb, cmd, &sector_ret); sectors = transport_get_sectors_16(cdb, cmd, &sector_ret);
...@@ -3087,7 +3097,7 @@ static int transport_generic_cmd_sequencer( ...@@ -3087,7 +3097,7 @@ static int transport_generic_cmd_sequencer(
if (target_check_write_same_discard(&cdb[1], dev) < 0) if (target_check_write_same_discard(&cdb[1], dev) < 0)
goto out_unsupported_cdb; goto out_unsupported_cdb;
if (!passthrough) if (!passthrough)
cmd->execute_task = target_emulate_write_same; cmd->execute_cmd = target_emulate_write_same;
break; break;
case WRITE_SAME: case WRITE_SAME:
sectors = transport_get_sectors_10(cdb, cmd, &sector_ret); sectors = transport_get_sectors_10(cdb, cmd, &sector_ret);
...@@ -3110,7 +3120,7 @@ static int transport_generic_cmd_sequencer( ...@@ -3110,7 +3120,7 @@ static int transport_generic_cmd_sequencer(
if (target_check_write_same_discard(&cdb[1], dev) < 0) if (target_check_write_same_discard(&cdb[1], dev) < 0)
goto out_unsupported_cdb; goto out_unsupported_cdb;
if (!passthrough) if (!passthrough)
cmd->execute_task = target_emulate_write_same; cmd->execute_cmd = target_emulate_write_same;
break; break;
case ALLOW_MEDIUM_REMOVAL: case ALLOW_MEDIUM_REMOVAL:
case ERASE: case ERASE:
...@@ -3123,7 +3133,7 @@ static int transport_generic_cmd_sequencer( ...@@ -3123,7 +3133,7 @@ static int transport_generic_cmd_sequencer(
case WRITE_FILEMARKS: case WRITE_FILEMARKS:
cmd->se_cmd_flags |= SCF_SCSI_NON_DATA_CDB; cmd->se_cmd_flags |= SCF_SCSI_NON_DATA_CDB;
if (!passthrough) if (!passthrough)
cmd->execute_task = target_emulate_noop; cmd->execute_cmd = target_emulate_noop;
break; break;
case GPCMD_CLOSE_TRACK: case GPCMD_CLOSE_TRACK:
case INITIALIZE_ELEMENT_STATUS: case INITIALIZE_ELEMENT_STATUS:
...@@ -3133,7 +3143,7 @@ static int transport_generic_cmd_sequencer( ...@@ -3133,7 +3143,7 @@ static int transport_generic_cmd_sequencer(
cmd->se_cmd_flags |= SCF_SCSI_NON_DATA_CDB; cmd->se_cmd_flags |= SCF_SCSI_NON_DATA_CDB;
break; break;
case REPORT_LUNS: case REPORT_LUNS:
cmd->execute_task = target_report_luns; cmd->execute_cmd = target_report_luns;
size = (cdb[6] << 24) | (cdb[7] << 16) | (cdb[8] << 8) | cdb[9]; size = (cdb[6] << 24) | (cdb[7] << 16) | (cdb[8] << 8) | cdb[9];
/* /*
* Do implict HEAD_OF_QUEUE processing for REPORT_LUNS * Do implict HEAD_OF_QUEUE processing for REPORT_LUNS
...@@ -3201,7 +3211,7 @@ static int transport_generic_cmd_sequencer( ...@@ -3201,7 +3211,7 @@ static int transport_generic_cmd_sequencer(
} }
/* reject any command that we don't have a handler for */ /* reject any command that we don't have a handler for */
if (!(passthrough || cmd->execute_task || if (!(passthrough || cmd->execute_cmd ||
(cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB))) (cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB)))
goto out_unsupported_cdb; goto out_unsupported_cdb;
......
...@@ -27,7 +27,7 @@ struct se_subsystem_api { ...@@ -27,7 +27,7 @@ struct se_subsystem_api {
struct se_task *(*alloc_task)(unsigned char *cdb); struct se_task *(*alloc_task)(unsigned char *cdb);
int (*do_task)(struct se_task *); int (*do_task)(struct se_task *);
int (*do_discard)(struct se_device *, sector_t, u32); int (*do_discard)(struct se_device *, sector_t, u32);
void (*do_sync_cache)(struct se_task *); void (*do_sync_cache)(struct se_cmd *);
void (*free_task)(struct se_task *); void (*free_task)(struct se_task *);
ssize_t (*check_configfs_dev_params)(struct se_hba *, ssize_t (*check_configfs_dev_params)(struct se_hba *,
struct se_subsystem_dev *); struct se_subsystem_dev *);
...@@ -50,6 +50,7 @@ struct se_device *transport_add_device_to_core_hba(struct se_hba *, ...@@ -50,6 +50,7 @@ struct se_device *transport_add_device_to_core_hba(struct se_hba *,
void transport_complete_sync_cache(struct se_cmd *, int); void transport_complete_sync_cache(struct se_cmd *, int);
void transport_complete_task(struct se_task *, int); void transport_complete_task(struct se_task *, int);
void target_complete_cmd(struct se_cmd *, u8);
void transport_set_vpd_proto_id(struct t10_vpd *, unsigned char *); void transport_set_vpd_proto_id(struct t10_vpd *, unsigned char *);
int transport_set_vpd_assoc(struct t10_vpd *, unsigned char *); int transport_set_vpd_assoc(struct t10_vpd *, unsigned char *);
......
...@@ -563,7 +563,7 @@ struct se_cmd { ...@@ -563,7 +563,7 @@ struct se_cmd {
struct completion cmd_wait_comp; struct completion cmd_wait_comp;
struct kref cmd_kref; struct kref cmd_kref;
struct target_core_fabric_ops *se_tfo; struct target_core_fabric_ops *se_tfo;
int (*execute_task)(struct se_task *); int (*execute_cmd)(struct se_cmd *);
void (*transport_complete_callback)(struct se_cmd *); void (*transport_complete_callback)(struct se_cmd *);
unsigned char *t_task_cdb; unsigned char *t_task_cdb;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment