If the WRITE_SAME NDOB bit is set then there is not going to be a buffer. LIO core will then complain: TARGET_CORE[iSCSI]: Expected Transfer Length: 0 does not match SCSI CDB Length: 512 for SAM Opcode: 0x93 This fixes the issue by detecting when the bit is set and adjusting the size. Signed-off-by: Mike Christie <michael.christie@xxxxxxxxxx> --- drivers/target/target_core_sbc.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c index ca1b2312d6e7..6d98b016a942 100644 --- a/drivers/target/target_core_sbc.c +++ b/drivers/target/target_core_sbc.c @@ -976,7 +976,11 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops) return TCM_INVALID_CDB_FIELD; } - size = sbc_get_size(cmd, 1); + /* If NDOB is set there will not be a Data-Out buffer */ + if (cdb[1] & 0x01) + size = 0; + else + size = sbc_get_size(cmd, 1); cmd->t_task_lba = get_unaligned_be64(&cdb[12]); ret = sbc_setup_write_same(cmd, cdb[10], ops); @@ -1075,7 +1079,11 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops) return TCM_INVALID_CDB_FIELD; } - size = sbc_get_size(cmd, 1); + /* If NDOB is set there will not be a Data-Out buffer */ + if (cdb[1] & 0x01) + size = 0; + else + size = sbc_get_size(cmd, 1); cmd->t_task_lba = get_unaligned_be64(&cdb[2]); ret = sbc_setup_write_same(cmd, cdb[1], ops); -- 2.25.1