[Devel] [PATCH VZ9 v3 08/13] dm-ploop: make new allocations immediately visible in BAT
Andrey Zhadchenko
andrey.zhadchenko at virtuozzo.com
Thu Oct 24 20:23:36 MSK 2024
We are planning to delay metadata writeback, so we want to
immediately apply metadata changes to BAT page.
Make all request that trigger PIWB_TYPE_RELOC apply metadata
changes immediately.
https://virtuozzo.atlassian.net/browse/VSTOR-91817
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
---
drivers/md/dm-ploop-map.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index 76d344a7bcad..fb16f7e66dd2 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -762,6 +762,10 @@ static void ploop_advance_local_after_bat_wb(struct ploop *ploop,
dst_clu = piwb->kmpage;
+ write_lock_irqsave(&md->lock, flags);
+ if (piwb->type == PIWB_TYPE_ALLOC)
+ goto skip_apply;
+
for (; i < last; i++) {
if (piwb->type == PIWB_TYPE_DISCARD) {
ploop_piwb_discard_completed(ploop, success, i + off, dst_clu[i]);
@@ -771,12 +775,6 @@ static void ploop_advance_local_after_bat_wb(struct ploop *ploop,
if (!dst_clu[i])
continue;
- if (ploop_cluster_is_in_top_delta(ploop, i + off)
- && piwb->type == PIWB_TYPE_ALLOC) {
- WARN_ON(bat_entries[i] != dst_clu[i]);
- continue;
- }
-
if (success) {
bat_entries[i] = READ_ONCE(dst_clu[i]);
WRITE_ONCE(md->bat_levels[i], ploop_top_level(ploop));
@@ -784,11 +782,10 @@ static void ploop_advance_local_after_bat_wb(struct ploop *ploop,
ploop_hole_set_bit(i + off, ploop);
}
}
+skip_apply:
WARN_ON_ONCE(!test_bit(MD_WRITEBACK, &md->status));
clear_bit(MD_WRITEBACK, &md->status);
- /* protect piwb */
- write_lock_irqsave(&md->lock, flags);
md->piwb = NULL;
write_unlock_irqrestore(&md->lock, flags);
@@ -1123,6 +1120,8 @@ static int ploop_alloc_cluster(struct ploop *ploop, struct ploop_index_wb *piwb,
to = piwb->kmpage;
WRITE_ONCE(to[clu], *dst_clu);
+ to = piwb->md->kmpage;
+ WRITE_ONCE(to[clu], *dst_clu);
out:
return ret;
}
@@ -1379,6 +1378,7 @@ static void ploop_submit_cow_index_wb(struct ploop_cow *cow)
u32 page_id, clu = cow_pio->clu;
struct ploop_index_wb *piwb;
struct md_page *md;
+ unsigned long flags;
map_index_t *to;
WARN_ON_ONCE(cow->aux_pio->queue_list_id != PLOOP_LIST_COW);
@@ -1403,6 +1403,12 @@ static void ploop_submit_cow_index_wb(struct ploop_cow *cow)
WARN_ON(to[clu]);
WRITE_ONCE(to[clu], cow->dst_clu);
+ write_lock_irqsave(&md->lock, flags);
+ to = md->kmpage;
+ WRITE_ONCE(to[clu], cow->dst_clu);
+ WRITE_ONCE(md->bat_levels[clu], ploop_top_level(ploop));
+ write_unlock_irqrestore(&md->lock, flags);
+
/* Prevent double clearing of holes_bitmap bit on complete_cow() */
cow->dst_clu = BAT_ENTRY_NONE;
spin_lock_irq(&ploop->deferred_lock);
--
2.39.3
More information about the Devel
mailing list