All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block: cap atomic write size by PI buffer size constraints take #2
@ 2026-09-14 13:23 John Garry
  2026-09-15  9:01 ` Christoph Hellwig
  2026-09-15 12:53 ` Jens Axboe
  0 siblings, 2 replies; 3+ messages in thread
From: John Garry @ 2026-09-14 13:23 UTC (permalink / raw)
  To: axboe, hch; +Cc: mkp, linux-block, John Garry

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] block: cap atomic write size by PI buffer size constraints take #2
  2026-09-14 13:23 [PATCH] block: cap atomic write size by PI buffer size constraints take #2 John Garry
@ 2026-09-15  9:01 ` Christoph Hellwig
  2026-09-15 12:53 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2026-09-15  9:01 UTC (permalink / raw)
  To: John Garry; +Cc: axboe, hch, mkp, linux-block

On Mon, Sep 14, 2026 at 02:23:23PM +0100, John Garry wrote:
> 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.

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] block: cap atomic write size by PI buffer size constraints take #2
  2026-09-14 13:23 [PATCH] block: cap atomic write size by PI buffer size constraints take #2 John Garry
  2026-09-15  9:01 ` Christoph Hellwig
@ 2026-09-15 12:53 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2026-09-15 12:53 UTC (permalink / raw)
  To: hch, John Garry; +Cc: mkp, linux-block


On Mon, 14 Sep 2026 14:23:23 +0100, John Garry wrote:
> 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.
> 
> [...]

Applied, thanks!

[1/1] block: cap atomic write size by PI buffer size constraints take #2
      commit: 657fe9c4f08355da51dc035547f221be3e79454f

Best regards,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-15 12:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-14 13:23 [PATCH] block: cap atomic write size by PI buffer size constraints take #2 John Garry
2026-09-15  9:01 ` Christoph Hellwig
2026-09-15 12:53 ` Jens Axboe

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.