From: Andrey Zhadchenko <andrey.zhadche...@virtuozzo.com> On every flush request we should submit all accumulated metadata changes, wait for their completion and only then do the flush.
https://virtuozzo.atlassian.net/browse/VSTOR-91817 Signed-off-by: Andrey Zhadchenko <andrey.zhadche...@virtuozzo.com> --- drivers/md/dm-ploop-map.c | 42 ++++++++++++++++++++++++++++++++++++ drivers/md/dm-ploop-target.c | 2 +- drivers/md/dm-ploop.h | 3 +++ 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c index d6cfec430e45..8b72b5680a2b 100644 --- a/drivers/md/dm-ploop-map.c +++ b/drivers/md/dm-ploop-map.c @@ -68,6 +68,7 @@ void ploop_index_wb_init(struct ploop_index_wb *piwb, struct ploop *ploop) piwb->completed = false; piwb->page_id = PAGE_NR_NONE; piwb->type = PIWB_TYPE_ALLOC; + piwb->flush_pio = NULL; } void ploop_init_pio(struct ploop *ploop, unsigned int bi_op, struct pio *pio) @@ -870,6 +871,7 @@ static void ploop_bat_write_complete(struct pio *pio, void *piwb_ptr, blk_status_t bi_status) { struct ploop_index_wb *piwb = piwb_ptr; + struct pio *flush_pio = piwb->flush_pio; struct ploop *ploop = piwb->ploop; struct pio *aux_pio; struct ploop_cow *cow; @@ -908,6 +910,12 @@ static void ploop_bat_write_complete(struct pio *pio, void *piwb_ptr, ploop_complete_cow(cow, bi_status); } + if (flush_pio) { + if (atomic_dec_and_test(&flush_pio->md_inflight)) + ploop_dispatch_pios(ploop, flush_pio, NULL); + piwb->flush_pio = NULL; + } + /* * In case of update BAT is failed, dst_clusters will be * set back to holes_bitmap on last put_piwb(). @@ -1964,6 +1972,35 @@ int ploop_worker(void *data) } +static void ploop_prepare_flush(struct ploop *ploop, struct pio *pio) +{ + struct md_page *md, *n; + int md_inflight = 0; + + write_lock_irq(&ploop->bat_rwlock); + + list_for_each_entry(md, &ploop->wb_batch_list_prio, wb_link) { + md_inflight++; + md->piwb->flush_pio = pio; + } + + list_for_each_entry_safe(md, n, &ploop->wb_batch_list, wb_link) { + md_inflight++; + md->piwb->flush_pio = pio; + list_del(&md->wb_link); + list_add_tail(&md->wb_link, &ploop->wb_batch_list_prio); + } + + atomic_set(&pio->md_inflight, md_inflight); + + write_unlock_irq(&ploop->bat_rwlock); + + if (md_inflight) + queue_work(ploop->wq, &ploop->worker); + else + ploop_dispatch_pios(ploop, pio, NULL); +} + static void ploop_submit_embedded_pio(struct ploop *ploop, struct pio *pio) { struct ploop_rq *prq = pio->endio_cb_data; @@ -1989,6 +2026,11 @@ static void ploop_submit_embedded_pio(struct ploop *ploop, struct pio *pio) ploop_inc_nr_inflight(ploop, pio); + if ((pio->bi_op & REQ_OP_MASK) == REQ_OP_FLUSH) { + ploop_prepare_flush(ploop, pio); + return; + } + if (pio->queue_list_id == PLOOP_LIST_FLUSH) { /* Let the FLUSH go last from the queue , do not run here to preserve ordering */ llist_add((struct llist_node *)(&pio->list), &ploop->pios[PLOOP_LIST_PREPARE]); diff --git a/drivers/md/dm-ploop-target.c b/drivers/md/dm-ploop-target.c index e5a75e87ae39..53ad6049624a 100644 --- a/drivers/md/dm-ploop-target.c +++ b/drivers/md/dm-ploop-target.c @@ -386,7 +386,7 @@ static struct ploop_worker *ploop_worker_create(struct ploop *ploop) kfree(worker); return NULL; } -#endif + /* * <data dev> */ diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h index 8f6e89412fb6..406d27192776 100644 --- a/drivers/md/dm-ploop.h +++ b/drivers/md/dm-ploop.h @@ -109,6 +109,7 @@ struct ploop_index_wb { blk_status_t bi_status; u32 page_id; struct bio_vec aux_bvec; + struct pio *flush_pio; }; /* Metadata page */ @@ -302,6 +303,8 @@ struct pio { int ret; /* iocb result */ void (*complete)(struct pio *me); void *data; + + atomic_t md_inflight; }; /* Delta COW private */ -- 2.43.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel