]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
block: update validation of atomic writes boundary for stacked devices
authorJohn Garry <john.g.garry@oracle.com>
Mon, 15 Sep 2025 10:34:58 +0000 (10:34 +0000)
committerJens Axboe <axboe@kernel.dk>
Tue, 16 Sep 2025 18:29:10 +0000 (12:29 -0600)
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>
block/blk-settings.c

index 693bc8d20acf3cb4e9d5a791284e712d54bb468c..6760dbf130b2405076f5faa55d248b5ad18bb45e 100644 (file)
@@ -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;
 }