diff options
author | Weston Andros Adamson <dros@primarydata.com> | 2014-06-09 11:48:35 -0400 |
---|---|---|
committer | Trond Myklebust <trond.myklebust@primarydata.com> | 2014-06-24 18:47:00 -0400 |
commit | d45f60c67848b9f19160692581d78e5b4757a000 (patch) | |
tree | 5f31965abe5bd21e73eae10454db74fe6ce901e9 | |
parent | 823b0c9d9800e712374cda89ac3565bd29f6701b (diff) |
nfs: merge nfs_pgio_data into _header
struct nfs_pgio_data only exists as a member of nfs_pgio_header, but is
passed around everywhere, because there used to be multiple _data structs
per _header. Many of these functions then use the _data to find a pointer
to the _header. This patch cleans this up by merging the nfs_pgio_data
structure into nfs_pgio_header and passing nfs_pgio_header around instead.
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Weston Andros Adamson <dros@primarydata.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
-rw-r--r-- | fs/nfs/blocklayout/blocklayout.c | 98 | ||||
-rw-r--r-- | fs/nfs/direct.c | 8 | ||||
-rw-r--r-- | fs/nfs/filelayout/filelayout.c | 170 | ||||
-rw-r--r-- | fs/nfs/internal.h | 6 | ||||
-rw-r--r-- | fs/nfs/nfs3proc.c | 21 | ||||
-rw-r--r-- | fs/nfs/nfs4_fs.h | 6 | ||||
-rw-r--r-- | fs/nfs/nfs4proc.c | 105 | ||||
-rw-r--r-- | fs/nfs/nfs4trace.h | 28 | ||||
-rw-r--r-- | fs/nfs/objlayout/objio_osd.c | 24 | ||||
-rw-r--r-- | fs/nfs/objlayout/objlayout.c | 81 | ||||
-rw-r--r-- | fs/nfs/objlayout/objlayout.h | 8 | ||||
-rw-r--r-- | fs/nfs/pagelist.c | 120 | ||||
-rw-r--r-- | fs/nfs/pnfs.c | 80 | ||||
-rw-r--r-- | fs/nfs/pnfs.h | 10 | ||||
-rw-r--r-- | fs/nfs/proc.c | 27 | ||||
-rw-r--r-- | fs/nfs/read.c | 42 | ||||
-rw-r--r-- | fs/nfs/write.c | 56 | ||||
-rw-r--r-- | include/linux/nfs_page.h | 9 | ||||
-rw-r--r-- | include/linux/nfs_xdr.h | 43 |
19 files changed, 460 insertions, 482 deletions
diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c index 36b01cef849e..c3ccfe440390 100644 --- a/fs/nfs/blocklayout/blocklayout.c +++ b/fs/nfs/blocklayout/blocklayout.c | |||
@@ -210,8 +210,7 @@ static void bl_end_io_read(struct bio *bio, int err) | |||
210 | SetPageUptodate(bvec->bv_page); | 210 | SetPageUptodate(bvec->bv_page); |
211 | 211 | ||
212 | if (err) { | 212 | if (err) { |
213 | struct nfs_pgio_data *rdata = par->data; | 213 | struct nfs_pgio_header *header = par->data; |
214 | struct nfs_pgio_header *header = rdata->header; | ||
215 | 214 | ||
216 | if (!header->pnfs_error) | 215 | if (!header->pnfs_error) |
217 | header->pnfs_error = -EIO; | 216 | header->pnfs_error = -EIO; |
@@ -224,44 +223,44 @@ static void bl_end_io_read(struct bio *bio, int err) | |||
224 | static void bl_read_cleanup(struct work_struct *work) | 223 | static void bl_read_cleanup(struct work_struct *work) |
225 | { | 224 | { |
226 | struct rpc_task *task; | 225 | struct rpc_task *task; |
227 | struct nfs_pgio_data *rdata; | 226 | struct nfs_pgio_header *hdr; |
228 | dprintk("%s enter\n", __func__); | 227 | dprintk("%s enter\n", __func__); |
229 | task = container_of(work, struct rpc_task, u.tk_work); | 228 | task = container_of(work, struct rpc_task, u.tk_work); |
230 | rdata = container_of(task, struct nfs_pgio_data, task); | 229 | hdr = container_of(task, struct nfs_pgio_header, task); |
231 | pnfs_ld_read_done(rdata); | 230 | pnfs_ld_read_done(hdr); |
232 | } | 231 | } |
233 | 232 | ||
234 | static void | 233 | static void |
235 | bl_end_par_io_read(void *data, int unused) | 234 | bl_end_par_io_read(void *data, int unused) |
236 | { | 235 | { |
237 | struct nfs_pgio_data *rdata = data; | 236 | struct nfs_pgio_header *hdr = data; |
238 | 237 | ||
239 | rdata->task.tk_status = rdata->header->pnfs_error; | 238 | hdr->task.tk_status = hdr->pnfs_error; |
240 | INIT_WORK(&rdata->task.u.tk_work, bl_read_cleanup); | 239 | INIT_WORK(&hdr->task.u.tk_work, bl_read_cleanup); |
241 | schedule_work(&rdata->task.u.tk_work); | 240 | schedule_work(&hdr->task.u.tk_work); |
242 | } | 241 | } |
243 | 242 | ||
244 | static enum pnfs_try_status | 243 | static enum pnfs_try_status |
245 | bl_read_pagelist(struct nfs_pgio_data *rdata) | 244 | bl_read_pagelist(struct nfs_pgio_header *hdr) |
246 | { | 245 | { |
247 | struct nfs_pgio_header *header = rdata->header; | 246 | struct nfs_pgio_header *header = hdr; |
248 | int i, hole; | 247 | int i, hole; |
249 | struct bio *bio = NULL; | 248 | struct bio *bio = NULL; |
250 | struct pnfs_block_extent *be = NULL, *cow_read = NULL; | 249 | struct pnfs_block_extent *be = NULL, *cow_read = NULL; |
251 | sector_t isect, extent_length = 0; | 250 | sector_t isect, extent_length = 0; |
252 | struct parallel_io *par; | 251 | struct parallel_io *par; |
253 | loff_t f_offset = rdata->args.offset; | 252 | loff_t f_offset = hdr->args.offset; |
254 | size_t bytes_left = rdata->args.count; | 253 | size_t bytes_left = hdr->args.count; |
255 | unsigned int pg_offset, pg_len; | 254 | unsigned int pg_offset, pg_len; |
256 | struct page **pages = rdata->args.pages; | 255 | struct page **pages = hdr->args.pages; |
257 | int pg_index = rdata->args.pgbase >> PAGE_CACHE_SHIFT; | 256 | int pg_index = hdr->args.pgbase >> PAGE_CACHE_SHIFT; |
258 | const bool is_dio = (header->dreq != NULL); | 257 | const bool is_dio = (header->dreq != NULL); |
259 | 258 | ||
260 | dprintk("%s enter nr_pages %u offset %lld count %u\n", __func__, | 259 | dprintk("%s enter nr_pages %u offset %lld count %u\n", __func__, |
261 | rdata->page_array.npages, f_offset, | 260 | hdr->page_array.npages, f_offset, |
262 | (unsigned int)rdata->args.count); | 261 | (unsigned int)hdr->args.count); |
263 | 262 | ||
264 | par = alloc_parallel(rdata); | 263 | par = alloc_parallel(hdr); |
265 | if (!par) | 264 | if (!par) |
266 | goto use_mds; | 265 | goto use_mds; |
267 | par->pnfs_callback = bl_end_par_io_read; | 266 | par->pnfs_callback = bl_end_par_io_read; |
@@ -269,7 +268,7 @@ bl_read_pagelist(struct nfs_pgio_data *rdata) | |||
269 | 268 | ||
270 | isect = (sector_t) (f_offset >> SECTOR_SHIFT); | 269 | isect = (sector_t) (f_offset >> SECTOR_SHIFT); |
271 | /* Code assumes extents are page-aligned */ | 270 | /* Code assumes extents are page-aligned */ |
272 | for (i = pg_index; i < rdata->page_array.npages; i++) { | 271 | for (i = pg_index; i < hdr->page_array.npages; i++) { |
273 | if (!extent_length) { | 272 | if (!extent_length) { |
274 | /* We've used up the previous extent */ | 273 | /* We've used up the previous extent */ |
275 | bl_put_extent(be); | 274 | bl_put_extent(be); |
@@ -319,7 +318,7 @@ bl_read_pagelist(struct nfs_pgio_data *rdata) | |||
319 | 318 | ||
320 | be_read = (hole && cow_read) ? cow_read : be; | 319 | be_read = (hole && cow_read) ? cow_read : be; |
321 | bio = do_add_page_to_bio(bio, | 320 | bio = do_add_page_to_bio(bio, |
322 | rdata->page_array.npages - i, | 321 | hdr->page_array.npages - i, |
323 | READ, | 322 | READ, |
324 | isect, pages[i], be_read, | 323 | isect, pages[i], be_read, |
325 | bl_end_io_read, par, | 324 | bl_end_io_read, par, |
@@ -334,10 +333,10 @@ bl_read_pagelist(struct nfs_pgio_data *rdata) | |||
334 | extent_length -= PAGE_CACHE_SECTORS; | 333 | extent_length -= PAGE_CACHE_SECTORS; |
335 | } | 334 | } |
336 | if ((isect << SECTOR_SHIFT) >= header->inode->i_size) { | 335 | if ((isect << SECTOR_SHIFT) >= header->inode->i_size) { |
337 | rdata->res.eof = 1; | 336 | hdr->res.eof = 1; |
338 | rdata->res.count = header->inode->i_size - rdata->args.offset; | 337 | hdr->res.count = header->inode->i_size - hdr->args.offset; |
339 | } else { | 338 | } else { |
340 | rdata->res.count = (isect << SECTOR_SHIFT) - rdata->args.offset; | 339 | hdr->res.count = (isect << SECTOR_SHIFT) - hdr->args.offset; |
341 | } | 340 | } |
342 | out: | 341 | out: |
343 | bl_put_extent(be); | 342 | bl_put_extent(be); |
@@ -392,8 +391,7 @@ static void bl_end_io_write_zero(struct bio *bio, int err) | |||
392 | } | 391 | } |
393 | 392 | ||
394 | if (unlikely(err)) { | 393 | if (unlikely(err)) { |
395 | struct nfs_pgio_data *data = par->data; | 394 | struct nfs_pgio_header *header = par->data; |
396 | struct nfs_pgio_header *header = data->header; | ||
397 | 395 | ||
398 | if (!header->pnfs_error) | 396 | if (!header->pnfs_error) |
399 | header->pnfs_error = -EIO; | 397 | header->pnfs_error = -EIO; |
@@ -407,8 +405,7 @@ static void bl_end_io_write(struct bio *bio, int err) | |||
407 | { | 405 | { |
408 | struct parallel_io *par = bio->bi_private; | 406 | struct parallel_io *par = bio->bi_private; |
409 | const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); | 407 | const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); |
410 | struct nfs_pgio_data *data = par->data; | 408 | struct nfs_pgio_header *header = par->data; |
411 | struct nfs_pgio_header *header = data->header; | ||
412 | 409 | ||
413 | if (!uptodate) { | 410 | if (!uptodate) { |
414 | if (!header->pnfs_error) | 411 | if (!header->pnfs_error) |
@@ -425,32 +422,32 @@ static void bl_end_io_write(struct bio *bio, int err) | |||
425 | static void bl_write_cleanup(struct work_struct *work) | 422 | static void bl_write_cleanup(struct work_struct *work) |
426 | { | 423 | { |
427 | struct rpc_task *task; | 424 | struct rpc_task *task; |
428 | struct nfs_pgio_data *wdata; | 425 | struct nfs_pgio_header *hdr; |
429 | dprintk("%s enter\n", __func__); | 426 | dprintk("%s enter\n", __func__); |
430 | task = container_of(work, struct rpc_task, u.tk_work); | 427 | task = container_of(work, struct rpc_task, u.tk_work); |
431 | wdata = container_of(task, struct nfs_pgio_data, task); | 428 | hdr = container_of(task, struct nfs_pgio_header, task); |
432 | if (likely(!wdata->header->pnfs_error)) { | 429 | if (likely(!hdr->pnfs_error)) { |
433 | /* Marks for LAYOUTCOMMIT */ | 430 | /* Marks for LAYOUTCOMMIT */ |
434 | mark_extents_written(BLK_LSEG2EXT(wdata->header->lseg), | 431 | mark_extents_written(BLK_LSEG2EXT(hdr->lseg), |
435 | wdata->args.offset, wdata->args.count); | 432 | hdr->args.offset, hdr->args.count); |
436 | } | 433 | } |
437 | pnfs_ld_write_done(wdata); | 434 | pnfs_ld_write_done(hdr); |
438 | } | 435 | } |
439 | 436 | ||
440 | /* Called when last of bios associated with a bl_write_pagelist call finishes */ | 437 | /* Called when last of bios associated with a bl_write_pagelist call finishes */ |
441 | static void bl_end_par_io_write(void *data, int num_se) | 438 | static void bl_end_par_io_write(void *data, int num_se) |
442 | { | 439 | { |
443 | struct nfs_pgio_data *wdata = data; | 440 | struct nfs_pgio_header *hdr = data; |
444 | 441 | ||
445 | if (unlikely(wdata->header->pnfs_error)) { | 442 | if (unlikely(hdr->pnfs_error)) { |
446 | bl_free_short_extents(&BLK_LSEG2EXT(wdata->header->lseg)->bl_inval, | 443 | bl_free_short_extents(&BLK_LSEG2EXT(hdr->lseg)->bl_inval, |
447 | num_se); | 444 | num_se); |
448 | } | 445 | } |
449 | 446 | ||
450 | wdata->task.tk_status = wdata->header->pnfs_error; | 447 | hdr->task.tk_status = hdr->pnfs_error; |
451 | wdata->writeverf.committed = NFS_FILE_SYNC; | 448 | hdr->writeverf.committed = NFS_FILE_SYNC; |
452 | INIT_WORK(&wdata->task.u.tk_work, bl_write_cleanup); | 449 | INIT_WORK(&hdr->task.u.tk_work, bl_write_cleanup); |
453 | schedule_work(&wdata->task.u.tk_work); | 450 | schedule_work(&hdr->task.u.tk_work); |
454 | } | 451 | } |
455 | 452 | ||
456 | /* FIXME STUB - mark intersection of layout and page as bad, so is not | 453 | /* FIXME STUB - mark intersection of layout and page as bad, so is not |
@@ -675,18 +672,17 @@ check_page: | |||
675 | } | 672 | } |
676 | 673 | ||
677 | static enum pnfs_try_status | 674 | static enum pnfs_try_status |
678 | bl_write_pagelist(struct nfs_pgio_data *wdata, int sync) | 675 | bl_write_pagelist(struct nfs_pgio_header *header, int sync) |
679 | { | 676 | { |
680 | struct nfs_pgio_header *header = wdata->header; | ||
681 | int i, ret, npg_zero, pg_index, last = 0; | 677 | int i, ret, npg_zero, pg_index, last = 0; |
682 | struct bio *bio = NULL; | 678 | struct bio *bio = NULL; |
683 | struct pnfs_block_extent *be = NULL, *cow_read = NULL; | 679 | struct pnfs_block_extent *be = NULL, *cow_read = NULL; |
684 | sector_t isect, last_isect = 0, extent_length = 0; | 680 | sector_t isect, last_isect = 0, extent_length = 0; |
685 | struct parallel_io *par = NULL; | 681 | struct parallel_io *par = NULL; |
686 | loff_t offset = wdata->args.offset; | 682 | loff_t offset = header->args.offset; |
687 | size_t count = wdata->args.count; | 683 | size_t count = header->args.count; |
688 | unsigned int pg_offset, pg_len, saved_len; | 684 | unsigned int pg_offset, pg_len, saved_len; |
689 | struct page **pages = wdata->args.pages; | 685 | struct page **pages = header->args.pages; |
690 | struct page *page; | 686 | struct page *page; |
691 | pgoff_t index; | 687 | pgoff_t index; |
692 | u64 temp; | 688 | u64 temp; |
@@ -701,11 +697,11 @@ bl_write_pagelist(struct nfs_pgio_data *wdata, int sync) | |||
701 | dprintk("pnfsblock nonblock aligned DIO writes. Resend MDS\n"); | 697 | dprintk("pnfsblock nonblock aligned DIO writes. Resend MDS\n"); |
702 | goto out_mds; | 698 | goto out_mds; |
703 | } | 699 | } |
704 | /* At this point, wdata->page_aray is a (sequential) list of nfs_pages. | 700 | /* At this point, header->page_aray is a (sequential) list of nfs_pages. |
705 | * We want to write each, and if there is an error set pnfs_error | 701 | * We want to write each, and if there is an error set pnfs_error |
706 | * to have it redone using nfs. | 702 | * to have it redone using nfs. |
707 | */ | 703 | */ |
708 | par = alloc_parallel(wdata); | 704 | par = alloc_parallel(header); |
709 | if (!par) | 705 | if (!par) |
710 | goto out_mds; | 706 | goto out_mds; |
711 | par->pnfs_callback = bl_end_par_io_write; | 707 | par->pnfs_callback = bl_end_par_io_write; |
@@ -792,8 +788,8 @@ next_page: | |||
792 | bio = bl_submit_bio(WRITE, bio); | 788 | bio = bl_submit_bio(WRITE, bio); |
793 | 789 | ||
794 | /* Middle pages */ | 790 | /* Middle pages */ |
795 | pg_index = wdata->args.pgbase >> PAGE_CACHE_SHIFT; | 791 | pg_index = header->args.pgbase >> PAGE_CACHE_SHIFT; |
796 | for (i = pg_index; i < wdata->page_array.npages; i++) { | 792 | for (i = pg_index; i < header->page_array.npages; i++) { |
797 | if (!extent_length) { | 793 | if (!extent_length) { |
798 | /* We've used up the previous extent */ | 794 | /* We've used up the previous extent */ |
799 | bl_put_extent(be); | 795 | bl_put_extent(be); |
@@ -864,7 +860,7 @@ next_page: | |||
864 | } | 860 | } |
865 | 861 | ||
866 | 862 | ||
867 | bio = do_add_page_to_bio(bio, wdata->page_array.npages - i, | 863 | bio = do_add_page_to_bio(bio, header->page_array.npages - i, |
868 | WRITE, | 864 | WRITE, |
869 | isect, pages[i], be, | 865 | isect, pages[i], be, |
870 | bl_end_io_write, par, | 866 | bl_end_io_write, par, |
@@ -893,7 +889,7 @@ next_page: | |||
893 | } | 889 | } |
894 | 890 | ||
895 | write_done: | 891 | write_done: |
896 | wdata->res.count = wdata->args.count; | 892 | header->res.count = header->args.count; |
897 | out: | 893 | out: |
898 | bl_put_extent(be); | 894 | bl_put_extent(be); |
899 | bl_put_extent(cow_read); | 895 | bl_put_extent(cow_read); |
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index 179de67ca907..6c4c867ee04c 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c | |||
@@ -148,8 +148,8 @@ static void nfs_direct_set_hdr_verf(struct nfs_direct_req *dreq, | |||
148 | { | 148 | { |
149 | struct nfs_writeverf *verfp; | 149 | struct nfs_writeverf *verfp; |
150 | 150 | ||
151 | verfp = nfs_direct_select_verf(dreq, hdr->data.ds_clp, | 151 | verfp = nfs_direct_select_verf(dreq, hdr->ds_clp, |
152 | hdr->data.ds_idx); | 152 | hdr->ds_idx); |
153 | WARN_ON_ONCE(verfp->committed >= 0); | 153 | WARN_ON_ONCE(verfp->committed >= 0); |
154 | memcpy(verfp, &hdr->verf, sizeof(struct nfs_writeverf)); | 154 | memcpy(verfp, &hdr->verf, sizeof(struct nfs_writeverf)); |
155 | WARN_ON_ONCE(verfp->committed < 0); | 155 | WARN_ON_ONCE(verfp->committed < 0); |
@@ -169,8 +169,8 @@ static int nfs_direct_set_or_cmp_hdr_verf(struct nfs_direct_req *dreq, | |||
169 | { | 169 | { |
170 | struct nfs_writeverf *verfp; | 170 | struct nfs_writeverf *verfp; |
171 | 171 | ||
172 | verfp = nfs_direct_select_verf(dreq, hdr->data.ds_clp, | 172 | verfp = nfs_direct_select_verf(dreq, hdr->ds_clp, |
173 | hdr->data.ds_idx); | 173 | hdr->ds_idx); |
174 | if (verfp->committed < 0) { | 174 | if (verfp->committed < 0) { |
175 | nfs_direct_set_hdr_verf(dreq, hdr); | 175 | nfs_direct_set_hdr_verf(dreq, hdr); |
176 | return 0; | 176 | return 0; |
diff --git a/fs/nfs/filelayout/filelayout.c b/fs/nfs/filelayout/filelayout.c index d2eba1c13b7e..537e7f7a0b48 100644 --- a/fs/nfs/filelayout/filelayout.c +++ b/fs/nfs/filelayout/filelayout.c | |||
@@ -84,19 +84,18 @@ filelayout_get_dserver_offset(struct pnfs_layout_segment *lseg, loff_t offset) | |||
84 | BUG(); | 84 | BUG(); |
85 | } | 85 | } |
86 | 86 | ||
87 | static void filelayout_reset_write(struct nfs_pgio_data *data) | 87 | static void filelayout_reset_write(struct nfs_pgio_header *hdr) |
88 | { | 88 | { |
89 | struct nfs_pgio_header *hdr = data->header; | 89 | struct rpc_task *task = &hdr->task; |
90 | struct rpc_task *task = &data->task; | ||
91 | 90 | ||
92 | if (!test_and_set_bit(NFS_IOHDR_REDO, &hdr->flags)) { | 91 | if (!test_and_set_bit(NFS_IOHDR_REDO, &hdr->flags)) { |
93 | dprintk("%s Reset task %5u for i/o through MDS " | 92 | dprintk("%s Reset task %5u for i/o through MDS " |
94 | "(req %s/%llu, %u bytes @ offset %llu)\n", __func__, | 93 | "(req %s/%llu, %u bytes @ offset %llu)\n", __func__, |
95 | data->task.tk_pid, | 94 | hdr->task.tk_pid, |
96 | hdr->inode->i_sb->s_id, | 95 | hdr->inode->i_sb->s_id, |
97 | (unsigned long long)NFS_FILEID(hdr->inode), | 96 | (unsigned long long)NFS_FILEID(hdr->inode), |
98 | data->args.count, | 97 | hdr->args.count, |
99 | (unsigned long long)data->args.offset); | 98 | (unsigned long long)hdr->args.offset); |
100 | 99 | ||
101 | task->tk_status = pnfs_write_done_resend_to_mds(hdr->inode, | 100 | task->tk_status = pnfs_write_done_resend_to_mds(hdr->inode, |
102 | &hdr->pages, | 101 | &hdr->pages, |
@@ -105,19 +104,18 @@ static void filelayout_reset_write(struct nfs_pgio_data *data) | |||
105 | } | 104 | } |
106 | } | 105 | } |
107 | 106 | ||
108 | static void filelayout_reset_read(struct nfs_pgio_data *data) | 107 | static void filelayout_reset_read(struct nfs_pgio_header *hdr) |
109 | { | 108 | { |
110 | struct nfs_pgio_header *hdr = data->header; | 109 | struct rpc_task *task = &hdr->task; |
111 | struct rpc_task *task = &data->task; | ||
112 | 110 | ||
113 | if (!test_and_set_bit(NFS_IOHDR_REDO, &hdr->flags)) { | 111 | if (!test_and_set_bit(NFS_IOHDR_REDO, &hdr->flags)) { |
114 | dprintk("%s Reset task %5u for i/o through MDS " | 112 | dprintk("%s Reset task %5u for i/o through MDS " |
115 | "(req %s/%llu, %u bytes @ offset %llu)\n", __func__, | 113 | "(req %s/%llu, %u bytes @ offset %llu)\n", __func__, |
116 | data->task.tk_pid, | 114 | hdr->task.tk_pid, |
117 | hdr->inode->i_sb->s_id, | 115 | hdr->inode->i_sb->s_id, |
118 | (unsigned long long)NFS_FILEID(hdr->inode), | 116 | (unsigned long long)NFS_FILEID(hdr->inode), |
119 | data->args.count, | 117 | hdr->args.count, |
120 | (unsigned long long)data->args.offset); | 118 | (unsigned long long)hdr->args.offset); |
121 | 119 | ||
122 | task->tk_status = pnfs_read_done_resend_to_mds(hdr->inode, | 120 | task->tk_status = pnfs_read_done_resend_to_mds(hdr->inode, |
123 | &hdr->pages, | 121 | &hdr->pages, |
@@ -243,18 +241,17 @@ wait_on_recovery: | |||
243 | /* NFS_PROTO call done callback routines */ | 241 | /* NFS_PROTO call done callback routines */ |
244 | 242 | ||
245 | static int filelayout_read_done_cb(struct rpc_task *task, | 243 | static int filelayout_read_done_cb(struct rpc_task *task, |
246 | struct nfs_pgio_data *data) | 244 | struct nfs_pgio_header *hdr) |
247 | { | 245 | { |
248 | struct nfs_pgio_header *hdr = data->header; | ||
249 | int err; | 246 | int err; |
250 | 247 | ||
251 | trace_nfs4_pnfs_read(data, task->tk_status); | 248 | trace_nfs4_pnfs_read(hdr, task->tk_status); |
252 | err = filelayout_async_handle_error(task, data->args.context->state, | 249 | err = filelayout_async_handle_error(task, hdr->args.context->state, |
253 | data->ds_clp, hdr->lseg); | 250 | hdr->ds_clp, hdr->lseg); |
254 | 251 | ||
255 | switch (err) { | 252 | switch (err) { |
256 | case -NFS4ERR_RESET_TO_MDS: | 253 | case -NFS4ERR_RESET_TO_MDS: |
257 | filelayout_reset_read(data); | 254 | filelayout_reset_read(hdr); |
258 | return task->tk_status; | 255 | return task->tk_status; |
259 | case -EAGAIN: | 256 | case -EAGAIN: |
260 | rpc_restart_call_prepare(task); | 257 | rpc_restart_call_prepare(task); |
@@ -270,15 +267,14 @@ static int filelayout_read_done_cb(struct rpc_task *task, | |||
270 | * rfc5661 is not clear about which credential should be used. | 267 | * rfc5661 is not clear about which credential should be used. |
271 | */ | 268 | */ |
272 | static void | 269 | static void |
273 | filelayout_set_layoutcommit(struct nfs_pgio_data *wdata) | 270 | filelayout_set_layoutcommit(struct nfs_pgio_header *hdr) |
274 | { | 271 | { |
275 | struct nfs_pgio_header *hdr = wdata->header; | ||
276 | 272 | ||
277 | if (FILELAYOUT_LSEG(hdr->lseg)->commit_through_mds || | 273 | if (FILELAYOUT_LSEG(hdr->lseg)->commit_through_mds || |
278 | wdata->res.verf->committed == NFS_FILE_SYNC) | 274 | hdr->res.verf->committed == NFS_FILE_SYNC) |
279 | return; | 275 | return; |
280 | 276 | ||
281 | pnfs_set_layoutcommit(wdata); | 277 | pnfs_set_layoutcommit(hdr); |
282 | dprintk("%s inode %lu pls_end_pos %lu\n", __func__, hdr->inode->i_ino, | 278 | dprintk("%s inode %lu pls_end_pos %lu\n", __func__, hdr->inode->i_ino, |
283 | (unsigned long) NFS_I(hdr->inode)->layout->plh_lwb); | 279 | (unsigned long) NFS_I(hdr->inode)->layout->plh_lwb); |
284 | } | 280 | } |
@@ -305,83 +301,82 @@ filelayout_reset_to_mds(struct pnfs_layout_segment *lseg) | |||
305 | */ | 301 | */ |
306 | static void filelayout_read_prepare(struct rpc_task *task, void *data) | 302 | static void filelayout_read_prepare(struct rpc_task *task, void *data) |
307 | { | 303 | { |
308 | struct nfs_pgio_data *rdata = data; | 304 | struct nfs_pgio_header *hdr = data; |
309 | 305 | ||
310 | if (unlikely(test_bit(NFS_CONTEXT_BAD, &rdata->args.context->flags))) { | 306 | if (unlikely(test_bit(NFS_CONTEXT_BAD, &hdr->args.context->flags))) { |
311 | rpc_exit(task, -EIO); | 307 | rpc_exit(task, -EIO); |
312 | return; | 308 | return; |
313 | } | 309 | } |
314 | if (filelayout_reset_to_mds(rdata->header->lseg)) { | 310 | if (filelayout_reset_to_mds(hdr->lseg)) { |
315 | dprintk("%s task %u reset io to MDS\n", __func__, task->tk_pid); | 311 | dprintk("%s task %u reset io to MDS\n", __func__, task->tk_pid); |
316 | filelayout_reset_read(rdata); | 312 | filelayout_reset_read(hdr); |
317 | rpc_exit(task, 0); | 313 | rpc_exit(task, 0); |
318 | return; | 314 | return; |
319 | } | 315 | } |
320 | rdata->pgio_done_cb = filelayout_read_done_cb; | 316 | hdr->pgio_done_cb = filelayout_read_done_cb; |
321 | 317 | ||
322 | if (nfs41_setup_sequence(rdata->ds_clp->cl_session, | 318 | if (nfs41_setup_sequence(hdr->ds_clp->cl_session, |
323 | &rdata->args.seq_args, | 319 | &hdr->args.seq_args, |
324 | &rdata->res.seq_res, | 320 | &hdr->res.seq_res, |
325 | task)) | 321 | task)) |
326 | return; | 322 | return; |
327 | if (nfs4_set_rw_stateid(&rdata->args.stateid, rdata->args.context, | 323 | if (nfs4_set_rw_stateid(&hdr->args.stateid, hdr->args.context, |
328 | rdata->args.lock_context, FMODE_READ) == -EIO) | 324 | hdr->args.lock_context, FMODE_READ) == -EIO) |
329 | rpc_exit(task, -EIO); /* lost lock, terminate I/O */ | 325 | rpc_exit(task, -EIO); /* lost lock, terminate I/O */ |
330 | } | 326 | } |
331 | 327 | ||
332 | static void filelayout_read_call_done(struct rpc_task *task, void *data) | 328 | static void filelayout_read_call_done(struct rpc_task *task, void *data) |
333 | { | 329 | { |
334 | struct nfs_pgio_data *rdata = data; | 330 | struct nfs_pgio_header *hdr = data; |
335 | 331 | ||
336 | dprintk("--> %s task->tk_status %d\n", __func__, task->tk_status); | 332 | dprintk("--> %s task->tk_status %d\n", __func__, task->tk_status); |
337 | 333 | ||
338 | if (test_bit(NFS_IOHDR_REDO, &rdata->header->flags) && | 334 | if (test_bit(NFS_IOHDR_REDO, &hdr->flags) && |
339 | task->tk_status == 0) { | 335 | task->tk_status == 0) { |
340 | nfs41_sequence_done(task, &rdata->res.seq_res); | 336 | nfs41_sequence_done(task, &hdr->res.seq_res); |
341 | return; | 337 | return; |
342 | } | 338 | } |
343 | 339 | ||
344 | /* Note this may cause RPC to be resent */ | 340 | /* Note this may cause RPC to be resent */ |
345 | rdata->header->mds_ops->rpc_call_done(task, data); | 341 | hdr->mds_ops->rpc_call_done(task, data); |
346 | } | 342 | } |
347 | 343 | ||
348 | static void filelayout_read_count_stats(struct rpc_task *task, void *data) | 344 | static void filelayout_read_count_stats(struct rpc_task *task, void *data) |
349 | { | 345 | { |
350 | struct nfs_pgio_data *rdata = data; | 346 | struct nfs_pgio_header *hdr = data; |
351 | 347 | ||
352 | rpc_count_iostats(task, NFS_SERVER(rdata->header->inode)->client->cl_metrics); | 348 | rpc_count_iostats(task, NFS_SERVER(hdr->inode)->client->cl_metrics); |
353 | } | 349 | } |
354 | 350 | ||
355 | static void filelayout_read_release(void *data) | 351 | static void filelayout_read_release(void *data) |
356 | { | 352 | { |
357 | struct nfs_pgio_data *rdata = data; | 353 | struct nfs_pgio_header *hdr = data; |
358 | struct pnfs_layout_hdr *lo = rdata->header->lseg->pls_layout; | 354 | struct pnfs_layout_hdr *lo = hdr->lseg->pls_layout; |
359 | 355 | ||
360 | filelayout_fenceme(lo->plh_inode, lo); | 356 | filelayout_fenceme(lo->plh_inode, lo); |
361 | nfs_put_client(rdata->ds_clp); | 357 | nfs_put_client(hdr->ds_clp); |
362 | rdata->header->mds_ops->rpc_release(data); | 358 | hdr->mds_ops->rpc_release(data); |
363 | } | 359 | } |
364 | 360 | ||
365 | static int filelayout_write_done_cb(struct rpc_task *task, | 361 | static int filelayout_write_done_cb(struct rpc_task *task, |
366 | struct nfs_pgio_data *data) | 362 | struct nfs_pgio_header *hdr) |
367 | { | 363 | { |
368 | struct nfs_pgio_header *hdr = data->header; | ||
369 | int err; | 364 | int err; |
370 | 365 | ||
371 | trace_nfs4_pnfs_write(data, task->tk_status); | 366 | trace_nfs4_pnfs_write(hdr, task->tk_status); |
372 | err = filelayout_async_handle_error(task, data->args.context->state, | 367 | err = filelayout_async_handle_error(task, hdr->args.context->state, |
373 | data->ds_clp, hdr->lseg); | 368 | hdr->ds_clp, hdr->lseg); |
374 | 369 | ||
375 | switch (err) { | 370 | switch (err) { |
376 | case -NFS4ERR_RESET_TO_MDS: | 371 | case -NFS4ERR_RESET_TO_MDS: |
377 | filelayout_reset_write(data); | 372 | filelayout_reset_write(hdr); |
378 | return task->tk_status; | 373 | return task->tk_status; |
379 | case -EAGAIN: | 374 | case -EAGAIN: |
380 | rpc_restart_call_prepare(task); | 375 | rpc_restart_call_prepare(task); |
381 | return -EAGAIN; | 376 | return -EAGAIN; |
382 | } | 377 | } |
383 | 378 | ||
384 | filelayout_set_layoutcommit(data); | 379 | filelayout_set_layoutcommit(hdr); |
385 | return 0; | 380 | return 0; |
386 | } | 381 | } |
387 | 382 | ||
@@ -419,57 +414,57 @@ static int filelayout_commit_done_cb(struct rpc_task *task, | |||
419 | 414 | ||
420 | static void filelayout_write_prepare(struct rpc_task *task, void *data) | 415 | static void filelayout_write_prepare(struct rpc_task *task, void *data) |
421 | { | 416 | { |
422 | struct nfs_pgio_data *wdata = data; | 417 | struct nfs_pgio_header *hdr = data; |
423 | 418 | ||
424 | if (unlikely(test_bit(NFS_CONTEXT_BAD, &wdata->args.context->flags))) { | 419 | if (unlikely(test_bit(NFS_CONTEXT_BAD, &hdr->args.context->flags))) { |
425 | rpc_exit(task, -EIO); | 420 | rpc_exit(task, -EIO); |
426 | return; | 421 | return; |
427 | } | 422 | } |
428 | if (filelayout_reset_to_mds(wdata->header->lseg)) { | 423 | if (filelayout_reset_to_mds(hdr->lseg)) { |
429 | dprintk("%s task %u reset io to MDS\n", __func__, task->tk_pid); | 424 | dprintk("%s task %u reset io to MDS\n", __func__, task->tk_pid); |
430 | filelayout_reset_write(wdata); | 425 | filelayout_reset_write(hdr); |
431 | rpc_exit(task, 0); | 426 | rpc_exit(task, 0); |
432 | return; | 427 | return; |
433 | } | 428 | } |
434 | if (nfs41_setup_sequence(wdata->ds_clp->cl_session, | 429 | if (nfs41_setup_sequence(hdr->ds_clp->cl_session, |
435 | &wdata->args.seq_args, | 430 | &hdr->args.seq_args, |
436 | &wdata->res.seq_res, | 431 | &hdr->res.seq_res, |
437 | task)) | 432 | task)) |
438 | return; | 433 | return; |
439 | if (nfs4_set_rw_stateid(&wdata->args.stateid, wdata->args.context, | 434 | if (nfs4_set_rw_stateid(&hdr->args.stateid, hdr->args.context, |
440 | wdata->args.lock_context, FMODE_WRITE) == -EIO) | 435 | hdr->args.lock_context, FMODE_WRITE) == -EIO) |
441 | rpc_exit(task, -EIO); /* lost lock, terminate I/O */ | 436 | rpc_exit(task, -EIO); /* lost lock, terminate I/O */ |
442 | } | 437 | } |
443 | 438 | ||
444 | static void filelayout_write_call_done(struct rpc_task *task, void *data) | 439 | static void filelayout_write_call_done(struct rpc_task *task, void *data) |
445 | { | 440 | { |
446 | struct nfs_pgio_data *wdata = data; | 441 | struct nfs_pgio_header *hdr = data; |
447 | 442 | ||
448 | if (test_bit(NFS_IOHDR_REDO, &wdata->header->flags) && | 443 | if (test_bit(NFS_IOHDR_REDO, &hdr->flags) && |
449 | task->tk_status == 0) { | 444 | task->tk_status == 0) { |
450 | nfs41_sequence_done(task, &wdata->res.seq_res); | 445 | nfs41_sequence_done(task, &hdr->res.seq_res); |
451 | return; | 446 | return; |
452 | } | 447 | } |
453 | 448 | ||
454 | /* Note this may cause RPC to be resent */ | 449 | /* Note this may cause RPC to be resent */ |
455 | wdata->header->mds_ops->rpc_call_done(task, data); | 450 | hdr->mds_ops->rpc_call_done(task, data); |
456 | } | 451 | } |
457 | 452 | ||
458 | static void filelayout_write_count_stats(struct rpc_task *task, void *data) | 453 | static void filelayout_write_count_stats(struct rpc_task *task, void *data) |
459 | { | 454 | { |
460 | struct nfs_pgio_data *wdata = data; | 455 | struct nfs_pgio_header *hdr = data; |
461 | 456 | ||
462 | rpc_count_iostats(task, NFS_SERVER(wdata->header->inode)->client->cl_metrics); | 457 | rpc_count_iostats(task, NFS_SERVER(hdr->inode)->client->cl_metrics); |
463 | } | 458 | } |
464 | 459 | ||
465 | static void filelayout_write_release(void *data) | 460 | static void filelayout_write_release(void *data) |
466 | { | 461 | { |
467 | struct nfs_pgio_data *wdata = data; | 462 | struct nfs_pgio_header *hdr = data; |
468 | struct pnfs_layout_hdr *lo = wdata->header->lseg->pls_layout; | 463 | struct pnfs_layout_hdr *lo = hdr->lseg->pls_layout; |
469 | 464 | ||
470 | filelayout_fenceme(lo->plh_inode, lo); | 465 | filelayout_fenceme(lo->plh_inode, lo); |
471 | nfs_put_client(wdata->ds_clp); | 466 | nfs_put_client(hdr->ds_clp); |
472 | wdata->header->mds_ops->rpc_release(data); | 467 | hdr->mds_ops->rpc_release(data); |
473 | } | 468 | } |
474 | 469 | ||
475 | static void filelayout_commit_prepare(struct rpc_task *task, void *data) | 470 | static void filelayout_commit_prepare(struct rpc_task *task, void *data) |
@@ -529,19 +524,18 @@ static const struct rpc_call_ops filelayout_commit_call_ops = { | |||
529 | }; | 524 | }; |
530 | 525 | ||
531 | static enum pnfs_try_status | 526 | static enum pnfs_try_status |
532 | filelayout_read_pagelist(struct nfs_pgio_data *data) | 527 | filelayout_read_pagelist(struct nfs_pgio_header *hdr) |
533 | { | 528 | { |
534 | struct nfs_pgio_header *hdr = data->header; | ||
535 | struct pnfs_layout_segment *lseg = hdr->lseg; | 529 | struct pnfs_layout_segment *lseg = hdr->lseg; |
536 | struct nfs4_pnfs_ds *ds; | 530 | struct nfs4_pnfs_ds *ds; |
537 | struct rpc_clnt *ds_clnt; | 531 | struct rpc_clnt *ds_clnt; |
538 | loff_t offset = data->args.offset; | 532 | loff_t offset = hdr->args.offset; |
539 | u32 j, idx; | 533 | u32 j, idx; |
540 | struct nfs_fh *fh; | 534 | struct nfs_fh *fh; |
541 | 535 | ||
542 | dprintk("--> %s ino %lu pgbase %u req %Zu@%llu\n", | 536 | dprintk("--> %s ino %lu pgbase %u req %Zu@%llu\n", |
543 | __func__, hdr->inode->i_ino, | 537 | __func__, hdr->inode->i_ino, |
544 | data->args.pgbase, (size_t)data->args.count, offset); | 538 | hdr->args.pgbase, (size_t)hdr->args.count, offset); |
545 | 539 | ||
546 | /* Retrieve the correct rpc_client for the byte range */ | 540 | /* Retrieve the correct rpc_client for the byte range */ |
547 | j = nfs4_fl_calc_j_index(lseg, offset); | 541 | j = nfs4_fl_calc_j_index(lseg, offset); |
@@ -559,30 +553,29 @@ filelayout_read_pagelist(struct nfs_pgio_data *data) | |||
559 | 553 | ||
560 | /* No multipath support. Use first DS */ | 554 | /* No multipath support. Use first DS */ |
561 | atomic_inc(&ds->ds_clp->cl_count); | 555 | atomic_inc(&ds->ds_clp->cl_count); |
562 | data->ds_clp = ds->ds_clp; | 556 | hdr->ds_clp = ds->ds_clp; |
563 | data->ds_idx = idx; | 557 | hdr->ds_idx = idx; |
564 | fh = nfs4_fl_select_ds_fh(lseg, j); | 558 | fh = nfs4_fl_select_ds_fh(lseg, j); |
565 | if (fh) | 559 | if (fh) |
566 | data->args.fh = fh; | 560 | hdr->args.fh = fh; |
567 | 561 | ||
568 | data->args.offset = filelayout_get_dserver_offset(lseg, offset); | 562 | hdr->args.offset = filelayout_get_dserver_offset(lseg, offset); |
569 | data->mds_offset = offset; | 563 | hdr->mds_offset = offset; |
570 | 564 | ||
571 | /* Perform an asynchronous read to ds */ | 565 | /* Perform an asynchronous read to ds */ |
572 | nfs_initiate_pgio(ds_clnt, data, | 566 | nfs_initiate_pgio(ds_clnt, hdr, |
573 | &filelayout_read_call_ops, 0, RPC_TASK_SOFTCONN); | 567 | &filelayout_read_call_ops, 0, RPC_TASK_SOFTCONN); |
574 | return PNFS_ATTEMPTED; | 568 | return PNFS_ATTEMPTED; |
575 | } | 569 | } |
576 | 570 | ||
577 | /* Perform async writes. */ | 571 | /* Perform async writes. */ |
578 | static enum pnfs_try_status | 572 | static enum pnfs_try_status |
579 | filelayout_write_pagelist(struct nfs_pgio_data *data, int sync) | 573 | filelayout_write_pagelist(struct nfs_pgio_header *hdr, int sync) |
580 | { | 574 | { |
581 | struct nfs_pgio_header *hdr = data->header; | ||
582 | struct pnfs_layout_segment *lseg = hdr->lseg; | 575 | struct pnfs_layout_segment *lseg = hdr->lseg; |
583 | struct nfs4_pnfs_ds *ds; | 576 | struct nfs4_pnfs_ds *ds; |
584 | struct rpc_clnt *ds_clnt; | 577 | struct rpc_clnt *ds_clnt; |
585 | loff_t offset = data->args.offset; | 578 | loff_t offset = hdr->args.offset; |
586 | u32 j, idx; | 579 | u32 j, idx; |
587 | struct nfs_fh *fh; | 580 | struct nfs_fh *fh; |
588 | 581 | ||
@@ -598,21 +591,20 @@ filelayout_write_pagelist(struct nfs_pgio_data *data, int sync) | |||
598 | return PNFS_NOT_ATTEMPTED; | 591 | return PNFS_NOT_ATTEMPTED; |
599 | 592 | ||
600 | dprintk("%s ino %lu sync %d req %Zu@%llu DS: %s cl_count %d\n", | 593 | dprintk("%s ino %lu sync %d req %Zu@%llu DS: %s cl_count %d\n", |
601 | __func__, hdr->inode->i_ino, sync, (size_t) data->args.count, | 594 | __func__, hdr->inode->i_ino, sync, (size_t) hdr->args.count, |
602 | offset, ds->ds_remotestr, atomic_read(&ds->ds_clp->cl_count)); | 595 | offset, ds->ds_remotestr, atomic_read(&ds->ds_clp->cl_count)); |
603 | 596 | ||
604 | data->pgio_done_cb = filelayout_write_done_cb; | 597 | hdr->pgio_done_cb = filelayout_write_done_cb; |
605 | atomic_inc(&ds->ds_clp->cl_count); | 598 | atomic_inc(&ds->ds_clp->cl_count); |
606 | data->ds_clp = ds->ds_clp; | 599 | hdr->ds_clp = ds->ds_clp; |
607 | data->ds_idx = idx; | 600 | hdr->ds_idx = idx; |
608 | fh = nfs4_fl_select_ds_fh(lseg, j); | 601 | fh = nfs4_fl_select_ds_fh(lseg, j); |
609 | if (fh) | 602 | if (fh) |
610 | data->args.fh = fh; | 603 | hdr->args.fh = fh; |
611 | 604 | hdr->args.offset = filelayout_get_dserver_offset(lseg, offset); | |
612 | data->args.offset = filelayout_get_dserver_offset(lseg, offset); | ||
613 | 605 | ||
614 | /* Perform an asynchronous write */ | 606 | /* Perform an asynchronous write */ |
615 | nfs_initiate_pgio(ds_clnt, data, | 607 | nfs_initiate_pgio(ds_clnt, hdr, |
616 | &filelayout_write_call_ops, sync, | 608 | &filelayout_write_call_ops, sync, |
617 | RPC_TASK_SOFTCONN); | 609 | RPC_TASK_SOFTCONN); |
618 | return PNFS_ATTEMPTED; | 610 | return PNFS_ATTEMPTED; |
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index 5cda049c8f9b..3f3aedd2e8c9 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h | |||
@@ -240,9 +240,9 @@ int nfs_iocounter_wait(struct nfs_io_counter *c); | |||
240 | extern const struct nfs_pageio_ops nfs_pgio_rw_ops; | 240 | extern const struct nfs_pageio_ops nfs_pgio_rw_ops; |
241 | struct nfs_pgio_header *nfs_pgio_header_alloc(const struct nfs_rw_ops *); | 241 | struct nfs_pgio_header *nfs_pgio_header_alloc(const struct nfs_rw_ops *); |
242 | void nfs_pgio_header_free(struct nfs_pgio_header *); | 242 | void nfs_pgio_header_free(struct nfs_pgio_header *); |
243 | void nfs_pgio_data_destroy(struct nfs_pgio_data *); | 243 | void nfs_pgio_data_destroy(struct nfs_pgio_header *); |
244 | int nfs_generic_pgio(struct nfs_pageio_descriptor *, struct nfs_pgio_header *); | 244 | int nfs_generic_pgio(struct nfs_pageio_descriptor *, struct nfs_pgio_header *); |
245 | int nfs_initiate_pgio(struct rpc_clnt *, struct nfs_pgio_data *, | 245 | int nfs_initiate_pgio(struct rpc_clnt *, struct nfs_pgio_header *, |
246 | const struct rpc_call_ops *, int, int); | 246 | const struct rpc_call_ops *, int, int); |
247 | 247 | ||
248 | static inline void nfs_iocounter_init(struct nfs_io_counter *c) | 248 | static inline void nfs_iocounter_init(struct nfs_io_counter *c) |
@@ -481,7 +481,7 @@ static inline void nfs_inode_dio_wait(struct inode *inode) | |||
481 | extern ssize_t nfs_dreq_bytes_left(struct nfs_direct_req *dreq); | 481 | extern ssize_t nfs_dreq_bytes_left(struct nfs_direct_req *dreq); |
482 | 482 | ||
483 | /* nfs4proc.c */ | 483 | /* nfs4proc.c */ |
484 | extern void __nfs4_read_done_cb(struct nfs_pgio_data *); | 484 | extern void __nfs4_read_done_cb(struct nfs_pgio_header *); |
485 | extern struct nfs_client *nfs4_init_client(struct nfs_client *clp, | 485 | extern struct nfs_client *nfs4_init_client(struct nfs_client *clp, |
486 | const struct rpc_timeout *timeparms, | 486 | const struct rpc_timeout *timeparms, |
487 | const char *ip_addr); | 487 | const char *ip_addr); |
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c index e7daa42bbc86..854959db0e5d 100644 --- a/fs/nfs/nfs3proc.c +++ b/fs/nfs/nfs3proc.c | |||
@@ -795,41 +795,44 @@ nfs3_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle, | |||
795 | return status; | 795 | return status; |
796 | } | 796 | } |
797 | 797 | ||
798 | static int nfs3_read_done(struct rpc_task *task, struct nfs_pgio_data *data) | 798 | static int nfs3_read_done(struct rpc_task *task, struct nfs_pgio_header *hdr) |
799 | { | 799 | { |
800 | struct inode *inode = data->header->inode; | 800 | struct inode *inode = hdr->inode; |
801 | 801 | ||
802 | if (nfs3_async_handle_jukebox(task, inode)) | 802 | if (nfs3_async_handle_jukebox(task, inode)) |
803 | return -EAGAIN; | 803 | return -EAGAIN; |
804 | 804 | ||
805 | nfs_invalidate_atime(inode); | 805 | nfs_invalidate_atime(inode); |
806 | nfs_refresh_inode(inode, &data->fattr); | 806 | nfs_refresh_inode(inode, &hdr->fattr); |
807 | return 0; | 807 | return 0; |
808 | } | 808 | } |
809 | 809 | ||
810 | static void nfs3_proc_read_setup(struct nfs_pgio_data *data, struct rpc_message *msg) | 810 | static void nfs3_proc_read_setup(struct nfs_pgio_header *hdr, |
811 | struct rpc_message *msg) | ||
811 | { | 812 | { |
812 | msg->rpc_proc = &nfs3_procedures[NFS3PROC_READ]; | 813 | msg->rpc_proc = &nfs3_procedures[NFS3PROC_READ]; |
813 | } | 814 | } |
814 | 815 | ||
815 | static int nfs3_proc_pgio_rpc_prepare(struct rpc_task *task, struct nfs_pgio_data *data) | 816 | static int nfs3_proc_pgio_rpc_prepare(struct rpc_task *task, |
817 | struct nfs_pgio_header *hdr) | ||
816 | { | 818 | { |
817 | rpc_call_start(task); | 819 | rpc_call_start(task); |
818 | return 0; | 820 | return 0; |
819 | } | 821 | } |
820 | 822 | ||
821 | static int nfs3_write_done(struct rpc_task *task, struct nfs_pgio_data *data) | 823 | static int nfs3_write_done(struct rpc_task *task, struct nfs_pgio_header *hdr) |
822 | { | 824 | { |
823 | struct inode *inode = data->header->inode; | 825 | struct inode *inode = hdr->inode; |
824 | 826 | ||
825 | if (nfs3_async_handle_jukebox(task, inode)) | 827 | if (nfs3_async_handle_jukebox(task, inode)) |
826 | return -EAGAIN; | 828 | return -EAGAIN; |
827 | if (task->tk_status >= 0) | 829 | if (task->tk_status >= 0) |
828 | nfs_post_op_update_inode_force_wcc(inode, data->res.fattr); | 830 | nfs_post_op_update_inode_force_wcc(inode, hdr->res.fattr); |
829 | return 0; | 831 | return 0; |
830 | } | 832 | } |
831 | 833 | ||
832 | static void nfs3_proc_write_setup(struct nfs_pgio_data *data, struct rpc_message *msg) | 834 | static void nfs3_proc_write_setup(struct nfs_pgio_header *hdr, |
835 | struct rpc_message *msg) | ||
833 | { | 836 | { |
834 | msg->rpc_proc = &nfs3_procedures[NFS3PROC_WRITE]; | 837 | msg->rpc_proc = &nfs3_procedures[NFS3PROC_WRITE]; |
835 | } | 838 | } |
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index ba2affa51941..b8ea4a26998c 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h | |||
@@ -337,11 +337,11 @@ nfs4_state_protect(struct nfs_client *clp, unsigned long sp4_mode, | |||
337 | */ | 337 | */ |
338 | static inline void | 338 | static inline void |
339 | nfs4_state_protect_write(struct nfs_client *clp, struct rpc_clnt **clntp, | 339 | nfs4_state_protect_write(struct nfs_client *clp, struct rpc_clnt **clntp, |
340 | struct rpc_message *msg, struct nfs_pgio_data *wdata) | 340 | struct rpc_message *msg, struct nfs_pgio_header *hdr) |
341 | { | 341 | { |
342 | if (_nfs4_state_protect(clp, NFS_SP4_MACH_CRED_WRITE, clntp, msg) && | 342 | if (_nfs4_state_protect(clp, NFS_SP4_MACH_CRED_WRITE, clntp, msg) && |
343 | !test_bit(NFS_SP4_MACH_CRED_COMMIT, &clp->cl_sp4_flags)) | 343 | !test_bit(NFS_SP4_MACH_CRED_COMMIT, &clp->cl_sp4_flags)) |
344 | wdata->args.stable = NFS_FILE_SYNC; | 344 | hdr->args.stable = NFS_FILE_SYNC; |
345 | } | 345 | } |
346 | #else /* CONFIG_NFS_v4_1 */ | 346 | #else /* CONFIG_NFS_v4_1 */ |
347 | static inline struct nfs4_session *nfs4_get_session(const struct nfs_server *server) | 347 | static inline struct nfs4_session *nfs4_get_session(const struct nfs_server *server) |
@@ -369,7 +369,7 @@ nfs4_state_protect(struct nfs_client *clp, unsigned long sp4_flags, | |||
369 | 369 | ||
370 | static inline void | 370 | static inline void |
371 | nfs4_state_protect_write(struct nfs_client *clp, struct rpc_clnt **clntp, | 371 | nfs4_state_protect_write(struct nfs_client *clp, struct rpc_clnt **clntp, |
372 | struct rpc_message *msg, struct nfs_pgio_data *wdata) | 372 | struct rpc_message *msg, struct nfs_pgio_header *hdr) |
373 | { | 373 | { |
374 | } | 374 | } |
375 | #endif /* CONFIG_NFS_V4_1 */ | 375 | #endif /* CONFIG_NFS_V4_1 */ |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 4bf3d97cc5a0..b0e5705599bf 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -4033,24 +4033,25 @@ static bool nfs4_error_stateid_expired(int err) | |||
4033 | return false; | 4033 | return false; |
4034 | } | 4034 | } |
4035 | 4035 | ||
4036 | void __nfs4_read_done_cb(struct nfs_pgio_data *data) | 4036 | void __nfs4_read_done_cb(struct nfs_pgio_header *hdr) |
4037 | { | 4037 | { |
4038 | nfs_invalidate_atime(data->header->inode); | 4038 | nfs_invalidate_atime(hdr->inode); |
4039 | } | 4039 | } |
4040 | 4040 | ||
4041 | static int nfs4_read_done_cb(struct rpc_task *task, struct nfs_pgio_data *data) | 4041 | static int nfs4_read_done_cb(struct rpc_task *task, struct nfs_pgio_header *hdr) |
4042 | { | 4042 | { |
4043 | struct nfs_server *server = NFS_SERVER(data->header->inode); | 4043 | struct nfs_server *server = NFS_SERVER(hdr->inode); |
4044 | 4044 | ||
4045 | trace_nfs4_read(data, task->tk_status); | 4045 | trace_nfs4_read(hdr, task->tk_status); |
4046 | if (nfs4_async_handle_error(task, server, data->args.context->state) == -EAGAIN) { | 4046 | if (nfs4_async_handle_error(task, server, |
4047 | hdr->args.context->state) == -EAGAIN) { | ||
4047 | rpc_restart_call_prepare(task); | 4048 | rpc_restart_call_prepare(task); |
4048 | return -EAGAIN; | 4049 | return -EAGAIN; |
4049 | } | 4050 | } |
4050 | 4051 | ||
4051 | __nfs4_read_done_cb(data); | 4052 | __nfs4_read_done_cb(hdr); |
4052 | if (task->tk_status > 0) | 4053 | if (task->tk_status > 0) |
4053 | renew_lease(server, data->timestamp); | 4054 | renew_lease(server, hdr->timestamp); |
4054 | return 0; | 4055 | return 0; |
4055 | } | 4056 | } |
4056 | 4057 | ||
@@ -4068,54 +4069,59 @@ static bool nfs4_read_stateid_changed(struct rpc_task *task, | |||
4068 | return true; | 4069 | return true; |
4069 | } | 4070 | } |
4070 | 4071 | ||
4071 | static int nfs4_read_done(struct rpc_task *task, struct nfs_pgio_data *data) | 4072 | static int nfs4_read_done(struct rpc_task *task, struct nfs_pgio_header *hdr) |
4072 | { | 4073 | { |
4073 | 4074 | ||
4074 | dprintk("--> %s\n", __func__); | 4075 | dprintk("--> %s\n", __func__); |
4075 | 4076 | ||
4076 | if (!nfs4_sequence_done(task, &data->res.seq_res)) | 4077 | if (!nfs4_sequence_done(task, &hdr->res.seq_res)) |
4077 | return -EAGAIN; | 4078 | return -EAGAIN; |
4078 | if (nfs4_read_stateid_changed(task, &data->args)) | 4079 | if (nfs4_read_stateid_changed(task, &hdr->args)) |
4079 | return -EAGAIN; | 4080 | return -EAGAIN; |
4080 | return data->pgio_done_cb ? data->pgio_done_cb(task, data) : | 4081 | return hdr->pgio_done_cb ? hdr->pgio_done_cb(task, hdr) : |
4081 | nfs4_read_done_cb(task, data); | 4082 | nfs4_read_done_cb(task, hdr); |
4082 | } | 4083 | } |
4083 | 4084 | ||
4084 | static void nfs4_proc_read_setup(struct nfs_pgio_data *data, struct rpc_message *msg) | 4085 | static void nfs4_proc_read_setup(struct nfs_pgio_header *hdr, |
4086 | struct rpc_message *msg) | ||
4085 | { | 4087 | { |
4086 | data->timestamp = jiffies; | 4088 | hdr->timestamp = jiffies; |
4087 | data->pgio_done_cb = nfs4_read_done_cb; | 4089 | hdr->pgio_done_cb = nfs4_read_done_cb; |
4088 | msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_READ]; | 4090 | msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_READ]; |
4089 | nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 0); | 4091 | nfs4_init_sequence(&hdr->args.seq_args, &hdr->res.seq_res, 0); |
4090 | } | 4092 | } |
4091 | 4093 | ||
4092 | static int nfs4_proc_pgio_rpc_prepare(struct rpc_task *task, struct nfs_pgio_data *data) | 4094 | static int nfs4_proc_pgio_rpc_prepare(struct rpc_task *task, |
4095 | struct nfs_pgio_header *hdr) | ||
4093 | { | 4096 | { |
4094 | if (nfs4_setup_sequence(NFS_SERVER(data->header->inode), | 4097 | if (nfs4_setup_sequence(NFS_SERVER(hdr->inode), |
4095 | &data->args.seq_args, | 4098 | &hdr->args.seq_args, |
4096 | &data->res.seq_res, | 4099 | &hdr->res.seq_res, |
4097 | task)) | 4100 | task)) |
4098 | return 0; | 4101 | return 0; |
4099 | if (nfs4_set_rw_stateid(&data->args.stateid, data->args.context, | 4102 | if (nfs4_set_rw_stateid(&hdr->args.stateid, hdr->args.context, |
4100 | data->args.lock_context, data->header->rw_ops->rw_mode) == -EIO) | 4103 | hdr->args.lock_context, |
4104 | hdr->rw_ops->rw_mode) == -EIO) | ||
4101 | return -EIO; | 4105 | return -EIO; |
4102 | if (unlikely(test_bit(NFS_CONTEXT_BAD, &data->args.context->flags))) | 4106 | if (unlikely(test_bit(NFS_CONTEXT_BAD, &hdr->args.context->flags))) |
4103 | return -EIO; | 4107 | return -EIO; |
4104 | return 0; | 4108 | return 0; |
4105 | } | 4109 | } |
4106 | 4110 | ||
4107 | static int nfs4_write_done_cb(struct rpc_task *task, struct nfs_pgio_data *data) | 4111 | static int nfs4_write_done_cb(struct rpc_task *task, |
4112 | struct nfs_pgio_header *hdr) | ||
4108 | { | 4113 | { |
4109 | struct inode *inode = data->header->inode; | 4114 | struct inode *inode = hdr->inode; |
4110 | 4115 | ||
4111 | trace_nfs4_write(data, task->tk_status); | 4116 | trace_nfs4_write(hdr, task->tk_status); |
4112 | if (nfs4_async_handle_error(task, NFS_SERVER(inode), data->args.context->state) == -EAGAIN) { | 4117 | if (nfs4_async_handle_error(task, NFS_SERVER(inode), |
4118 | hdr->args.context->state) == -EAGAIN) { | ||
4113 | rpc_restart_call_prepare(task); | 4119 | rpc_restart_call_prepare(task); |
4114 | return -EAGAIN; | 4120 | return -EAGAIN; |
4115 | } | 4121 | } |
4116 | if (task->tk_status >= 0) { | 4122 | if (task->tk_status >= 0) { |
4117 | renew_lease(NFS_SERVER(inode), data->timestamp); | 4123 | renew_lease(NFS_SERVER(inode), hdr->timestamp); |
4118 | nfs_post_op_update_inode_force_wcc(inode, &data->fattr); | 4124 | nfs_post_op_update_inode_force_wcc(inode, &hdr->fattr); |
4119 | } | 4125 | } |
4120 | return 0; | 4126 | return 0; |
4121 | } | 4127 | } |
@@ -4134,23 +4140,21 @@ static bool nfs4_write_stateid_changed(struct rpc_task *task, | |||
4134 | return true; | 4140 | return true; |
4135 | } | 4141 | } |
4136 | 4142 | ||
4137 | static int nfs4_write_done(struct rpc_task *task, struct nfs_pgio_data *data) | 4143 | static int nfs4_write_done(struct rpc_task *task, struct nfs_pgio_header *hdr) |
4138 | { | 4144 | { |
4139 | if (!nfs4_sequence_done(task, &data->res.seq_res)) | 4145 | if (!nfs4_sequence_done(task, &hdr->res.seq_res)) |
4140 | return -EAGAIN; | 4146 | return -EAGAIN; |
4141 | if (nfs4_write_stateid_changed(task, &data->args)) | 4147 | if (nfs4_write_stateid_changed(task, &hdr->args)) |
4142 | return -EAGAIN; | 4148 | return -EAGAIN; |
4143 | return data->pgio_done_cb ? data->pgio_done_cb(task, data) : | 4149 | return hdr->pgio_done_cb ? hdr->pgio_done_cb(task, hdr) : |
4144 | nfs4_write_done_cb(task, data); | 4150 | nfs4_write_done_cb(task, hdr); |
4145 | } | 4151 | } |
4146 | 4152 | ||
4147 | static | 4153 | static |
4148 | bool nfs4_write_need_cache_consistency_data(const struct nfs_pgio_data *data) | 4154 | bool nfs4_write_need_cache_consistency_data(struct nfs_pgio_header *hdr) |
4149 | { | 4155 | { |
4150 | const struct nfs_pgio_header *hdr = data->header; | ||
4151 | |||
4152 | /* Don't request attributes for pNFS or O_DIRECT writes */ | 4156 | /* Don't request attributes for pNFS or O_DIRECT writes */ |
4153 | if (data->ds_clp != NULL || hdr->dreq != NULL) | 4157 | if (hdr->ds_clp != NULL || hdr->dreq != NULL) |
4154 | return false; | 4158 | return false; |
4155 | /* Otherwise, request attributes if and only if we don't hold | 4159 | /* Otherwise, request attributes if and only if we don't hold |
4156 | * a delegation | 4160 | * a delegation |
@@ -4158,23 +4162,24 @@ bool nfs4_write_need_cache_consistency_data(const struct nfs_pgio_data *data) | |||
4158 | return nfs4_have_delegation(hdr->inode, FMODE_READ) == 0; | 4162 | return nfs4_have_delegation(hdr->inode, FMODE_READ) == 0; |
4159 | } | 4163 | } |
4160 | 4164 | ||
4161 | static void nfs4_proc_write_setup(struct nfs_pgio_data *data, struct rpc_message *msg) | 4165 | static void nfs4_proc_write_setup(struct nfs_pgio_header *hdr, |
4166 | struct rpc_message *msg) | ||
4162 | { | 4167 | { |
4163 | struct nfs_server *server = NFS_SERVER(data->header->inode); | 4168 | struct nfs_server *server = NFS_SERVER(hdr->inode); |
4164 | 4169 | ||
4165 | if (!nfs4_write_need_cache_consistency_data(data)) { | 4170 | if (!nfs4_write_need_cache_consistency_data(hdr)) { |
4166 | data->args.bitmask = NULL; | 4171 | hdr->args.bitmask = NULL; |
4167 | data->res.fattr = NULL; | 4172 | hdr->res.fattr = NULL; |
4168 | } else | 4173 | } else |
4169 | data->args.bitmask = server->cache_consistency_bitmask; | 4174 | hdr->args.bitmask = server->cache_consistency_bitmask; |
4170 | 4175 | ||
4171 | if (!data->pgio_done_cb) | 4176 | if (!hdr->pgio_done_cb) |
4172 | data->pgio_done_cb = nfs4_write_done_cb; | 4177 | hdr->pgio_done_cb = nfs4_write_done_cb; |
4173 | data->res.server = server; | 4178 | hdr->res.server = server; |
4174 | data->timestamp = jiffies; | 4179 | hdr->timestamp = jiffies; |
4175 | 4180 | ||
4176 | msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_WRITE]; | 4181 | msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_WRITE]; |
4177 | nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1); | 4182 | nfs4_init_sequence(&hdr->args.seq_args, &hdr->res.seq_res, 1); |
4178 | } | 4183 | } |
4179 | 4184 | ||
4180 | static void nfs4_proc_commit_rpc_prepare(struct rpc_task *task, struct nfs_commit_data *data) | 4185 | static void nfs4_proc_commit_rpc_prepare(struct rpc_task *task, struct nfs_commit_data *data) |
diff --git a/fs/nfs/nfs4trace.h b/fs/nfs/nfs4trace.h index 0a744f3a86f6..1c32adbe728d 100644 --- a/fs/nfs/nfs4trace.h +++ b/fs/nfs/nfs4trace.h | |||
@@ -932,11 +932,11 @@ DEFINE_NFS4_IDMAP_EVENT(nfs4_map_gid_to_group); | |||
932 | 932 | ||
933 | DECLARE_EVENT_CLASS(nfs4_read_event, | 933 | DECLARE_EVENT_CLASS(nfs4_read_event, |
934 | TP_PROTO( | 934 | TP_PROTO( |
935 | const struct nfs_pgio_data *data, | 935 | const struct nfs_pgio_header *hdr, |
936 | int error | 936 | int error |
937 | ), | 937 | ), |
938 | 938 | ||
939 | TP_ARGS(data, error), | 939 | TP_ARGS(hdr, error), |
940 | 940 | ||
941 | TP_STRUCT__entry( | 941 | TP_STRUCT__entry( |
942 | __field(dev_t, dev) | 942 | __field(dev_t, dev) |
@@ -948,12 +948,12 @@ DECLARE_EVENT_CLASS(nfs4_read_event, | |||
948 | ), | 948 | ), |
949 | 949 | ||
950 | TP_fast_assign( | 950 | TP_fast_assign( |
951 | const struct inode *inode = data->header->inode; | 951 | const struct inode *inode = hdr->inode; |
952 | __entry->dev = inode->i_sb->s_dev; | 952 | __entry->dev = inode->i_sb->s_dev; |
953 | __entry->fileid = NFS_FILEID(inode); | 953 | __entry->fileid = NFS_FILEID(inode); |
954 | __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode)); | 954 | __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode)); |
955 | __entry->offset = data->args.offset; | 955 | __entry->offset = hdr->args.offset; |
956 | __entry->count = data->args.count; | 956 | __entry->count = hdr->args.count; |
957 | __entry->error = error; | 957 | __entry->error = error; |
958 | ), | 958 | ), |
959 | 959 | ||
@@ -972,10 +972,10 @@ DECLARE_EVENT_CLASS(nfs4_read_event, | |||
972 | #define DEFINE_NFS4_READ_EVENT(name) \ | 972 | #define DEFINE_NFS4_READ_EVENT(name) \ |
973 | DEFINE_EVENT(nfs4_read_event, name, \ | 973 | DEFINE_EVENT(nfs4_read_event, name, \ |
974 | TP_PROTO( \ | 974 | TP_PROTO( \ |
975 | const struct nfs_pgio_data *data, \ | 975 | const struct nfs_pgio_header *hdr, \ |
976 | int error \ | 976 | int error \ |
977 | ), \ | 977 | ), \ |
978 | TP_ARGS(data, error)) | 978 | TP_ARGS(hdr, error)) |
979 | DEFINE_NFS4_READ_EVENT(nfs4_read); | 979 | DEFINE_NFS4_READ_EVENT(nfs4_read); |
980 | #ifdef CONFIG_NFS_V4_1 | 980 | #ifdef CONFIG_NFS_V4_1 |
981 | DEFINE_NFS4_READ_EVENT(nfs4_pnfs_read); | 981 | DEFINE_NFS4_READ_EVENT(nfs4_pnfs_read); |
@@ -983,11 +983,11 @@ DEFINE_NFS4_READ_EVENT(nfs4_pnfs_read); | |||
983 | 983 | ||
984 | DECLARE_EVENT_CLASS(nfs4_write_event, | 984 | DECLARE_EVENT_CLASS(nfs4_write_event, |
985 | TP_PROTO( | 985 | TP_PROTO( |
986 | const struct nfs_pgio_data *data, | 986 | const struct nfs_pgio_header *hdr, |
987 | int error | 987 | int error |
988 | ), | 988 | ), |
989 | 989 | ||
990 | TP_ARGS(data, error), | 990 | TP_ARGS(hdr, error), |
991 | 991 | ||
992 | TP_STRUCT__entry( | 992 | TP_STRUCT__entry( |
993 | __field(dev_t, dev) | 993 | __field(dev_t, dev) |
@@ -999,12 +999,12 @@ DECLARE_EVENT_CLASS(nfs4_write_event, | |||
999 | ), | 999 | ), |
1000 | 1000 | ||
1001 | TP_fast_assign( | 1001 | TP_fast_assign( |
1002 | const struct inode *inode = data->header->inode; | 1002 | const struct inode *inode = hdr->inode; |
1003 | __entry->dev = inode->i_sb->s_dev; | 1003 | __entry->dev = inode->i_sb->s_dev; |
1004 | __entry->fileid = NFS_FILEID(inode); | 1004 | __entry->fileid = NFS_FILEID(inode); |
1005 | __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode)); | 1005 | __entry->fhandle = nfs_fhandle_hash(NFS_FH(inode)); |
1006 | __entry->offset = data->args.offset; | 1006 | __entry->offset = hdr->args.offset; |
1007 | __entry->count = data->args.count; | 1007 | __entry->count = hdr->args.count; |
1008 | __entry->error = error; | 1008 | __entry->error = error; |
1009 | ), | 1009 | ), |
1010 | 1010 | ||
@@ -1024,10 +1024,10 @@ DECLARE_EVENT_CLASS(nfs4_write_event, | |||
1024 | #define DEFINE_NFS4_WRITE_EVENT(name) \ | 1024 | #define DEFINE_NFS4_WRITE_EVENT(name) \ |
1025 | DEFINE_EVENT(nfs4_write_event, name, \ | 1025 | DEFINE_EVENT(nfs4_write_event, name, \ |
1026 | TP_PROTO( \ | 1026 | TP_PROTO( \ |
1027 | const struct nfs_pgio_data *data, \ | 1027 | const struct nfs_pgio_header *hdr, \ |
1028 | int error \ | 1028 | int error \ |
1029 | ), \ | 1029 | ), \ |
1030 | TP_ARGS(data, error)) | 1030 | TP_ARGS(hdr, error)) |
1031 | DEFINE_NFS4_WRITE_EVENT(nfs4_write); | 1031 | DEFINE_NFS4_WRITE_EVENT(nfs4_write); |
1032 | #ifdef CONFIG_NFS_V4_1 | 1032 | #ifdef CONFIG_NFS_V4_1 |
1033 | DEFINE_NFS4_WRITE_EVENT(nfs4_pnfs_write); | 1033 | DEFINE_NFS4_WRITE_EVENT(nfs4_pnfs_write); |
diff --git a/fs/nfs/objlayout/objio_osd.c b/fs/nfs/objlayout/objio_osd.c index 611320753db2..ae05278b3761 100644 --- a/fs/nfs/objlayout/objio_osd.c +++ b/fs/nfs/objlayout/objio_osd.c | |||
@@ -439,22 +439,21 @@ static void _read_done(struct ore_io_state *ios, void *private) | |||
439 | objlayout_read_done(&objios->oir, status, objios->sync); | 439 | objlayout_read_done(&objios->oir, status, objios->sync); |
440 | } | 440 | } |
441 | 441 | ||
442 | int objio_read_pagelist(struct nfs_pgio_data *rdata) | 442 | int objio_read_pagelist(struct nfs_pgio_header *hdr) |
443 | { | 443 | { |
444 | struct nfs_pgio_header *hdr = rdata->header; | ||
445 | struct objio_state *objios; | 444 | struct objio_state *objios; |
446 | int ret; | 445 | int ret; |
447 | 446 | ||
448 | ret = objio_alloc_io_state(NFS_I(hdr->inode)->layout, true, | 447 | ret = objio_alloc_io_state(NFS_I(hdr->inode)->layout, true, |
449 | hdr->lseg, rdata->args.pages, rdata->args.pgbase, | 448 | hdr->lseg, hdr->args.pages, hdr->args.pgbase, |
450 | rdata->args.offset, rdata->args.count, rdata, | 449 | hdr->args.offset, hdr->args.count, hdr, |
451 | GFP_KERNEL, &objios); | 450 | GFP_KERNEL, &objios); |
452 | if (unlikely(ret)) | 451 | if (unlikely(ret)) |
453 | return ret; | 452 | return ret; |
454 | 453 | ||
455 | objios->ios->done = _read_done; | 454 | objios->ios->done = _read_done; |
456 | dprintk("%s: offset=0x%llx length=0x%x\n", __func__, | 455 | dprintk("%s: offset=0x%llx length=0x%x\n", __func__, |
457 | rdata->args.offset, rdata->args.count); | 456 | hdr->args.offset, hdr->args.count); |
458 | ret = ore_read(objios->ios); | 457 | ret = ore_read(objios->ios); |
459 | if (unlikely(ret)) | 458 | if (unlikely(ret)) |
460 | objio_free_result(&objios->oir); | 459 | objio_free_result(&objios->oir); |
@@ -487,11 +486,11 @@ static void _write_done(struct ore_io_state *ios, void *private) | |||
487 | static struct page *__r4w_get_page(void *priv, u64 offset, bool *uptodate) | 486 | static struct page *__r4w_get_page(void *priv, u64 offset, bool *uptodate) |
488 | { | 487 | { |
489 | struct objio_state *objios = priv; | 488 | struct objio_state *objios = priv; |
490 | struct nfs_pgio_data *wdata = objios->oir.rpcdata; | 489 | struct nfs_pgio_header *hdr = objios->oir.rpcdata; |
491 | struct address_space *mapping = wdata->header->inode->i_mapping; | 490 | struct address_space *mapping = hdr->inode->i_mapping; |
492 | pgoff_t index = offset / PAGE_SIZE; | 491 | pgoff_t index = offset / PAGE_SIZE; |
493 | struct page *page; | 492 | struct page *page; |
494 | loff_t i_size = i_size_read(wdata->header->inode); | 493 | loff_t i_size = i_size_read(hdr->inode); |
495 | 494 | ||
496 | if (offset >= i_size) { | 495 | if (offset >= i_size) { |
497 | *uptodate = true; | 496 | *uptodate = true; |
@@ -531,15 +530,14 @@ static const struct _ore_r4w_op _r4w_op = { | |||
531 | .put_page = &__r4w_put_page, | 530 | .put_page = &__r4w_put_page, |
532 | }; | 531 | }; |
533 | 532 | ||
534 | int objio_write_pagelist(struct nfs_pgio_data *wdata, int how) | 533 | int objio_write_pagelist(struct nfs_pgio_header *hdr, int how) |
535 | { | 534 | { |
536 | struct nfs_pgio_header *hdr = wdata->header; | ||
537 | struct objio_state *objios; | 535 | struct objio_state *objios; |
538 | int ret; | 536 | int ret; |
539 | 537 | ||
540 | ret = objio_alloc_io_state(NFS_I(hdr->inode)->layout, false, | 538 | ret = objio_alloc_io_state(NFS_I(hdr->inode)->layout, false, |
541 | hdr->lseg, wdata->args.pages, wdata->args.pgbase, | 539 | hdr->lseg, hdr->args.pages, hdr->args.pgbase, |
542 | wdata->args.offset, wdata->args.count, wdata, GFP_NOFS, | 540 | hdr->args.offset, hdr->args.count, hdr, GFP_NOFS, |
543 | &objios); | 541 | &objios); |
544 | if (unlikely(ret)) | 542 | if (unlikely(ret)) |
545 | return ret; | 543 | return ret; |
@@ -551,7 +549,7 @@ int objio_write_pagelist(struct nfs_pgio_data *wdata, int how) | |||
551 | objios->ios->done = _write_done; | 549 | objios->ios->done = _write_done; |
552 | 550 | ||
553 | dprintk("%s: offset=0x%llx length=0x%x\n", __func__, | 551 | dprintk("%s: offset=0x%llx length=0x%x\n", __func__, |
554 | wdata->args.offset, wdata->args.count); | 552 | hdr->args.offset, hdr->args.count); |
555 | ret = ore_write(objios->ios); | 553 | ret = ore_write(objios->ios); |
556 | if (unlikely(ret)) { | 554 | if (unlikely(ret)) { |
557 | objio_free_result(&objios->oir); | 555 | objio_free_result(&objios->oir); |
diff --git a/fs/nfs/objlayout/objlayout.c b/fs/nfs/objlayout/objlayout.c index 31fed91a8bac..86312787cee6 100644 --- a/fs/nfs/objlayout/objlayout.c +++ b/fs/nfs/objlayout/objlayout.c | |||
@@ -229,36 +229,36 @@ objlayout_io_set_result(struct objlayout_io_res *oir, unsigned index, | |||
229 | static void _rpc_read_complete(struct work_struct *work) | 229 | static void _rpc_read_complete(struct work_struct *work) |
230 | { | 230 | { |
231 | struct rpc_task *task; | 231 | struct rpc_task *task; |
232 | struct nfs_pgio_data *rdata; | 232 | struct nfs_pgio_header *hdr; |
233 | 233 | ||
234 | dprintk("%s enter\n", __func__); | 234 | dprintk("%s enter\n", __func__); |
235 | task = container_of(work, struct rpc_task, u.tk_work); | 235 | task = container_of(work, struct rpc_task, u.tk_work); |
236 | rdata = container_of(task, struct nfs_pgio_data, task); | 236 | hdr = container_of(task, struct nfs_pgio_header, task); |
237 | 237 | ||
238 | pnfs_ld_read_done(rdata); | 238 | pnfs_ld_read_done(hdr); |
239 | } | 239 | } |
240 | 240 | ||
241 | void | 241 | void |
242 | objlayout_read_done(struct objlayout_io_res *oir, ssize_t status, bool sync) | 242 | objlayout_read_done(struct objlayout_io_res *oir, ssize_t status, bool sync) |
243 | { | 243 | { |
244 | struct nfs_pgio_data *rdata = oir->rpcdata; | 244 | struct nfs_pgio_header *hdr = oir->rpcdata; |
245 | 245 | ||
246 | oir->status = rdata->task.tk_status = status; | 246 | oir->status = hdr->task.tk_status = status; |
247 | if (status >= 0) | 247 | if (status >= 0) |
248 | rdata->res.count = status; | 248 | hdr->res.count = status; |
249 | else | 249 | else |
250 | rdata->header->pnfs_error = status; | 250 | hdr->pnfs_error = status; |
251 | objlayout_iodone(oir); | 251 | objlayout_iodone(oir); |
252 | /* must not use oir after this point */ | 252 | /* must not use oir after this point */ |
253 | 253 | ||
254 | dprintk("%s: Return status=%zd eof=%d sync=%d\n", __func__, | 254 | dprintk("%s: Return status=%zd eof=%d sync=%d\n", __func__, |
255 | status, rdata->res.eof, sync); | 255 | status, hdr->res.eof, sync); |
256 | 256 | ||
257 | if (sync) | 257 | if (sync) |
258 | pnfs_ld_read_done(rdata); | 258 | pnfs_ld_read_done(hdr); |
259 | else { | 259 | else { |
260 | INIT_WORK(&rdata->task.u.tk_work, _rpc_read_complete); | 260 | INIT_WORK(&hdr->task.u.tk_work, _rpc_read_complete); |
261 | schedule_work(&rdata->task.u.tk_work); | 261 | schedule_work(&hdr->task.u.tk_work); |
262 | } | 262 | } |
263 | } | 263 | } |
264 | 264 | ||
@@ -266,12 +266,11 @@ objlayout_read_done(struct objlayout_io_res *oir, ssize_t status, bool sync) | |||
266 | * Perform sync or async reads. | 266 | * Perform sync or async reads. |
267 | */ | 267 | */ |
268 | enum pnfs_try_status | 268 | enum pnfs_try_status |
269 | objlayout_read_pagelist(struct nfs_pgio_data *rdata) | 269 | objlayout_read_pagelist(struct nfs_pgio_header *hdr) |
270 | { | 270 | { |
271 | struct nfs_pgio_header *hdr = rdata->header; | ||
272 | struct inode *inode = hdr->inode; | 271 | struct inode *inode = hdr->inode; |
273 | loff_t offset = rdata->args.offset; | 272 | loff_t offset = hdr->args.offset; |
274 | size_t count = rdata->args.count; | 273 | size_t count = hdr->args.count; |
275 | int err; | 274 | int err; |
276 | loff_t eof; | 275 | loff_t eof; |
277 | 276 | ||
@@ -279,23 +278,23 @@ objlayout_read_pagelist(struct nfs_pgio_data *rdata) | |||
279 | if (unlikely(offset + count > eof)) { | 278 | if (unlikely(offset + count > eof)) { |
280 | if (offset >= eof) { | 279 | if (offset >= eof) { |
281 | err = 0; | 280 | err = 0; |
282 | rdata->res.count = 0; | 281 | hdr->res.count = 0; |
283 | rdata->res.eof = 1; | 282 | hdr->res.eof = 1; |
284 | /*FIXME: do we need to call pnfs_ld_read_done() */ | 283 | /*FIXME: do we need to call pnfs_ld_read_done() */ |
285 | goto out; | 284 | goto out; |
286 | } | 285 | } |
287 | count = eof - offset; | 286 | count = eof - offset; |
288 | } | 287 | } |
289 | 288 | ||
290 | rdata->res.eof = (offset + count) >= eof; | 289 | hdr->res.eof = (offset + count) >= eof; |
291 | _fix_verify_io_params(hdr->lseg, &rdata->args.pages, | 290 | _fix_verify_io_params(hdr->lseg, &hdr->args.pages, |
292 | &rdata->args.pgbase, | 291 | &hdr->args.pgbase, |
293 | rdata->args.offset, rdata->args.count); | 292 | hdr->args.offset, hdr->args.count); |
294 | 293 | ||
295 | dprintk("%s: inode(%lx) offset 0x%llx count 0x%Zx eof=%d\n", | 294 | dprintk("%s: inode(%lx) offset 0x%llx count 0x%Zx eof=%d\n", |
296 | __func__, inode->i_ino, offset, count, rdata->res.eof); | 295 | __func__, inode->i_ino, offset, count, hdr->res.eof); |
297 | 296 | ||
298 | err = objio_read_pagelist(rdata); | 297 | err = objio_read_pagelist(hdr); |
299 | out: | 298 | out: |
300 | if (unlikely(err)) { | 299 | if (unlikely(err)) { |
301 | hdr->pnfs_error = err; | 300 | hdr->pnfs_error = err; |
@@ -312,38 +311,38 @@ objlayout_read_pagelist(struct nfs_pgio_data *rdata) | |||
312 | static void _rpc_write_complete(struct work_struct *work) | 311 | static void _rpc_write_complete(struct work_struct *work) |
313 | { | 312 | { |
314 | struct rpc_task *task; | 313 | struct rpc_task *task; |
315 | struct nfs_pgio_data *wdata; | 314 | struct nfs_pgio_header *hdr; |
316 | 315 | ||
317 | dprintk("%s enter\n", __func__); | 316 | dprintk("%s enter\n", __func__); |
318 | task = container_of(work, struct rpc_task, u.tk_work); | 317 | task = container_of(work, struct rpc_task, u.tk_work); |
319 | wdata = container_of(task, struct nfs_pgio_data, task); | 318 | hdr = container_of(task, struct nfs_pgio_header, task); |
320 | 319 | ||
321 | pnfs_ld_write_done(wdata); | 320 | pnfs_ld_write_done(hdr); |
322 | } | 321 | } |
323 | 322 | ||
324 | void | 323 | void |
325 | objlayout_write_done(struct objlayout_io_res *oir, ssize_t status, bool sync) | 324 | objlayout_write_done(struct objlayout_io_res *oir, ssize_t status, bool sync) |
326 | { | 325 | { |
327 | struct nfs_pgio_data *wdata = oir->rpcdata; | 326 | struct nfs_pgio_header *hdr = oir->rpcdata; |
328 | 327 | ||
329 | oir->status = wdata->task.tk_status = status; | 328 | oir->status = hdr->task.tk_status = status; |
330 | if (status >= 0) { | 329 | if (status >= 0) { |
331 | wdata->res.count = status; | 330 | hdr->res.count = status; |
332 | wdata->writeverf.committed = oir->committed; | 331 | hdr->writeverf.committed = oir->committed; |
333 | } else { | 332 | } else { |
334 | wdata->header->pnfs_error = status; | 333 | hdr->pnfs_error = status; |
335 | } | 334 | } |
336 | objlayout_iodone(oir); | 335 | objlayout_iodone(oir); |
337 | /* must not use oir after this point */ | 336 | /* must not use oir after this point */ |
338 | 337 | ||
339 | dprintk("%s: Return status %zd committed %d sync=%d\n", __func__, | 338 | dprintk("%s: Return status %zd committed %d sync=%d\n", __func__, |
340 | status, wdata->writeverf.committed, sync); | 339 | status, hdr->writeverf.committed, sync); |
341 | 340 | ||
342 | if (sync) | 341 | if (sync) |
343 | pnfs_ld_write_done(wdata); | 342 | pnfs_ld_write_done(hdr); |
344 | else { | 343 | else { |
345 | INIT_WORK(&wdata->task.u.tk_work, _rpc_write_complete); | 344 | INIT_WORK(&hdr->task.u.tk_work, _rpc_write_complete); |
346 | schedule_work(&wdata->task.u.tk_work); | 345 | schedule_work(&hdr->task.u.tk_work); |
347 | } | 346 | } |
348 | } | 347 | } |
349 | 348 | ||
@@ -351,17 +350,15 @@ objlayout_write_done(struct objlayout_io_res *oir, ssize_t status, bool sync) | |||
351 | * Perform sync or async writes. | 350 | * Perform sync or async writes. |
352 | */ | 351 | */ |
353 | enum pnfs_try_status | 352 | enum pnfs_try_status |
354 | objlayout_write_pagelist(struct nfs_pgio_data *wdata, | 353 | objlayout_write_pagelist(struct nfs_pgio_header *hdr, int how) |
355 | int how) | ||
356 | { | 354 | { |
357 | struct nfs_pgio_header *hdr = wdata->header; | ||
358 | int err; | 355 | int err; |
359 | 356 | ||
360 | _fix_verify_io_params(hdr->lseg, &wdata->args.pages, | 357 | _fix_verify_io_params(hdr->lseg, &hdr->args.pages, |
361 | &wdata->args.pgbase, | 358 | &hdr->args.pgbase, |
362 | wdata->args.offset, wdata->args.count); | 359 | hdr->args.offset, hdr->args.count); |
363 | 360 | ||
364 | err = objio_write_pagelist(wdata, how); | 361 | err = objio_write_pagelist(hdr, how); |
365 | if (unlikely(err)) { | 362 | if (unlikely(err)) { |
366 | hdr->pnfs_error = err; | 363 | hdr->pnfs_error = err; |
367 | dprintk("%s: Returned Error %d\n", __func__, err); | 364 | dprintk("%s: Returned Error %d\n", __func__, err); |
diff --git a/fs/nfs/objlayout/objlayout.h b/fs/nfs/objlayout/objlayout.h index 01e041029a6c..fd13f1d2f136 100644 --- a/fs/nfs/objlayout/objlayout.h +++ b/fs/nfs/objlayout/objlayout.h | |||
@@ -119,8 +119,8 @@ extern void objio_free_lseg(struct pnfs_layout_segment *lseg); | |||
119 | */ | 119 | */ |
120 | extern void objio_free_result(struct objlayout_io_res *oir); | 120 | extern void objio_free_result(struct objlayout_io_res *oir); |
121 | 121 | ||
122 | extern int objio_read_pagelist(struct nfs_pgio_data *rdata); | 122 | extern int objio_read_pagelist(struct nfs_pgio_header *rdata); |
123 | extern int objio_write_pagelist(struct nfs_pgio_data *wdata, int how); | 123 | extern int objio_write_pagelist(struct nfs_pgio_header *wdata, int how); |
124 | 124 | ||
125 | /* | 125 | /* |
126 | * callback API | 126 | * callback API |
@@ -168,10 +168,10 @@ extern struct pnfs_layout_segment *objlayout_alloc_lseg( | |||
168 | extern void objlayout_free_lseg(struct pnfs_layout_segment *); | 168 | extern void objlayout_free_lseg(struct pnfs_layout_segment *); |
169 | 169 | ||
170 | extern enum pnfs_try_status objlayout_read_pagelist( | 170 | extern enum pnfs_try_status objlayout_read_pagelist( |
171 | struct nfs_pgio_data *); | 171 | struct nfs_pgio_header *); |
172 | 172 | ||
173 | extern enum pnfs_try_status objlayout_write_pagelist( | 173 | extern enum pnfs_try_status objlayout_write_pagelist( |
174 | struct nfs_pgio_data *, | 174 | struct nfs_pgio_header *, |
175 | int how); | 175 | int how); |
176 | 176 | ||
177 | extern void objlayout_encode_layoutcommit( | 177 | extern void objlayout_encode_layoutcommit( |
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c index 5e70918f6c95..ecb3d4cdbc85 100644 --- a/fs/nfs/pagelist.c +++ b/fs/nfs/pagelist.c | |||
@@ -484,8 +484,7 @@ EXPORT_SYMBOL_GPL(nfs_pgio_header_free); | |||
484 | static bool nfs_pgio_data_init(struct nfs_pgio_header *hdr, | 484 | static bool nfs_pgio_data_init(struct nfs_pgio_header *hdr, |
485 | unsigned int pagecount) | 485 | unsigned int pagecount) |
486 | { | 486 | { |
487 | if (nfs_pgarray_set(&hdr->data.page_array, pagecount)) { | 487 | if (nfs_pgarray_set(&hdr->page_array, pagecount)) { |
488 | hdr->data.header = hdr; | ||
489 | atomic_inc(&hdr->refcnt); | 488 | atomic_inc(&hdr->refcnt); |
490 | return true; | 489 | return true; |
491 | } | 490 | } |
@@ -493,16 +492,14 @@ static bool nfs_pgio_data_init(struct nfs_pgio_header *hdr, | |||
493 | } | 492 | } |
494 | 493 | ||
495 | /** | 494 | /** |
496 | * nfs_pgio_data_destroy - Properly free pageio data | 495 | * nfs_pgio_data_destroy - Properly release pageio data |
497 | * @data: The data to destroy | 496 | * @hdr: The header with data to destroy |
498 | */ | 497 | */ |
499 | void nfs_pgio_data_destroy(struct nfs_pgio_data *data) | 498 | void nfs_pgio_data_destroy(struct nfs_pgio_header *hdr) |
500 | { | 499 | { |
501 | struct nfs_pgio_header *hdr = data->header; | 500 | put_nfs_open_context(hdr->args.context); |
502 | 501 | if (hdr->page_array.pagevec != hdr->page_array.page_array) | |
503 | put_nfs_open_context(data->args.context); | 502 | kfree(hdr->page_array.pagevec); |
504 | if (data->page_array.pagevec != data->page_array.page_array) | ||
505 | kfree(data->page_array.pagevec); | ||
506 | if (atomic_dec_and_test(&hdr->refcnt)) | 503 | if (atomic_dec_and_test(&hdr->refcnt)) |
507 | hdr->completion_ops->completion(hdr); | 504 | hdr->completion_ops->completion(hdr); |
508 | } | 505 | } |
@@ -510,31 +507,31 @@ EXPORT_SYMBOL_GPL(nfs_pgio_data_destroy); | |||
510 | 507 | ||
511 | /** | 508 | /** |
512 | * nfs_pgio_rpcsetup - Set up arguments for a pageio call | 509 | * nfs_pgio_rpcsetup - Set up arguments for a pageio call |
513 | * @data: The pageio data | 510 | * @hdr: The pageio hdr |
514 | * @count: Number of bytes to read | 511 | * @count: Number of bytes to read |
515 | * @offset: Initial offset | 512 | * @offset: Initial offset |
516 | * @how: How to commit data (writes only) | 513 | * @how: How to commit data (writes only) |
517 | * @cinfo: Commit information for the call (writes only) | 514 | * @cinfo: Commit information for the call (writes only) |
518 | */ | 515 | */ |
519 | static void nfs_pgio_rpcsetup(struct nfs_pgio_data *data, | 516 | static void nfs_pgio_rpcsetup(struct nfs_pgio_header *hdr, |
520 | unsigned int count, unsigned int offset, | 517 | unsigned int count, unsigned int offset, |
521 | int how, struct nfs_commit_info *cinfo) | 518 | int how, struct nfs_commit_info *cinfo) |
522 | { | 519 | { |
523 | struct nfs_page *req = data->header->req; | 520 | struct nfs_page *req = hdr->req; |
524 | 521 | ||
525 | /* Set up the RPC argument and reply structs | 522 | /* Set up the RPC argument and reply structs |
526 | * NB: take care not to mess about with data->commit et al. */ | 523 | * NB: take care not to mess about with hdr->commit et al. */ |
527 | 524 | ||
528 | data->args.fh = NFS_FH(data->header->inode); | 525 | hdr->args.fh = NFS_FH(hdr->inode); |
529 | data->args.offset = req_offset(req) + offset; | 526 | hdr->args.offset = req_offset(req) + offset; |
530 | /* pnfs_set_layoutcommit needs this */ | 527 | /* pnfs_set_layoutcommit needs this */ |
531 | data->mds_offset = data->args.offset; | 528 | hdr->mds_offset = hdr->args.offset; |
532 | data->args.pgbase = req->wb_pgbase + offset; | 529 | hdr->args.pgbase = req->wb_pgbase + offset; |
533 | data->args.pages = data->page_array.pagevec; | 530 | hdr->args.pages = hdr->page_array.pagevec; |
534 | data->args.count = count; | 531 | hdr->args.count = count; |
535 | data->args.context = get_nfs_open_context(req->wb_context); | 532 | hdr->args.context = get_nfs_open_context(req->wb_context); |
536 | data->args.lock_context = req->wb_lock_context; | 533 | hdr->args.lock_context = req->wb_lock_context; |
537 | data->args.stable = NFS_UNSTABLE; | 534 | hdr->args.stable = NFS_UNSTABLE; |
538 | switch (how & (FLUSH_STABLE | FLUSH_COND_STABLE)) { | 535 | switch (how & (FLUSH_STABLE | FLUSH_COND_STABLE)) { |
539 | case 0: | 536 | case 0: |
540 | break; | 537 | break; |
@@ -542,59 +539,60 @@ static void nfs_pgio_rpcsetup(struct nfs_pgio_data *data, | |||
542 | if (nfs_reqs_to_commit(cinfo)) | 539 | if (nfs_reqs_to_commit(cinfo)) |
543 | break; | 540 | break; |
544 | default: | 541 | default: |
545 | data->args.stable = NFS_FILE_SYNC; | 542 | hdr->args.stable = NFS_FILE_SYNC; |
546 | } | 543 | } |
547 | 544 | ||
548 | data->res.fattr = &data->fattr; | 545 | hdr->res.fattr = &hdr->fattr; |
549 | data->res.count = count; | 546 | hdr->res.count = count; |
550 | data->res.eof = 0; | 547 | hdr->res.eof = 0; |
551 | data->res.verf = &data->writeverf; | 548 | hdr->res.verf = &hdr->writeverf; |
552 | nfs_fattr_init(&data->fattr); | 549 | nfs_fattr_init(&hdr->fattr); |
553 | } | 550 | } |
554 | 551 | ||
555 | /** | 552 | /** |
556 | * nfs_pgio_prepare - Prepare pageio data to go over the wire | 553 | * nfs_pgio_prepare - Prepare pageio hdr to go over the wire |
557 | * @task: The current task | 554 | * @task: The current task |
558 | * @calldata: pageio data to prepare | 555 | * @calldata: pageio header to prepare |
559 | */ | 556 | */ |
560 | static void nfs_pgio_prepare(struct rpc_task *task, void *calldata) | 557 | static void nfs_pgio_prepare(struct rpc_task *task, void *calldata) |
561 | { | 558 | { |
562 | struct nfs_pgio_data *data = calldata; | 559 | struct nfs_pgio_header *hdr = calldata; |
563 | int err; | 560 | int err; |
564 | err = NFS_PROTO(data->header->inode)->pgio_rpc_prepare(task, data); | 561 | err = NFS_PROTO(hdr->inode)->pgio_rpc_prepare(task, hdr); |
565 | if (err) | 562 | if (err) |
566 | rpc_exit(task, err); | 563 | rpc_exit(task, err); |
567 | } | 564 | } |
568 | 565 | ||
569 | int nfs_initiate_pgio(struct rpc_clnt *clnt, struct nfs_pgio_data *data, | 566 | int nfs_initiate_pgio(struct rpc_clnt *clnt, struct nfs_pgio_header *hdr, |
570 | const struct rpc_call_ops *call_ops, int how, int flags) | 567 | const struct rpc_call_ops *call_ops, int how, int flags) |
571 | { | 568 | { |
569 | struct inode *inode = hdr->inode; | ||
572 | struct rpc_task *task; | 570 | struct rpc_task *task; |
573 | struct rpc_message msg = { | 571 | struct rpc_message msg = { |
574 | .rpc_argp = &data->args, | 572 | .rpc_argp = &hdr->args, |
575 | .rpc_resp = &data->res, | 573 | .rpc_resp = &hdr->res, |
576 | .rpc_cred = data->header->cred, | 574 | .rpc_cred = hdr->cred, |
577 | }; | 575 | }; |
578 | struct rpc_task_setup task_setup_data = { | 576 | struct rpc_task_setup task_setup_data = { |
579 | .rpc_client = clnt, | 577 | .rpc_client = clnt, |
580 | .task = &data->task, | 578 | .task = &hdr->task, |
581 | .rpc_message = &msg, | 579 | .rpc_message = &msg, |
582 | .callback_ops = call_ops, | 580 | .callback_ops = call_ops, |
583 | .callback_data = data, | 581 | .callback_data = hdr, |
584 | .workqueue = nfsiod_workqueue, | 582 | .workqueue = nfsiod_workqueue, |
585 | .flags = RPC_TASK_ASYNC | flags, | 583 | .flags = RPC_TASK_ASYNC | flags, |
586 | }; | 584 | }; |
587 | int ret = 0; | 585 | int ret = 0; |
588 | 586 | ||
589 | data->header->rw_ops->rw_initiate(data, &msg, &task_setup_data, how); | 587 | hdr->rw_ops->rw_initiate(hdr, &msg, &task_setup_data, how); |
590 | 588 | ||
591 | dprintk("NFS: %5u initiated pgio call " | 589 | dprintk("NFS: %5u initiated pgio call " |
592 | "(req %s/%llu, %u bytes @ offset %llu)\n", | 590 | "(req %s/%llu, %u bytes @ offset %llu)\n", |
593 | data->task.tk_pid, | 591 | hdr->task.tk_pid, |
594 | data->header->inode->i_sb->s_id, | 592 | inode->i_sb->s_id, |
595 | (unsigned long long)NFS_FILEID(data->header->inode), | 593 | (unsigned long long)NFS_FILEID(inode), |
596 | data->args.count, | 594 | hdr->args.count, |
597 | (unsigned long long)data->args.offset); | 595 | (unsigned long long)hdr->args.offset); |
598 | 596 | ||
599 | task = rpc_run_task(&task_setup_data); | 597 | task = rpc_run_task(&task_setup_data); |
600 | if (IS_ERR(task)) { | 598 | if (IS_ERR(task)) { |
@@ -621,21 +619,21 @@ static int nfs_pgio_error(struct nfs_pageio_descriptor *desc, | |||
621 | struct nfs_pgio_header *hdr) | 619 | struct nfs_pgio_header *hdr) |
622 | { | 620 | { |
623 | set_bit(NFS_IOHDR_REDO, &hdr->flags); | 621 | set_bit(NFS_IOHDR_REDO, &hdr->flags); |
624 | nfs_pgio_data_destroy(&hdr->data); | 622 | nfs_pgio_data_destroy(hdr); |
625 | desc->pg_completion_ops->error_cleanup(&desc->pg_list); | 623 | desc->pg_completion_ops->error_cleanup(&desc->pg_list); |
626 | return -ENOMEM; | 624 | return -ENOMEM; |
627 | } | 625 | } |
628 | 626 | ||
629 | /** | 627 | /** |
630 | * nfs_pgio_release - Release pageio data | 628 | * nfs_pgio_release - Release pageio data |
631 | * @calldata: The pageio data to release | 629 | * @calldata: The pageio header to release |
632 | */ | 630 | */ |
633 | static void nfs_pgio_release(void *calldata) | 631 | static void nfs_pgio_release(void *calldata) |
634 | { | 632 | { |
635 | struct nfs_pgio_data *data = calldata; | 633 | struct nfs_pgio_header *hdr = calldata; |
636 | if (data->header->rw_ops->rw_release) | 634 | if (hdr->rw_ops->rw_release) |
637 | data->header->rw_ops->rw_release(data); | 635 | hdr->rw_ops->rw_release(hdr); |
638 | nfs_pgio_data_destroy(data); | 636 | nfs_pgio_data_destroy(hdr); |
639 | } | 637 | } |
640 | 638 | ||
641 | /** | 639 | /** |
@@ -676,22 +674,22 @@ EXPORT_SYMBOL_GPL(nfs_pageio_init); | |||
676 | /** | 674 | /** |
677 | * nfs_pgio_result - Basic pageio error handling | 675 | * nfs_pgio_result - Basic pageio error handling |
678 | * @task: The task that ran | 676 | * @task: The task that ran |
679 | * @calldata: Pageio data to check | 677 | * @calldata: Pageio header to check |
680 | */ | 678 | */ |
681 | static void nfs_pgio_result(struct rpc_task *task, void *calldata) | 679 | static void nfs_pgio_result(struct rpc_task *task, void *calldata) |
682 | { | 680 | { |
683 | struct nfs_pgio_data *data = calldata; | 681 | struct nfs_pgio_header *hdr = calldata; |
684 | struct inode *inode = data->header->inode; | 682 | struct inode *inode = hdr->inode; |
685 | 683 | ||
686 | dprintk("NFS: %s: %5u, (status %d)\n", __func__, | 684 | dprintk("NFS: %s: %5u, (status %d)\n", __func__, |
687 | task->tk_pid, task->tk_status); | 685 | task->tk_pid, task->tk_status); |
688 | 686 | ||
689 | if (data->header->rw_ops->rw_done(task, data, inode) != 0) | 687 | if (hdr->rw_ops->rw_done(task, hdr, inode) != 0) |
690 | return; | 688 | return; |
691 | if (task->tk_status < 0) | 689 | if (task->tk_status < 0) |
692 | nfs_set_pgio_error(data->header, task->tk_status, data->args.offset); | 690 | nfs_set_pgio_error(hdr, task->tk_status, hdr->args.offset); |
693 | else | 691 | else |
694 | data->header->rw_ops->rw_result(task, data); | 692 | hdr->rw_ops->rw_result(task, hdr); |
695 | } | 693 | } |
696 | 694 | ||
697 | /* | 695 | /* |
@@ -707,7 +705,6 @@ int nfs_generic_pgio(struct nfs_pageio_descriptor *desc, | |||
707 | { | 705 | { |
708 | struct nfs_page *req; | 706 | struct nfs_page *req; |
709 | struct page **pages; | 707 | struct page **pages; |
710 | struct nfs_pgio_data *data; | ||
711 | struct list_head *head = &desc->pg_list; | 708 | struct list_head *head = &desc->pg_list; |
712 | struct nfs_commit_info cinfo; | 709 | struct nfs_commit_info cinfo; |
713 | 710 | ||
@@ -715,9 +712,8 @@ int nfs_generic_pgio(struct nfs_pageio_descriptor *desc, | |||
715 | desc->pg_count))) | 712 | desc->pg_count))) |
716 | return nfs_pgio_error(desc, hdr); | 713 | return nfs_pgio_error(desc, hdr); |
717 | 714 | ||
718 | data = &hdr->data; | ||
719 | nfs_init_cinfo(&cinfo, desc->pg_inode, desc->pg_dreq); | 715 | nfs_init_cinfo(&cinfo, desc->pg_inode, desc->pg_dreq); |
720 | pages = data->page_array.pagevec; | 716 | pages = hdr->page_array.pagevec; |
721 | while (!list_empty(head)) { | 717 | while (!list_empty(head)) { |
722 | req = nfs_list_entry(head->next); | 718 | req = nfs_list_entry(head->next); |
723 | nfs_list_remove_request(req); | 719 | nfs_list_remove_request(req); |
@@ -730,7 +726,7 @@ int nfs_generic_pgio(struct nfs_pageio_descriptor *desc, | |||
730 | desc->pg_ioflags &= ~FLUSH_COND_STABLE; | 726 | desc->pg_ioflags &= ~FLUSH_COND_STABLE; |
731 | 727 | ||
732 | /* Set up the argument struct */ | 728 | /* Set up the argument struct */ |
733 | nfs_pgio_rpcsetup(data, desc->pg_count, 0, desc->pg_ioflags, &cinfo); | 729 | nfs_pgio_rpcsetup(hdr, desc->pg_count, 0, desc->pg_ioflags, &cinfo); |
734 | desc->pg_rpc_callops = &nfs_pgio_common_ops; | 730 | desc->pg_rpc_callops = &nfs_pgio_common_ops; |
735 | return 0; | 731 | return 0; |
736 | } | 732 | } |
@@ -751,7 +747,7 @@ static int nfs_generic_pg_pgios(struct nfs_pageio_descriptor *desc) | |||
751 | ret = nfs_generic_pgio(desc, hdr); | 747 | ret = nfs_generic_pgio(desc, hdr); |
752 | if (ret == 0) | 748 | if (ret == 0) |
753 | ret = nfs_initiate_pgio(NFS_CLIENT(hdr->inode), | 749 | ret = nfs_initiate_pgio(NFS_CLIENT(hdr->inode), |
754 | &hdr->data, desc->pg_rpc_callops, | 750 | hdr, desc->pg_rpc_callops, |
755 | desc->pg_ioflags, 0); | 751 | desc->pg_ioflags, 0); |
756 | if (atomic_dec_and_test(&hdr->refcnt)) | 752 | if (atomic_dec_and_test(&hdr->refcnt)) |
757 | hdr->completion_ops->completion(hdr); | 753 | hdr->completion_ops->completion(hdr); |
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 067104cce181..ecc911347750 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c | |||
@@ -1502,9 +1502,8 @@ int pnfs_write_done_resend_to_mds(struct inode *inode, | |||
1502 | } | 1502 | } |
1503 | EXPORT_SYMBOL_GPL(pnfs_write_done_resend_to_mds); | 1503 | EXPORT_SYMBOL_GPL(pnfs_write_done_resend_to_mds); |
1504 | 1504 | ||
1505 | static void pnfs_ld_handle_write_error(struct nfs_pgio_data *data) | 1505 | static void pnfs_ld_handle_write_error(struct nfs_pgio_header *hdr) |
1506 | { | 1506 | { |
1507 | struct nfs_pgio_header *hdr = data->header; | ||
1508 | 1507 | ||
1509 | dprintk("pnfs write error = %d\n", hdr->pnfs_error); | 1508 | dprintk("pnfs write error = %d\n", hdr->pnfs_error); |
1510 | if (NFS_SERVER(hdr->inode)->pnfs_curr_ld->flags & | 1509 | if (NFS_SERVER(hdr->inode)->pnfs_curr_ld->flags & |
@@ -1512,7 +1511,7 @@ static void pnfs_ld_handle_write_error(struct nfs_pgio_data *data) | |||
1512 | pnfs_return_layout(hdr->inode); | 1511 | pnfs_return_layout(hdr->inode); |
1513 | } | 1512 | } |
1514 | if (!test_and_set_bit(NFS_IOHDR_REDO, &hdr->flags)) | 1513 | if (!test_and_set_bit(NFS_IOHDR_REDO, &hdr->flags)) |
1515 | data->task.tk_status = pnfs_write_done_resend_to_mds(hdr->inode, | 1514 | hdr->task.tk_status = pnfs_write_done_resend_to_mds(hdr->inode, |
1516 | &hdr->pages, | 1515 | &hdr->pages, |
1517 | hdr->completion_ops, | 1516 | hdr->completion_ops, |
1518 | hdr->dreq); | 1517 | hdr->dreq); |
@@ -1521,41 +1520,36 @@ static void pnfs_ld_handle_write_error(struct nfs_pgio_data *data) | |||
1521 | /* | 1520 | /* |
1522 | * Called by non rpc-based layout drivers | 1521 | * Called by non rpc-based layout drivers |
1523 | */ | 1522 | */ |
1524 | void pnfs_ld_write_done(struct nfs_pgio_data *data) | 1523 | void pnfs_ld_write_done(struct nfs_pgio_header *hdr) |
1525 | { | 1524 | { |
1526 | struct nfs_pgio_header *hdr = data->header; | 1525 | trace_nfs4_pnfs_write(hdr, hdr->pnfs_error); |
1527 | |||
1528 | trace_nfs4_pnfs_write(data, hdr->pnfs_error); | ||
1529 | if (!hdr->pnfs_error) { | 1526 | if (!hdr->pnfs_error) { |
1530 | pnfs_set_layoutcommit(data); | 1527 | pnfs_set_layoutcommit(hdr); |
1531 | hdr->mds_ops->rpc_call_done(&data->task, data); | 1528 | hdr->mds_ops->rpc_call_done(&hdr->task, hdr); |
1532 | } else | 1529 | } else |
1533 | pnfs_ld_handle_write_error(data); | 1530 | pnfs_ld_handle_write_error(hdr); |
1534 | hdr->mds_ops->rpc_release(data); | 1531 | hdr->mds_ops->rpc_release(hdr); |
1535 | } | 1532 | } |
1536 | EXPORT_SYMBOL_GPL(pnfs_ld_write_done); | 1533 | EXPORT_SYMBOL_GPL(pnfs_ld_write_done); |
1537 | 1534 | ||
1538 | static void | 1535 | static void |
1539 | pnfs_write_through_mds(struct nfs_pageio_descriptor *desc, | 1536 | pnfs_write_through_mds(struct nfs_pageio_descriptor *desc, |
1540 | struct nfs_pgio_data *data) | 1537 | struct nfs_pgio_header *hdr) |
1541 | { | 1538 | { |
1542 | struct nfs_pgio_header *hdr = data->header; | ||
1543 | |||
1544 | if (!test_and_set_bit(NFS_IOHDR_REDO, &hdr->flags)) { | 1539 | if (!test_and_set_bit(NFS_IOHDR_REDO, &hdr->flags)) { |
1545 | list_splice_tail_init(&hdr->pages, &desc->pg_list); | 1540 | list_splice_tail_init(&hdr->pages, &desc->pg_list); |
1546 | nfs_pageio_reset_write_mds(desc); | 1541 | nfs_pageio_reset_write_mds(desc); |
1547 | desc->pg_recoalesce = 1; | 1542 | desc->pg_recoalesce = 1; |
1548 | } | 1543 | } |
1549 | nfs_pgio_data_destroy(data); | 1544 | nfs_pgio_data_destroy(hdr); |
1550 | } | 1545 | } |
1551 | 1546 | ||
1552 | static enum pnfs_try_status | 1547 | static enum pnfs_try_status |
1553 | pnfs_try_to_write_data(struct nfs_pgio_data *wdata, | 1548 | pnfs_try_to_write_data(struct nfs_pgio_header *hdr, |
1554 | const struct rpc_call_ops *call_ops, | 1549 | const struct rpc_call_ops *call_ops, |
1555 | struct pnfs_layout_segment *lseg, | 1550 | struct pnfs_layout_segment *lseg, |
1556 | int how) | 1551 | int how) |
1557 | { | 1552 | { |
1558 | struct nfs_pgio_header *hdr = wdata->header; | ||
1559 | struct inode *inode = hdr->inode; | 1553 | struct inode *inode = hdr->inode; |
1560 | enum pnfs_try_status trypnfs; | 1554 | enum pnfs_try_status trypnfs; |
1561 | struct nfs_server *nfss = NFS_SERVER(inode); | 1555 | struct nfs_server *nfss = NFS_SERVER(inode); |
@@ -1563,8 +1557,8 @@ pnfs_try_to_write_data(struct nfs_pgio_data *wdata, | |||
1563 | hdr->mds_ops = call_ops; | 1557 | hdr->mds_ops = call_ops; |
1564 | 1558 | ||
1565 | dprintk("%s: Writing ino:%lu %u@%llu (how %d)\n", __func__, | 1559 | dprintk("%s: Writing ino:%lu %u@%llu (how %d)\n", __func__, |
1566 | inode->i_ino, wdata->args.count, wdata->args.offset, how); | 1560 | inode->i_ino, hdr->args.count, hdr->args.offset, how); |
1567 | trypnfs = nfss->pnfs_curr_ld->write_pagelist(wdata, how); | 1561 | trypnfs = nfss->pnfs_curr_ld->write_pagelist(hdr, how); |
1568 | if (trypnfs != PNFS_NOT_ATTEMPTED) | 1562 | if (trypnfs != PNFS_NOT_ATTEMPTED) |
1569 | nfs_inc_stats(inode, NFSIOS_PNFS_WRITE); | 1563 | nfs_inc_stats(inode, NFSIOS_PNFS_WRITE); |
1570 | dprintk("%s End (trypnfs:%d)\n", __func__, trypnfs); | 1564 | dprintk("%s End (trypnfs:%d)\n", __func__, trypnfs); |
@@ -1575,15 +1569,14 @@ static void | |||
1575 | pnfs_do_write(struct nfs_pageio_descriptor *desc, | 1569 | pnfs_do_write(struct nfs_pageio_descriptor *desc, |
1576 | struct nfs_pgio_header *hdr, int how) | 1570 | struct nfs_pgio_header *hdr, int how) |
1577 | { | 1571 | { |
1578 | struct nfs_pgio_data *data = &hdr->data; | ||
1579 | const struct rpc_call_ops *call_ops = desc->pg_rpc_callops; | 1572 | const struct rpc_call_ops *call_ops = desc->pg_rpc_callops; |
1580 | struct pnfs_layout_segment *lseg = desc->pg_lseg; | 1573 | struct pnfs_layout_segment *lseg = desc->pg_lseg; |
1581 | enum pnfs_try_status trypnfs; | 1574 | enum pnfs_try_status trypnfs; |
1582 | 1575 | ||
1583 | desc->pg_lseg = NULL; | 1576 | desc->pg_lseg = NULL; |
1584 | trypnfs = pnfs_try_to_write_data(data, call_ops, lseg, how); | 1577 | trypnfs = pnfs_try_to_write_data(hdr, call_ops, lseg, how); |
1585 | if (trypnfs == PNFS_NOT_ATTEMPTED) | 1578 | if (trypnfs == PNFS_NOT_ATTEMPTED) |
1586 | pnfs_write_through_mds(desc, data); | 1579 | pnfs_write_through_mds(desc, hdr); |
1587 | pnfs_put_lseg(lseg); | 1580 | pnfs_put_lseg(lseg); |
1588 | } | 1581 | } |
1589 | 1582 | ||
@@ -1650,17 +1643,15 @@ int pnfs_read_done_resend_to_mds(struct inode *inode, | |||
1650 | } | 1643 | } |
1651 | EXPORT_SYMBOL_GPL(pnfs_read_done_resend_to_mds); | 1644 | EXPORT_SYMBOL_GPL(pnfs_read_done_resend_to_mds); |
1652 | 1645 | ||
1653 | static void pnfs_ld_handle_read_error(struct nfs_pgio_data *data) | 1646 | static void pnfs_ld_handle_read_error(struct nfs_pgio_header *hdr) |
1654 | { | 1647 | { |
1655 | struct nfs_pgio_header *hdr = data->header; | ||
1656 | |||
1657 | dprintk("pnfs read error = %d\n", hdr->pnfs_error); | 1648 | dprintk("pnfs read error = %d\n", hdr->pnfs_error); |
1658 | if (NFS_SERVER(hdr->inode)->pnfs_curr_ld->flags & | 1649 | if (NFS_SERVER(hdr->inode)->pnfs_curr_ld->flags & |
1659 | PNFS_LAYOUTRET_ON_ERROR) { | 1650 | PNFS_LAYOUTRET_ON_ERROR) { |
1660 | pnfs_return_layout(hdr->inode); | 1651 | pnfs_return_layout(hdr->inode); |
1661 | } | 1652 | } |
1662 | if (!test_and_set_bit(NFS_IOHDR_REDO, &hdr->flags)) | 1653 | if (!test_and_set_bit(NFS_IOHDR_REDO, &hdr->flags)) |
1663 | data->task.tk_status = pnfs_read_done_resend_to_mds(hdr->inode, | 1654 | hdr->task.tk_status = pnfs_read_done_resend_to_mds(hdr->inode, |
1664 | &hdr->pages, | 1655 | &hdr->pages, |
1665 | hdr->completion_ops, | 1656 | hdr->completion_ops, |
1666 | hdr->dreq); | 1657 | hdr->dreq); |
@@ -1669,43 +1660,38 @@ static void pnfs_ld_handle_read_error(struct nfs_pgio_data *data) | |||
1669 | /* | 1660 | /* |
1670 | * Called by non rpc-based layout drivers | 1661 | * Called by non rpc-based layout drivers |
1671 | */ | 1662 | */ |
1672 | void pnfs_ld_read_done(struct nfs_pgio_data *data) | 1663 | void pnfs_ld_read_done(struct nfs_pgio_header *hdr) |
1673 | { | 1664 | { |
1674 | struct nfs_pgio_header *hdr = data->header; | 1665 | trace_nfs4_pnfs_read(hdr, hdr->pnfs_error); |
1675 | |||
1676 | trace_nfs4_pnfs_read(data, hdr->pnfs_error); | ||
1677 | if (likely(!hdr->pnfs_error)) { | 1666 | if (likely(!hdr->pnfs_error)) { |
1678 | __nfs4_read_done_cb(data); | 1667 | __nfs4_read_done_cb(hdr); |
1679 | hdr->mds_ops->rpc_call_done(&data->task, data); | 1668 | hdr->mds_ops->rpc_call_done(&hdr->task, hdr); |
1680 | } else | 1669 | } else |
1681 | pnfs_ld_handle_read_error(data); | 1670 | pnfs_ld_handle_read_error(hdr); |
1682 | hdr->mds_ops->rpc_release(data); | 1671 | hdr->mds_ops->rpc_release(hdr); |
1683 | } | 1672 | } |
1684 | EXPORT_SYMBOL_GPL(pnfs_ld_read_done); | 1673 | EXPORT_SYMBOL_GPL(pnfs_ld_read_done); |
1685 | 1674 | ||
1686 | static void | 1675 | static void |
1687 | pnfs_read_through_mds(struct nfs_pageio_descriptor *desc, | 1676 | pnfs_read_through_mds(struct nfs_pageio_descriptor *desc, |
1688 | struct nfs_pgio_data *data) | 1677 | struct nfs_pgio_header *hdr) |
1689 | { | 1678 | { |
1690 | struct nfs_pgio_header *hdr = data->header; | ||
1691 | |||
1692 | if (!test_and_set_bit(NFS_IOHDR_REDO, &hdr->flags)) { | 1679 | if (!test_and_set_bit(NFS_IOHDR_REDO, &hdr->flags)) { |
1693 | list_splice_tail_init(&hdr->pages, &desc->pg_list); | 1680 | list_splice_tail_init(&hdr->pages, &desc->pg_list); |
1694 | nfs_pageio_reset_read_mds(desc); | 1681 | nfs_pageio_reset_read_mds(desc); |
1695 | desc->pg_recoalesce = 1; | 1682 | desc->pg_recoalesce = 1; |
1696 | } | 1683 | } |
1697 | nfs_pgio_data_destroy(data); | 1684 | nfs_pgio_data_destroy(hdr); |
1698 | } | 1685 | } |
1699 | 1686 | ||
1700 | /* | 1687 | /* |
1701 | * Call the appropriate parallel I/O subsystem read function. | 1688 | * Call the appropriate parallel I/O subsystem read function. |
1702 | */ | 1689 | */ |
1703 | static enum pnfs_try_status | 1690 | static enum pnfs_try_status |
1704 | pnfs_try_to_read_data(struct nfs_pgio_data *rdata, | 1691 | pnfs_try_to_read_data(struct nfs_pgio_header *hdr, |
1705 | const struct rpc_call_ops *call_ops, | 1692 | const struct rpc_call_ops *call_ops, |
1706 | struct pnfs_layout_segment *lseg) | 1693 | struct pnfs_layout_segment *lseg) |
1707 | { | 1694 | { |
1708 | struct nfs_pgio_header *hdr = rdata->header; | ||
1709 | struct inode *inode = hdr->inode; | 1695 | struct inode *inode = hdr->inode; |
1710 | struct nfs_server *nfss = NFS_SERVER(inode); | 1696 | struct nfs_server *nfss = NFS_SERVER(inode); |
1711 | enum pnfs_try_status trypnfs; | 1697 | enum pnfs_try_status trypnfs; |
@@ -1713,9 +1699,9 @@ pnfs_try_to_read_data(struct nfs_pgio_data *rdata, | |||
1713 | hdr->mds_ops = call_ops; | 1699 | hdr->mds_ops = call_ops; |
1714 | 1700 | ||
1715 | dprintk("%s: Reading ino:%lu %u@%llu\n", | 1701 | dprintk("%s: Reading ino:%lu %u@%llu\n", |
1716 | __func__, inode->i_ino, rdata->args.count, rdata->args.offset); | 1702 | __func__, inode->i_ino, hdr->args.count, hdr->args.offset); |
1717 | 1703 | ||
1718 | trypnfs = nfss->pnfs_curr_ld->read_pagelist(rdata); | 1704 | trypnfs = nfss->pnfs_curr_ld->read_pagelist(hdr); |
1719 | if (trypnfs != PNFS_NOT_ATTEMPTED) | 1705 | if (trypnfs != PNFS_NOT_ATTEMPTED) |
1720 | nfs_inc_stats(inode, NFSIOS_PNFS_READ); | 1706 | nfs_inc_stats(inode, NFSIOS_PNFS_READ); |
1721 | dprintk("%s End (trypnfs:%d)\n", __func__, trypnfs); | 1707 | dprintk("%s End (trypnfs:%d)\n", __func__, trypnfs); |
@@ -1725,15 +1711,14 @@ pnfs_try_to_read_data(struct nfs_pgio_data *rdata, | |||
1725 | static void | 1711 | static void |
1726 | pnfs_do_read(struct nfs_pageio_descriptor *desc, struct nfs_pgio_header *hdr) | 1712 | pnfs_do_read(struct nfs_pageio_descriptor *desc, struct nfs_pgio_header *hdr) |
1727 | { | 1713 | { |
1728 | struct nfs_pgio_data *data = &hdr->data; | ||
1729 | const struct rpc_call_ops *call_ops = desc->pg_rpc_callops; | 1714 | const struct rpc_call_ops *call_ops = desc->pg_rpc_callops; |
1730 | struct pnfs_layout_segment *lseg = desc->pg_lseg; | 1715 | struct pnfs_layout_segment *lseg = desc->pg_lseg; |
1731 | enum pnfs_try_status trypnfs; | 1716 | enum pnfs_try_status trypnfs; |
1732 | 1717 | ||
1733 | desc->pg_lseg = NULL; | 1718 | desc->pg_lseg = NULL; |
1734 | trypnfs = pnfs_try_to_read_data(data, call_ops, lseg); | 1719 | trypnfs = pnfs_try_to_read_data(hdr, call_ops, lseg); |
1735 | if (trypnfs == PNFS_NOT_ATTEMPTED) | 1720 | if (trypnfs == PNFS_NOT_ATTEMPTED) |
1736 | pnfs_read_through_mds(desc, data); | 1721 | pnfs_read_through_mds(desc, hdr); |
1737 | pnfs_put_lseg(lseg); | 1722 | pnfs_put_lseg(lseg); |
1738 | } | 1723 | } |
1739 | 1724 | ||
@@ -1816,12 +1801,11 @@ void pnfs_set_lo_fail(struct pnfs_layout_segment *lseg) | |||
1816 | EXPORT_SYMBOL_GPL(pnfs_set_lo_fail); | 1801 | EXPORT_SYMBOL_GPL(pnfs_set_lo_fail); |
1817 | 1802 | ||
1818 | void | 1803 | void |
1819 | pnfs_set_layoutcommit(struct nfs_pgio_data *wdata) | 1804 | pnfs_set_layoutcommit(struct nfs_pgio_header *hdr) |
1820 | { | 1805 | { |
1821 | struct nfs_pgio_header *hdr = wdata->header; | ||
1822 | struct inode *inode = hdr->inode; | 1806 | struct inode *inode = hdr->inode; |
1823 | struct nfs_inode *nfsi = NFS_I(inode); | 1807 | struct nfs_inode *nfsi = NFS_I(inode); |
1824 | loff_t end_pos = wdata->mds_offset + wdata->res.count; | 1808 | loff_t end_pos = hdr->mds_offset + hdr->res.count; |
1825 | bool mark_as_dirty = false; | 1809 | bool mark_as_dirty = false; |
1826 | 1810 | ||
1827 | spin_lock(&inode->i_lock); | 1811 | spin_lock(&inode->i_lock); |
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index 4fb309a2b4c4..a4a58be94064 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h | |||
@@ -113,8 +113,8 @@ struct pnfs_layoutdriver_type { | |||
113 | * Return PNFS_ATTEMPTED to indicate the layout code has attempted | 113 | * Return PNFS_ATTEMPTED to indicate the layout code has attempted |
114 | * I/O, else return PNFS_NOT_ATTEMPTED to fall back to normal NFS | 114 | * I/O, else return PNFS_NOT_ATTEMPTED to fall back to normal NFS |
115 | */ | 115 | */ |
116 | enum pnfs_try_status (*read_pagelist) (struct nfs_pgio_data *nfs_data); | 116 | enum pnfs_try_status (*read_pagelist)(struct nfs_pgio_header *); |
117 | enum pnfs_try_status (*write_pagelist) (struct nfs_pgio_data *nfs_data, int how); | 117 | enum pnfs_try_status (*write_pagelist)(struct nfs_pgio_header *, int); |
118 | 118 | ||
119 | void (*free_deviceid_node) (struct nfs4_deviceid_node *); | 119 | void (*free_deviceid_node) (struct nfs4_deviceid_node *); |
120 | 120 | ||
@@ -213,13 +213,13 @@ bool pnfs_roc(struct inode *ino); | |||
213 | void pnfs_roc_release(struct inode *ino); | 213 | void pnfs_roc_release(struct inode *ino); |
214 | void pnfs_roc_set_barrier(struct inode *ino, u32 barrier); | 214 | void pnfs_roc_set_barrier(struct inode *ino, u32 barrier); |
215 | bool pnfs_roc_drain(struct inode *ino, u32 *barrier, struct rpc_task *task); | 215 | bool pnfs_roc_drain(struct inode *ino, u32 *barrier, struct rpc_task *task); |
216 | void pnfs_set_layoutcommit(struct nfs_pgio_data *wdata); | 216 | void pnfs_set_layoutcommit(struct nfs_pgio_header *); |
217 | void pnfs_cleanup_layoutcommit(struct nfs4_layoutcommit_data *data); | 217 | void pnfs_cleanup_layoutcommit(struct nfs4_layoutcommit_data *data); |
218 | int pnfs_layoutcommit_inode(struct inode *inode, bool sync); | 218 | int pnfs_layoutcommit_inode(struct inode *inode, bool sync); |
219 | int _pnfs_return_layout(struct inode *); | 219 | int _pnfs_return_layout(struct inode *); |
220 | int pnfs_commit_and_return_layout(struct inode *); | 220 | int pnfs_commit_and_return_layout(struct inode *); |
221 | void pnfs_ld_write_done(struct nfs_pgio_data *); | 221 | void pnfs_ld_write_done(struct nfs_pgio_header *); |
222 | void pnfs_ld_read_done(struct nfs_pgio_data *); | 222 | void pnfs_ld_read_done(struct nfs_pgio_header *); |
223 | struct pnfs_layout_segment *pnfs_update_layout(struct inode *ino, | 223 | struct pnfs_layout_segment *pnfs_update_layout(struct inode *ino, |
224 | struct nfs_open_context *ctx, | 224 | struct nfs_open_context *ctx, |
225 | loff_t pos, | 225 | loff_t pos, |
diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c index c171ce1a8a30..b09cc23d6f43 100644 --- a/fs/nfs/proc.c +++ b/fs/nfs/proc.c | |||
@@ -578,46 +578,49 @@ nfs_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle, | |||
578 | return 0; | 578 | return 0; |
579 | } | 579 | } |
580 | 580 | ||
581 | static int nfs_read_done(struct rpc_task *task, struct nfs_pgio_data *data) | 581 | static int nfs_read_done(struct rpc_task *task, struct nfs_pgio_header *hdr) |
582 | { | 582 | { |
583 | struct inode *inode = data->header->inode; | 583 | struct inode *inode = hdr->inode; |
584 | 584 | ||
585 | nfs_invalidate_atime(inode); | 585 | nfs_invalidate_atime(inode); |
586 | if (task->tk_status >= 0) { | 586 | if (task->tk_status >= 0) { |
587 | nfs_refresh_inode(inode, data->res.fattr); | 587 | nfs_refresh_inode(inode, hdr->res.fattr); |
588 | /* Emulate the eof flag, which isn't normally needed in NFSv2 | 588 | /* Emulate the eof flag, which isn't normally needed in NFSv2 |
589 | * as it is guaranteed to always return the file attributes | 589 | * as it is guaranteed to always return the file attributes |
590 | */ | 590 | */ |
591 | if (data->args.offset + data->res.count >= data->res.fattr->size) | 591 | if (hdr->args.offset + hdr->res.count >= hdr->res.fattr->size) |
592 | data->res.eof = 1; | 592 | hdr->res.eof = 1; |
593 | } | 593 | } |
594 | return 0; | 594 | return 0; |
595 | } | 595 | } |
596 | 596 | ||
597 | static void nfs_proc_read_setup(struct nfs_pgio_data *data, struct rpc_message *msg) | 597 | static void nfs_proc_read_setup(struct nfs_pgio_header *hdr, |
598 | struct rpc_message *msg) | ||
598 | { | 599 | { |
599 | msg->rpc_proc = &nfs_procedures[NFSPROC_READ]; | 600 | msg->rpc_proc = &nfs_procedures[NFSPROC_READ]; |
600 | } | 601 | } |
601 | 602 | ||
602 | static int nfs_proc_pgio_rpc_prepare(struct rpc_task *task, struct nfs_pgio_data *data) | 603 | static int nfs_proc_pgio_rpc_prepare(struct rpc_task *task, |
604 | struct nfs_pgio_header *hdr) | ||
603 | { | 605 | { |
604 | rpc_call_start(task); | 606 | rpc_call_start(task); |
605 | return 0; | 607 | return 0; |
606 | } | 608 | } |
607 | 609 | ||
608 | static int nfs_write_done(struct rpc_task *task, struct nfs_pgio_data *data) | 610 | static int nfs_write_done(struct rpc_task *task, struct nfs_pgio_header *hdr) |
609 | { | 611 | { |
610 | struct inode *inode = data->header->inode; | 612 | struct inode *inode = hdr->inode; |
611 | 613 | ||
612 | if (task->tk_status >= 0) | 614 | if (task->tk_status >= 0) |
613 | nfs_post_op_update_inode_force_wcc(inode, data->res.fattr); | 615 | nfs_post_op_update_inode_force_wcc(inode, hdr->res.fattr); |
614 | return 0; | 616 | return 0; |
615 | } | 617 | } |
616 | 618 | ||
617 | static void nfs_proc_write_setup(struct nfs_pgio_data *data, struct rpc_message *msg) | 619 | static void nfs_proc_write_setup(struct nfs_pgio_header *hdr, |
620 | struct rpc_message *msg) | ||
618 | { | 621 | { |
619 | /* Note: NFSv2 ignores @stable and always uses NFS_FILE_SYNC */ | 622 | /* Note: NFSv2 ignores @stable and always uses NFS_FILE_SYNC */ |
620 | data->args.stable = NFS_FILE_SYNC; | 623 | hdr->args.stable = NFS_FILE_SYNC; |
621 | msg->rpc_proc = &nfs_procedures[NFSPROC_WRITE]; | 624 | msg->rpc_proc = &nfs_procedures[NFSPROC_WRITE]; |
622 | } | 625 | } |
623 | 626 | ||
diff --git a/fs/nfs/read.c b/fs/nfs/read.c index d9df4ab3737b..b1532b73fea3 100644 --- a/fs/nfs/read.c +++ b/fs/nfs/read.c | |||
@@ -172,14 +172,15 @@ out: | |||
172 | hdr->release(hdr); | 172 | hdr->release(hdr); |
173 | } | 173 | } |
174 | 174 | ||
175 | static void nfs_initiate_read(struct nfs_pgio_data *data, struct rpc_message *msg, | 175 | static void nfs_initiate_read(struct nfs_pgio_header *hdr, |
176 | struct rpc_message *msg, | ||
176 | struct rpc_task_setup *task_setup_data, int how) | 177 | struct rpc_task_setup *task_setup_data, int how) |
177 | { | 178 | { |
178 | struct inode *inode = data->header->inode; | 179 | struct inode *inode = hdr->inode; |
179 | int swap_flags = IS_SWAPFILE(inode) ? NFS_RPC_SWAPFLAGS : 0; | 180 | int swap_flags = IS_SWAPFILE(inode) ? NFS_RPC_SWAPFLAGS : 0; |
180 | 181 | ||
181 | task_setup_data->flags |= swap_flags; | 182 | task_setup_data->flags |= swap_flags; |
182 | NFS_PROTO(inode)->read_setup(data, msg); | 183 | NFS_PROTO(inode)->read_setup(hdr, msg); |
183 | } | 184 | } |
184 | 185 | ||
185 | static void | 186 | static void |
@@ -203,14 +204,15 @@ static const struct nfs_pgio_completion_ops nfs_async_read_completion_ops = { | |||
203 | * This is the callback from RPC telling us whether a reply was | 204 | * This is the callback from RPC telling us whether a reply was |
204 | * received or some error occurred (timeout or socket shutdown). | 205 | * received or some error occurred (timeout or socket shutdown). |
205 | */ | 206 | */ |
206 | static int nfs_readpage_done(struct rpc_task *task, struct nfs_pgio_data *data, | 207 | static int nfs_readpage_done(struct rpc_task *task, |
208 | struct nfs_pgio_header *hdr, | ||
207 | struct inode *inode) | 209 | struct inode *inode) |
208 | { | 210 | { |
209 | int status = NFS_PROTO(inode)->read_done(task, data); | 211 | int status = NFS_PROTO(inode)->read_done(task, hdr); |
210 | if (status != 0) | 212 | if (status != 0) |
211 | return status; | 213 | return status; |
212 | 214 | ||
213 | nfs_add_stats(inode, NFSIOS_SERVERREADBYTES, data->res.count); | 215 | nfs_add_stats(inode, NFSIOS_SERVERREADBYTES, hdr->res.count); |
214 | 216 | ||
215 | if (task->tk_status == -ESTALE) { | 217 | if (task->tk_status == -ESTALE) { |
216 | set_bit(NFS_INO_STALE, &NFS_I(inode)->flags); | 218 | set_bit(NFS_INO_STALE, &NFS_I(inode)->flags); |
@@ -219,34 +221,34 @@ static int nfs_readpage_done(struct rpc_task *task, struct nfs_pgio_data *data, | |||
219 | return 0; | 221 | return 0; |
220 | } | 222 | } |
221 | 223 | ||
222 | static void nfs_readpage_retry(struct rpc_task *task, struct nfs_pgio_data *data) | 224 | static void nfs_readpage_retry(struct rpc_task *task, |
225 | struct nfs_pgio_header *hdr) | ||
223 | { | 226 | { |
224 | struct nfs_pgio_args *argp = &data->args; | 227 | struct nfs_pgio_args *argp = &hdr->args; |
225 | struct nfs_pgio_res *resp = &data->res; | 228 | struct nfs_pgio_res *resp = &hdr->res; |
226 | 229 | ||
227 | /* This is a short read! */ | 230 | /* This is a short read! */ |
228 | nfs_inc_stats(data->header->inode, NFSIOS_SHORTREAD); | 231 | nfs_inc_stats(hdr->inode, NFSIOS_SHORTREAD); |
229 | /* Has the server at least made some progress? */ | 232 | /* Has the server at least made some progress? */ |
230 | if (resp->count == 0) { | 233 | if (resp->count == 0) { |
231 | nfs_set_pgio_error(data->header, -EIO, argp->offset); | 234 | nfs_set_pgio_error(hdr, -EIO, argp->offset); |
232 | return; | 235 | return; |
233 | } | 236 | } |
234 | /* Yes, so retry the read at the end of the data */ | 237 | /* Yes, so retry the read at the end of the hdr */ |
235 | data->mds_offset += resp->count; | 238 | hdr->mds_offset += resp->count; |
236 | argp->offset += resp->count; | 239 | argp->offset += resp->count; |
237 | argp->pgbase += resp->count; | 240 | argp->pgbase += resp->count; |
238 | argp->count -= resp->count; | 241 | argp->count -= resp->count; |
239 | rpc_restart_call_prepare(task); | 242 | rpc_restart_call_prepare(task); |
240 | } | 243 | } |
241 | 244 | ||
242 | static void nfs_readpage_result(struct rpc_task *task, struct nfs_pgio_data *data) | 245 | static void nfs_readpage_result(struct rpc_task *task, |
246 | struct nfs_pgio_header *hdr) | ||
243 | { | 247 | { |
244 | struct nfs_pgio_header *hdr = data->header; | 248 | if (hdr->res.eof) { |
245 | |||
246 | if (data->res.eof) { | ||
247 | loff_t bound; | 249 | loff_t bound; |
248 | 250 | ||
249 | bound = data->args.offset + data->res.count; | 251 | bound = hdr->args.offset + hdr->res.count; |
250 | spin_lock(&hdr->lock); | 252 | spin_lock(&hdr->lock); |
251 | if (bound < hdr->io_start + hdr->good_bytes) { | 253 | if (bound < hdr->io_start + hdr->good_bytes) { |
252 | set_bit(NFS_IOHDR_EOF, &hdr->flags); | 254 | set_bit(NFS_IOHDR_EOF, &hdr->flags); |
@@ -254,8 +256,8 @@ static void nfs_readpage_result(struct rpc_task *task, struct nfs_pgio_data *dat | |||
254 | hdr->good_bytes = bound - hdr->io_start; | 256 | hdr->good_bytes = bound - hdr->io_start; |
255 | } | 257 | } |
256 | spin_unlock(&hdr->lock); | 258 | spin_unlock(&hdr->lock); |
257 | } else if (data->res.count != data->args.count) | 259 | } else if (hdr->res.count != hdr->args.count) |
258 | nfs_readpage_retry(task, data); | 260 | nfs_readpage_retry(task, hdr); |
259 | } | 261 | } |
260 | 262 | ||
261 | /* | 263 | /* |
diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 6afe0f679420..6a2d0986a3a3 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c | |||
@@ -596,11 +596,11 @@ nfs_clear_request_commit(struct nfs_page *req) | |||
596 | } | 596 | } |
597 | 597 | ||
598 | static inline | 598 | static inline |
599 | int nfs_write_need_commit(struct nfs_pgio_data *data) | 599 | int nfs_write_need_commit(struct nfs_pgio_header *hdr) |
600 | { | 600 | { |
601 | if (data->writeverf.committed == NFS_DATA_SYNC) | 601 | if (hdr->writeverf.committed == NFS_DATA_SYNC) |
602 | return data->header->lseg == NULL; | 602 | return hdr->lseg == NULL; |
603 | return data->writeverf.committed != NFS_FILE_SYNC; | 603 | return hdr->writeverf.committed != NFS_FILE_SYNC; |
604 | } | 604 | } |
605 | 605 | ||
606 | #else | 606 | #else |
@@ -627,7 +627,7 @@ nfs_clear_request_commit(struct nfs_page *req) | |||
627 | } | 627 | } |
628 | 628 | ||
629 | static inline | 629 | static inline |
630 | int nfs_write_need_commit(struct nfs_pgio_data *data) | 630 | int nfs_write_need_commit(struct nfs_pgio_header *hdr) |
631 | { | 631 | { |
632 | return 0; | 632 | return 0; |
633 | } | 633 | } |
@@ -1013,17 +1013,18 @@ static int flush_task_priority(int how) | |||
1013 | return RPC_PRIORITY_NORMAL; | 1013 | return RPC_PRIORITY_NORMAL; |
1014 | } | 1014 | } |
1015 | 1015 | ||
1016 | static void nfs_initiate_write(struct nfs_pgio_data *data, struct rpc_message *msg, | 1016 | static void nfs_initiate_write(struct nfs_pgio_header *hdr, |
1017 | struct rpc_message *msg, | ||
1017 | struct rpc_task_setup *task_setup_data, int how) | 1018 | struct rpc_task_setup *task_setup_data, int how) |
1018 | { | 1019 | { |
1019 | struct inode *inode = data->header->inode; | 1020 | struct inode *inode = hdr->inode; |
1020 | int priority = flush_task_priority(how); | 1021 | int priority = flush_task_priority(how); |
1021 | 1022 | ||
1022 | task_setup_data->priority = priority; | 1023 | task_setup_data->priority = priority; |
1023 | NFS_PROTO(inode)->write_setup(data, msg); | 1024 | NFS_PROTO(inode)->write_setup(hdr, msg); |
1024 | 1025 | ||
1025 | nfs4_state_protect_write(NFS_SERVER(inode)->nfs_client, | 1026 | nfs4_state_protect_write(NFS_SERVER(inode)->nfs_client, |
1026 | &task_setup_data->rpc_client, msg, data); | 1027 | &task_setup_data->rpc_client, msg, hdr); |
1027 | } | 1028 | } |
1028 | 1029 | ||
1029 | /* If a nfs_flush_* function fails, it should remove reqs from @head and | 1030 | /* If a nfs_flush_* function fails, it should remove reqs from @head and |
@@ -1085,19 +1086,17 @@ void nfs_commit_prepare(struct rpc_task *task, void *calldata) | |||
1085 | NFS_PROTO(data->inode)->commit_rpc_prepare(task, data); | 1086 | NFS_PROTO(data->inode)->commit_rpc_prepare(task, data); |
1086 | } | 1087 | } |
1087 | 1088 | ||
1088 | static void nfs_writeback_release_common(struct nfs_pgio_data *data) | 1089 | static void nfs_writeback_release_common(struct nfs_pgio_header *hdr) |
1089 | { | 1090 | { |
1090 | struct nfs_pgio_header *hdr = data->header; | 1091 | int status = hdr->task.tk_status; |
1091 | int status = data->task.tk_status; | ||
1092 | 1092 | ||
1093 | if ((status >= 0) && nfs_write_need_commit(data)) { | 1093 | if ((status >= 0) && nfs_write_need_commit(hdr)) { |
1094 | spin_lock(&hdr->lock); | 1094 | spin_lock(&hdr->lock); |
1095 | if (test_bit(NFS_IOHDR_NEED_RESCHED, &hdr->flags)) | 1095 | if (test_bit(NFS_IOHDR_NEED_RESCHED, &hdr->flags)) |
1096 | ; /* Do nothing */ | 1096 | ; /* Do nothing */ |
1097 | else if (!test_and_set_bit(NFS_IOHDR_NEED_COMMIT, &hdr->flags)) | 1097 | else if (!test_and_set_bit(NFS_IOHDR_NEED_COMMIT, &hdr->flags)) |
1098 | memcpy(&hdr->verf, &data->writeverf, sizeof(hdr->verf)); | 1098 | memcpy(&hdr->verf, &hdr->writeverf, sizeof(hdr->verf)); |
1099 | else if (memcmp(&hdr->verf, &data->writeverf, | 1099 | else if (memcmp(&hdr->verf, &hdr->writeverf, sizeof(hdr->verf))) |
1100 | sizeof(hdr->verf))) | ||
1101 | set_bit(NFS_IOHDR_NEED_RESCHED, &hdr->flags); | 1100 | set_bit(NFS_IOHDR_NEED_RESCHED, &hdr->flags); |
1102 | spin_unlock(&hdr->lock); | 1101 | spin_unlock(&hdr->lock); |
1103 | } | 1102 | } |
@@ -1131,7 +1130,8 @@ static int nfs_should_remove_suid(const struct inode *inode) | |||
1131 | /* | 1130 | /* |
1132 | * This function is called when the WRITE call is complete. | 1131 | * This function is called when the WRITE call is complete. |
1133 | */ | 1132 | */ |
1134 | static int nfs_writeback_done(struct rpc_task *task, struct nfs_pgio_data *data, | 1133 | static int nfs_writeback_done(struct rpc_task *task, |
1134 | struct nfs_pgio_header *hdr, | ||
1135 | struct inode *inode) | 1135 | struct inode *inode) |
1136 | { | 1136 | { |
1137 | int status; | 1137 | int status; |
@@ -1143,13 +1143,14 @@ static int nfs_writeback_done(struct rpc_task *task, struct nfs_pgio_data *data, | |||
1143 | * another writer had changed the file, but some applications | 1143 | * another writer had changed the file, but some applications |
1144 | * depend on tighter cache coherency when writing. | 1144 | * depend on tighter cache coherency when writing. |
1145 | */ | 1145 | */ |
1146 | status = NFS_PROTO(inode)->write_done(task, data); | 1146 | status = NFS_PROTO(inode)->write_done(task, hdr); |
1147 | if (status != 0) | 1147 | if (status != 0) |
1148 | return status; | 1148 | return status; |
1149 | nfs_add_stats(inode, NFSIOS_SERVERWRITTENBYTES, data->res.count); | 1149 | nfs_add_stats(inode, NFSIOS_SERVERWRITTENBYTES, hdr->res.count); |
1150 | 1150 | ||
1151 | #if IS_ENABLED(CONFIG_NFS_V3) || IS_ENABLED(CONFIG_NFS_V4) | 1151 | #if IS_ENABLED(CONFIG_NFS_V3) || IS_ENABLED(CONFIG_NFS_V4) |
1152 | if (data->res.verf->committed < data->args.stable && task->tk_status >= 0) { | 1152 | if (hdr->res.verf->committed < hdr->args.stable && |
1153 | task->tk_status >= 0) { | ||
1153 | /* We tried a write call, but the server did not | 1154 | /* We tried a write call, but the server did not |
1154 | * commit data to stable storage even though we | 1155 | * commit data to stable storage even though we |
1155 | * requested it. | 1156 | * requested it. |
@@ -1165,7 +1166,7 @@ static int nfs_writeback_done(struct rpc_task *task, struct nfs_pgio_data *data, | |||
1165 | dprintk("NFS: faulty NFS server %s:" | 1166 | dprintk("NFS: faulty NFS server %s:" |
1166 | " (committed = %d) != (stable = %d)\n", | 1167 | " (committed = %d) != (stable = %d)\n", |
1167 | NFS_SERVER(inode)->nfs_client->cl_hostname, | 1168 | NFS_SERVER(inode)->nfs_client->cl_hostname, |
1168 | data->res.verf->committed, data->args.stable); | 1169 | hdr->res.verf->committed, hdr->args.stable); |
1169 | complain = jiffies + 300 * HZ; | 1170 | complain = jiffies + 300 * HZ; |
1170 | } | 1171 | } |
1171 | } | 1172 | } |
@@ -1180,16 +1181,17 @@ static int nfs_writeback_done(struct rpc_task *task, struct nfs_pgio_data *data, | |||
1180 | /* | 1181 | /* |
1181 | * This function is called when the WRITE call is complete. | 1182 | * This function is called when the WRITE call is complete. |
1182 | */ | 1183 | */ |
1183 | static void nfs_writeback_result(struct rpc_task *task, struct nfs_pgio_data *data) | 1184 | static void nfs_writeback_result(struct rpc_task *task, |
1185 | struct nfs_pgio_header *hdr) | ||
1184 | { | 1186 | { |
1185 | struct nfs_pgio_args *argp = &data->args; | 1187 | struct nfs_pgio_args *argp = &hdr->args; |
1186 | struct nfs_pgio_res *resp = &data->res; | 1188 | struct nfs_pgio_res *resp = &hdr->res; |
1187 | 1189 | ||
1188 | if (resp->count < argp->count) { | 1190 | if (resp->count < argp->count) { |
1189 | static unsigned long complain; | 1191 | static unsigned long complain; |
1190 | 1192 | ||
1191 | /* This a short write! */ | 1193 | /* This a short write! */ |
1192 | nfs_inc_stats(data->header->inode, NFSIOS_SHORTWRITE); | 1194 | nfs_inc_stats(hdr->inode, NFSIOS_SHORTWRITE); |
1193 | 1195 | ||
1194 | /* Has the server at least made some progress? */ | 1196 | /* Has the server at least made some progress? */ |
1195 | if (resp->count == 0) { | 1197 | if (resp->count == 0) { |
@@ -1199,14 +1201,14 @@ static void nfs_writeback_result(struct rpc_task *task, struct nfs_pgio_data *da | |||
1199 | argp->count); | 1201 | argp->count); |
1200 | complain = jiffies + 300 * HZ; | 1202 | complain = jiffies + 300 * HZ; |
1201 | } | 1203 | } |
1202 | nfs_set_pgio_error(data->header, -EIO, argp->offset); | 1204 | nfs_set_pgio_error(hdr, -EIO, argp->offset); |
1203 | task->tk_status = -EIO; | 1205 | task->tk_status = -EIO; |
1204 | return; | 1206 | return; |
1205 | } | 1207 | } |
1206 | /* Was this an NFSv2 write or an NFSv3 stable write? */ | 1208 | /* Was this an NFSv2 write or an NFSv3 stable write? */ |
1207 | if (resp->verf->committed != NFS_UNSTABLE) { | 1209 | if (resp->verf->committed != NFS_UNSTABLE) { |
1208 | /* Resend from where the server left off */ | 1210 | /* Resend from where the server left off */ |
1209 | data->mds_offset += resp->count; | 1211 | hdr->mds_offset += resp->count; |
1210 | argp->offset += resp->count; | 1212 | argp->offset += resp->count; |
1211 | argp->pgbase += resp->count; | 1213 | argp->pgbase += resp->count; |
1212 | argp->count -= resp->count; | 1214 | argp->count -= resp->count; |
diff --git a/include/linux/nfs_page.h b/include/linux/nfs_page.h index 43592651cd5a..d0fae7b78252 100644 --- a/include/linux/nfs_page.h +++ b/include/linux/nfs_page.h | |||
@@ -64,10 +64,11 @@ struct nfs_rw_ops { | |||
64 | const fmode_t rw_mode; | 64 | const fmode_t rw_mode; |
65 | struct nfs_pgio_header *(*rw_alloc_header)(void); | 65 | struct nfs_pgio_header *(*rw_alloc_header)(void); |
66 | void (*rw_free_header)(struct nfs_pgio_header *); | 66 | void (*rw_free_header)(struct nfs_pgio_header *); |
67 | void (*rw_release)(struct nfs_pgio_data *); | 67 | void (*rw_release)(struct nfs_pgio_header *); |
68 | int (*rw_done)(struct rpc_task *, struct nfs_pgio_data *, struct inode *); | 68 | int (*rw_done)(struct rpc_task *, struct nfs_pgio_header *, |
69 | void (*rw_result)(struct rpc_task *, struct nfs_pgio_data *); | 69 | struct inode *); |
70 | void (*rw_initiate)(struct nfs_pgio_data *, struct rpc_message *, | 70 | void (*rw_result)(struct rpc_task *, struct nfs_pgio_header *); |
71 | void (*rw_initiate)(struct nfs_pgio_header *, struct rpc_message *, | ||
71 | struct rpc_task_setup *, int); | 72 | struct rpc_task_setup *, int); |
72 | }; | 73 | }; |
73 | 74 | ||
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index bb18dba1aefe..efeaf7690b51 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h | |||
@@ -1257,27 +1257,10 @@ enum { | |||
1257 | NFS_IOHDR_NEED_RESCHED, | 1257 | NFS_IOHDR_NEED_RESCHED, |
1258 | }; | 1258 | }; |
1259 | 1259 | ||
1260 | struct nfs_pgio_data { | ||
1261 | struct nfs_pgio_header *header; | ||
1262 | struct list_head list; | ||
1263 | struct rpc_task task; | ||
1264 | struct nfs_fattr fattr; | ||
1265 | struct nfs_writeverf writeverf; /* Used for writes */ | ||
1266 | struct nfs_pgio_args args; /* argument struct */ | ||
1267 | struct nfs_pgio_res res; /* result struct */ | ||
1268 | unsigned long timestamp; /* For lease renewal */ | ||
1269 | int (*pgio_done_cb)(struct rpc_task *task, struct nfs_pgio_data *data); | ||
1270 | __u64 mds_offset; /* Filelayout dense stripe */ | ||
1271 | struct nfs_page_array page_array; | ||
1272 | struct nfs_client *ds_clp; /* pNFS data server */ | ||
1273 | int ds_idx; /* ds index if ds_clp is set */ | ||
1274 | }; | ||
1275 | |||
1276 | struct nfs_pgio_header { | 1260 | struct nfs_pgio_header { |
1277 | struct inode *inode; | 1261 | struct inode *inode; |
1278 | struct rpc_cred *cred; | 1262 | struct rpc_cred *cred; |
1279 | struct list_head pages; | 1263 | struct list_head pages; |
1280 | struct nfs_pgio_data data; | ||
1281 | atomic_t refcnt; | 1264 | atomic_t refcnt; |
1282 | struct nfs_page *req; | 1265 | struct nfs_page *req; |
1283 | struct nfs_writeverf verf; /* Used for writes */ | 1266 | struct nfs_writeverf verf; /* Used for writes */ |
@@ -1295,6 +1278,21 @@ struct nfs_pgio_header { | |||
1295 | int error; /* merge with pnfs_error */ | 1278 | int error; /* merge with pnfs_error */ |
1296 | unsigned long good_bytes; /* boundary of good data */ | 1279 | unsigned long good_bytes; /* boundary of good data */ |
1297 | unsigned long flags; | 1280 | unsigned long flags; |
1281 | |||
1282 | /* | ||
1283 | * rpc data | ||
1284 | */ | ||
1285 | struct rpc_task task; | ||
1286 | struct nfs_fattr fattr; | ||
1287 | struct nfs_writeverf writeverf; /* Used for writes */ | ||
1288 | struct nfs_pgio_args args; /* argument struct */ | ||
1289 | struct nfs_pgio_res res; /* result struct */ | ||
1290 | unsigned long timestamp; /* For lease renewal */ | ||
1291 | int (*pgio_done_cb)(struct rpc_task *, struct nfs_pgio_header *); | ||
1292 | __u64 mds_offset; /* Filelayout dense stripe */ | ||
1293 | struct nfs_page_array page_array; | ||
1294 | struct nfs_client *ds_clp; /* pNFS data server */ | ||
1295 | int ds_idx; /* ds index if ds_clp is set */ | ||
1298 | }; | 1296 | }; |
1299 | 1297 | ||
1300 | struct nfs_mds_commit_info { | 1298 | struct nfs_mds_commit_info { |
@@ -1426,11 +1424,12 @@ struct nfs_rpc_ops { | |||
1426 | struct nfs_pathconf *); | 1424 | struct nfs_pathconf *); |
1427 | int (*set_capabilities)(struct nfs_server *, struct nfs_fh *); | 1425 | int (*set_capabilities)(struct nfs_server *, struct nfs_fh *); |
1428 | int (*decode_dirent)(struct xdr_stream *, struct nfs_entry *, int); | 1426 | int (*decode_dirent)(struct xdr_stream *, struct nfs_entry *, int); |
1429 | int (*pgio_rpc_prepare)(struct rpc_task *, struct nfs_pgio_data *); | 1427 | int (*pgio_rpc_prepare)(struct rpc_task *, |
1430 | void (*read_setup) (struct nfs_pgio_data *, struct rpc_message *); | 1428 | struct nfs_pgio_header *); |
1431 | int (*read_done) (struct rpc_task *, struct nfs_pgio_data *); | 1429 | void (*read_setup)(struct nfs_pgio_header *, struct rpc_message *); |
1432 | void (*write_setup) (struct nfs_pgio_data *, struct rpc_message *); | 1430 | int (*read_done)(struct rpc_task *, struct nfs_pgio_header *); |
1433 | int (*write_done) (struct rpc_task *, struct nfs_pgio_data *); | 1431 | void (*write_setup)(struct nfs_pgio_header *, struct rpc_message *); |
1432 | int (*write_done)(struct rpc_task *, struct nfs_pgio_header *); | ||
1434 | void (*commit_setup) (struct nfs_commit_data *, struct rpc_message *); | 1433 | void (*commit_setup) (struct nfs_commit_data *, struct rpc_message *); |
1435 | void (*commit_rpc_prepare)(struct rpc_task *, struct nfs_commit_data *); | 1434 | void (*commit_rpc_prepare)(struct rpc_task *, struct nfs_commit_data *); |
1436 | int (*commit_done) (struct rpc_task *, struct nfs_commit_data *); | 1435 | int (*commit_done) (struct rpc_task *, struct nfs_commit_data *); |