public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
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>
Subject: [PATCH v3 3/6] block: Fix the DMA segment boundary mask check
Date: Fri, 27 Mar 2026 14:13:43 -0700	[thread overview]
Message-ID: <20260327211349.2239633-4-bvanassche@acm.org> (raw)
In-Reply-To: <20260327211349.2239633-1-bvanassche@acm.org>

Commit d690cb8ae14b ("block: add an API to atomically update queue limits")
introduced the following code:

       /*
        * By default there is no limit on the segment boundary alignment,
        * but if there is one it can't be smaller than the page size as
        * that would break all the normal I/O patterns.
        */
       if (!lim->seg_boundary_mask)
               lim->seg_boundary_mask = BLK_SEG_BOUNDARY_MASK;
       if (WARN_ON_ONCE(lim->seg_boundary_mask < PAGE_SIZE - 1))
               return -EINVAL;

The comment about "breaking normal I/O patterns" is no longer correct
since the block layer now supports DMA segments smaller than the page size.
Modify the check such that it still passes for all current block drivers.
The qedi iSCSI driver is an example of a driver that sets
.seg_boundary_mask to 0xfff.

This patch prepares for reducing the value of BLK_MIN_SEGMENT_SIZE.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 block/blk-settings.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/block/blk-settings.c b/block/blk-settings.c
index 56017098d2c7..e900405d0cc3 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -450,14 +450,14 @@ int blk_validate_limits(struct queue_limits *lim)
 
 	/*
 	 * By default there is no limit on the segment boundary alignment,
-	 * but if there is one it can't be smaller than the page size as
-	 * that would break all the normal I/O patterns.
+	 * but if there is one, check that it allows at least 4 KiB of data to
+	 * be submitted at once. All known block device DMA controllers support
+	 * 4 KiB DMA segments that do not cross 4 KiB boundaries.
 	 */
 	if (!lim->seg_boundary_mask)
 		lim->seg_boundary_mask = BLK_SEG_BOUNDARY_MASK;
-	if (WARN_ON_ONCE(lim->seg_boundary_mask < BLK_MIN_SEGMENT_SIZE - 1))
+	if (WARN_ON_ONCE(lim->seg_boundary_mask < SZ_4K - 1))
 		return -EINVAL;
-
 	/*
 	 * Stacking device may have both virtual boundary and max segment
 	 * size limit, so allow this setting now, and long-term the two

  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 ` Bart Van Assche [this message]
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 ` [PATCH v3 6/6] scsi_debug: Support configuring the maximum " 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=20260327211349.2239633-4-bvanassche@acm.org \
    --to=bvanassche@acm.org \
    --cc=axboe@kernel.dk \
    --cc=dlemoal@kernel.org \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --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