aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/pnfs.c
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/pnfs.c
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/pnfs.c')
-rw-r--r--fs/nfs/pnfs.c55
1 files changed, 15 insertions, 40 deletions
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 */