mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-16 05:50:19 +00:00
target: add struct spc_ops + initial ->execute_rw pointer usage
Remove the execute_cmd method in struct se_subsystem_api, and always use the one directly in struct se_cmd. To make life simpler for SBC virtual backends a struct spc_ops that is passed to sbc_parse_cmd is added. For now it only contains an execute_rw member, but more will follow with the subsequent commits. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
This commit is contained in:
parent
e1306bdab3
commit
0c2ad7d113
@ -375,9 +375,11 @@ static void fd_emulate_sync_cache(struct se_cmd *cmd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fd_execute_cmd(struct se_cmd *cmd, struct scatterlist *sgl,
|
static int fd_execute_rw(struct se_cmd *cmd)
|
||||||
u32 sgl_nents, enum dma_data_direction data_direction)
|
|
||||||
{
|
{
|
||||||
|
struct scatterlist *sgl = cmd->t_data_sg;
|
||||||
|
u32 sgl_nents = cmd->t_data_nents;
|
||||||
|
enum dma_data_direction data_direction = cmd->data_direction;
|
||||||
struct se_device *dev = cmd->se_dev;
|
struct se_device *dev = cmd->se_dev;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
@ -550,6 +552,15 @@ static sector_t fd_get_blocks(struct se_device *dev)
|
|||||||
return div_u64(dev_size, dev->se_sub_dev->se_dev_attrib.block_size);
|
return div_u64(dev_size, dev->se_sub_dev->se_dev_attrib.block_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct spc_ops fd_spc_ops = {
|
||||||
|
.execute_rw = fd_execute_rw,
|
||||||
|
};
|
||||||
|
|
||||||
|
static int fd_parse_cdb(struct se_cmd *cmd)
|
||||||
|
{
|
||||||
|
return sbc_parse_cdb(cmd, &fd_spc_ops);
|
||||||
|
}
|
||||||
|
|
||||||
static struct se_subsystem_api fileio_template = {
|
static struct se_subsystem_api fileio_template = {
|
||||||
.name = "fileio",
|
.name = "fileio",
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
@ -561,8 +572,7 @@ static struct se_subsystem_api fileio_template = {
|
|||||||
.allocate_virtdevice = fd_allocate_virtdevice,
|
.allocate_virtdevice = fd_allocate_virtdevice,
|
||||||
.create_virtdevice = fd_create_virtdevice,
|
.create_virtdevice = fd_create_virtdevice,
|
||||||
.free_device = fd_free_device,
|
.free_device = fd_free_device,
|
||||||
.parse_cdb = sbc_parse_cdb,
|
.parse_cdb = fd_parse_cdb,
|
||||||
.execute_cmd = fd_execute_cmd,
|
|
||||||
.do_sync_cache = fd_emulate_sync_cache,
|
.do_sync_cache = fd_emulate_sync_cache,
|
||||||
.check_configfs_dev_params = fd_check_configfs_dev_params,
|
.check_configfs_dev_params = fd_check_configfs_dev_params,
|
||||||
.set_configfs_dev_params = fd_set_configfs_dev_params,
|
.set_configfs_dev_params = fd_set_configfs_dev_params,
|
||||||
|
@ -514,9 +514,11 @@ static void iblock_submit_bios(struct bio_list *list, int rw)
|
|||||||
blk_finish_plug(&plug);
|
blk_finish_plug(&plug);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int iblock_execute_cmd(struct se_cmd *cmd, struct scatterlist *sgl,
|
static int iblock_execute_rw(struct se_cmd *cmd)
|
||||||
u32 sgl_nents, enum dma_data_direction data_direction)
|
|
||||||
{
|
{
|
||||||
|
struct scatterlist *sgl = cmd->t_data_sg;
|
||||||
|
u32 sgl_nents = cmd->t_data_nents;
|
||||||
|
enum dma_data_direction data_direction = cmd->data_direction;
|
||||||
struct se_device *dev = cmd->se_dev;
|
struct se_device *dev = cmd->se_dev;
|
||||||
struct iblock_req *ibr;
|
struct iblock_req *ibr;
|
||||||
struct bio *bio;
|
struct bio *bio;
|
||||||
@ -663,6 +665,15 @@ static void iblock_bio_done(struct bio *bio, int err)
|
|||||||
iblock_complete_cmd(cmd);
|
iblock_complete_cmd(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct spc_ops iblock_spc_ops = {
|
||||||
|
.execute_rw = iblock_execute_rw,
|
||||||
|
};
|
||||||
|
|
||||||
|
static int iblock_parse_cdb(struct se_cmd *cmd)
|
||||||
|
{
|
||||||
|
return sbc_parse_cdb(cmd, &iblock_spc_ops);
|
||||||
|
}
|
||||||
|
|
||||||
static struct se_subsystem_api iblock_template = {
|
static struct se_subsystem_api iblock_template = {
|
||||||
.name = "iblock",
|
.name = "iblock",
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
@ -674,8 +685,7 @@ static struct se_subsystem_api iblock_template = {
|
|||||||
.allocate_virtdevice = iblock_allocate_virtdevice,
|
.allocate_virtdevice = iblock_allocate_virtdevice,
|
||||||
.create_virtdevice = iblock_create_virtdevice,
|
.create_virtdevice = iblock_create_virtdevice,
|
||||||
.free_device = iblock_free_device,
|
.free_device = iblock_free_device,
|
||||||
.parse_cdb = sbc_parse_cdb,
|
.parse_cdb = iblock_parse_cdb,
|
||||||
.execute_cmd = iblock_execute_cmd,
|
|
||||||
.do_discard = iblock_do_discard,
|
.do_discard = iblock_do_discard,
|
||||||
.do_sync_cache = iblock_emulate_sync_cache,
|
.do_sync_cache = iblock_emulate_sync_cache,
|
||||||
.check_configfs_dev_params = iblock_check_configfs_dev_params,
|
.check_configfs_dev_params = iblock_check_configfs_dev_params,
|
||||||
|
@ -55,6 +55,7 @@
|
|||||||
|
|
||||||
static struct se_subsystem_api pscsi_template;
|
static struct se_subsystem_api pscsi_template;
|
||||||
|
|
||||||
|
static int pscsi_execute_cmd(struct se_cmd *cmd);
|
||||||
static void pscsi_req_done(struct request *, int);
|
static void pscsi_req_done(struct request *, int);
|
||||||
|
|
||||||
/* pscsi_attach_hba():
|
/* pscsi_attach_hba():
|
||||||
@ -1081,17 +1082,20 @@ static int pscsi_parse_cdb(struct se_cmd *cmd)
|
|||||||
case WRITE_16:
|
case WRITE_16:
|
||||||
case WRITE_VERIFY:
|
case WRITE_VERIFY:
|
||||||
cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
|
cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
|
||||||
break;
|
/* FALLTHROUGH*/
|
||||||
default:
|
default:
|
||||||
|
cmd->execute_cmd = pscsi_execute_cmd;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pscsi_execute_cmd(struct se_cmd *cmd, struct scatterlist *sgl,
|
static int pscsi_execute_cmd(struct se_cmd *cmd)
|
||||||
u32 sgl_nents, enum dma_data_direction data_direction)
|
|
||||||
{
|
{
|
||||||
|
struct scatterlist *sgl = cmd->t_data_sg;
|
||||||
|
u32 sgl_nents = cmd->t_data_nents;
|
||||||
|
enum dma_data_direction data_direction = cmd->data_direction;
|
||||||
struct pscsi_dev_virt *pdv = cmd->se_dev->dev_ptr;
|
struct pscsi_dev_virt *pdv = cmd->se_dev->dev_ptr;
|
||||||
struct pscsi_plugin_task *pt;
|
struct pscsi_plugin_task *pt;
|
||||||
struct request *req;
|
struct request *req;
|
||||||
@ -1259,7 +1263,6 @@ static struct se_subsystem_api pscsi_template = {
|
|||||||
.free_device = pscsi_free_device,
|
.free_device = pscsi_free_device,
|
||||||
.transport_complete = pscsi_transport_complete,
|
.transport_complete = pscsi_transport_complete,
|
||||||
.parse_cdb = pscsi_parse_cdb,
|
.parse_cdb = pscsi_parse_cdb,
|
||||||
.execute_cmd = pscsi_execute_cmd,
|
|
||||||
.check_configfs_dev_params = pscsi_check_configfs_dev_params,
|
.check_configfs_dev_params = pscsi_check_configfs_dev_params,
|
||||||
.set_configfs_dev_params = pscsi_set_configfs_dev_params,
|
.set_configfs_dev_params = pscsi_set_configfs_dev_params,
|
||||||
.show_configfs_dev_params = pscsi_show_configfs_dev_params,
|
.show_configfs_dev_params = pscsi_show_configfs_dev_params,
|
||||||
|
@ -284,9 +284,11 @@ static struct rd_dev_sg_table *rd_get_sg_table(struct rd_dev *rd_dev, u32 page)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rd_execute_cmd(struct se_cmd *cmd, struct scatterlist *sgl,
|
static int rd_execute_rw(struct se_cmd *cmd)
|
||||||
u32 sgl_nents, enum dma_data_direction data_direction)
|
|
||||||
{
|
{
|
||||||
|
struct scatterlist *sgl = cmd->t_data_sg;
|
||||||
|
u32 sgl_nents = cmd->t_data_nents;
|
||||||
|
enum dma_data_direction data_direction = cmd->data_direction;
|
||||||
struct se_device *se_dev = cmd->se_dev;
|
struct se_device *se_dev = cmd->se_dev;
|
||||||
struct rd_dev *dev = se_dev->dev_ptr;
|
struct rd_dev *dev = se_dev->dev_ptr;
|
||||||
struct rd_dev_sg_table *table;
|
struct rd_dev_sg_table *table;
|
||||||
@ -460,6 +462,15 @@ static sector_t rd_get_blocks(struct se_device *dev)
|
|||||||
return blocks_long;
|
return blocks_long;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct spc_ops rd_spc_ops = {
|
||||||
|
.execute_rw = rd_execute_rw,
|
||||||
|
};
|
||||||
|
|
||||||
|
static int rd_parse_cdb(struct se_cmd *cmd)
|
||||||
|
{
|
||||||
|
return sbc_parse_cdb(cmd, &rd_spc_ops);
|
||||||
|
}
|
||||||
|
|
||||||
static struct se_subsystem_api rd_mcp_template = {
|
static struct se_subsystem_api rd_mcp_template = {
|
||||||
.name = "rd_mcp",
|
.name = "rd_mcp",
|
||||||
.transport_type = TRANSPORT_PLUGIN_VHBA_VDEV,
|
.transport_type = TRANSPORT_PLUGIN_VHBA_VDEV,
|
||||||
@ -468,8 +479,7 @@ static struct se_subsystem_api rd_mcp_template = {
|
|||||||
.allocate_virtdevice = rd_allocate_virtdevice,
|
.allocate_virtdevice = rd_allocate_virtdevice,
|
||||||
.create_virtdevice = rd_create_virtdevice,
|
.create_virtdevice = rd_create_virtdevice,
|
||||||
.free_device = rd_free_device,
|
.free_device = rd_free_device,
|
||||||
.parse_cdb = sbc_parse_cdb,
|
.parse_cdb = rd_parse_cdb,
|
||||||
.execute_cmd = rd_execute_cmd,
|
|
||||||
.check_configfs_dev_params = rd_check_configfs_dev_params,
|
.check_configfs_dev_params = rd_check_configfs_dev_params,
|
||||||
.set_configfs_dev_params = rd_set_configfs_dev_params,
|
.set_configfs_dev_params = rd_set_configfs_dev_params,
|
||||||
.show_configfs_dev_params = rd_show_configfs_dev_params,
|
.show_configfs_dev_params = rd_show_configfs_dev_params,
|
||||||
|
@ -395,7 +395,7 @@ out:
|
|||||||
kfree(buf);
|
kfree(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sbc_parse_cdb(struct se_cmd *cmd)
|
int sbc_parse_cdb(struct se_cmd *cmd, struct spc_ops *ops)
|
||||||
{
|
{
|
||||||
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_device *dev = cmd->se_dev;
|
struct se_device *dev = cmd->se_dev;
|
||||||
@ -409,26 +409,31 @@ int sbc_parse_cdb(struct se_cmd *cmd)
|
|||||||
sectors = transport_get_sectors_6(cdb);
|
sectors = transport_get_sectors_6(cdb);
|
||||||
cmd->t_task_lba = transport_lba_21(cdb);
|
cmd->t_task_lba = transport_lba_21(cdb);
|
||||||
cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
|
cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
|
||||||
|
cmd->execute_cmd = ops->execute_rw;
|
||||||
break;
|
break;
|
||||||
case READ_10:
|
case READ_10:
|
||||||
sectors = transport_get_sectors_10(cdb);
|
sectors = transport_get_sectors_10(cdb);
|
||||||
cmd->t_task_lba = transport_lba_32(cdb);
|
cmd->t_task_lba = transport_lba_32(cdb);
|
||||||
cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
|
cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
|
||||||
|
cmd->execute_cmd = ops->execute_rw;
|
||||||
break;
|
break;
|
||||||
case READ_12:
|
case READ_12:
|
||||||
sectors = transport_get_sectors_12(cdb);
|
sectors = transport_get_sectors_12(cdb);
|
||||||
cmd->t_task_lba = transport_lba_32(cdb);
|
cmd->t_task_lba = transport_lba_32(cdb);
|
||||||
cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
|
cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
|
||||||
|
cmd->execute_cmd = ops->execute_rw;
|
||||||
break;
|
break;
|
||||||
case READ_16:
|
case READ_16:
|
||||||
sectors = transport_get_sectors_16(cdb);
|
sectors = transport_get_sectors_16(cdb);
|
||||||
cmd->t_task_lba = transport_lba_64(cdb);
|
cmd->t_task_lba = transport_lba_64(cdb);
|
||||||
cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
|
cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
|
||||||
|
cmd->execute_cmd = ops->execute_rw;
|
||||||
break;
|
break;
|
||||||
case WRITE_6:
|
case WRITE_6:
|
||||||
sectors = transport_get_sectors_6(cdb);
|
sectors = transport_get_sectors_6(cdb);
|
||||||
cmd->t_task_lba = transport_lba_21(cdb);
|
cmd->t_task_lba = transport_lba_21(cdb);
|
||||||
cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
|
cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
|
||||||
|
cmd->execute_cmd = ops->execute_rw;
|
||||||
break;
|
break;
|
||||||
case WRITE_10:
|
case WRITE_10:
|
||||||
case WRITE_VERIFY:
|
case WRITE_VERIFY:
|
||||||
@ -437,6 +442,7 @@ int sbc_parse_cdb(struct se_cmd *cmd)
|
|||||||
if (cdb[1] & 0x8)
|
if (cdb[1] & 0x8)
|
||||||
cmd->se_cmd_flags |= SCF_FUA;
|
cmd->se_cmd_flags |= SCF_FUA;
|
||||||
cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
|
cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
|
||||||
|
cmd->execute_cmd = ops->execute_rw;
|
||||||
break;
|
break;
|
||||||
case WRITE_12:
|
case WRITE_12:
|
||||||
sectors = transport_get_sectors_12(cdb);
|
sectors = transport_get_sectors_12(cdb);
|
||||||
@ -444,6 +450,7 @@ int sbc_parse_cdb(struct se_cmd *cmd)
|
|||||||
if (cdb[1] & 0x8)
|
if (cdb[1] & 0x8)
|
||||||
cmd->se_cmd_flags |= SCF_FUA;
|
cmd->se_cmd_flags |= SCF_FUA;
|
||||||
cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
|
cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
|
||||||
|
cmd->execute_cmd = ops->execute_rw;
|
||||||
break;
|
break;
|
||||||
case WRITE_16:
|
case WRITE_16:
|
||||||
sectors = transport_get_sectors_16(cdb);
|
sectors = transport_get_sectors_16(cdb);
|
||||||
@ -451,6 +458,7 @@ int sbc_parse_cdb(struct se_cmd *cmd)
|
|||||||
if (cdb[1] & 0x8)
|
if (cdb[1] & 0x8)
|
||||||
cmd->se_cmd_flags |= SCF_FUA;
|
cmd->se_cmd_flags |= SCF_FUA;
|
||||||
cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
|
cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
|
||||||
|
cmd->execute_cmd = ops->execute_rw;
|
||||||
break;
|
break;
|
||||||
case XDWRITEREAD_10:
|
case XDWRITEREAD_10:
|
||||||
if ((cmd->data_direction != DMA_TO_DEVICE) ||
|
if ((cmd->data_direction != DMA_TO_DEVICE) ||
|
||||||
@ -464,6 +472,7 @@ int sbc_parse_cdb(struct se_cmd *cmd)
|
|||||||
/*
|
/*
|
||||||
* Setup BIDI XOR callback to be run after I/O completion.
|
* Setup BIDI XOR callback to be run after I/O completion.
|
||||||
*/
|
*/
|
||||||
|
cmd->execute_cmd = ops->execute_rw;
|
||||||
cmd->transport_complete_callback = &xdreadwrite_callback;
|
cmd->transport_complete_callback = &xdreadwrite_callback;
|
||||||
if (cdb[1] & 0x8)
|
if (cdb[1] & 0x8)
|
||||||
cmd->se_cmd_flags |= SCF_FUA;
|
cmd->se_cmd_flags |= SCF_FUA;
|
||||||
@ -486,6 +495,7 @@ int sbc_parse_cdb(struct se_cmd *cmd)
|
|||||||
* Setup BIDI XOR callback to be run during after I/O
|
* Setup BIDI XOR callback to be run during after I/O
|
||||||
* completion.
|
* completion.
|
||||||
*/
|
*/
|
||||||
|
cmd->execute_cmd = ops->execute_rw;
|
||||||
cmd->transport_complete_callback = &xdreadwrite_callback;
|
cmd->transport_complete_callback = &xdreadwrite_callback;
|
||||||
if (cdb[1] & 0x8)
|
if (cdb[1] & 0x8)
|
||||||
cmd->se_cmd_flags |= SCF_FUA;
|
cmd->se_cmd_flags |= SCF_FUA;
|
||||||
|
@ -1865,7 +1865,7 @@ EXPORT_SYMBOL(transport_generic_request_failure);
|
|||||||
|
|
||||||
static void __target_execute_cmd(struct se_cmd *cmd)
|
static void __target_execute_cmd(struct se_cmd *cmd)
|
||||||
{
|
{
|
||||||
int error;
|
int error = 0;
|
||||||
|
|
||||||
spin_lock_irq(&cmd->t_state_lock);
|
spin_lock_irq(&cmd->t_state_lock);
|
||||||
cmd->transport_state |= (CMD_T_BUSY|CMD_T_SENT);
|
cmd->transport_state |= (CMD_T_BUSY|CMD_T_SENT);
|
||||||
@ -1873,10 +1873,6 @@ static void __target_execute_cmd(struct se_cmd *cmd)
|
|||||||
|
|
||||||
if (cmd->execute_cmd)
|
if (cmd->execute_cmd)
|
||||||
error = cmd->execute_cmd(cmd);
|
error = cmd->execute_cmd(cmd);
|
||||||
else {
|
|
||||||
error = cmd->se_dev->transport->execute_cmd(cmd, cmd->t_data_sg,
|
|
||||||
cmd->t_data_nents, cmd->data_direction);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
spin_lock_irq(&cmd->t_state_lock);
|
spin_lock_irq(&cmd->t_state_lock);
|
||||||
|
@ -26,8 +26,6 @@ struct se_subsystem_api {
|
|||||||
int (*transport_complete)(struct se_cmd *cmd, struct scatterlist *);
|
int (*transport_complete)(struct se_cmd *cmd, struct scatterlist *);
|
||||||
|
|
||||||
int (*parse_cdb)(struct se_cmd *cmd);
|
int (*parse_cdb)(struct se_cmd *cmd);
|
||||||
int (*execute_cmd)(struct se_cmd *, struct scatterlist *, u32,
|
|
||||||
enum dma_data_direction);
|
|
||||||
int (*do_discard)(struct se_device *, sector_t, u32);
|
int (*do_discard)(struct se_device *, sector_t, u32);
|
||||||
void (*do_sync_cache)(struct se_cmd *);
|
void (*do_sync_cache)(struct se_cmd *);
|
||||||
ssize_t (*check_configfs_dev_params)(struct se_hba *,
|
ssize_t (*check_configfs_dev_params)(struct se_hba *,
|
||||||
@ -42,6 +40,10 @@ struct se_subsystem_api {
|
|||||||
unsigned char *(*get_sense_buffer)(struct se_cmd *);
|
unsigned char *(*get_sense_buffer)(struct se_cmd *);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct spc_ops {
|
||||||
|
int (*execute_rw)(struct se_cmd *cmd);
|
||||||
|
};
|
||||||
|
|
||||||
int transport_subsystem_register(struct se_subsystem_api *);
|
int transport_subsystem_register(struct se_subsystem_api *);
|
||||||
void transport_subsystem_release(struct se_subsystem_api *);
|
void transport_subsystem_release(struct se_subsystem_api *);
|
||||||
|
|
||||||
@ -51,7 +53,7 @@ struct se_device *transport_add_device_to_core_hba(struct se_hba *,
|
|||||||
|
|
||||||
void target_complete_cmd(struct se_cmd *, u8);
|
void target_complete_cmd(struct se_cmd *, u8);
|
||||||
|
|
||||||
int sbc_parse_cdb(struct se_cmd *cmd);
|
int sbc_parse_cdb(struct se_cmd *cmd, struct spc_ops *ops);
|
||||||
int spc_parse_cdb(struct se_cmd *cmd, unsigned int *size);
|
int spc_parse_cdb(struct se_cmd *cmd, unsigned int *size);
|
||||||
|
|
||||||
void transport_set_vpd_proto_id(struct t10_vpd *, unsigned char *);
|
void transport_set_vpd_proto_id(struct t10_vpd *, unsigned char *);
|
||||||
|
Loading…
Reference in New Issue
Block a user