mirror of
https://github.com/hardkernel/linux.git
synced 2026-03-25 20:10:23 +09:00
FROMLIST: scsi: scsi_debug: Support injecting unaligned write errors
Allow user space software, e.g. a blktests test, to inject unaligned write errors. Cc: Martin K. Petersen <martin.petersen@oracle.com> Cc: Douglas Gilbert <dgilbert@interlog.com> Change-Id: I05beba49f97d897b46bb1dc030037d4ae461f02b Signed-off-by: Bart Van Assche <bvanassche@acm.org> Bug: 234829282 Link: https://lore.kernel.org/linux-block/20230804154821.3232094-1-bvanassche@acm.org/T/#m90e1577803b1b226a8d85c9ac6195b4c0a4d2e3f Signed-off-by: Bart Van Assche <bvanassche@google.com>
This commit is contained in:
committed by
Bart Van Assche
parent
6c0276ef82
commit
1c33b80bf7
@@ -181,6 +181,7 @@ static const char *sdebug_version_date = "20200710";
|
||||
#define SDEBUG_OPT_NO_CDB_NOISE 0x4000
|
||||
#define SDEBUG_OPT_HOST_BUSY 0x8000
|
||||
#define SDEBUG_OPT_CMD_ABORT 0x10000
|
||||
#define SDEBUG_OPT_UNALIGNED_WRITE 0x20000
|
||||
#define SDEBUG_OPT_ALL_NOISE (SDEBUG_OPT_NOISE | SDEBUG_OPT_Q_NOISE | \
|
||||
SDEBUG_OPT_RESET_NOISE)
|
||||
#define SDEBUG_OPT_ALL_INJECTING (SDEBUG_OPT_RECOVERED_ERR | \
|
||||
@@ -188,7 +189,8 @@ static const char *sdebug_version_date = "20200710";
|
||||
SDEBUG_OPT_DIF_ERR | SDEBUG_OPT_DIX_ERR | \
|
||||
SDEBUG_OPT_SHORT_TRANSFER | \
|
||||
SDEBUG_OPT_HOST_BUSY | \
|
||||
SDEBUG_OPT_CMD_ABORT)
|
||||
SDEBUG_OPT_CMD_ABORT | \
|
||||
SDEBUG_OPT_UNALIGNED_WRITE)
|
||||
#define SDEBUG_OPT_RECOV_DIF_DIX (SDEBUG_OPT_RECOVERED_ERR | \
|
||||
SDEBUG_OPT_DIF_ERR | SDEBUG_OPT_DIX_ERR)
|
||||
|
||||
@@ -3495,6 +3497,14 @@ static int resp_write_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)
|
||||
rwlock_t *macc_lckp = &sip->macc_lck;
|
||||
u8 *cmd = scp->cmnd;
|
||||
|
||||
if (unlikely(sdebug_opts & SDEBUG_OPT_UNALIGNED_WRITE &&
|
||||
atomic_read(&sdeb_inject_pending))) {
|
||||
atomic_set(&sdeb_inject_pending, 0);
|
||||
mk_sense_buffer(scp, ILLEGAL_REQUEST, LBA_OUT_OF_RANGE,
|
||||
UNALIGNED_WRITE_ASCQ);
|
||||
return check_condition_result;
|
||||
}
|
||||
|
||||
switch (cmd[0]) {
|
||||
case WRITE_16:
|
||||
ei_lba = 0;
|
||||
|
||||
Reference in New Issue
Block a user