Skip to content

Commit b719125

Browse files
author
Nicholas Bellinger
committed
target: Reset data_length for COMPARE_AND_WRITE to NoLB * block_size
This patch resets se_cmd->data_length for COMPARE_AND_WRITE emulation within sbc_compare_and_write() to NoLB * block_size in order to address a bug with FILEIO backends where a I/O failure will occur when data_length does not match the I/O size being actually dispatched for the individual per block READs + WRITEs. This is done late enough in sbc_compare_and_write() after the memory allocations have occured in transport_generic_new_cmd() to not cause any unwanted side-effects. Reported-by: Thomas Glanzmann <[email protected]> Tested-by: Thomas Glanzmann <[email protected]> Signed-off-by: Nicholas Bellinger <[email protected]>
1 parent c807f64 commit b719125

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/target/target_core_sbc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,12 @@ sbc_compare_and_write(struct se_cmd *cmd)
508508
cmd->transport_complete_callback = NULL;
509509
return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
510510
}
511+
/*
512+
* Reset cmd->data_length to individual block_size in order to not
513+
* confuse backend drivers that depend on this value matching the
514+
* size of the I/O being submitted.
515+
*/
516+
cmd->data_length = cmd->t_task_nolb * dev->dev_attrib.block_size;
511517

512518
ret = cmd->execute_rw(cmd, cmd->t_bidi_data_sg, cmd->t_bidi_data_nents,
513519
DMA_FROM_DEVICE);

0 commit comments

Comments
 (0)