Rework ploop_advance_local_after_bat_wb so that if we have delayed
update to the same page is really executed and don't endup in wait_list.
Due to releasing and taking locks there was a window that a new update
could go into the wait_list. Both due to WRITEBACK bit cleared after
retaking the lock.

To fix this take all pending pios and clear the bit under lock,
using the same schema as in other code that checks the bit.
After releasing the lock displatch delayed pios.

https://virtuozzo.atlassian.net/browse/VSTOR-102677
https://virtuozzo.atlassian.net/browse/VSTOR-103768
Signed-off-by: Alexander Atanasov <alexander.atana...@virtuozzo.com>
---
 drivers/md/dm-ploop-map.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index 76544cdb476e..8ef0426e7468 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -884,11 +884,15 @@ static void ploop_advance_local_after_bat_wb(struct ploop 
*ploop,
 #endif
 
        WARN_ON_ONCE(!test_bit(MD_WRITEBACK, &md->status));
+
+       wait_llist_pending = llist_del_all(&md->wait_llist);
+
+       /* Clear flag at the end when all processing related is done */
+       clear_bit(MD_WRITEBACK, &md->status);
        spin_unlock(&md->md_lock);
        spin_unlock_irqrestore(&ploop->bat_lock, flags);
        kunmap_local(dst_clu);
 
-       wait_llist_pending = llist_del_all(&md->wait_llist);
        if (wait_llist_pending) {
                llist_for_each_safe(pos, t, wait_llist_pending) {
                        pio = list_entry((struct list_head *)pos, typeof(*pio), 
list);
@@ -900,10 +904,6 @@ static void ploop_advance_local_after_bat_wb(struct ploop 
*ploop,
        if (!list_empty(&list))
                ploop_dispatch_pios(ploop, NULL, &list);
 
-       spin_lock_irqsave(&ploop->bat_lock, flags);
-       /* Clear flag at the end when all processing related is done */
-       clear_bit(MD_WRITEBACK, &md->status);
-       spin_unlock_irqrestore(&ploop->bat_lock, flags);
 }
 
 static void ploop_free_piwb(struct ploop_index_wb *piwb)
-- 
2.43.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to