diff options
author | John Garry <john.g.garry@oracle.com> | 2025-01-09 11:39:59 +0000 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2025-01-15 09:47:43 -0700 |
commit | 6564862d646e7d630929ba1ff330740bb215bdac (patch) | |
tree | 2bb7b407a234a226c6ec07673d876d4fb779c248 /block/blk-settings.c | |
parent | 659381520a3b13403c3051516317adc02e48259b (diff) |
block: Ensure start sector is aligned for stacking atomic writes
For stacking atomic writes, ensure that the start sector is aligned with
the device atomic write unit min and any boundary. Otherwise, we may
permit misaligned atomic writes.
Rework bdev_can_atomic_write() into a common helper to resuse the
alignment check. There also use atomic_write_hw_unit_min, which is more
proper (than atomic_write_unit_min).
Fixes: d7f36dc446e89 ("block: Support atomic writes limits for stacked devices")
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Link: https://lore.kernel.org/r/20250109114000.2299896-2-john.g.garry@oracle.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-settings.c')
-rw-r--r-- | block/blk-settings.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/block/blk-settings.c b/block/blk-settings.c index 6c96a73261d1..c2b99262db26 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -609,7 +609,7 @@ static bool blk_stack_atomic_writes_head(struct queue_limits *t, } static void blk_stack_atomic_writes_limits(struct queue_limits *t, - struct queue_limits *b) + struct queue_limits *b, sector_t start) { if (!(t->features & BLK_FEAT_ATOMIC_WRITES_STACKED)) goto unsupported; @@ -617,6 +617,9 @@ static void blk_stack_atomic_writes_limits(struct queue_limits *t, if (!b->atomic_write_unit_min) goto unsupported; + 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. @@ -799,7 +802,7 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, t->zone_write_granularity = 0; t->max_zone_append_sectors = 0; } - blk_stack_atomic_writes_limits(t, b); + blk_stack_atomic_writes_limits(t, b, start); return ret; } |