All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Garry <john.garry@linux.dev>
To: axboe@kernel.dk, hch@lst.de
Cc: mkp@kernel.org, linux-block@vger.kernel.org,
	John Garry <john.garry@linux.dev>
Subject: [PATCH] block: cap atomic write size by PI buffer size constraints take #2
Date: Mon, 14 Sep 2026 14:23:23 +0100	[thread overview]
Message-ID: <20260914132323.208321-1-john.garry@linux.dev> (raw)

Commit 1418b5633ca9 ("block: cap atomic write size by PI buffer size
constraints") attempted to fix atomic writes limits according to integrity
limits. However, it just reduced the atomic_write_max_sectors. The other
atomic write limits - unit min and unit max - are not derived directly
from this value.

Update blk_atomic_writes_update_limits() to properly set the atomic write
limits according to integrity limits.

Signed-off-by: John Garry <john.garry@linux.dev>

diff --git a/block/blk-settings.c b/block/blk-settings.c
index e469baa1f08b..1f5ee2453269 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -206,12 +206,6 @@ static int blk_validate_integrity_limits(struct queue_limits *lim)
 	lim->max_sectors = min(lim->max_sectors,
 		max_integrity_io_size(lim) >> SECTOR_SHIFT);
 
-	if (lim->features & BLK_FEAT_ATOMIC_WRITES) {
-		lim->atomic_write_max_sectors =
-			min(lim->atomic_write_max_sectors,
-				max_integrity_io_size(lim) >> SECTOR_SHIFT);
-	}
-
 	return 0;
 }
 
@@ -236,14 +230,20 @@ static unsigned int blk_queue_max_guaranteed_bio(struct queue_limits *lim)
 
 static void blk_atomic_writes_update_limits(struct queue_limits *lim)
 {
+	unsigned int integrity_max = lim->integrity.metadata_size ?
+					max_integrity_io_size(lim) : 0;
 	unsigned int unit_limit = min(lim->max_hw_sectors << SECTOR_SHIFT,
 					blk_queue_max_guaranteed_bio(lim));
 
+	unit_limit = min_not_zero(unit_limit, integrity_max);
 	unit_limit = rounddown_pow_of_two(unit_limit);
 
 	lim->atomic_write_max_sectors =
 		min(lim->atomic_write_hw_max >> SECTOR_SHIFT,
 			lim->max_hw_sectors);
+	lim->atomic_write_max_sectors =
+		min_not_zero(lim->atomic_write_max_sectors,
+				integrity_max >> SECTOR_SHIFT);
 	lim->atomic_write_unit_min =
 		min(lim->atomic_write_hw_unit_min, unit_limit);
 	lim->atomic_write_unit_max =
@@ -511,11 +511,13 @@ int blk_validate_limits(struct queue_limits *lim)
 	if (!(lim->features & BLK_FEAT_WRITE_CACHE))
 		lim->features &= ~BLK_FEAT_FUA;
 
-	blk_validate_atomic_write_limits(lim);
-
 	err = blk_validate_integrity_limits(lim);
 	if (err)
 		return err;
+
+	/* atomics limits depend on integrity limits */
+	blk_validate_atomic_write_limits(lim);
+
 	return blk_validate_zoned_limits(lim);
 }
 EXPORT_SYMBOL_GPL(blk_validate_limits);
-- 
2.43.0


             reply	other threads:[~2026-09-14 13:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14 13:23 John Garry [this message]
2026-09-15  9:01 ` [PATCH] block: cap atomic write size by PI buffer size constraints take #2 Christoph Hellwig
2026-09-15 12:53 ` Jens Axboe

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=20260914132323.208321-1-john.garry@linux.dev \
    --to=john.garry@linux.dev \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=mkp@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.