aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2013-03-01 19:00:15 -0500
committerSage Weil <sage@inktank.com>2013-05-02 00:16:23 -0400
commit153e5167e0e237faaefb7adf82db5748c1452d73 (patch)
treefa0e5ec90ef466cb7100f64ee4d2b9bf7c4ad69d /fs
parent3a42b6c43e4ef65d0edd7d9e5c4366002b4e951d (diff)
libceph: don't assign page info in ceph_osdc_new_request()
Currently ceph_osdc_new_request() assigns an osd request's r_num_pages and r_alignment fields. The only thing it does after that is call ceph_osdc_build_request(), and that doesn't need those fields to be assigned. Move the assignment of those fields out of ceph_osdc_new_request() and into its caller. As a result, the page_align parameter is no longer used, so get rid of it. Note that in ceph_sync_write(), the value for req->r_num_pages had already been calculated earlier (as num_pages, and fortunately it was computed the same way). So don't bother recomputing it, but because it's not needed earlier, move that calculation after the call to ceph_osdc_new_request(). Hold off making the assignment to r_alignment, doing it instead r_pages and r_num_pages are getting set. Similarly, in start_read(), nr_pages already holds the number of pages in the array (and is calculated the same way), so there's no need to recompute it. Move the assignment of the page alignment down with the others there as well. This and the next few patches are preparation work for: http://tracker.ceph.com/issues/4127 Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/ceph/addr.c7
-rw-r--r--fs/ceph/file.c9
2 files changed, 10 insertions, 6 deletions
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index e53f24b15b12..e324222acc82 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -309,7 +309,7 @@ static int start_read(struct inode *inode, struct list_head *page_list, int max)
309 CEPH_OSD_OP_READ, CEPH_OSD_FLAG_READ, 309 CEPH_OSD_OP_READ, CEPH_OSD_FLAG_READ,
310 NULL, 0, 310 NULL, 0,
311 ci->i_truncate_seq, ci->i_truncate_size, 311 ci->i_truncate_seq, ci->i_truncate_size,
312 NULL, false, 0); 312 NULL, false);
313 if (IS_ERR(req)) 313 if (IS_ERR(req))
314 return PTR_ERR(req); 314 return PTR_ERR(req);
315 315
@@ -338,6 +338,7 @@ static int start_read(struct inode *inode, struct list_head *page_list, int max)
338 } 338 }
339 req->r_pages = pages; 339 req->r_pages = pages;
340 req->r_num_pages = nr_pages; 340 req->r_num_pages = nr_pages;
341 req->r_page_alignment = 0;
341 req->r_callback = finish_read; 342 req->r_callback = finish_read;
342 req->r_inode = inode; 343 req->r_inode = inode;
343 344
@@ -820,7 +821,7 @@ get_more_pages:
820 snapc, do_sync, 821 snapc, do_sync,
821 ci->i_truncate_seq, 822 ci->i_truncate_seq,
822 ci->i_truncate_size, 823 ci->i_truncate_size,
823 &inode->i_mtime, true, 0); 824 &inode->i_mtime, true);
824 825
825 if (IS_ERR(req)) { 826 if (IS_ERR(req)) {
826 rc = PTR_ERR(req); 827 rc = PTR_ERR(req);
@@ -828,6 +829,8 @@ get_more_pages:
828 break; 829 break;
829 } 830 }
830 831
832 req->r_num_pages = calc_pages_for(0, len);
833 req->r_page_alignment = 0;
831 max_pages = req->r_num_pages; 834 max_pages = req->r_num_pages;
832 835
833 alloc_page_vec(fsc, req); 836 alloc_page_vec(fsc, req);
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 146ac9040141..f2754cdb5a03 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -527,19 +527,19 @@ more:
527 buf_align = (unsigned long)data & ~PAGE_MASK; 527 buf_align = (unsigned long)data & ~PAGE_MASK;
528 len = left; 528 len = left;
529 529
530 /* write from beginning of first page, regardless of io alignment */
531 page_align = file->f_flags & O_DIRECT ? buf_align : io_align;
532 num_pages = calc_pages_for(page_align, len);
533 req = ceph_osdc_new_request(&fsc->client->osdc, &ci->i_layout, 530 req = ceph_osdc_new_request(&fsc->client->osdc, &ci->i_layout,
534 ceph_vino(inode), pos, &len, 531 ceph_vino(inode), pos, &len,
535 CEPH_OSD_OP_WRITE, flags, 532 CEPH_OSD_OP_WRITE, flags,
536 ci->i_snap_realm->cached_context, 533 ci->i_snap_realm->cached_context,
537 do_sync, 534 do_sync,
538 ci->i_truncate_seq, ci->i_truncate_size, 535 ci->i_truncate_seq, ci->i_truncate_size,
539 &mtime, false, page_align); 536 &mtime, false);
540 if (IS_ERR(req)) 537 if (IS_ERR(req))
541 return PTR_ERR(req); 538 return PTR_ERR(req);
542 539
540 /* write from beginning of first page, regardless of io alignment */
541 page_align = file->f_flags & O_DIRECT ? buf_align : io_align;
542 num_pages = calc_pages_for(page_align, len);
543 if (file->f_flags & O_DIRECT) { 543 if (file->f_flags & O_DIRECT) {
544 pages = ceph_get_direct_page_vector(data, num_pages, false); 544 pages = ceph_get_direct_page_vector(data, num_pages, false);
545 if (IS_ERR(pages)) { 545 if (IS_ERR(pages)) {
@@ -573,6 +573,7 @@ more:
573 } 573 }
574 req->r_pages = pages; 574 req->r_pages = pages;
575 req->r_num_pages = num_pages; 575 req->r_num_pages = num_pages;
576 req->r_page_alignment = page_align;
576 req->r_inode = inode; 577 req->r_inode = inode;
577 578
578 ret = ceph_osdc_start_request(&fsc->client->osdc, req, false); 579 ret = ceph_osdc_start_request(&fsc->client->osdc, req, false);