From: Denis V. Lunev <[email protected]>

ploop_locate_new_cluster_and_attach_pio() and
ploop_process_one_discard_pio() set MD_UPDATING on the BAT page while
they prepare its update. A pio that needs the page meanwhile is parked
in md->wait_llist by ploop_delay_if_md_busy(), and only
ploop_advance_local_after_bat_wb(), at the end of a writeback of the
page, gives the parked pios back.

When the update fails, the error path breaks it, clears MD_DIRTY and
MD_UPDATING and leaves the parked pios where they are. No writeback of
the page is queued, so they are never resubmitted: the writers hang in
D state, and after a buffered write every later sync on the host hangs
behind them until a reboot. An allocation fails this way when
ploop_prepare_bat_update() runs out of memory, when no free cluster is
left, or when the punch, zero or preallocation of the new cluster in
the top delta fails, e.g. on a write to a read-only device that needs
a new cluster.

Take the parked pios together with clearing MD_UPDATING, under
bat_lock, which every caller of ploop_delay_if_md_busy() holds, and
resubmit them with ploop_dispatch_md_waiters(), as the writeback
completion does. The error paths of ploop_prepare_reloc_index_wb() and
ploop_grow_relocate_cluster() clear MD_UPDATING without a drain too,
but they run with pio submission stopped, so nothing is parked there.

https://virtuozzo.atlassian.net/browse/VSTOR-154096

Fixes: ddf38fa44df4 ("dm-ploop: fix and rework md updates")
Reported-by: Denis Genov <[email protected]>
Feature: dm-ploop: ploop target driver
Signed-off-by: Denis V. Lunev <[email protected]>
---
 drivers/md/dm-ploop-map.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index f0569263622c..b49281691a01 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -1750,6 +1750,7 @@ static bool 
ploop_locate_new_cluster_and_attach_pio(struct ploop *ploop,
                                                    struct pio *pio)
 {
        bool bat_update_prepared = false;
+       struct llist_node *waiters;
        struct ploop_index_wb *piwb;
        bool attached = false;
        u32 page_id;
@@ -1818,7 +1819,9 @@ static bool 
ploop_locate_new_cluster_and_attach_pio(struct ploop *ploop,
        if (add_to_wblist)
                clear_bit(MD_DIRTY, &md->status);
        clear_bit(MD_UPDATING, &md->status);
+       waiters = llist_del_all(&md->wait_llist);
        spin_unlock_irqrestore(&ploop->bat_lock, flags);
+       ploop_dispatch_md_waiters(ploop, waiters);
        return false;
 }
 
@@ -2026,6 +2029,7 @@ static void ploop_process_one_discard_pio(struct ploop 
*ploop, struct pio *pio)
 {
        bool bat_update_prepared = false;
        u32 page_id, clu = pio->clu;
+       struct llist_node *waiters;
        struct ploop_index_wb *piwb;
        struct md_page *md;
        map_index_t *to;
@@ -2092,7 +2096,9 @@ static void ploop_process_one_discard_pio(struct ploop 
*ploop, struct pio *pio)
        if (add_to_wblist)
                clear_bit(MD_DIRTY, &md->status);
        clear_bit(MD_UPDATING, &md->status);
+       waiters = llist_del_all(&md->wait_llist);
        spin_unlock_irqrestore(&ploop->bat_lock, flags);
+       ploop_dispatch_md_waiters(ploop, waiters);
 }
 
 static inline int ploop_runners_have_pending(struct ploop *ploop)
-- 
2.53.0

_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to