Allow stacked devices to support atomic writes by aggregating the minimum capacility of all bottom devices. If a bottom device does not support atomic writes, then BLK_FEAT_ATOMIC_WRITES should be cleared for that device, and the top device then will also not support atomic writes. Signed-off-by: John Garry <john.g.garry@xxxxxxxxxx> --- block/blk-settings.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/block/blk-settings.c b/block/blk-settings.c index 036e67f73116..aeb05fb24801 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -682,6 +682,25 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, t->zone_write_granularity = 0; t->max_zone_append_sectors = 0; } + if (!(b->features & BLK_FEAT_ATOMIC_WRITES)) { + t->atomic_write_hw_max = 0; + t->atomic_write_hw_unit_max = 0; + t->atomic_write_hw_unit_min = 0; + t->atomic_write_hw_boundary = 0; + t->features &= ~BLK_FEAT_ATOMIC_WRITES; + } else if (t->features & BLK_FEAT_ATOMIC_WRITES) { + t->atomic_write_hw_max = min_not_zero(t->atomic_write_hw_max, + b->atomic_write_hw_max); + t->atomic_write_boundary_sectors = + min_not_zero(t->atomic_write_boundary_sectors, + b->atomic_write_boundary_sectors); + t->atomic_write_hw_unit_min = max(t->atomic_write_hw_unit_min, + b->atomic_write_hw_unit_min); + t->atomic_write_hw_unit_max = + min_not_zero(t->atomic_write_hw_unit_max, + b->atomic_write_hw_unit_max); + } + return ret; } EXPORT_SYMBOL(blk_stack_limits); -- 2.31.1