[RFC 02/12] nfs: Create a common pnfs_generic_pg_init() function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Most of this code can be shared.  There are some differences with
calculating bsize, but that needs to be changed in the layout drivers
that call the read and write versions of this function.

Signed-off-by: Anna Schumaker <Anna.Schumaker@xxxxxxxxxx>
---
 fs/nfs/pnfs.c | 61 +++++++++++++++++++++++++++--------------------------------
 1 file changed, 28 insertions(+), 33 deletions(-)

diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 8da7ff6..4d57003 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -1387,48 +1387,22 @@ void pnfs_pageio_reset_mds(struct nfs_pageio_descriptor *pgio)
 }
 EXPORT_SYMBOL_GPL(pnfs_pageio_reset_mds);
 
-void
-pnfs_generic_pg_init_read(struct nfs_pageio_descriptor *pgio, struct nfs_page *req)
-{
-	u64 rd_size = req->wb_bytes;
-
-	WARN_ON_ONCE(pgio->pg_lseg != NULL);
-
-	if (pgio->pg_dreq == NULL)
-		rd_size = i_size_read(pgio->pg_inode) - req_offset(req);
-	else
-		rd_size = nfs_dreq_bytes_left(pgio->pg_dreq);
-
-	pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode,
-					   req->wb_context,
-					   req_offset(req),
-					   rd_size,
-					   IOMODE_READ,
-					   GFP_KERNEL);
-	/* If no lseg, fall back to read through mds */
-	if (pgio->pg_lseg == NULL)
-		pnfs_pageio_reset_mds(pgio);
-
-}
-EXPORT_SYMBOL_GPL(pnfs_generic_pg_init_read);
-
-void
-pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *pgio,
-			   struct nfs_page *req, u64 wb_size)
+static void pnfs_generic_pg_init(struct nfs_pageio_descriptor *pgio,
+				 struct nfs_page *req, u64 bsize,
+				 enum pnfs_iomode iomode, gfp_t gfp_flags)
 {
 	WARN_ON_ONCE(pgio->pg_lseg != NULL);
 
 	pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode,
 					   req->wb_context,
 					   req_offset(req),
-					   wb_size,
-					   IOMODE_RW,
-					   GFP_NOFS);
-	/* If no lseg, fall back to write through mds */
+					   bsize,
+					   iomode,
+					   gfp_flags);
+	/* If no lseg, fall back to IO through mds */
 	if (pgio->pg_lseg == NULL)
 		pnfs_pageio_reset_mds(pgio);
 }
-EXPORT_SYMBOL_GPL(pnfs_generic_pg_init_write);
 
 /*
  * Return 0 if @req cannot be coalesced into @pgio, otherwise return the number
@@ -1472,6 +1446,14 @@ pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev,
 }
 EXPORT_SYMBOL_GPL(pnfs_generic_pg_test);
 
+void
+pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *pgio,
+			   struct nfs_page *req, u64 wb_size)
+{
+	pnfs_generic_pg_init(pgio, req, wb_size, IOMODE_RW, GFP_NOFS);
+}
+EXPORT_SYMBOL_GPL(pnfs_generic_pg_init_write);
+
 int pnfs_write_done_resend_to_mds(struct nfs_pgio_header *hdr)
 {
 	struct nfs_pageio_descriptor pgio;
@@ -1590,6 +1572,19 @@ pnfs_generic_pg_writepages(struct nfs_pageio_descriptor *desc)
 }
 EXPORT_SYMBOL_GPL(pnfs_generic_pg_writepages);
 
+void
+pnfs_generic_pg_init_read(struct nfs_pageio_descriptor *pgio, struct nfs_page *req)
+{
+	u64 rd_size;
+	if (pgio->pg_dreq == NULL)
+		rd_size = i_size_read(pgio->pg_inode) - req_offset(req);
+	else
+		rd_size = nfs_dreq_bytes_left(pgio->pg_dreq);
+
+	pnfs_generic_pg_init(pgio, req, rd_size, IOMODE_READ, GFP_KERNEL);
+}
+EXPORT_SYMBOL_GPL(pnfs_generic_pg_init_read);
+
 int pnfs_read_done_resend_to_mds(struct nfs_pgio_header *hdr)
 {
 	struct nfs_pageio_descriptor pgio;
-- 
1.9.2

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux