[Devel] [PATCH RH8 1/3] ploop: Use local piwb in resize

Kirill Tkhai ktkhai at virtuozzo.com
Wed Jun 23 18:12:34 MSK 2021


Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/md/dm-ploop-cmd.c |   17 ++++++++---------
 drivers/md/dm-ploop-map.c |    4 ++--
 drivers/md/dm-ploop.h     |    4 ++--
 3 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index 914a44725270..7a971be34e65 100644
--- a/drivers/md/dm-ploop-cmd.c
+++ b/drivers/md/dm-ploop-cmd.c
@@ -398,12 +398,14 @@ static void ploop_add_md_pages(struct ploop *ploop, struct rb_root *from)
  * This is called from deferred work -- the only place we alloc clusters.
  * So, nobody can reallocate clusters updated in ploop_grow_relocate_cluster().
  */
-static void process_resize_cmd(struct ploop *ploop, struct ploop_index_wb *piwb,
-			       struct ploop_cmd *cmd)
+static void process_resize_cmd(struct ploop *ploop, struct ploop_cmd *cmd)
 {
+	struct ploop_index_wb piwb;
 	unsigned int dst_cluster;
 	int ret = 0;
 
+	ploop_index_wb_init(&piwb, ploop);
+
 	/*
 	 *  Update memory arrays and hb_nr, but do not update nr_bat_entries.
 	 *  This is noop except first enter to this function.
@@ -411,7 +413,7 @@ static void process_resize_cmd(struct ploop *ploop, struct ploop_index_wb *piwb,
 	ploop_advance_holes_bitmap(ploop, cmd);
 
 	if (cmd->resize.dst_cluster <= cmd->resize.end_dst_cluster) {
-		ret = ploop_grow_relocate_cluster(ploop, piwb, cmd);
+		ret = ploop_grow_relocate_cluster(ploop, &piwb, cmd);
 		if (ret)
 			goto out;
 
@@ -420,7 +422,7 @@ static void process_resize_cmd(struct ploop *ploop, struct ploop_index_wb *piwb,
 		return;
 	} else {
 		/* Update header metadata */
-		ret = ploop_grow_update_header(ploop, piwb, cmd);
+		ret = ploop_grow_update_header(ploop, &piwb, cmd);
 	}
 
 out:
@@ -1171,7 +1173,7 @@ static int ploop_flip_upper_deltas(struct ploop *ploop)
 }
 
 /* Handle user commands requested via "message" interface */
-void process_deferred_cmd(struct ploop *ploop, struct ploop_index_wb *piwb)
+void process_deferred_cmd(struct ploop *ploop)
 	__releases(&ploop->deferred_lock)
 	__acquires(&ploop->deferred_lock)
 {
@@ -1183,11 +1185,8 @@ void process_deferred_cmd(struct ploop *ploop, struct ploop_index_wb *piwb)
 	ploop->deferred_cmd = NULL;
 	spin_unlock_irq(&ploop->deferred_lock);
 
-	/* There must not be a pending index wb */
-	WARN_ON(piwb->page_nr != PAGE_NR_NONE);
-
 	if (cmd->type == PLOOP_CMD_RESIZE) {
-		process_resize_cmd(ploop, piwb, cmd);
+		process_resize_cmd(ploop, cmd);
 	} else if (cmd->type == PLOOP_CMD_MERGE_SNAPSHOT) {
 		process_merge_latest_snapshot_cmd(ploop, cmd);
 	} else {
diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index c3fd80b5c937..05b93f98adb8 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -48,7 +48,7 @@ static unsigned int pio_nr_segs(struct pio *pio)
         return nr_segs;
 }
 
-static void ploop_index_wb_init(struct ploop_index_wb *piwb, struct ploop *ploop)
+void ploop_index_wb_init(struct ploop_index_wb *piwb, struct ploop *ploop)
 {
 	piwb->ploop = ploop;
 	init_completion(&piwb->comp);
@@ -1546,7 +1546,7 @@ void do_ploop_work(struct work_struct *ws)
 	ploop_index_wb_init(&piwb, ploop);
 
 	spin_lock_irq(&ploop->deferred_lock);
-	process_deferred_cmd(ploop, &piwb);
+	process_deferred_cmd(ploop);
 	process_delta_wb(ploop, &piwb);
 
 	list_splice_init(&ploop->deferred_pios, &deferred_pios);
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index 08262e5e48ca..f518278c8be3 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -500,8 +500,7 @@ extern void defer_pios(struct ploop *ploop, struct pio *pio, struct list_head *p
 extern void do_ploop_work(struct work_struct *ws);
 extern void do_ploop_fsync_work(struct work_struct *ws);
 extern void ploop_event_work(struct work_struct *work);
-extern void process_deferred_cmd(struct ploop *ploop,
-			struct ploop_index_wb *piwb);
+extern void process_deferred_cmd(struct ploop *ploop);
 extern int ploop_clone_and_map(struct dm_target *ti, struct request *rq,
 		    union map_info *map_context, struct request **clone);
 extern struct pio *find_lk_of_cluster(struct ploop *ploop, u32 cluster);
@@ -527,6 +526,7 @@ extern void pio_prepare_offsets(struct ploop *, struct pio *, unsigned int);
 extern int ploop_setup_metadata(struct ploop *ploop, struct page *page);
 extern int ploop_read_delta_metadata(struct ploop *ploop, struct file *file,
 				     void **d_hdr);
+extern void ploop_index_wb_init(struct ploop_index_wb *piwb, struct ploop *ploop);
 extern void ploop_call_rw_iter(struct file *file, loff_t pos, unsigned rw,
 			       struct iov_iter *iter, struct pio *pio);
 extern void ploop_enospc_timer(struct timer_list *timer);




More information about the Devel mailing list