Split ploop_process_delta_cow in two - list iterator and processing
functions, unify handling with other pio types.
We need this to be able to call pio by pio from threads.

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

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index 6fa94d301e0f..574ed9045c2d 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -1458,39 +1458,42 @@ static void ploop_submit_cow_index_wb(struct ploop_cow 
*cow)
        ploop_complete_cow(cow, BLK_STS_RESOURCE);
 }
 
-static void ploop_process_delta_cow(struct ploop *ploop,
-                                   struct llist_node *cow_llist)
+static void ploop_process_one_delta_cow(struct ploop *ploop, struct pio 
*aux_pio)
 {
        struct ploop_cow *cow;
-       struct pio *aux_pio;
 
+       cow = aux_pio->endio_cb_data;
+       if (unlikely(aux_pio->bi_status != BLK_STS_OK)) {
+               ploop_complete_cow(cow, aux_pio->bi_status);
+               return;
+       }
+       /* until type is changed */
+       INIT_LIST_HEAD(&aux_pio->list);
+
+       if (cow->dst_clu == BAT_ENTRY_NONE) {
+               /*
+                * Stage #1: assign dst_clu and write data
+                * to top delta.
+                */
+               ploop_submit_cluster_write(cow);
+       } else {
+               /*
+                * Stage #2: data is written to top delta.
+                * Update index.
+                */
+               ploop_submit_cow_index_wb(cow);
+       }
+}
+
+static void ploop_process_delta_cow(struct ploop *ploop,
+                                   struct llist_node *cow_llist)
+{
        struct llist_node *pos, *t;
        llist_for_each_safe(pos, t, cow_llist) {
-               aux_pio = list_entry((struct list_head *)pos, typeof(*aux_pio), 
list);
-               cow = aux_pio->endio_cb_data;
-               if (unlikely(aux_pio->bi_status != BLK_STS_OK)) {
-                       ploop_complete_cow(cow, aux_pio->bi_status);
-                       continue;
-               }
-               /* until type is changed */
-               INIT_LIST_HEAD(&aux_pio->list);
-
-               if (cow->dst_clu == BAT_ENTRY_NONE) {
-                       /*
-                        * Stage #1: assign dst_clu and write data
-                        * to top delta.
-                        */
-                       ploop_submit_cluster_write(cow);
-               } else {
-                       /*
-                        * Stage #2: data is written to top delta.
-                        * Update index.
-                        */
-                       ploop_submit_cow_index_wb(cow);
-               }
+               struct pio *aux_pio = list_entry((struct list_head *)pos, 
typeof(*aux_pio), list);
+               ploop_process_one_delta_cow(ploop, aux_pio);
        }
 }
-
 /*
  * This allocates a new clu (if clu wb is not pending yet),
  * or tries to attach a bio to a planned page index wb.
-- 
2.43.0

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

Reply via email to