Skip to content

Commit e854fcf

Browse files
bvanasschekawasaki
authored andcommitted
scsi: scsi_debug: Support injecting unaligned write errors
Allow user space software, e.g. a blktests test, to inject unaligned write errors. Acked-by: Douglas Gilbert <dgilbert@interlog.com> Reviewed-by: Damien Le Moal <dlemoal@kernel.org> Cc: Martin K. Petersen <martin.petersen@oracle.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Ming Lei <ming.lei@redhat.com> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
1 parent f91a800 commit e854fcf

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

drivers/scsi/scsi_debug.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,14 +230,16 @@ struct tape_block {
230230
#define SDEBUG_OPT_NO_CDB_NOISE 0x4000
231231
#define SDEBUG_OPT_HOST_BUSY 0x8000
232232
#define SDEBUG_OPT_CMD_ABORT 0x10000
233+
#define SDEBUG_OPT_UNALIGNED_WRITE 0x20000
233234
#define SDEBUG_OPT_ALL_NOISE (SDEBUG_OPT_NOISE | SDEBUG_OPT_Q_NOISE | \
234235
SDEBUG_OPT_RESET_NOISE)
235236
#define SDEBUG_OPT_ALL_INJECTING (SDEBUG_OPT_RECOVERED_ERR | \
236237
SDEBUG_OPT_TRANSPORT_ERR | \
237238
SDEBUG_OPT_DIF_ERR | SDEBUG_OPT_DIX_ERR | \
238239
SDEBUG_OPT_SHORT_TRANSFER | \
239240
SDEBUG_OPT_HOST_BUSY | \
240-
SDEBUG_OPT_CMD_ABORT)
241+
SDEBUG_OPT_CMD_ABORT | \
242+
SDEBUG_OPT_UNALIGNED_WRITE)
241243
#define SDEBUG_OPT_RECOV_DIF_DIX (SDEBUG_OPT_RECOVERED_ERR | \
242244
SDEBUG_OPT_DIF_ERR | SDEBUG_OPT_DIX_ERR)
243245

@@ -4915,6 +4917,14 @@ static int resp_write_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)
49154917
u8 *cmd = scp->cmnd;
49164918
bool meta_data_locked = false;
49174919

4920+
if (unlikely(sdebug_opts & SDEBUG_OPT_UNALIGNED_WRITE &&
4921+
atomic_read(&sdeb_inject_pending))) {
4922+
atomic_set(&sdeb_inject_pending, 0);
4923+
mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE,
4924+
UNALIGNED_WRITE_ASCQ);
4925+
return check_condition_result;
4926+
}
4927+
49184928
switch (cmd[0]) {
49194929
case WRITE_16:
49204930
ei_lba = 0;

0 commit comments

Comments
 (0)