For other backing subsystems, LIO core breaks SCSI commands that both read and write (bidirectional cmds, or "BIDI") into read call to their execute_rw function, followed by a write call to that function. This keeps things simple for the backstore code. However, for TCMU, we want userspace to handle the BIDI command in one pass. Set execute_cmd and transport_complete_callback ptrs to NULL after sbc_parse_cdb returns. We can't just skip calling sbc_parse_cdb -- it does other setup for BIDI cmds that we need. Reported-by: Christoph Hellwig <hch@xxxxxx> Signed-off-by: Andy Grover <agrover@xxxxxxxxxx> --- drivers/target/target_core_user.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c index 0e0feea..41fa012 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c @@ -1051,7 +1051,20 @@ static struct sbc_ops tcmu_sbc_ops = { static sense_reason_t tcmu_parse_cdb(struct se_cmd *cmd) { - return sbc_parse_cdb(cmd, &tcmu_sbc_ops); + sense_reason_t ret; + + ret = sbc_parse_cdb(cmd, &tcmu_sbc_ops); + + /* + * Since TCMU handles BIDI commands in one pass instead of two, + * fix things to work correctly. + */ + if (cmd->se_cmd_flags & SCF_BIDI) { + cmd->execute_cmd = tcmu_pass_op; + cmd->transport_complete_callback = NULL; + } + + return ret; } DEF_TB_DEFAULT_ATTRIBS(tcmu); -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe target-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html