Skip to content

Commit 8fcdc23

Browse files
mikechristiemartinkpetersen
authored andcommitted
scsi: target: Remove XDWRITEREAD emulated support
This patch removes XDWRITEREAD support because it never fully worked when it was added in the initial LIO merge and it's been fully broken since 2013 from commit a289008 ("target: Add compare_and_write_post() completion callback fall through"). The two issues above are: 1. XDWRITEREAD support was just never completed when LIO was merged. We never did the DISABLE WRITE check and so we never write data out. 2. Since the commit above, we never complete the command. After we do the XOR, we return from xdreadwrite_callback and that's it. We never send a response for the command, so the command will always time out and fail. Since this has been fully broken for almost nine years this patch just removes emulated support. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mike Christie <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 68126ee commit 8fcdc23

File tree

1 file changed

+0
-99
lines changed

1 file changed

+0
-99
lines changed

drivers/target/target_core_sbc.c

Lines changed: 0 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -339,68 +339,6 @@ sbc_setup_write_same(struct se_cmd *cmd, unsigned char flags, struct sbc_ops *op
339339
return 0;
340340
}
341341

342-
static sense_reason_t xdreadwrite_callback(struct se_cmd *cmd, bool success,
343-
int *post_ret)
344-
{
345-
unsigned char *buf, *addr;
346-
struct scatterlist *sg;
347-
unsigned int offset;
348-
sense_reason_t ret = TCM_NO_SENSE;
349-
int i, count;
350-
351-
if (!success)
352-
return 0;
353-
354-
/*
355-
* From sbc3r22.pdf section 5.48 XDWRITEREAD (10) command
356-
*
357-
* 1) read the specified logical block(s);
358-
* 2) transfer logical blocks from the data-out buffer;
359-
* 3) XOR the logical blocks transferred from the data-out buffer with
360-
* the logical blocks read, storing the resulting XOR data in a buffer;
361-
* 4) if the DISABLE WRITE bit is set to zero, then write the logical
362-
* blocks transferred from the data-out buffer; and
363-
* 5) transfer the resulting XOR data to the data-in buffer.
364-
*/
365-
buf = kmalloc(cmd->data_length, GFP_KERNEL);
366-
if (!buf) {
367-
pr_err("Unable to allocate xor_callback buf\n");
368-
return TCM_OUT_OF_RESOURCES;
369-
}
370-
/*
371-
* Copy the scatterlist WRITE buffer located at cmd->t_data_sg
372-
* into the locally allocated *buf
373-
*/
374-
sg_copy_to_buffer(cmd->t_data_sg,
375-
cmd->t_data_nents,
376-
buf,
377-
cmd->data_length);
378-
379-
/*
380-
* Now perform the XOR against the BIDI read memory located at
381-
* cmd->t_mem_bidi_list
382-
*/
383-
384-
offset = 0;
385-
for_each_sg(cmd->t_bidi_data_sg, sg, cmd->t_bidi_data_nents, count) {
386-
addr = kmap_atomic(sg_page(sg));
387-
if (!addr) {
388-
ret = TCM_OUT_OF_RESOURCES;
389-
goto out;
390-
}
391-
392-
for (i = 0; i < sg->length; i++)
393-
*(addr + sg->offset + i) ^= *(buf + offset + i);
394-
395-
offset += sg->length;
396-
kunmap_atomic(addr);
397-
}
398-
399-
out:
400-
kfree(buf);
401-
return ret;
402-
}
403-
404342
static sense_reason_t
405343
sbc_execute_rw(struct se_cmd *cmd)
406344
{
@@ -927,47 +865,10 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
927865
cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
928866
cmd->execute_cmd = sbc_execute_rw;
929867
break;
930-
case XDWRITEREAD_10:
931-
if (cmd->data_direction != DMA_TO_DEVICE ||
932-
!(cmd->se_cmd_flags & SCF_BIDI))
933-
return TCM_INVALID_CDB_FIELD;
934-
sectors = transport_get_sectors_10(cdb);
935-
936-
if (sbc_check_dpofua(dev, cmd, cdb))
937-
return TCM_INVALID_CDB_FIELD;
938-
939-
cmd->t_task_lba = transport_lba_32(cdb);
940-
cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
941-
942-
/*
943-
* Setup BIDI XOR callback to be run after I/O completion.
944-
*/
945-
cmd->execute_cmd = sbc_execute_rw;
946-
cmd->transport_complete_callback = &xdreadwrite_callback;
947-
break;
948868
case VARIABLE_LENGTH_CMD:
949869
{
950870
u16 service_action = get_unaligned_be16(&cdb[8]);
951871
switch (service_action) {
952-
case XDWRITEREAD_32:
953-
sectors = transport_get_sectors_32(cdb);
954-
955-
if (sbc_check_dpofua(dev, cmd, cdb))
956-
return TCM_INVALID_CDB_FIELD;
957-
/*
958-
* Use WRITE_32 and READ_32 opcodes for the emulated
959-
* XDWRITE_READ_32 logic.
960-
*/
961-
cmd->t_task_lba = transport_lba_64_ext(cdb);
962-
cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
963-
964-
/*
965-
* Setup BIDI XOR callback to be run during after I/O
966-
* completion.
967-
*/
968-
cmd->execute_cmd = sbc_execute_rw;
969-
cmd->transport_complete_callback = &xdreadwrite_callback;
970-
break;
971872
case WRITE_SAME_32:
972873
sectors = transport_get_sectors_32(cdb);
973874
if (!sectors) {

0 commit comments

Comments
 (0)