aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ceph/addr.c
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2013-02-14 13:16:43 -0500
committerSage Weil <sage@inktank.com>2013-05-02 00:16:24 -0400
commit2794a82a11cfeae0890741b18b0049ddb55ce646 (patch)
tree9dc71c4a7d95fceed3942418586c5ced230ecdc2 /fs/ceph/addr.c
parent153e5167e0e237faaefb7adf82db5748c1452d73 (diff)
libceph: separate osd request data info
Pull the fields in an osd request structure that define the data for the request out into a separate structure. Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'fs/ceph/addr.c')
-rw-r--r--fs/ceph/addr.c55
1 files changed, 28 insertions, 27 deletions
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index e324222acc82..3a1a77b0ae9f 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -243,8 +243,8 @@ static void finish_read(struct ceph_osd_request *req, struct ceph_msg *msg)
243 dout("finish_read %p req %p rc %d bytes %d\n", inode, req, rc, bytes); 243 dout("finish_read %p req %p rc %d bytes %d\n", inode, req, rc, bytes);
244 244
245 /* unlock all pages, zeroing any data we didn't read */ 245 /* unlock all pages, zeroing any data we didn't read */
246 for (i = 0; i < req->r_num_pages; i++, bytes -= PAGE_CACHE_SIZE) { 246 for (i = 0; i < req->r_data.num_pages; i++, bytes -= PAGE_CACHE_SIZE) {
247 struct page *page = req->r_pages[i]; 247 struct page *page = req->r_data.pages[i];
248 248
249 if (bytes < (int)PAGE_CACHE_SIZE) { 249 if (bytes < (int)PAGE_CACHE_SIZE) {
250 /* zero (remainder of) page */ 250 /* zero (remainder of) page */
@@ -258,7 +258,7 @@ static void finish_read(struct ceph_osd_request *req, struct ceph_msg *msg)
258 unlock_page(page); 258 unlock_page(page);
259 page_cache_release(page); 259 page_cache_release(page);
260 } 260 }
261 kfree(req->r_pages); 261 kfree(req->r_data.pages);
262} 262}
263 263
264static void ceph_unlock_page_vector(struct page **pages, int num_pages) 264static void ceph_unlock_page_vector(struct page **pages, int num_pages)
@@ -336,9 +336,9 @@ static int start_read(struct inode *inode, struct list_head *page_list, int max)
336 } 336 }
337 pages[i] = page; 337 pages[i] = page;
338 } 338 }
339 req->r_pages = pages; 339 req->r_data.pages = pages;
340 req->r_num_pages = nr_pages; 340 req->r_data.num_pages = nr_pages;
341 req->r_page_alignment = 0; 341 req->r_data.alignment = 0;
342 req->r_callback = finish_read; 342 req->r_callback = finish_read;
343 req->r_inode = inode; 343 req->r_inode = inode;
344 344
@@ -374,7 +374,8 @@ static int ceph_readpages(struct file *file, struct address_space *mapping,
374 max = (fsc->mount_options->rsize + PAGE_CACHE_SIZE - 1) 374 max = (fsc->mount_options->rsize + PAGE_CACHE_SIZE - 1)
375 >> PAGE_SHIFT; 375 >> PAGE_SHIFT;
376 376
377 dout("readpages %p file %p nr_pages %d max %d\n", inode, file, nr_pages, 377 dout("readpages %p file %p nr_pages %d max %d\n", inode,
378 file, nr_pages,
378 max); 379 max);
379 while (!list_empty(page_list)) { 380 while (!list_empty(page_list)) {
380 rc = start_read(inode, page_list, max); 381 rc = start_read(inode, page_list, max);
@@ -567,7 +568,7 @@ static void writepages_finish(struct ceph_osd_request *req,
567 * raced with a truncation and was adjusted at the osd, 568 * raced with a truncation and was adjusted at the osd,
568 * so don't believe the reply. 569 * so don't believe the reply.
569 */ 570 */
570 wrote = req->r_num_pages; 571 wrote = req->r_data.num_pages;
571 } else { 572 } else {
572 wrote = 0; 573 wrote = 0;
573 mapping_set_error(mapping, rc); 574 mapping_set_error(mapping, rc);
@@ -576,8 +577,8 @@ static void writepages_finish(struct ceph_osd_request *req,
576 inode, rc, bytes, wrote); 577 inode, rc, bytes, wrote);
577 578
578 /* clean all pages */ 579 /* clean all pages */
579 for (i = 0; i < req->r_num_pages; i++) { 580 for (i = 0; i < req->r_data.num_pages; i++) {
580 page = req->r_pages[i]; 581 page = req->r_data.pages[i];
581 BUG_ON(!page); 582 BUG_ON(!page);
582 WARN_ON(!PageUptodate(page)); 583 WARN_ON(!PageUptodate(page));
583 584
@@ -606,31 +607,31 @@ static void writepages_finish(struct ceph_osd_request *req,
606 unlock_page(page); 607 unlock_page(page);
607 } 608 }
608 dout("%p wrote+cleaned %d pages\n", inode, wrote); 609 dout("%p wrote+cleaned %d pages\n", inode, wrote);
609 ceph_put_wrbuffer_cap_refs(ci, req->r_num_pages, snapc); 610 ceph_put_wrbuffer_cap_refs(ci, req->r_data.num_pages, snapc);
610 611
611 ceph_release_pages(req->r_pages, req->r_num_pages); 612 ceph_release_pages(req->r_data.pages, req->r_data.num_pages);
612 if (req->r_pages_from_pool) 613 if (req->r_data.pages_from_pool)
613 mempool_free(req->r_pages, 614 mempool_free(req->r_data.pages,
614 ceph_sb_to_client(inode->i_sb)->wb_pagevec_pool); 615 ceph_sb_to_client(inode->i_sb)->wb_pagevec_pool);
615 else 616 else
616 kfree(req->r_pages); 617 kfree(req->r_data.pages);
617 ceph_osdc_put_request(req); 618 ceph_osdc_put_request(req);
618} 619}
619 620
620/* 621/*
621 * allocate a page vec, either directly, or if necessary, via a the 622 * allocate a page vec, either directly, or if necessary, via a the
622 * mempool. we avoid the mempool if we can because req->r_num_pages 623 * mempool. we avoid the mempool if we can because req->r_data.num_pages
623 * may be less than the maximum write size. 624 * may be less than the maximum write size.
624 */ 625 */
625static void alloc_page_vec(struct ceph_fs_client *fsc, 626static void alloc_page_vec(struct ceph_fs_client *fsc,
626 struct ceph_osd_request *req) 627 struct ceph_osd_request *req)
627{ 628{
628 req->r_pages = kmalloc(sizeof(struct page *) * req->r_num_pages, 629 req->r_data.pages = kmalloc(sizeof(struct page *) * req->r_data.num_pages,
629 GFP_NOFS); 630 GFP_NOFS);
630 if (!req->r_pages) { 631 if (!req->r_data.pages) {
631 req->r_pages = mempool_alloc(fsc->wb_pagevec_pool, GFP_NOFS); 632 req->r_data.pages = mempool_alloc(fsc->wb_pagevec_pool, GFP_NOFS);
632 req->r_pages_from_pool = 1; 633 req->r_data.pages_from_pool = 1;
633 WARN_ON(!req->r_pages); 634 WARN_ON(!req->r_data.pages);
634 } 635 }
635} 636}
636 637
@@ -829,9 +830,9 @@ get_more_pages:
829 break; 830 break;
830 } 831 }
831 832
832 req->r_num_pages = calc_pages_for(0, len); 833 req->r_data.num_pages = calc_pages_for(0, len);
833 req->r_page_alignment = 0; 834 req->r_data.alignment = 0;
834 max_pages = req->r_num_pages; 835 max_pages = req->r_data.num_pages;
835 836
836 alloc_page_vec(fsc, req); 837 alloc_page_vec(fsc, req);
837 req->r_callback = writepages_finish; 838 req->r_callback = writepages_finish;
@@ -853,7 +854,7 @@ get_more_pages:
853 } 854 }
854 855
855 set_page_writeback(page); 856 set_page_writeback(page);
856 req->r_pages[locked_pages] = page; 857 req->r_data.pages[locked_pages] = page;
857 locked_pages++; 858 locked_pages++;
858 next = page->index + 1; 859 next = page->index + 1;
859 } 860 }
@@ -883,14 +884,14 @@ get_more_pages:
883 } 884 }
884 885
885 /* submit the write */ 886 /* submit the write */
886 offset = req->r_pages[0]->index << PAGE_CACHE_SHIFT; 887 offset = req->r_data.pages[0]->index << PAGE_CACHE_SHIFT;
887 len = min((snap_size ? snap_size : i_size_read(inode)) - offset, 888 len = min((snap_size ? snap_size : i_size_read(inode)) - offset,
888 (u64)locked_pages << PAGE_CACHE_SHIFT); 889 (u64)locked_pages << PAGE_CACHE_SHIFT);
889 dout("writepages got %d pages at %llu~%llu\n", 890 dout("writepages got %d pages at %llu~%llu\n",
890 locked_pages, offset, len); 891 locked_pages, offset, len);
891 892
892 /* revise final length, page count */ 893 /* revise final length, page count */
893 req->r_num_pages = locked_pages; 894 req->r_data.num_pages = locked_pages;
894 req->r_request_ops[0].extent.length = cpu_to_le64(len); 895 req->r_request_ops[0].extent.length = cpu_to_le64(len);
895 req->r_request_ops[0].payload_len = cpu_to_le32(len); 896 req->r_request_ops[0].payload_len = cpu_to_le32(len);
896 req->r_request->hdr.data_len = cpu_to_le32(len); 897 req->r_request->hdr.data_len = cpu_to_le32(len);