[Devel] [PATCH VZ9 v3 07/13] dm-ploop: speed up ploop_prepare_bat_update()
Andrey Zhadchenko
andrey.zhadchenko at virtuozzo.com
Thu Oct 24 20:23:35 MSK 2024
Drop ploop_cluster_is_in_top_delta(), because
- it internally searches md on every call
- it takes read lock every time
https://virtuozzo.atlassian.net/browse/VSTOR-91817
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
---
drivers/md/dm-ploop-map.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index b160dd00e497..76d344a7bcad 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -885,13 +885,14 @@ static void ploop_bat_write_complete(struct pio *pio, void *piwb_ptr,
static int ploop_prepare_bat_update(struct ploop *ploop, struct md_page *md,
enum piwb_type type)
{
- u32 i, off, last, *bat_entries;
+ u32 i, off, last, *bat_entries, clu;
struct ploop_index_wb *piwb;
bool is_last_page = true;
u32 page_id = md->id;
struct page *page;
struct pio *pio;
map_index_t *to;
+ u8 level;
piwb = kmalloc(sizeof(*piwb), GFP_NOIO);
if (!piwb)
@@ -914,6 +915,8 @@ static int ploop_prepare_bat_update(struct ploop *ploop, struct md_page *md,
piwb->page_id = page_id;
to = piwb->kmpage;
+
+ read_lock_irq(&md->lock);
memcpy((void *)to, bat_entries, PAGE_SIZE);
/* Absolute number of first index in page (negative for page#0) */
@@ -932,10 +935,14 @@ static int ploop_prepare_bat_update(struct ploop *ploop, struct md_page *md,
/* Copy BAT (BAT goes right after hdr, see .ctr) */
for (; i < last; i++) {
- if (ploop_cluster_is_in_top_delta(ploop, i + off))
- continue;
- to[i] = 0;
+ level = md->bat_levels[i];
+ clu = READ_ONCE(bat_entries[i]);
+
+ if (clu == BAT_ENTRY_NONE || level < ploop_top_level(ploop))
+ to[i] = 0;
}
+ read_unlock_irq(&md->lock);
+
if (is_last_page) {
/* Fill tail of page with 0 */
for (i = last; i < PAGE_SIZE / sizeof(map_index_t); i++)
--
2.39.3
More information about the Devel
mailing list