diff options
author | Bryan Schumaker <bjschuma@netapp.com> | 2012-06-20 15:53:47 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-06-29 11:46:46 -0400 |
commit | 1abb50886afe8a126705c93dab2b50c1252a9c19 (patch) | |
tree | 484ae821c5b5b1a7dee221e9eba41119a27a3fb1 | |
parent | 6663ee7f8187708143255c057bc132bbc84c1894 (diff) |
NFS: Create an read_pageio_init() function
pNFS needs to select a read function based on the layout driver
currently in use, so I let each NFS version decide how to best handle
initializing reads.
Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r-- | fs/nfs/internal.h | 2 | ||||
-rw-r--r-- | fs/nfs/nfs3proc.c | 1 | ||||
-rw-r--r-- | fs/nfs/nfs4proc.c | 1 | ||||
-rw-r--r-- | fs/nfs/pnfs.c | 11 | ||||
-rw-r--r-- | fs/nfs/pnfs.h | 6 | ||||
-rw-r--r-- | fs/nfs/proc.c | 1 | ||||
-rw-r--r-- | fs/nfs/read.c | 16 | ||||
-rw-r--r-- | include/linux/nfs_xdr.h | 3 |
8 files changed, 18 insertions, 23 deletions
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index 633af813984d..b3121123b40d 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h | |||
@@ -306,7 +306,7 @@ extern int nfs_initiate_read(struct rpc_clnt *clnt, | |||
306 | extern void nfs_read_prepare(struct rpc_task *task, void *calldata); | 306 | extern void nfs_read_prepare(struct rpc_task *task, void *calldata); |
307 | extern int nfs_generic_pagein(struct nfs_pageio_descriptor *desc, | 307 | extern int nfs_generic_pagein(struct nfs_pageio_descriptor *desc, |
308 | struct nfs_pgio_header *hdr); | 308 | struct nfs_pgio_header *hdr); |
309 | extern void nfs_pageio_init_read_mds(struct nfs_pageio_descriptor *pgio, | 309 | extern void nfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, |
310 | struct inode *inode, | 310 | struct inode *inode, |
311 | const struct nfs_pgio_completion_ops *compl_ops); | 311 | const struct nfs_pgio_completion_ops *compl_ops); |
312 | extern void nfs_pageio_reset_read_mds(struct nfs_pageio_descriptor *pgio); | 312 | extern void nfs_pageio_reset_read_mds(struct nfs_pageio_descriptor *pgio); |
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c index 77c7aac228bb..9864d05432da 100644 --- a/fs/nfs/nfs3proc.c +++ b/fs/nfs/nfs3proc.c | |||
@@ -921,6 +921,7 @@ const struct nfs_rpc_ops nfs_v3_clientops = { | |||
921 | .pathconf = nfs3_proc_pathconf, | 921 | .pathconf = nfs3_proc_pathconf, |
922 | .decode_dirent = nfs3_decode_dirent, | 922 | .decode_dirent = nfs3_decode_dirent, |
923 | .read_setup = nfs3_proc_read_setup, | 923 | .read_setup = nfs3_proc_read_setup, |
924 | .read_pageio_init = nfs_pageio_init_read, | ||
924 | .read_rpc_prepare = nfs3_proc_read_rpc_prepare, | 925 | .read_rpc_prepare = nfs3_proc_read_rpc_prepare, |
925 | .read_done = nfs3_read_done, | 926 | .read_done = nfs3_read_done, |
926 | .write_setup = nfs3_proc_write_setup, | 927 | .write_setup = nfs3_proc_write_setup, |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 7f39e7ecde6c..f99cf71f4e36 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -6792,6 +6792,7 @@ const struct nfs_rpc_ops nfs_v4_clientops = { | |||
6792 | .set_capabilities = nfs4_server_capabilities, | 6792 | .set_capabilities = nfs4_server_capabilities, |
6793 | .decode_dirent = nfs4_decode_dirent, | 6793 | .decode_dirent = nfs4_decode_dirent, |
6794 | .read_setup = nfs4_proc_read_setup, | 6794 | .read_setup = nfs4_proc_read_setup, |
6795 | .read_pageio_init = pnfs_pageio_init_read, | ||
6795 | .read_rpc_prepare = nfs4_proc_read_rpc_prepare, | 6796 | .read_rpc_prepare = nfs4_proc_read_rpc_prepare, |
6796 | .read_done = nfs4_read_done, | 6797 | .read_done = nfs4_read_done, |
6797 | .write_setup = nfs4_proc_write_setup, | 6798 | .write_setup = nfs4_proc_write_setup, |
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index bbc49caa7a82..9c830603a16c 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c | |||
@@ -1209,7 +1209,7 @@ pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *pgio, struct nfs_page * | |||
1209 | } | 1209 | } |
1210 | EXPORT_SYMBOL_GPL(pnfs_generic_pg_init_write); | 1210 | EXPORT_SYMBOL_GPL(pnfs_generic_pg_init_write); |
1211 | 1211 | ||
1212 | bool | 1212 | void |
1213 | pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, struct inode *inode, | 1213 | pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, struct inode *inode, |
1214 | const struct nfs_pgio_completion_ops *compl_ops) | 1214 | const struct nfs_pgio_completion_ops *compl_ops) |
1215 | { | 1215 | { |
@@ -1217,10 +1217,9 @@ pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, struct inode *inode, | |||
1217 | struct pnfs_layoutdriver_type *ld = server->pnfs_curr_ld; | 1217 | struct pnfs_layoutdriver_type *ld = server->pnfs_curr_ld; |
1218 | 1218 | ||
1219 | if (ld == NULL) | 1219 | if (ld == NULL) |
1220 | return false; | 1220 | nfs_pageio_init_read(pgio, inode, compl_ops); |
1221 | nfs_pageio_init(pgio, inode, ld->pg_read_ops, compl_ops, | 1221 | else |
1222 | server->rsize, 0); | 1222 | nfs_pageio_init(pgio, inode, ld->pg_read_ops, compl_ops, server->rsize, 0); |
1223 | return true; | ||
1224 | } | 1223 | } |
1225 | 1224 | ||
1226 | bool | 1225 | bool |
@@ -1427,7 +1426,7 @@ int pnfs_read_done_resend_to_mds(struct inode *inode, | |||
1427 | LIST_HEAD(failed); | 1426 | LIST_HEAD(failed); |
1428 | 1427 | ||
1429 | /* Resend all requests through the MDS */ | 1428 | /* Resend all requests through the MDS */ |
1430 | nfs_pageio_init_read_mds(&pgio, inode, compl_ops); | 1429 | nfs_pageio_init_read(&pgio, inode, compl_ops); |
1431 | while (!list_empty(head)) { | 1430 | while (!list_empty(head)) { |
1432 | struct nfs_page *req = nfs_list_entry(head->next); | 1431 | struct nfs_page *req = nfs_list_entry(head->next); |
1433 | 1432 | ||
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index 64f90d845f6a..80ee8919dd5e 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h | |||
@@ -178,7 +178,7 @@ extern int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp); | |||
178 | void get_layout_hdr(struct pnfs_layout_hdr *lo); | 178 | void get_layout_hdr(struct pnfs_layout_hdr *lo); |
179 | void put_lseg(struct pnfs_layout_segment *lseg); | 179 | void put_lseg(struct pnfs_layout_segment *lseg); |
180 | 180 | ||
181 | bool pnfs_pageio_init_read(struct nfs_pageio_descriptor *, struct inode *, | 181 | void pnfs_pageio_init_read(struct nfs_pageio_descriptor *, struct inode *, |
182 | const struct nfs_pgio_completion_ops *); | 182 | const struct nfs_pgio_completion_ops *); |
183 | bool pnfs_pageio_init_write(struct nfs_pageio_descriptor *, struct inode *, | 183 | bool pnfs_pageio_init_write(struct nfs_pageio_descriptor *, struct inode *, |
184 | int, const struct nfs_pgio_completion_ops *); | 184 | int, const struct nfs_pgio_completion_ops *); |
@@ -438,10 +438,10 @@ static inline void unset_pnfs_layoutdriver(struct nfs_server *s) | |||
438 | { | 438 | { |
439 | } | 439 | } |
440 | 440 | ||
441 | static inline bool pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, struct inode *inode, | 441 | static inline void pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, struct inode *inode, |
442 | const struct nfs_pgio_completion_ops *compl_ops) | 442 | const struct nfs_pgio_completion_ops *compl_ops) |
443 | { | 443 | { |
444 | return false; | 444 | nfs_pageio_init_read(pgio, inode, compl_ops); |
445 | } | 445 | } |
446 | 446 | ||
447 | static inline bool pnfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, struct inode *inode, int ioflags, | 447 | static inline bool pnfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, struct inode *inode, int ioflags, |
diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c index 99a002515dfe..6fea6e107bc3 100644 --- a/fs/nfs/proc.c +++ b/fs/nfs/proc.c | |||
@@ -778,6 +778,7 @@ const struct nfs_rpc_ops nfs_v2_clientops = { | |||
778 | .pathconf = nfs_proc_pathconf, | 778 | .pathconf = nfs_proc_pathconf, |
779 | .decode_dirent = nfs2_decode_dirent, | 779 | .decode_dirent = nfs2_decode_dirent, |
780 | .read_setup = nfs_proc_read_setup, | 780 | .read_setup = nfs_proc_read_setup, |
781 | .read_pageio_init = nfs_pageio_init_read, | ||
781 | .read_rpc_prepare = nfs_proc_read_rpc_prepare, | 782 | .read_rpc_prepare = nfs_proc_read_rpc_prepare, |
782 | .read_done = nfs_read_done, | 783 | .read_done = nfs_read_done, |
783 | .write_setup = nfs_proc_write_setup, | 784 | .write_setup = nfs_proc_write_setup, |
diff --git a/fs/nfs/read.c b/fs/nfs/read.c index 86ced7836214..6267b873bbcb 100644 --- a/fs/nfs/read.c +++ b/fs/nfs/read.c | |||
@@ -20,8 +20,6 @@ | |||
20 | #include <linux/nfs_page.h> | 20 | #include <linux/nfs_page.h> |
21 | #include <linux/module.h> | 21 | #include <linux/module.h> |
22 | 22 | ||
23 | #include "pnfs.h" | ||
24 | |||
25 | #include "nfs4_fs.h" | 23 | #include "nfs4_fs.h" |
26 | #include "internal.h" | 24 | #include "internal.h" |
27 | #include "iostat.h" | 25 | #include "iostat.h" |
@@ -108,7 +106,7 @@ int nfs_return_empty_page(struct page *page) | |||
108 | return 0; | 106 | return 0; |
109 | } | 107 | } |
110 | 108 | ||
111 | void nfs_pageio_init_read_mds(struct nfs_pageio_descriptor *pgio, | 109 | void nfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, |
112 | struct inode *inode, | 110 | struct inode *inode, |
113 | const struct nfs_pgio_completion_ops *compl_ops) | 111 | const struct nfs_pgio_completion_ops *compl_ops) |
114 | { | 112 | { |
@@ -123,14 +121,6 @@ void nfs_pageio_reset_read_mds(struct nfs_pageio_descriptor *pgio) | |||
123 | } | 121 | } |
124 | EXPORT_SYMBOL_GPL(nfs_pageio_reset_read_mds); | 122 | EXPORT_SYMBOL_GPL(nfs_pageio_reset_read_mds); |
125 | 123 | ||
126 | void nfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, | ||
127 | struct inode *inode, | ||
128 | const struct nfs_pgio_completion_ops *compl_ops) | ||
129 | { | ||
130 | if (!pnfs_pageio_init_read(pgio, inode, compl_ops)) | ||
131 | nfs_pageio_init_read_mds(pgio, inode, compl_ops); | ||
132 | } | ||
133 | |||
134 | int nfs_readpage_async(struct nfs_open_context *ctx, struct inode *inode, | 124 | int nfs_readpage_async(struct nfs_open_context *ctx, struct inode *inode, |
135 | struct page *page) | 125 | struct page *page) |
136 | { | 126 | { |
@@ -149,7 +139,7 @@ int nfs_readpage_async(struct nfs_open_context *ctx, struct inode *inode, | |||
149 | if (len < PAGE_CACHE_SIZE) | 139 | if (len < PAGE_CACHE_SIZE) |
150 | zero_user_segment(page, len, PAGE_CACHE_SIZE); | 140 | zero_user_segment(page, len, PAGE_CACHE_SIZE); |
151 | 141 | ||
152 | nfs_pageio_init_read(&pgio, inode, &nfs_async_read_completion_ops); | 142 | NFS_PROTO(inode)->read_pageio_init(&pgio, inode, &nfs_async_read_completion_ops); |
153 | nfs_pageio_add_request(&pgio, new); | 143 | nfs_pageio_add_request(&pgio, new); |
154 | nfs_pageio_complete(&pgio); | 144 | nfs_pageio_complete(&pgio); |
155 | NFS_I(inode)->read_io += pgio.pg_bytes_written; | 145 | NFS_I(inode)->read_io += pgio.pg_bytes_written; |
@@ -652,7 +642,7 @@ int nfs_readpages(struct file *filp, struct address_space *mapping, | |||
652 | if (ret == 0) | 642 | if (ret == 0) |
653 | goto read_complete; /* all pages were read */ | 643 | goto read_complete; /* all pages were read */ |
654 | 644 | ||
655 | nfs_pageio_init_read(&pgio, inode, &nfs_async_read_completion_ops); | 645 | NFS_PROTO(inode)->read_pageio_init(&pgio, inode, &nfs_async_read_completion_ops); |
656 | 646 | ||
657 | ret = read_cache_pages(mapping, pages, readpage_async_filler, &desc); | 647 | ret = read_cache_pages(mapping, pages, readpage_async_filler, &desc); |
658 | 648 | ||
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 4d62b774ddaf..e00b8b3c334e 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h | |||
@@ -1354,6 +1354,7 @@ struct nfs_access_entry; | |||
1354 | struct nfs_client; | 1354 | struct nfs_client; |
1355 | struct rpc_timeout; | 1355 | struct rpc_timeout; |
1356 | struct nfs_client_initdata; | 1356 | struct nfs_client_initdata; |
1357 | struct nfs_pageio_descriptor; | ||
1357 | 1358 | ||
1358 | /* | 1359 | /* |
1359 | * RPC procedure vector for NFSv2/NFSv3 demuxing | 1360 | * RPC procedure vector for NFSv2/NFSv3 demuxing |
@@ -1407,6 +1408,8 @@ struct nfs_rpc_ops { | |||
1407 | int (*set_capabilities)(struct nfs_server *, struct nfs_fh *); | 1408 | int (*set_capabilities)(struct nfs_server *, struct nfs_fh *); |
1408 | int (*decode_dirent)(struct xdr_stream *, struct nfs_entry *, int); | 1409 | int (*decode_dirent)(struct xdr_stream *, struct nfs_entry *, int); |
1409 | void (*read_setup) (struct nfs_read_data *, struct rpc_message *); | 1410 | void (*read_setup) (struct nfs_read_data *, struct rpc_message *); |
1411 | void (*read_pageio_init)(struct nfs_pageio_descriptor *, struct inode *, | ||
1412 | const struct nfs_pgio_completion_ops *); | ||
1410 | void (*read_rpc_prepare)(struct rpc_task *, struct nfs_read_data *); | 1413 | void (*read_rpc_prepare)(struct rpc_task *, struct nfs_read_data *); |
1411 | int (*read_done) (struct rpc_task *, struct nfs_read_data *); | 1414 | int (*read_done) (struct rpc_task *, struct nfs_read_data *); |
1412 | void (*write_setup) (struct nfs_write_data *, struct rpc_message *); | 1415 | void (*write_setup) (struct nfs_write_data *, struct rpc_message *); |