[Devel] [RFC PATCH vz9 v6 23/62] dm-ploop: make new allocations immediately visible in BAT
Andrey Zhadchenko
andrey.zhadchenko at virtuozzo.com
Fri Dec 13 15:49:01 MSK 2024
On 12/5/24 22:55, Alexander Atanasov wrote:
> From: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
>
> 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
Actually should be PIWB_TYPE_ALLOC - my bad :)
> 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 de885049e3f9..eb01eab18019 100644
> --- a/drivers/md/dm-ploop-map.c
> +++ b/drivers/md/dm-ploop-map.c
> @@ -776,6 +776,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]);
> @@ -785,12 +789,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));
> @@ -798,11 +796,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);
>
> @@ -1120,6 +1117,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;
> }
> @@ -1378,6 +1377,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);
> @@ -1402,6 +1402,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);
More information about the Devel
mailing list