dm: optimize flushes

Device mapper sends flush bios to all the targets and the targets send it
to the underlying device. That may be inefficient, for example if a table
contains 10 linear targets pointing to the same physical device, then
device mapper would send 10 flush bios to that device - despite the fact
that only one bio would be sufficient.

This commit optimizes the flush behavior. It introduces a per-target
variable flush_bypasses_map - it is set when the target supports flush
optimization - currently, the dm-linear and dm-stripe targets support it.
When all the targets in a table have flush_bypasses_map,
flush_bypasses_map on the table is set. __send_empty_flush tests if the
table has flush_bypasses_map - and if it has, no flush bios are sent to
the targets via the "map" method and the list dm_table->devices is
iterated and the flush bios are sent to each member of the list.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Reviewed-by: Mike Snitzer <snitzer@kernel.org>
Suggested-by: Yang Yang <yang.yang@vivo.com>
This commit is contained in:
Mikulas Patocka
2024-05-28 13:32:34 +02:00
committed by Mike Snitzer
parent cf546dd289
commit aaa53168cb
6 changed files with 61 additions and 12 deletions
+15
View File
@@ -397,6 +397,21 @@ struct dm_target {
* bio_set_dev(). NOTE: ideally a target should _not_ need this.
*/
bool needs_bio_set_dev:1;
/*
* Set if the target supports flush optimization. If all the targets in
* a table have flush_bypasses_map set, the dm core will not send
* flushes to the targets via a ->map method. It will iterate over
* dm_table->devices and send flushes to the devices directly. This
* optimization reduces the number of flushes being sent when multiple
* targets in a table use the same underlying device.
*
* This optimization may be enabled on targets that just pass the
* flushes to the underlying devices without performing any other
* actions on the flush request. Currently, dm-linear and dm-stripe
* support it.
*/
bool flush_bypasses_map:1;
};
void *dm_per_bio_data(struct bio *bio, size_t data_size);