diff options
author | Andy Grover <agrover@redhat.com> | 2015-05-11 20:39:45 -0700 |
---|---|---|
committer | Andy Grover <agrover@redhat.com> | 2015-05-11 20:39:45 -0700 |
commit | 0ebd49e7ba0e321aece65d905f6b3a9a311ee72a (patch) | |
tree | 78cefff4f0ec048f99084d344682bd178431ad74 | |
parent | 0d34082b2f11a94f3f372e1490d7a6f179b5a820 (diff) | |
download | linux-tcmu-iomode-option5.tar.gz |
target/user: Disallow BIDI and COMPARE AND WRITE cmds for TCMU I/O modetcmu-iomode-option5
I/O mode is a partial-passthrough mode that saves userspace from handling
the complete set of required SCSI commands. Due to some issues with
emulation, it is preferable to not include BIDI commands like XDWRITEREAD,
and also COMPARE AND WRITE. If these are needed, the forthcoming
full-passthrough mode will allow their use.
Signed-off-by: Andy Grover <agrover@redhat.com>
-rw-r--r-- | Documentation/target/tcmu-design.txt | 2 | ||||
-rw-r--r-- | drivers/target/target_core_user.c | 24 |
2 files changed, 23 insertions, 3 deletions
diff --git a/Documentation/target/tcmu-design.txt b/Documentation/target/tcmu-design.txt index b495108c433c4..305b3bba46123 100644 --- a/Documentation/target/tcmu-design.txt +++ b/Documentation/target/tcmu-design.txt @@ -375,9 +375,7 @@ of: READ WRITE WRITE_VERIFY -XDWRITEREAD WRITE_SAME -COMPARE_AND_WRITE SYNCHRONIZE_CACHE UNMAP diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c index 0e0feeaec39c2..a01093daf943f 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c @@ -21,6 +21,7 @@ #include <linux/idr.h> #include <linux/timer.h> #include <linux/parser.h> +#include <asm/unaligned.h> #include <scsi/scsi.h> #include <scsi/scsi_host.h> #include <linux/uio_driver.h> @@ -1051,7 +1052,28 @@ 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; + unsigned char *cdb = cmd->t_task_cdb; + + switch (cdb[0]) { + case COMPARE_AND_WRITE: + case XDWRITEREAD_10: + pr_err("TCMU I/O mode does not support XDWRITEREAD10 or " + "COMPARE AND WRITE opcodes\n"); + ret = TCM_UNSUPPORTED_SCSI_OPCODE; + break; + case VARIABLE_LENGTH_CMD: + if (get_unaligned_be16(&cdb[8]) == XDWRITEREAD_32) { + pr_err("TCMU I/O mode does not support XDWRITEREAD32\n"); + ret = TCM_UNSUPPORTED_SCSI_OPCODE; + break; + } + /* fallthrough */ + default: + ret = sbc_parse_cdb(cmd, &tcmu_sbc_ops); + } + + return ret; } DEF_TB_DEFAULT_ATTRIBS(tcmu); |