[Devel] [PATCH rh7 4/9] ploop: minor rework of ->write_page() io method

Maxim Patlasov mpatlasov at virtuozzo.com
Thu Jun 23 22:39:54 PDT 2016


From: Dmitry Monakhov <dmonakhov at openvz.org>

No functional changes. Next patch will use this
rework to pass REQ_FLUSH to dio_write_page().

The patch is actually a part of Dima's patch:

> [PATCH 3/3] ploop: fixup FORCE_{FLUSH,FUA} handling v3

Signed-off-by: Maxim Patlasov <mpatlasov at virtuozzo.com>
---
 drivers/block/ploop/io_direct.c |    5 ++---
 drivers/block/ploop/io_kaio.c   |    8 +++++---
 drivers/block/ploop/map.c       |    5 +++--
 include/linux/ploop/ploop.h     |    2 +-
 4 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/block/ploop/io_direct.c b/drivers/block/ploop/io_direct.c
index 0907540..db82a61 100644
--- a/drivers/block/ploop/io_direct.c
+++ b/drivers/block/ploop/io_direct.c
@@ -1505,15 +1505,14 @@ dio_read_page(struct ploop_io * io, struct ploop_request * preq,
 
 static void
 dio_write_page(struct ploop_io * io, struct ploop_request * preq,
-	       struct page * page, sector_t sec, int fua)
+	       struct page * page, sector_t sec, unsigned long rw)
 {
 	if (!(io->files.file->f_mode & FMODE_WRITE)) {
 		PLOOP_FAIL_REQUEST(preq, -EBADF);
 		return;
 	}
 
-	dio_io_page(io, WRITE | (fua ? REQ_FUA : 0) | REQ_SYNC,
-		    preq, page, sec);
+	dio_io_page(io, rw | WRITE | REQ_SYNC, preq, page, sec);
 }
 
 static int
diff --git a/drivers/block/ploop/io_kaio.c b/drivers/block/ploop/io_kaio.c
index e4e4411..73edc5e 100644
--- a/drivers/block/ploop/io_kaio.c
+++ b/drivers/block/ploop/io_kaio.c
@@ -612,12 +612,14 @@ kaio_read_page(struct ploop_io * io, struct ploop_request * preq,
 
 static void
 kaio_write_page(struct ploop_io * io, struct ploop_request * preq,
-		 struct page * page, sector_t sec, int fua)
+		 struct page * page, sector_t sec, unsigned long rw)
 {
 	ploop_prepare_tracker(preq, sec);
 
-	/* No FUA in kaio, convert it to fsync */
-	if (fua)
+	/* No FUA in kaio, convert it to fsync. Don't care
+	   about REQ_FLUSH: only io_direct relies on it,
+	   io_kaio implements delay_fua in another way... */
+	if (rw & REQ_FUA)
 		set_bit(PLOOP_REQ_KAIO_FSYNC, &preq->state);
 
 	kaio_io_page(io, IOCB_CMD_WRITE_ITER, preq, page, sec);
diff --git a/drivers/block/ploop/map.c b/drivers/block/ploop/map.c
index 3ba8a22..ae6cc15 100644
--- a/drivers/block/ploop/map.c
+++ b/drivers/block/ploop/map.c
@@ -966,7 +966,7 @@ void ploop_index_update(struct ploop_request * preq)
 		set_bit(PLOOP_REQ_FORCE_FUA, &preq->state);
 
 	top_delta->io.ops->write_page(&top_delta->io, preq, page, sec,
-				      !!(preq->req_rw & REQ_FUA));
+				      preq->req_rw & REQ_FUA);
 	put_page(page);
 	return;
 
@@ -1210,7 +1210,8 @@ static void map_wb_complete(struct map_node * m, int err)
 	if (force_fua)
 		set_bit(PLOOP_REQ_FORCE_FUA, &main_preq->state);
 
-	top_delta->io.ops->write_page(&top_delta->io, main_preq, page, sec, fua);
+	top_delta->io.ops->write_page(&top_delta->io, main_preq, page, sec,
+				      fua ? REQ_FUA : 0);
 	put_page(page);
 }
 
diff --git a/include/linux/ploop/ploop.h b/include/linux/ploop/ploop.h
index e1d8686..3e53b35 100644
--- a/include/linux/ploop/ploop.h
+++ b/include/linux/ploop/ploop.h
@@ -164,7 +164,7 @@ struct ploop_io_ops
 	void	(*read_page)(struct ploop_io * io, struct ploop_request * preq,
 			     struct page * page, sector_t sec);
 	void	(*write_page)(struct ploop_io * io, struct ploop_request * preq,
-			      struct page * page, sector_t sec, int fua);
+			      struct page * page, sector_t sec, unsigned long rw);
 
 
 	int	(*sync_read)(struct ploop_io * io, struct page * page,



More information about the Devel mailing list