block: Stacked device atomic writes fixes
cover block: Stacked device atomic writes fixes
This series is spun off the dm atomic writes series at [0], as the first patch fixes behaviour for md raid atomic write support also.
https://lore.kernel.org/linux-block/[email protected]/T/#m42a9481059ef011f2267db1ec2e00edb1ba4758d
Based on block/6.13 . Patch 2/2 is only required for dm atomic write support, so could be added to the block/6.14 queue.
John Garry (2):
block: Ensure start sector is aligned for stacking atomic writes
block: Change blk_stack_atomic_writes_limits() unit_min check
block/blk-settings.c | 9 ++++++--- include/linux/blkdev.h | 21 ++++++++++++--------- 2 files changed, 18 insertions(+), 12 deletions(-)
Signature · 1 line
2.31.1
PATCH 1/2 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).
--- block/blk-settings.c | 7 +++++-- include/linux/blkdev.h | 21 ++++++++++++--------- 2 files changed, 17 insertions(+), 11 deletions(-)
block/blk-settings.c +5 -2
@@ -584,7 +584,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;
@@ -592,6 +592,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.
@@ -774,7 +777,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; }
include/linux/blkdev.h +12 -9
@@ -1699,6 +1699,15 @@ struct io_comp_batch {void (*complete)(struct io_comp_batch *); }; +static inline bool blk_atomic_write_start_sect_aligned (sector_t sector, +struct queue_limits *limits) +{ +unsigned int alignment =max (limits->atomic_write_hw_unit_min, + limits->atomic_write_hw_boundary); + +return IS_ALIGNED (sector, alignment >>SECTOR_SHIFT ); +} +static inline bool bdev_can_atomic_write (struct block_device *bdev) {struct request_queue *bd_queue = bdev->bd_queue;
@@ -1707,15 +1716,9 @@ static inline bool bdev_can_atomic_write(struct block_device *bdev)if (!limits->atomic_write_unit_min)return false; -if (bdev_is_partition (bdev)) { -sector_t bd_start_sect = bdev->bd_start_sect; -unsigned int alignment = -max (limits->atomic_write_unit_min, - limits->atomic_write_hw_boundary); - -if (!IS_ALIGNED (bd_start_sect, alignment >>SECTOR_SHIFT )) -return false; - } +if (bdev_is_partition (bdev)) +return blk_atomic_write_start_sect_aligned (bdev->bd_start_sect, + limits);return true; }
Signature · 1 line
2.31.1
PATCH 2/2 block: Change blk_stack_atomic_writes_limits() unit_min check
In reply to John GarryThe current check in blk_stack_atomic_writes_limits() for a bottom device supporting atomic writes is to verify that limit atomic_write_unit_min is non-zero.
This would cause a problem for device mapper queue limits calculation. This is because it uses a temporary queue_limits structure to stack the limits, before finally commiting the limits update.
The value of atomic_write_unit_min for the temporary queue_limits structure is never evaluated and so cannot be used, so use limit atomic_write_hw_unit_min.
--- block/blk-settings.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/blk-settings.c +1 -1
@@ -589,7 +589,7 @@ static void blk_stack_atomic_writes_limits(struct queue_limits *t,if (!(t->features &BLK_FEAT_ATOMIC_WRITES_STACKED )) goto unsupported; -if (!b->atomic_write_unit_min) +if (!b->atomic_write_hw_unit_min) goto unsupported;if (!blk_atomic_write_start_sect_aligned (start, b))
Signature · 1 line
2.31.1
John,
Quoted 2 lines
This series is spun off the dm atomic writes series at [0], as the first patch fixes behaviour for md raid atomic write support also.
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Quoted 7 lines · John Garry
This series is spun off the dm atomic writes series at [0], as the first patch fixes behaviour for md raid atomic write support also.
https://lore.kernel.org/linux-block/[email protected]/T/#m42a9481059ef011f2267db1ec2e00edb1ba4758d
Based on
block/6.13. Patch 2/2 is only required for dm atomic write support, so could be added to theblock/6.14queue.
Hi Jens,
Could you please consider picking these up? They apply cleanly to your block/6.14 queue
Thanks
Quoted 9 lines
John Garry (2):
block: Ensure start sector is aligned for stacking atomic writes
block: Changeblk_stack_atomic_writes_limits()unit_mincheckblock/blk-settings.c | 9 ++++++--- include/linux/blkdev.h | 21 ++++++++++++--------- 2 files changed, 18 insertions(+), 12 deletions(-)
Quoted 9 lines · John Garry
This series is spun off the dm atomic writes series at [0], as the first patch fixes behaviour for md raid atomic write support also.
https://lore.kernel.org/linux-block/[email protected]/T/#m42a9481059ef011f2267db1ec2e00edb1ba4758d
Based on
block/6.13. Patch 2/2 is only required for dm atomic write support, so could be added to theblock/6.14queue.[...]
Applied, thanks!
[1/2] block: Ensure start sector is aligned for stacking atomic writes
commit: 6564862d646e7d630929ba1ff330740bb215bdac
[2/2] block: Change blk_stack_atomic_writes_limits() unit_min check
commit: 5d1f7ee7f0b6362c9148d500aeebe49b64b64df4Best regards,
Signature · 1 line
Jens Axboe