aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorBenny Halevy <bhalevy@panasas.com>2011-05-25 13:25:22 -0400
committerBoaz Harrosh <bharrosh@panasas.com>2011-05-29 13:56:43 -0400
commitdfed206b8857d41a91ebba030f99e30017a44dda (patch)
treeac4c161b548e872e92da36499a2e8c28f5a34aeb /fs/nfs
parenta0fe8bf427f4987d7b82678292ca03cfd7331467 (diff)
NFSv4.1: unify pnfs_pageio_init functions
Use common code for pnfs_pageio_init_{read,write} and use a common generic pg_test function. Note that this function always assumes the the layout driver's pg_test method is implemented. [Fix BUG] Signed-off-by: Boaz Harrosh <bharrosh@panasas.com> Signed-off-by: Benny Halevy <bhalevy@panasas.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/pagelist.c2
-rw-r--r--fs/nfs/pnfs.c55
-rw-r--r--fs/nfs/pnfs.h21
-rw-r--r--fs/nfs/read.c1
-rw-r--r--fs/nfs/write.c2
5 files changed, 27 insertions, 54 deletions
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
index c80add6e2213..b8704fedcd16 100644
--- a/fs/nfs/pagelist.c
+++ b/fs/nfs/pagelist.c
@@ -229,6 +229,8 @@ void nfs_pageio_init(struct nfs_pageio_descriptor *desc,
229 desc->pg_ioflags = io_flags; 229 desc->pg_ioflags = io_flags;
230 desc->pg_error = 0; 230 desc->pg_error = 0;
231 desc->pg_lseg = NULL; 231 desc->pg_lseg = NULL;
232 desc->pg_test = NULL;
233 pnfs_pageio_init(desc, inode);
232} 234}
233 235
234/** 236/**
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 00b128241746..568ab0eef677 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -1043,46 +1043,30 @@ out_forget_reply:
1043 goto out; 1043 goto out;
1044} 1044}
1045 1045
1046static int pnfs_read_pg_test(struct nfs_pageio_descriptor *pgio, 1046int
1047 struct nfs_page *prev, 1047pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev,
1048 struct nfs_page *req) 1048 struct nfs_page *req)
1049{
1050 if (pgio->pg_count == prev->wb_bytes) {
1051 /* This is first coelesce call for a series of nfs_pages */
1052 pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode,
1053 prev->wb_context,
1054 req_offset(req),
1055 pgio->pg_count,
1056 IOMODE_READ,
1057 GFP_KERNEL);
1058 } else if (pgio->pg_lseg &&
1059 req_offset(req) > end_offset(pgio->pg_lseg->pls_range.offset,
1060 pgio->pg_lseg->pls_range.length))
1061 return 0;
1062 return NFS_SERVER(pgio->pg_inode)->pnfs_curr_ld->pg_test(pgio, prev, req);
1063}
1064
1065void
1066pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, struct inode *inode)
1067{ 1049{
1068 struct pnfs_layoutdriver_type *ld; 1050 enum pnfs_iomode access_type;
1051 gfp_t gfp_flags;
1069 1052
1070 ld = NFS_SERVER(inode)->pnfs_curr_ld; 1053 /* We assume that pg_ioflags == 0 iff we're reading a page */
1071 pgio->pg_test = (ld && ld->pg_test) ? pnfs_read_pg_test : NULL; 1054 if (pgio->pg_ioflags == 0) {
1072} 1055 access_type = IOMODE_READ;
1056 gfp_flags = GFP_KERNEL;
1057 } else {
1058 access_type = IOMODE_RW;
1059 gfp_flags = GFP_NOFS;
1060 }
1073 1061
1074static int pnfs_write_pg_test(struct nfs_pageio_descriptor *pgio,
1075 struct nfs_page *prev,
1076 struct nfs_page *req)
1077{
1078 if (pgio->pg_count == prev->wb_bytes) { 1062 if (pgio->pg_count == prev->wb_bytes) {
1079 /* This is first coelesce call for a series of nfs_pages */ 1063 /* This is first coelesce call for a series of nfs_pages */
1080 pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, 1064 pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode,
1081 prev->wb_context, 1065 prev->wb_context,
1082 req_offset(req), 1066 req_offset(req),
1083 pgio->pg_count, 1067 pgio->pg_count,
1084 IOMODE_RW, 1068 access_type,
1085 GFP_NOFS); 1069 gfp_flags);
1086 } else if (pgio->pg_lseg && 1070 } else if (pgio->pg_lseg &&
1087 req_offset(req) > end_offset(pgio->pg_lseg->pls_range.offset, 1071 req_offset(req) > end_offset(pgio->pg_lseg->pls_range.offset,
1088 pgio->pg_lseg->pls_range.length)) 1072 pgio->pg_lseg->pls_range.length))
@@ -1090,15 +1074,6 @@ static int pnfs_write_pg_test(struct nfs_pageio_descriptor *pgio,
1090 return NFS_SERVER(pgio->pg_inode)->pnfs_curr_ld->pg_test(pgio, prev, req); 1074 return NFS_SERVER(pgio->pg_inode)->pnfs_curr_ld->pg_test(pgio, prev, req);
1091} 1075}
1092 1076
1093void
1094pnfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, struct inode *inode)
1095{
1096 struct pnfs_layoutdriver_type *ld;
1097
1098 ld = NFS_SERVER(inode)->pnfs_curr_ld;
1099 pgio->pg_test = (ld && ld->pg_test) ? pnfs_write_pg_test : NULL;
1100}
1101
1102/* 1077/*
1103 * Called by non rpc-based layout drivers 1078 * Called by non rpc-based layout drivers
1104 */ 1079 */
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
index 3fda97146777..c056688ee92b 100644
--- a/fs/nfs/pnfs.h
+++ b/fs/nfs/pnfs.h
@@ -158,8 +158,7 @@ enum pnfs_try_status pnfs_try_to_write_data(struct nfs_write_data *,
158 const struct rpc_call_ops *, int); 158 const struct rpc_call_ops *, int);
159enum pnfs_try_status pnfs_try_to_read_data(struct nfs_read_data *, 159enum pnfs_try_status pnfs_try_to_read_data(struct nfs_read_data *,
160 const struct rpc_call_ops *); 160 const struct rpc_call_ops *);
161void pnfs_pageio_init_read(struct nfs_pageio_descriptor *, struct inode *); 161int pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev, struct nfs_page *req);
162void pnfs_pageio_init_write(struct nfs_pageio_descriptor *, struct inode *);
163int pnfs_layout_process(struct nfs4_layoutget *lgp); 162int pnfs_layout_process(struct nfs4_layoutget *lgp);
164void pnfs_free_lseg_list(struct list_head *tmp_list); 163void pnfs_free_lseg_list(struct list_head *tmp_list);
165void pnfs_destroy_layout(struct nfs_inode *); 164void pnfs_destroy_layout(struct nfs_inode *);
@@ -293,6 +292,13 @@ static inline int pnfs_return_layout(struct inode *ino)
293 return 0; 292 return 0;
294} 293}
295 294
295static inline void pnfs_pageio_init(struct nfs_pageio_descriptor *pgio,
296 struct inode *inode)
297{
298 if (NFS_SERVER(inode)->pnfs_curr_ld)
299 pgio->pg_test = pnfs_generic_pg_test;
300}
301
296#else /* CONFIG_NFS_V4_1 */ 302#else /* CONFIG_NFS_V4_1 */
297 303
298static inline void pnfs_destroy_all_layouts(struct nfs_client *clp) 304static inline void pnfs_destroy_all_layouts(struct nfs_client *clp)
@@ -376,16 +382,9 @@ static inline void unset_pnfs_layoutdriver(struct nfs_server *s)
376{ 382{
377} 383}
378 384
379static inline void 385static inline void pnfs_pageio_init(struct nfs_pageio_descriptor *pgio,
380pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, struct inode *ino) 386 struct inode *inode)
381{
382 pgio->pg_test = NULL;
383}
384
385static inline void
386pnfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, struct inode *ino)
387{ 387{
388 pgio->pg_test = NULL;
389} 388}
390 389
391static inline void 390static inline void
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index 540c8bc93f95..20a7f952e244 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -664,7 +664,6 @@ int nfs_readpages(struct file *filp, struct address_space *mapping,
664 if (ret == 0) 664 if (ret == 0)
665 goto read_complete; /* all pages were read */ 665 goto read_complete; /* all pages were read */
666 666
667 pnfs_pageio_init_read(&pgio, inode);
668 if (rsize < PAGE_CACHE_SIZE) 667 if (rsize < PAGE_CACHE_SIZE)
669 nfs_pageio_init(&pgio, inode, nfs_pagein_multi, rsize, 0); 668 nfs_pageio_init(&pgio, inode, nfs_pagein_multi, rsize, 0);
670 else 669 else
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 7edb72f27c22..e268e3b23497 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -1036,8 +1036,6 @@ static void nfs_pageio_init_write(struct nfs_pageio_descriptor *pgio,
1036{ 1036{
1037 size_t wsize = NFS_SERVER(inode)->wsize; 1037 size_t wsize = NFS_SERVER(inode)->wsize;
1038 1038
1039 pnfs_pageio_init_write(pgio, inode);
1040
1041 if (wsize < PAGE_CACHE_SIZE) 1039 if (wsize < PAGE_CACHE_SIZE)
1042 nfs_pageio_init(pgio, inode, nfs_flush_multi, wsize, ioflags); 1040 nfs_pageio_init(pgio, inode, nfs_flush_multi, wsize, ioflags);
1043 else 1041 else