]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
block: fix stacking of atomic writes when atomics are not supported
authorJohn Garry <john.g.garry@oracle.com>
Mon, 15 Sep 2025 10:34:59 +0000 (10:34 +0000)
committerJens Axboe <axboe@kernel.dk>
Tue, 16 Sep 2025 18:29:10 +0000 (12:29 -0600)
Atomic writes support may not always be possible when stacking devices
which support atomic writes. Such as case is a different atomic write
boundary between stacked devices (which is not supported).

In the case that atomic writes cannot supported, the top device queue HW
limits are set to 0.

However, in blk_stack_atomic_writes_limits(), we detect that we are
stacking the first bottom device by checking the top device
atomic_write_hw_max value == 0. This get confused with the case of atomic
writes not supported, above.

Make the distinction between stacking the first bottom device and no
atomics supported by initializing stacked device atomic_write_hw_max =
UINT_MAX and checking that for stacking the first bottom device.

Fixes: d7f36dc446e8 ("block: Support atomic writes limits for stacked devices")
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 6760dbf130b2405076f5faa55d248b5ad18bb45e..8fa52914e16b026ec7eccddea20dcaf749184af0 100644 (file)
@@ -56,6 +56,7 @@ void blk_set_stacking_limits(struct queue_limits *lim)
        lim->max_user_wzeroes_unmap_sectors = UINT_MAX;
        lim->max_hw_zone_append_sectors = UINT_MAX;
        lim->max_user_discard_sectors = UINT_MAX;
+       lim->atomic_write_hw_max = UINT_MAX;
 }
 EXPORT_SYMBOL(blk_set_stacking_limits);
 
@@ -232,6 +233,10 @@ static void blk_validate_atomic_write_limits(struct queue_limits *lim)
        if (!(lim->features & BLK_FEAT_ATOMIC_WRITES))
                goto unsupported;
 
+       /* UINT_MAX indicates stacked limits in initial state */
+       if (lim->atomic_write_hw_max == UINT_MAX)
+               goto unsupported;
+
        if (!lim->atomic_write_hw_max)
                goto unsupported;
 
@@ -723,18 +728,14 @@ static void blk_stack_atomic_writes_limits(struct queue_limits *t,
        if (!blk_atomic_write_start_sect_aligned(start, b))
                goto unsupported;
 
-       /*
-        * If atomic_write_hw_max is set, we have already stacked 1x bottom
-        * device, so check for compliance.
-        */
-       if (t->atomic_write_hw_max) {
+       /* UINT_MAX indicates no stacking of bottom devices yet */
+       if (t->atomic_write_hw_max == UINT_MAX) {
+               if (!blk_stack_atomic_writes_head(t, b))
+                       goto unsupported;
+       } else {
                if (!blk_stack_atomic_writes_tail(t, b))
                        goto unsupported;
-               return;
        }
-
-       if (!blk_stack_atomic_writes_head(t, b))
-               goto unsupported;
        blk_stack_atomic_writes_chunk_sectors(t);
        return;