Commit 7a971b1b authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Nicholas Bellinger

target: replace se_cmd->execute_rw with a protocol_data field

Instead of leaking this SBC read/write implementation detail just add an
opaqueue protocol specific pointer to struct se_cmd that we can assign
the sbc_ops vector to.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarAndy Grover <agrover@redhat.com>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent e2e21bd8
...@@ -381,7 +381,9 @@ static sense_reason_t xdreadwrite_callback(struct se_cmd *cmd, bool success) ...@@ -381,7 +381,9 @@ static sense_reason_t xdreadwrite_callback(struct se_cmd *cmd, bool success)
static sense_reason_t static sense_reason_t
sbc_execute_rw(struct se_cmd *cmd) sbc_execute_rw(struct se_cmd *cmd)
{ {
return cmd->execute_rw(cmd, cmd->t_data_sg, cmd->t_data_nents, struct sbc_ops *ops = cmd->protocol_data;
return ops->execute_rw(cmd, cmd->t_data_sg, cmd->t_data_nents,
cmd->data_direction); cmd->data_direction);
} }
...@@ -560,6 +562,7 @@ static sense_reason_t compare_and_write_callback(struct se_cmd *cmd, bool succes ...@@ -560,6 +562,7 @@ static sense_reason_t compare_and_write_callback(struct se_cmd *cmd, bool succes
static sense_reason_t static sense_reason_t
sbc_compare_and_write(struct se_cmd *cmd) sbc_compare_and_write(struct se_cmd *cmd)
{ {
struct sbc_ops *ops = cmd->protocol_data;
struct se_device *dev = cmd->se_dev; struct se_device *dev = cmd->se_dev;
sense_reason_t ret; sense_reason_t ret;
int rc; int rc;
...@@ -579,7 +582,7 @@ sbc_compare_and_write(struct se_cmd *cmd) ...@@ -579,7 +582,7 @@ sbc_compare_and_write(struct se_cmd *cmd)
*/ */
cmd->data_length = cmd->t_task_nolb * dev->dev_attrib.block_size; cmd->data_length = cmd->t_task_nolb * dev->dev_attrib.block_size;
ret = cmd->execute_rw(cmd, cmd->t_bidi_data_sg, cmd->t_bidi_data_nents, ret = ops->execute_rw(cmd, cmd->t_bidi_data_sg, cmd->t_bidi_data_nents,
DMA_FROM_DEVICE); DMA_FROM_DEVICE);
if (ret) { if (ret) {
cmd->transport_complete_callback = NULL; cmd->transport_complete_callback = NULL;
...@@ -766,12 +769,13 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops) ...@@ -766,12 +769,13 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
u32 sectors = 0; u32 sectors = 0;
sense_reason_t ret; sense_reason_t ret;
cmd->protocol_data = ops;
switch (cdb[0]) { switch (cdb[0]) {
case READ_6: case READ_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_rw = ops->execute_rw;
cmd->execute_cmd = sbc_execute_rw; cmd->execute_cmd = sbc_execute_rw;
break; break;
case READ_10: case READ_10:
...@@ -786,7 +790,6 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops) ...@@ -786,7 +790,6 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
return ret; return ret;
cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB; cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
cmd->execute_rw = ops->execute_rw;
cmd->execute_cmd = sbc_execute_rw; cmd->execute_cmd = sbc_execute_rw;
break; break;
case READ_12: case READ_12:
...@@ -801,7 +804,6 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops) ...@@ -801,7 +804,6 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
return ret; return ret;
cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB; cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
cmd->execute_rw = ops->execute_rw;
cmd->execute_cmd = sbc_execute_rw; cmd->execute_cmd = sbc_execute_rw;
break; break;
case READ_16: case READ_16:
...@@ -816,14 +818,12 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops) ...@@ -816,14 +818,12 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
return ret; return ret;
cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB; cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
cmd->execute_rw = ops->execute_rw;
cmd->execute_cmd = sbc_execute_rw; cmd->execute_cmd = sbc_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_rw = ops->execute_rw;
cmd->execute_cmd = sbc_execute_rw; cmd->execute_cmd = sbc_execute_rw;
break; break;
case WRITE_10: case WRITE_10:
...@@ -839,7 +839,6 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops) ...@@ -839,7 +839,6 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
return ret; return ret;
cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB; cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
cmd->execute_rw = ops->execute_rw;
cmd->execute_cmd = sbc_execute_rw; cmd->execute_cmd = sbc_execute_rw;
break; break;
case WRITE_12: case WRITE_12:
...@@ -854,7 +853,6 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops) ...@@ -854,7 +853,6 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
return ret; return ret;
cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB; cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
cmd->execute_rw = ops->execute_rw;
cmd->execute_cmd = sbc_execute_rw; cmd->execute_cmd = sbc_execute_rw;
break; break;
case WRITE_16: case WRITE_16:
...@@ -869,7 +867,6 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops) ...@@ -869,7 +867,6 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
return ret; return ret;
cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB; cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
cmd->execute_rw = ops->execute_rw;
cmd->execute_cmd = sbc_execute_rw; cmd->execute_cmd = sbc_execute_rw;
break; break;
case XDWRITEREAD_10: case XDWRITEREAD_10:
...@@ -887,7 +884,6 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops) ...@@ -887,7 +884,6 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
/* /*
* Setup BIDI XOR callback to be run after I/O completion. * Setup BIDI XOR callback to be run after I/O completion.
*/ */
cmd->execute_rw = ops->execute_rw;
cmd->execute_cmd = sbc_execute_rw; cmd->execute_cmd = sbc_execute_rw;
cmd->transport_complete_callback = &xdreadwrite_callback; cmd->transport_complete_callback = &xdreadwrite_callback;
break; break;
...@@ -911,7 +907,6 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops) ...@@ -911,7 +907,6 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
* 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_rw = ops->execute_rw;
cmd->execute_cmd = sbc_execute_rw; cmd->execute_cmd = sbc_execute_rw;
cmd->transport_complete_callback = &xdreadwrite_callback; cmd->transport_complete_callback = &xdreadwrite_callback;
break; break;
...@@ -955,7 +950,6 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops) ...@@ -955,7 +950,6 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
cmd->t_task_lba = get_unaligned_be64(&cdb[2]); cmd->t_task_lba = get_unaligned_be64(&cdb[2]);
cmd->t_task_nolb = sectors; cmd->t_task_nolb = sectors;
cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB | SCF_COMPARE_AND_WRITE; cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB | SCF_COMPARE_AND_WRITE;
cmd->execute_rw = ops->execute_rw;
cmd->execute_cmd = sbc_compare_and_write; cmd->execute_cmd = sbc_compare_and_write;
cmd->transport_complete_callback = compare_and_write_callback; cmd->transport_complete_callback = compare_and_write_callback;
break; break;
......
...@@ -490,9 +490,8 @@ struct se_cmd { ...@@ -490,9 +490,8 @@ struct se_cmd {
struct kref cmd_kref; struct kref cmd_kref;
const struct target_core_fabric_ops *se_tfo; const struct target_core_fabric_ops *se_tfo;
sense_reason_t (*execute_cmd)(struct se_cmd *); sense_reason_t (*execute_cmd)(struct se_cmd *);
sense_reason_t (*execute_rw)(struct se_cmd *, struct scatterlist *,
u32, enum dma_data_direction);
sense_reason_t (*transport_complete_callback)(struct se_cmd *, bool); sense_reason_t (*transport_complete_callback)(struct se_cmd *, bool);
void *protocol_data;
unsigned char *t_task_cdb; unsigned char *t_task_cdb;
unsigned char __t_task_cdb[TCM_MAX_COMMAND_SIZE]; unsigned char __t_task_cdb[TCM_MAX_COMMAND_SIZE];
......
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