blob: 741825b9e19c0700370992724860d5e140296dc1 [file]
From f6911f1cb732ffc43b29e4ab0489258c21b9adec Mon Sep 17 00:00:00 2001
From: Sasha Levin <sashal@kernel.org>
Date: Mon, 15 Sep 2025 10:34:58 +0000
Subject: block: update validation of atomic writes boundary for stacked
devices
From: John Garry <john.g.garry@oracle.com>
[ Upstream commit bfd4037296bd7e1f95394a2e3daf8e3c1796c3b3 ]
In commit 63d092d1c1b1 ("block: use chunk_sectors when evaluating stacked
atomic write limits"), it was missed to use a chunk sectors limit check
in blk_stack_atomic_writes_boundary_head(), so update that function to
do the proper check.
Fixes: 63d092d1c1b1 ("block: use chunk_sectors when evaluating stacked atomic write limits")
Signed-off-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
block/blk-settings.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/block/blk-settings.c b/block/blk-settings.c
index 693bc8d20acf3..6760dbf130b24 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -643,18 +643,24 @@ static bool blk_stack_atomic_writes_tail(struct queue_limits *t,
static bool blk_stack_atomic_writes_boundary_head(struct queue_limits *t,
struct queue_limits *b)
{
+ unsigned int boundary_sectors;
+
+ if (!b->atomic_write_hw_boundary || !t->chunk_sectors)
+ return true;
+
+ boundary_sectors = b->atomic_write_hw_boundary >> SECTOR_SHIFT;
+
/*
* Ensure atomic write boundary is aligned with chunk sectors. Stacked
- * devices store chunk sectors in t->io_min.
+ * devices store any stripe size in t->chunk_sectors.
*/
- if (b->atomic_write_hw_boundary > t->io_min &&
- b->atomic_write_hw_boundary % t->io_min)
+ if (boundary_sectors > t->chunk_sectors &&
+ boundary_sectors % t->chunk_sectors)
return false;
- if (t->io_min > b->atomic_write_hw_boundary &&
- t->io_min % b->atomic_write_hw_boundary)
+ if (t->chunk_sectors > boundary_sectors &&
+ t->chunk_sectors % boundary_sectors)
return false;
- t->atomic_write_hw_boundary = b->atomic_write_hw_boundary;
return true;
}
@@ -695,13 +701,13 @@ static void blk_stack_atomic_writes_chunk_sectors(struct queue_limits *t)
static bool blk_stack_atomic_writes_head(struct queue_limits *t,
struct queue_limits *b)
{
- if (b->atomic_write_hw_boundary &&
- !blk_stack_atomic_writes_boundary_head(t, b))
+ if (!blk_stack_atomic_writes_boundary_head(t, b))
return false;
t->atomic_write_hw_unit_max = b->atomic_write_hw_unit_max;
t->atomic_write_hw_unit_min = b->atomic_write_hw_unit_min;
t->atomic_write_hw_max = b->atomic_write_hw_max;
+ t->atomic_write_hw_boundary = b->atomic_write_hw_boundary;
return true;
}
--
2.51.0