[Devel] [PATCH RHEL7 COMMIT] ploop: factor ->write_page() out

Konstantin Khorenko khorenko at virtuozzo.com
Tue Aug 9 01:29:59 PDT 2016


The commit is pushed to "branch-rh7-3.10.0-327.22.2.vz7.16.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.22.2.vz7.16.3
------>
commit 33522bc8939e28e4496b2527969e61c9ff21166b
Author: Maxim Patlasov <mpatlasov at virtuozzo.com>
Date:   Tue Aug 9 12:29:58 2016 +0400

    ploop: factor ->write_page() out
    
    Simple re-work. No logic changed. Will be useful for the next patch.
    
    Signed-off-by: Maxim Patlasov <mpatlasov at virtuozzo.com>
    Acked-by: Dmitry Monakhov <dmonakhov at openvz.org>
---
 drivers/block/ploop/map.c   | 39 +++++++++++++++++++++++++--------------
 include/linux/ploop/ploop.h |  2 ++
 2 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/drivers/block/ploop/map.c b/drivers/block/ploop/map.c
index 1883674..5f7fd66 100644
--- a/drivers/block/ploop/map.c
+++ b/drivers/block/ploop/map.c
@@ -896,6 +896,25 @@ static void copy_index_for_wb(struct page * page, struct map_node * m, int level
 	}
 }
 
+
+void ploop_index_wb_proceed(struct ploop_request * preq)
+{
+	struct map_node * m = preq->map;
+	struct ploop_delta * top_delta = map_top_delta(m->parent);
+	struct page * page = preq->sinfo.wi.tpage;
+	unsigned long rw = preq->req_index_update_rw;
+	sector_t sec;
+
+	preq->eng_state = PLOOP_E_INDEX_WB;
+
+	top_delta->ops->map_index(top_delta, m->mn_start, &sec);
+
+	__TRACE("wbi-proceed %p %u %p\n", preq, preq->req_cluster, m);
+	top_delta->io.ops->write_page(&top_delta->io, preq, page, sec, rw);
+
+	put_page(page);
+}
+
 /* Data write is commited. Now we need to update index. */
 
 void ploop_index_update(struct ploop_request * preq)
@@ -907,8 +926,6 @@ void ploop_index_update(struct ploop_request * preq)
 	map_index_t blk;
 	int old_level;
 	struct page * page;
-	sector_t sec;
-	unsigned long rw;
 	unsigned long state = READ_ONCE(preq->state);
 
 	/* No way back, we are going to initiate index write. */
@@ -955,15 +972,13 @@ void ploop_index_update(struct ploop_request * preq)
 
 	((map_index_t*)page_address(page))[idx] = preq->iblock << ploop_map_log(plo);
 
-	preq->eng_state = PLOOP_E_INDEX_WB;
 	get_page(page);
 	preq->sinfo.wi.tpage = page;
 
 	__TRACE("wbi %p %u %p\n", preq, preq->req_cluster, m);
 	plo->st.map_single_writes++;
-	top_delta->ops->map_index(top_delta, m->mn_start, &sec);
 
-	rw = (preq->req_rw & (REQ_FUA | REQ_FLUSH));
+	preq->req_index_update_rw = (preq->req_rw & (REQ_FUA | REQ_FLUSH));
 
 	/* We've just set REQ_FLUSH in rw, ->write_page() below
 	   will do the FLUSH */
@@ -971,11 +986,9 @@ void ploop_index_update(struct ploop_request * preq)
 
 	/* Relocate requires consistent index update */
 	if (state & (PLOOP_REQ_RELOC_A_FL|PLOOP_REQ_RELOC_S_FL))
-		rw |= (REQ_FLUSH | REQ_FUA);
+		preq->req_index_update_rw |= (REQ_FLUSH | REQ_FUA);
 
-	top_delta->io.ops->write_page(&top_delta->io, preq, page, sec, rw);
-
-	put_page(page);
+	ploop_index_wb_proceed(preq);
 	return;
 
 enomem:
@@ -991,6 +1004,7 @@ out:
 }
 EXPORT_SYMBOL(ploop_index_update);
 
+
 int map_index(struct ploop_delta * delta, struct ploop_request * preq, unsigned long *sec)
 {
 	return delta->ops->map_index(delta, preq->map->mn_start, sec);
@@ -1094,7 +1108,6 @@ static void map_wb_complete(struct map_node * m, int err)
 	struct page * page = NULL;
 	int delayed = 0;
 	unsigned int idx;
-	sector_t sec;
 	unsigned long rw;
 
 	/* First, complete processing of written back indices,
@@ -1219,11 +1232,9 @@ static void map_wb_complete(struct map_node * m, int err)
 
 	__TRACE("wbi2 %p %u %p\n", main_preq, main_preq->req_cluster, m);
 	plo->st.map_multi_writes++;
-	top_delta->ops->map_index(top_delta, m->mn_start, &sec);
 
-	top_delta->io.ops->write_page(&top_delta->io, main_preq, page, sec,
-				      rw);
-	put_page(page);
+	main_preq->req_index_update_rw = rw;
+	ploop_index_wb_proceed(main_preq);
 }
 
 void
diff --git a/include/linux/ploop/ploop.h b/include/linux/ploop/ploop.h
index 9d3410b..f9cd4a1 100644
--- a/include/linux/ploop/ploop.h
+++ b/include/linux/ploop/ploop.h
@@ -545,6 +545,7 @@ struct ploop_request
 	sector_t		req_sector;
 	unsigned int		req_size;
 	unsigned int		req_rw;
+	unsigned int		req_index_update_rw;
 	unsigned long		tstamp;
 	struct io_context	*ioc;
 
@@ -814,6 +815,7 @@ void map_init(struct ploop_device *, struct ploop_map * map);
 void ploop_map_start(struct ploop_map * map, u64 bd_size);
 void ploop_map_destroy(struct ploop_map * map);
 void ploop_map_remove_delta(struct ploop_map * map, int level);
+void ploop_index_wb_proceed(struct ploop_request * preq);
 void ploop_index_update(struct ploop_request * preq);
 void ploop_index_wb_complete(struct ploop_request * preq);
 int __init ploop_map_init(void);


More information about the Devel mailing list