diff options
Diffstat (limited to 'fs/nfs/read.c')
-rw-r--r-- | fs/nfs/read.c | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/fs/nfs/read.c b/fs/nfs/read.c index c91a4799c562..568ecf0a880f 100644 --- a/fs/nfs/read.c +++ b/fs/nfs/read.c | |||
@@ -70,8 +70,15 @@ EXPORT_SYMBOL_GPL(nfs_pageio_init_read); | |||
70 | 70 | ||
71 | void nfs_pageio_reset_read_mds(struct nfs_pageio_descriptor *pgio) | 71 | void nfs_pageio_reset_read_mds(struct nfs_pageio_descriptor *pgio) |
72 | { | 72 | { |
73 | struct nfs_pgio_mirror *mirror; | ||
74 | |||
73 | pgio->pg_ops = &nfs_pgio_rw_ops; | 75 | pgio->pg_ops = &nfs_pgio_rw_ops; |
74 | pgio->pg_bsize = NFS_SERVER(pgio->pg_inode)->rsize; | 76 | |
77 | /* read path should never have more than one mirror */ | ||
78 | WARN_ON_ONCE(pgio->pg_mirror_count != 1); | ||
79 | |||
80 | mirror = &pgio->pg_mirrors[0]; | ||
81 | mirror->pg_bsize = NFS_SERVER(pgio->pg_inode)->rsize; | ||
75 | } | 82 | } |
76 | EXPORT_SYMBOL_GPL(nfs_pageio_reset_read_mds); | 83 | EXPORT_SYMBOL_GPL(nfs_pageio_reset_read_mds); |
77 | 84 | ||
@@ -81,6 +88,7 @@ int nfs_readpage_async(struct nfs_open_context *ctx, struct inode *inode, | |||
81 | struct nfs_page *new; | 88 | struct nfs_page *new; |
82 | unsigned int len; | 89 | unsigned int len; |
83 | struct nfs_pageio_descriptor pgio; | 90 | struct nfs_pageio_descriptor pgio; |
91 | struct nfs_pgio_mirror *pgm; | ||
84 | 92 | ||
85 | len = nfs_page_length(page); | 93 | len = nfs_page_length(page); |
86 | if (len == 0) | 94 | if (len == 0) |
@@ -97,7 +105,13 @@ int nfs_readpage_async(struct nfs_open_context *ctx, struct inode *inode, | |||
97 | &nfs_async_read_completion_ops); | 105 | &nfs_async_read_completion_ops); |
98 | nfs_pageio_add_request(&pgio, new); | 106 | nfs_pageio_add_request(&pgio, new); |
99 | nfs_pageio_complete(&pgio); | 107 | nfs_pageio_complete(&pgio); |
100 | NFS_I(inode)->read_io += pgio.pg_bytes_written; | 108 | |
109 | /* It doesn't make sense to do mirrored reads! */ | ||
110 | WARN_ON_ONCE(pgio.pg_mirror_count != 1); | ||
111 | |||
112 | pgm = &pgio.pg_mirrors[0]; | ||
113 | NFS_I(inode)->read_io += pgm->pg_bytes_written; | ||
114 | |||
101 | return 0; | 115 | return 0; |
102 | } | 116 | } |
103 | 117 | ||
@@ -168,13 +182,14 @@ out: | |||
168 | 182 | ||
169 | static void nfs_initiate_read(struct nfs_pgio_header *hdr, | 183 | static void nfs_initiate_read(struct nfs_pgio_header *hdr, |
170 | struct rpc_message *msg, | 184 | struct rpc_message *msg, |
185 | const struct nfs_rpc_ops *rpc_ops, | ||
171 | struct rpc_task_setup *task_setup_data, int how) | 186 | struct rpc_task_setup *task_setup_data, int how) |
172 | { | 187 | { |
173 | struct inode *inode = hdr->inode; | 188 | struct inode *inode = hdr->inode; |
174 | int swap_flags = IS_SWAPFILE(inode) ? NFS_RPC_SWAPFLAGS : 0; | 189 | int swap_flags = IS_SWAPFILE(inode) ? NFS_RPC_SWAPFLAGS : 0; |
175 | 190 | ||
176 | task_setup_data->flags |= swap_flags; | 191 | task_setup_data->flags |= swap_flags; |
177 | NFS_PROTO(inode)->read_setup(hdr, msg); | 192 | rpc_ops->read_setup(hdr, msg); |
178 | } | 193 | } |
179 | 194 | ||
180 | static void | 195 | static void |
@@ -351,6 +366,7 @@ int nfs_readpages(struct file *filp, struct address_space *mapping, | |||
351 | struct list_head *pages, unsigned nr_pages) | 366 | struct list_head *pages, unsigned nr_pages) |
352 | { | 367 | { |
353 | struct nfs_pageio_descriptor pgio; | 368 | struct nfs_pageio_descriptor pgio; |
369 | struct nfs_pgio_mirror *pgm; | ||
354 | struct nfs_readdesc desc = { | 370 | struct nfs_readdesc desc = { |
355 | .pgio = &pgio, | 371 | .pgio = &pgio, |
356 | }; | 372 | }; |
@@ -386,10 +402,15 @@ int nfs_readpages(struct file *filp, struct address_space *mapping, | |||
386 | &nfs_async_read_completion_ops); | 402 | &nfs_async_read_completion_ops); |
387 | 403 | ||
388 | ret = read_cache_pages(mapping, pages, readpage_async_filler, &desc); | 404 | ret = read_cache_pages(mapping, pages, readpage_async_filler, &desc); |
389 | |||
390 | nfs_pageio_complete(&pgio); | 405 | nfs_pageio_complete(&pgio); |
391 | NFS_I(inode)->read_io += pgio.pg_bytes_written; | 406 | |
392 | npages = (pgio.pg_bytes_written + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; | 407 | /* It doesn't make sense to do mirrored reads! */ |
408 | WARN_ON_ONCE(pgio.pg_mirror_count != 1); | ||
409 | |||
410 | pgm = &pgio.pg_mirrors[0]; | ||
411 | NFS_I(inode)->read_io += pgm->pg_bytes_written; | ||
412 | npages = (pgm->pg_bytes_written + PAGE_CACHE_SIZE - 1) >> | ||
413 | PAGE_CACHE_SHIFT; | ||
393 | nfs_add_stats(inode, NFSIOS_READPAGES, npages); | 414 | nfs_add_stats(inode, NFSIOS_READPAGES, npages); |
394 | read_complete: | 415 | read_complete: |
395 | put_nfs_open_context(desc.ctx); | 416 | put_nfs_open_context(desc.ctx); |