From: Bart Van Assche <bvanassche@acm.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
Damien Le Moal <dlemoal@kernel.org>,
Ming Lei <ming.lei@redhat.com>,
Bart Van Assche <bvanassche@acm.org>,
John Garry <john.g.garry@oracle.com>,
Doug Gilbert <dgilbert@interlog.com>,
"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>
Subject: [PATCH v3 6/6] scsi_debug: Support configuring the maximum segment size
Date: Fri, 27 Mar 2026 14:13:46 -0700 [thread overview]
Message-ID: <20260327211349.2239633-7-bvanassche@acm.org> (raw)
In-Reply-To: <20260327211349.2239633-1-bvanassche@acm.org>
Add a kernel module parameter for configuring the maximum segment size.
Reject invalid max_segment_size values.
This patch enables testing SCSI support for segments smaller than the
page size.
Cc: John Garry <john.g.garry@oracle.com>
Cc: Doug Gilbert <dgilbert@interlog.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/scsi/scsi_debug.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 1515495fd9ea..7e5e171bfcda 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -915,6 +915,7 @@ static int sdebug_host_max_queue; /* per host */
static int sdebug_lowest_aligned = DEF_LOWEST_ALIGNED;
static int sdebug_max_luns = DEF_MAX_LUNS;
static int sdebug_max_queue = SDEBUG_CANQUEUE; /* per submit queue */
+static unsigned int sdebug_max_segment_size = UINT_MAX;
static unsigned int sdebug_medium_error_start = OPT_MEDIUM_ERR_ADDR;
static int sdebug_medium_error_count = OPT_MEDIUM_ERR_NUM;
static int sdebug_ndelay = DEF_NDELAY; /* if > 0 then unit is nanoseconds */
@@ -1041,6 +1042,26 @@ static const int condition_met_result = SAM_STAT_CONDITION_MET;
static struct dentry *sdebug_debugfs_root;
static ASYNC_DOMAIN_EXCLUSIVE(sdebug_async_domain);
+static int sdebug_set_max_segment_size(const char *val,
+ const struct kernel_param *kp)
+{
+ int res;
+
+ res = kstrtouint(val, 0, &sdebug_max_segment_size);
+ if (res < 0)
+ return res;
+
+ if (sdebug_max_segment_size < BLK_MIN_SEGMENT_SIZE)
+ return -EINVAL;
+
+ return 0;
+}
+
+static const struct kernel_param_ops max_segment_size_ops = {
+ .set = sdebug_set_max_segment_size,
+ .get = param_get_uint,
+};
+
static u32 sdebug_get_devsel(struct scsi_device *sdp)
{
unsigned char devtype = sdp->type;
@@ -7366,6 +7387,8 @@ module_param_named(lowest_aligned, sdebug_lowest_aligned, int, S_IRUGO);
module_param_named(lun_format, sdebug_lun_am_i, int, S_IRUGO | S_IWUSR);
module_param_named(max_luns, sdebug_max_luns, int, S_IRUGO | S_IWUSR);
module_param_named(max_queue, sdebug_max_queue, int, S_IRUGO | S_IWUSR);
+module_param_cb(max_segment_size, &max_segment_size_ops,
+ &sdebug_max_segment_size, S_IRUGO);
module_param_named(medium_error_count, sdebug_medium_error_count, int,
S_IRUGO | S_IWUSR);
module_param_named(medium_error_start, sdebug_medium_error_start, int,
@@ -7449,6 +7472,7 @@ MODULE_PARM_DESC(lowest_aligned, "lowest aligned lba (def=0)");
MODULE_PARM_DESC(lun_format, "LUN format: 0->peripheral (def); 1 --> flat address method");
MODULE_PARM_DESC(max_luns, "number of LUNs per target to simulate(def=1)");
MODULE_PARM_DESC(max_queue, "max number of queued commands (1 to max(def))");
+MODULE_PARM_DESC(max_segment_size, "max bytes in a single DMA segment");
MODULE_PARM_DESC(medium_error_count, "count of sectors to return follow on MEDIUM error");
MODULE_PARM_DESC(medium_error_start, "starting sector number to return MEDIUM error");
MODULE_PARM_DESC(ndelay, "response delay in nanoseconds (def=0 -> ignore)");
@@ -9539,7 +9563,6 @@ static const struct scsi_host_template sdebug_driver_template = {
.sg_tablesize = SG_MAX_SEGMENTS,
.cmd_per_lun = DEF_CMD_PER_LUN,
.max_sectors = -1U,
- .max_segment_size = -1U,
.module = THIS_MODULE,
.skip_settle_delay = 1,
.track_queue_depth = 1,
@@ -9566,6 +9589,7 @@ static int sdebug_driver_probe(struct device *dev)
}
hpnt->can_queue = sdebug_max_queue;
hpnt->cmd_per_lun = sdebug_max_queue;
+ hpnt->max_segment_size = sdebug_max_segment_size;
if (!sdebug_clustering)
hpnt->dma_boundary = PAGE_SIZE - 1;
prev parent reply other threads:[~2026-03-27 21:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-27 21:13 [PATCH v3 0/6] Enable testing small DMA segment sizes Bart Van Assche
2026-03-27 21:13 ` [PATCH v3 1/6] block: Fix a source code comment Bart Van Assche
2026-03-27 21:13 ` [PATCH v3 2/6] block: Fix the max_user_sectors lower bound Bart Van Assche
2026-03-27 21:13 ` [PATCH v3 3/6] block: Fix the DMA segment boundary mask check Bart Van Assche
2026-03-27 21:13 ` [PATCH v3 4/6] block: Reduce the minimum value for the maximum DMA segment size Bart Van Assche
2026-03-29 14:38 ` Ming Lei
2026-03-27 21:13 ` [PATCH v3 5/6] null_blk: Support configuring " Bart Van Assche
2026-03-29 12:30 ` Nilay Shroff
2026-03-30 2:23 ` Ming Lei
2026-03-27 21:13 ` Bart Van Assche [this message]
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=20260327211349.2239633-7-bvanassche@acm.org \
--to=bvanassche@acm.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=axboe@kernel.dk \
--cc=dgilbert@interlog.com \
--cc=dlemoal@kernel.org \
--cc=hch@lst.de \
--cc=john.g.garry@oracle.com \
--cc=linux-block@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