aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/direct.c
diff options
context:
space:
mode:
authorFred Isaman <iisaman@netapp.com>2012-04-20 14:47:45 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-04-27 14:10:37 -0400
commit30dd374f6fc1b202db3a1b57b61afff1326bad92 (patch)
tree7d3b631be897dd79a916ee8d410fd2bb92da4890 /fs/nfs/direct.c
parentcd841605f7a721878d8a2d1362484723d8abf569 (diff)
NFS: create struct nfs_page_array
Both nfs_read_data and nfs_write_data devote several fields which can be combined into a single shared struct. Signed-off-by: Fred Isaman <iisaman@netapp.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/direct.c')
-rw-r--r--fs/nfs/direct.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 56176af1436f..0faba4cb531d 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -252,11 +252,11 @@ static void nfs_direct_read_release(void *calldata)
252 } else { 252 } else {
253 dreq->count += data->res.count; 253 dreq->count += data->res.count;
254 spin_unlock(&dreq->lock); 254 spin_unlock(&dreq->lock);
255 nfs_direct_dirty_pages(data->pagevec, 255 nfs_direct_dirty_pages(data->pages.pagevec,
256 data->args.pgbase, 256 data->args.pgbase,
257 data->res.count); 257 data->res.count);
258 } 258 }
259 nfs_direct_release_pages(data->pagevec, data->npages); 259 nfs_direct_release_pages(data->pages.pagevec, data->pages.npages);
260 260
261 if (put_dreq(dreq)) 261 if (put_dreq(dreq))
262 nfs_direct_complete(dreq); 262 nfs_direct_complete(dreq);
@@ -273,8 +273,8 @@ static void nfs_direct_readhdr_release(struct nfs_read_header *rhdr)
273{ 273{
274 struct nfs_read_data *data = &rhdr->rpc_data; 274 struct nfs_read_data *data = &rhdr->rpc_data;
275 275
276 if (data->pagevec != data->page_array) 276 if (data->pages.pagevec != data->pages.page_array)
277 kfree(data->pagevec); 277 kfree(data->pages.pagevec);
278 nfs_readhdr_free(&rhdr->header); 278 nfs_readhdr_free(&rhdr->header);
279} 279}
280 280
@@ -312,6 +312,7 @@ static ssize_t nfs_direct_read_schedule_segment(struct nfs_direct_req *dreq,
312 do { 312 do {
313 struct nfs_read_header *rhdr; 313 struct nfs_read_header *rhdr;
314 struct nfs_read_data *data; 314 struct nfs_read_data *data;
315 struct nfs_page_array *pages;
315 size_t bytes; 316 size_t bytes;
316 317
317 pgbase = user_addr & ~PAGE_MASK; 318 pgbase = user_addr & ~PAGE_MASK;
@@ -322,24 +323,25 @@ static ssize_t nfs_direct_read_schedule_segment(struct nfs_direct_req *dreq,
322 if (unlikely(!rhdr)) 323 if (unlikely(!rhdr))
323 break; 324 break;
324 data = &rhdr->rpc_data; 325 data = &rhdr->rpc_data;
326 pages = &data->pages;
325 327
326 down_read(&current->mm->mmap_sem); 328 down_read(&current->mm->mmap_sem);
327 result = get_user_pages(current, current->mm, user_addr, 329 result = get_user_pages(current, current->mm, user_addr,
328 data->npages, 1, 0, data->pagevec, NULL); 330 pages->npages, 1, 0, pages->pagevec, NULL);
329 up_read(&current->mm->mmap_sem); 331 up_read(&current->mm->mmap_sem);
330 if (result < 0) { 332 if (result < 0) {
331 nfs_direct_readhdr_release(rhdr); 333 nfs_direct_readhdr_release(rhdr);
332 break; 334 break;
333 } 335 }
334 if ((unsigned)result < data->npages) { 336 if ((unsigned)result < pages->npages) {
335 bytes = result * PAGE_SIZE; 337 bytes = result * PAGE_SIZE;
336 if (bytes <= pgbase) { 338 if (bytes <= pgbase) {
337 nfs_direct_release_pages(data->pagevec, result); 339 nfs_direct_release_pages(pages->pagevec, result);
338 nfs_direct_readhdr_release(rhdr); 340 nfs_direct_readhdr_release(rhdr);
339 break; 341 break;
340 } 342 }
341 bytes -= pgbase; 343 bytes -= pgbase;
342 data->npages = result; 344 pages->npages = result;
343 } 345 }
344 346
345 get_dreq(dreq); 347 get_dreq(dreq);
@@ -352,7 +354,7 @@ static ssize_t nfs_direct_read_schedule_segment(struct nfs_direct_req *dreq,
352 data->args.lock_context = dreq->l_ctx; 354 data->args.lock_context = dreq->l_ctx;
353 data->args.offset = pos; 355 data->args.offset = pos;
354 data->args.pgbase = pgbase; 356 data->args.pgbase = pgbase;
355 data->args.pages = data->pagevec; 357 data->args.pages = pages->pagevec;
356 data->args.count = bytes; 358 data->args.count = bytes;
357 data->res.fattr = &data->fattr; 359 data->res.fattr = &data->fattr;
358 data->res.eof = 0; 360 data->res.eof = 0;
@@ -462,8 +464,8 @@ static void nfs_direct_writehdr_release(struct nfs_write_header *whdr)
462{ 464{
463 struct nfs_write_data *data = &whdr->rpc_data; 465 struct nfs_write_data *data = &whdr->rpc_data;
464 466
465 if (data->pagevec != data->page_array) 467 if (data->pages.pagevec != data->pages.page_array)
466 kfree(data->pagevec); 468 kfree(data->pages.pagevec);
467 nfs_writehdr_free(&whdr->header); 469 nfs_writehdr_free(&whdr->header);
468} 470}
469 471
@@ -472,8 +474,10 @@ static void nfs_direct_free_writedata(struct nfs_direct_req *dreq)
472 while (!list_empty(&dreq->rewrite_list)) { 474 while (!list_empty(&dreq->rewrite_list)) {
473 struct nfs_pgio_header *hdr = list_entry(dreq->rewrite_list.next, struct nfs_pgio_header, pages); 475 struct nfs_pgio_header *hdr = list_entry(dreq->rewrite_list.next, struct nfs_pgio_header, pages);
474 struct nfs_write_header *whdr = container_of(hdr, struct nfs_write_header, header); 476 struct nfs_write_header *whdr = container_of(hdr, struct nfs_write_header, header);
477 struct nfs_page_array *p = &whdr->rpc_data.pages;
478
475 list_del(&hdr->pages); 479 list_del(&hdr->pages);
476 nfs_direct_release_pages(whdr->rpc_data.pagevec, whdr->rpc_data.npages); 480 nfs_direct_release_pages(p->pagevec, p->npages);
477 nfs_direct_writehdr_release(whdr); 481 nfs_direct_writehdr_release(whdr);
478 } 482 }
479} 483}
@@ -751,6 +755,7 @@ static ssize_t nfs_direct_write_schedule_segment(struct nfs_direct_req *dreq,
751 do { 755 do {
752 struct nfs_write_header *whdr; 756 struct nfs_write_header *whdr;
753 struct nfs_write_data *data; 757 struct nfs_write_data *data;
758 struct nfs_page_array *pages;
754 size_t bytes; 759 size_t bytes;
755 760
756 pgbase = user_addr & ~PAGE_MASK; 761 pgbase = user_addr & ~PAGE_MASK;
@@ -762,24 +767,25 @@ static ssize_t nfs_direct_write_schedule_segment(struct nfs_direct_req *dreq,
762 break; 767 break;
763 768
764 data = &whdr->rpc_data; 769 data = &whdr->rpc_data;
770 pages = &data->pages;
765 771
766 down_read(&current->mm->mmap_sem); 772 down_read(&current->mm->mmap_sem);
767 result = get_user_pages(current, current->mm, user_addr, 773 result = get_user_pages(current, current->mm, user_addr,
768 data->npages, 0, 0, data->pagevec, NULL); 774 pages->npages, 0, 0, pages->pagevec, NULL);
769 up_read(&current->mm->mmap_sem); 775 up_read(&current->mm->mmap_sem);
770 if (result < 0) { 776 if (result < 0) {
771 nfs_direct_writehdr_release(whdr); 777 nfs_direct_writehdr_release(whdr);
772 break; 778 break;
773 } 779 }
774 if ((unsigned)result < data->npages) { 780 if ((unsigned)result < pages->npages) {
775 bytes = result * PAGE_SIZE; 781 bytes = result * PAGE_SIZE;
776 if (bytes <= pgbase) { 782 if (bytes <= pgbase) {
777 nfs_direct_release_pages(data->pagevec, result); 783 nfs_direct_release_pages(pages->pagevec, result);
778 nfs_direct_writehdr_release(whdr); 784 nfs_direct_writehdr_release(whdr);
779 break; 785 break;
780 } 786 }
781 bytes -= pgbase; 787 bytes -= pgbase;
782 data->npages = result; 788 pages->npages = result;
783 } 789 }
784 790
785 get_dreq(dreq); 791 get_dreq(dreq);
@@ -794,7 +800,7 @@ static ssize_t nfs_direct_write_schedule_segment(struct nfs_direct_req *dreq,
794 data->args.lock_context = dreq->l_ctx; 800 data->args.lock_context = dreq->l_ctx;
795 data->args.offset = pos; 801 data->args.offset = pos;
796 data->args.pgbase = pgbase; 802 data->args.pgbase = pgbase;
797 data->args.pages = data->pagevec; 803 data->args.pages = pages->pagevec;
798 data->args.count = bytes; 804 data->args.count = bytes;
799 data->args.stable = sync; 805 data->args.stable = sync;
800 data->res.fattr = &data->fattr; 806 data->res.fattr = &data->fattr;