aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2012-04-30 13:27:31 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-04-30 14:33:52 -0400
commit6d74743b088d116e31fe1b73f47e782ee2016b94 (patch)
treea5bd52d4281795786b41153c50a4fb41ee8bd0c3 /fs
parent3e9e0ca3f19e911ce13c2e6c9858fcb41a37496c (diff)
NFS: Simplify O_DIRECT page referencing
The O_DIRECT code shouldn't need to hold 2 references to each page. The reference held by the struct nfs_page should suffice. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> Cc: Fred Isaman <iisaman@netapp.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfs/direct.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index af02bde7741e..78d1ead8bc30 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -268,10 +268,9 @@ static void nfs_direct_read_completion(struct nfs_pgio_header *hdr)
268 } 268 }
269 bytes += req->wb_bytes; 269 bytes += req->wb_bytes;
270 nfs_list_remove_request(req); 270 nfs_list_remove_request(req);
271 nfs_direct_readpage_release(req);
272 if (!PageCompound(page)) 271 if (!PageCompound(page))
273 set_page_dirty(page); 272 set_page_dirty(page);
274 page_cache_release(page); 273 nfs_direct_readpage_release(req);
275 } 274 }
276 } else { 275 } else {
277 while (!list_empty(&hdr->pages)) { 276 while (!list_empty(&hdr->pages)) {
@@ -281,7 +280,6 @@ static void nfs_direct_read_completion(struct nfs_pgio_header *hdr)
281 if (!PageCompound(req->wb_page)) 280 if (!PageCompound(req->wb_page))
282 set_page_dirty(req->wb_page); 281 set_page_dirty(req->wb_page);
283 bytes += req->wb_bytes; 282 bytes += req->wb_bytes;
284 page_cache_release(req->wb_page);
285 nfs_list_remove_request(req); 283 nfs_list_remove_request(req);
286 nfs_direct_readpage_release(req); 284 nfs_direct_readpage_release(req);
287 } 285 }
@@ -375,8 +373,6 @@ static ssize_t nfs_direct_read_schedule_segment(struct nfs_pageio_descriptor *de
375 pagevec[i], 373 pagevec[i],
376 pgbase, req_len); 374 pgbase, req_len);
377 if (IS_ERR(req)) { 375 if (IS_ERR(req)) {
378 nfs_direct_release_pages(pagevec + i,
379 npages - i);
380 result = PTR_ERR(req); 376 result = PTR_ERR(req);
381 break; 377 break;
382 } 378 }
@@ -385,8 +381,6 @@ static ssize_t nfs_direct_read_schedule_segment(struct nfs_pageio_descriptor *de
385 if (!nfs_pageio_add_request(desc, req)) { 381 if (!nfs_pageio_add_request(desc, req)) {
386 result = desc->pg_error; 382 result = desc->pg_error;
387 nfs_release_request(req); 383 nfs_release_request(req);
388 nfs_direct_release_pages(pagevec + i,
389 npages - i);
390 break; 384 break;
391 } 385 }
392 pgbase = 0; 386 pgbase = 0;
@@ -396,6 +390,8 @@ static ssize_t nfs_direct_read_schedule_segment(struct nfs_pageio_descriptor *de
396 pos += req_len; 390 pos += req_len;
397 count -= req_len; 391 count -= req_len;
398 } 392 }
393 /* The nfs_page now hold references to these pages */
394 nfs_direct_release_pages(pagevec, npages);
399 } while (count != 0 && result >= 0); 395 } while (count != 0 && result >= 0);
400 396
401 kfree(pagevec); 397 kfree(pagevec);
@@ -509,7 +505,6 @@ static void nfs_direct_write_reschedule(struct nfs_direct_req *dreq)
509 nfs_pageio_complete(&desc); 505 nfs_pageio_complete(&desc);
510 506
511 while (!list_empty(&failed)) { 507 while (!list_empty(&failed)) {
512 page_cache_release(req->wb_page);
513 nfs_release_request(req); 508 nfs_release_request(req);
514 nfs_unlock_request(req); 509 nfs_unlock_request(req);
515 } 510 }
@@ -542,10 +537,8 @@ static void nfs_direct_commit_complete(struct nfs_commit_data *data)
542 if (dreq->flags == NFS_ODIRECT_RESCHED_WRITES) { 537 if (dreq->flags == NFS_ODIRECT_RESCHED_WRITES) {
543 /* Note the rewrite will go through mds */ 538 /* Note the rewrite will go through mds */
544 nfs_mark_request_commit(req, NULL, &cinfo); 539 nfs_mark_request_commit(req, NULL, &cinfo);
545 } else { 540 } else
546 page_cache_release(req->wb_page);
547 nfs_release_request(req); 541 nfs_release_request(req);
548 }
549 nfs_unlock_request(req); 542 nfs_unlock_request(req);
550 } 543 }
551 544
@@ -678,8 +671,6 @@ static ssize_t nfs_direct_write_schedule_segment(struct nfs_pageio_descriptor *d
678 pagevec[i], 671 pagevec[i],
679 pgbase, req_len); 672 pgbase, req_len);
680 if (IS_ERR(req)) { 673 if (IS_ERR(req)) {
681 nfs_direct_release_pages(pagevec + i,
682 npages - i);
683 result = PTR_ERR(req); 674 result = PTR_ERR(req);
684 break; 675 break;
685 } 676 }
@@ -690,8 +681,6 @@ static ssize_t nfs_direct_write_schedule_segment(struct nfs_pageio_descriptor *d
690 result = desc->pg_error; 681 result = desc->pg_error;
691 nfs_unlock_request(req); 682 nfs_unlock_request(req);
692 nfs_release_request(req); 683 nfs_release_request(req);
693 nfs_direct_release_pages(pagevec + i,
694 npages - i);
695 break; 684 break;
696 } 685 }
697 pgbase = 0; 686 pgbase = 0;
@@ -701,6 +690,8 @@ static ssize_t nfs_direct_write_schedule_segment(struct nfs_pageio_descriptor *d
701 pos += req_len; 690 pos += req_len;
702 count -= req_len; 691 count -= req_len;
703 } 692 }
693 /* The nfs_page now hold references to these pages */
694 nfs_direct_release_pages(pagevec, npages);
704 } while (count != 0 && result >= 0); 695 } while (count != 0 && result >= 0);
705 696
706 kfree(pagevec); 697 kfree(pagevec);
@@ -763,7 +754,6 @@ static void nfs_direct_write_completion(struct nfs_pgio_header *hdr)
763 nfs_mark_request_commit(req, hdr->lseg, &cinfo); 754 nfs_mark_request_commit(req, hdr->lseg, &cinfo);
764 break; 755 break;
765 default: 756 default:
766 page_cache_release(req->wb_page);
767 nfs_release_request(req); 757 nfs_release_request(req);
768 } 758 }
769 nfs_unlock_request(req); 759 nfs_unlock_request(req);