linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org,
	Christoph Hellwig <hch@lst.de>,
	Damien Le Moal <dlemoal@kernel.org>,
	Bart Van Assche <bvanassche@acm.org>,
	Douglas Gilbert <dgilbert@interlog.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Ming Lei <ming.lei@redhat.com>
Subject: [PATCH v24 17/18] scsi: scsi_debug: Support injecting unaligned write errors
Date: Wed, 27 Aug 2025 14:29:36 -0700	[thread overview]
Message-ID: <20250827212937.2759348-18-bvanassche@acm.org> (raw)
In-Reply-To: <20250827212937.2759348-1-bvanassche@acm.org>

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>
---
 drivers/scsi/scsi_debug.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 2eeed9f63c69..8465b3346876 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -230,6 +230,7 @@ struct tape_block {
 #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 | \
@@ -237,7 +238,8 @@ struct tape_block {
 				  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)
 
@@ -4938,6 +4940,14 @@ static int resp_write_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)
 	u8 *cmd = scp->cmnd;
 	bool meta_data_locked = false;
 
+	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;

  parent reply	other threads:[~2025-08-27 21:31 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-27 21:29 [PATCH v24 00/18] Improve write performance for zoned UFS devices Bart Van Assche
2025-08-27 21:29 ` [PATCH v24 01/18] block: Support block devices that preserve the order of write requests Bart Van Assche
2025-08-27 21:29 ` [PATCH v24 02/18] blk-mq: Always insert sequential zoned writes into a software queue Bart Van Assche
2025-08-27 21:29 ` [PATCH v24 03/18] blk-mq: Restore the zone write order when requeuing Bart Van Assche
2025-08-27 21:29 ` [PATCH v24 04/18] blk-mq: Move the blk_queue_sq_sched() calls Bart Van Assche
2025-08-27 21:29 ` [PATCH v24 05/18] blk-mq: Run all hwqs for sq scheds if write pipelining is enabled Bart Van Assche
2025-08-27 21:29 ` [PATCH v24 06/18] block/mq-deadline: Enable zoned write pipelining Bart Van Assche
2025-08-27 21:29 ` [PATCH v24 07/18] blk-zoned: Add an argument to blk_zone_plug_bio() Bart Van Assche
2025-08-27 21:29 ` [PATCH v24 08/18] blk-zoned: Split an if-statement Bart Van Assche
2025-08-27 21:29 ` [PATCH v24 09/18] blk-zoned: Move code from disk_zone_wplug_add_bio() into its caller Bart Van Assche
2025-08-27 21:29 ` [PATCH v24 10/18] blk-zoned: Introduce a loop in blk_zone_wplug_bio_work() Bart Van Assche
2025-08-27 21:29 ` [PATCH v24 11/18] blk-zoned: Document disk_zone_wplug_schedule_bio_work() locking Bart Van Assche
2025-08-27 21:29 ` [PATCH v24 12/18] blk-zoned: Support pipelining of zoned writes Bart Van Assche
2025-08-27 21:29 ` [PATCH v24 13/18] null_blk: Add the preserves_write_order attribute Bart Van Assche
2025-08-27 21:29 ` [PATCH v24 14/18] scsi: core: Retry unaligned zoned writes Bart Van Assche
2025-08-27 21:29 ` [PATCH v24 15/18] scsi: sd: Increase retry count for " Bart Van Assche
2025-08-27 21:29 ` [PATCH v24 16/18] scsi: scsi_debug: Add the preserves_write_order module parameter Bart Van Assche
2025-08-27 21:29 ` Bart Van Assche [this message]
2025-08-27 21:29 ` [PATCH v24 18/18] ufs: core: Inform the block layer about write ordering Bart Van Assche
2025-08-28 11:23 ` [PATCH v24 00/18] Improve write performance for zoned UFS devices Hannes Reinecke
2025-08-28 13:32   ` Bart Van Assche

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250827212937.2759348-18-bvanassche@acm.org \
    --to=bvanassche@acm.org \
    --cc=axboe@kernel.dk \
    --cc=dgilbert@interlog.com \
    --cc=dlemoal@kernel.org \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=ming.lei@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).