diff options
| author | John Garry <john.g.garry@oracle.com> | 2025-01-09 11:39:59 +0000 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-02-08 10:00:57 +0100 |
| commit | dc0541465aee46f3a735301c5e24def1b61aaa69 (patch) | |
| tree | 0c00a5edd4c554b0c8d413389eceb3ce2e525ebc /block | |
| parent | 88b34fbc42a51c234a66607574313a2a9862ccd4 (diff) | |
| download | linux-dc0541465aee46f3a735301c5e24def1b61aaa69.tar.gz linux-dc0541465aee46f3a735301c5e24def1b61aaa69.tar.bz2 linux-dc0541465aee46f3a735301c5e24def1b61aaa69.zip | |
block: Ensure start sector is aligned for stacking atomic writes
[ Upstream commit 6564862d646e7d630929ba1ff330740bb215bdac ]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'block')
| -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 b017637d9e73..64f2e67238d7 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -608,7 +608,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; @@ -616,6 +616,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. @@ -798,7 +801,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; } |
