aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ceph
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2013-04-03 02:28:58 -0400
committerSage Weil <sage@inktank.com>2013-05-02 00:18:10 -0400
commit87060c1089a94f89590fc0606b5178f5556833f0 (patch)
tree1ed532bf406fa6b6c3d7f51dcba8146237f40f53 /fs/ceph
parent23c08a9cb2d832cd1d2b7ccdb54d0ab7b8518933 (diff)
libceph: a few more osd data cleanups
These are very small changes that make use osd_data local pointers as shorthands for structures being operated on. Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'fs/ceph')
-rw-r--r--fs/ceph/addr.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index cf9032abc8f5..127be29a6c22 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -236,6 +236,7 @@ static int ceph_readpage(struct file *filp, struct page *page)
236static void finish_read(struct ceph_osd_request *req, struct ceph_msg *msg) 236static void finish_read(struct ceph_osd_request *req, struct ceph_msg *msg)
237{ 237{
238 struct inode *inode = req->r_inode; 238 struct inode *inode = req->r_inode;
239 struct ceph_osd_data *osd_data;
239 int rc = req->r_result; 240 int rc = req->r_result;
240 int bytes = le32_to_cpu(msg->hdr.data_len); 241 int bytes = le32_to_cpu(msg->hdr.data_len);
241 int num_pages; 242 int num_pages;
@@ -244,11 +245,12 @@ static void finish_read(struct ceph_osd_request *req, struct ceph_msg *msg)
244 dout("finish_read %p req %p rc %d bytes %d\n", inode, req, rc, bytes); 245 dout("finish_read %p req %p rc %d bytes %d\n", inode, req, rc, bytes);
245 246
246 /* unlock all pages, zeroing any data we didn't read */ 247 /* unlock all pages, zeroing any data we didn't read */
247 BUG_ON(req->r_data_in.type != CEPH_OSD_DATA_TYPE_PAGES); 248 osd_data = &req->r_data_in;
248 num_pages = calc_pages_for((u64)req->r_data_in.alignment, 249 BUG_ON(osd_data->type != CEPH_OSD_DATA_TYPE_PAGES);
249 (u64)req->r_data_in.length); 250 num_pages = calc_pages_for((u64)osd_data->alignment,
251 (u64)osd_data->length);
250 for (i = 0; i < num_pages; i++) { 252 for (i = 0; i < num_pages; i++) {
251 struct page *page = req->r_data_in.pages[i]; 253 struct page *page = osd_data->pages[i];
252 254
253 if (bytes < (int)PAGE_CACHE_SIZE) { 255 if (bytes < (int)PAGE_CACHE_SIZE) {
254 /* zero (remainder of) page */ 256 /* zero (remainder of) page */
@@ -263,7 +265,7 @@ static void finish_read(struct ceph_osd_request *req, struct ceph_msg *msg)
263 page_cache_release(page); 265 page_cache_release(page);
264 bytes -= PAGE_CACHE_SIZE; 266 bytes -= PAGE_CACHE_SIZE;
265 } 267 }
266 kfree(req->r_data_in.pages); 268 kfree(osd_data->pages);
267} 269}
268 270
269static void ceph_unlock_page_vector(struct page **pages, int num_pages) 271static void ceph_unlock_page_vector(struct page **pages, int num_pages)
@@ -557,6 +559,7 @@ static void writepages_finish(struct ceph_osd_request *req,
557{ 559{
558 struct inode *inode = req->r_inode; 560 struct inode *inode = req->r_inode;
559 struct ceph_inode_info *ci = ceph_inode(inode); 561 struct ceph_inode_info *ci = ceph_inode(inode);
562 struct ceph_osd_data *osd_data;
560 unsigned wrote; 563 unsigned wrote;
561 struct page *page; 564 struct page *page;
562 int num_pages; 565 int num_pages;
@@ -569,9 +572,10 @@ static void writepages_finish(struct ceph_osd_request *req,
569 long writeback_stat; 572 long writeback_stat;
570 unsigned issued = ceph_caps_issued(ci); 573 unsigned issued = ceph_caps_issued(ci);
571 574
572 BUG_ON(req->r_data_out.type != CEPH_OSD_DATA_TYPE_PAGES); 575 osd_data = &req->r_data_out;
573 num_pages = calc_pages_for((u64)req->r_data_out.alignment, 576 BUG_ON(osd_data->type != CEPH_OSD_DATA_TYPE_PAGES);
574 (u64)req->r_data_out.length); 577 num_pages = calc_pages_for((u64)osd_data->alignment,
578 (u64)osd_data->length);
575 if (rc >= 0) { 579 if (rc >= 0) {
576 /* 580 /*
577 * Assume we wrote the pages we originally sent. The 581 * Assume we wrote the pages we originally sent. The
@@ -589,7 +593,7 @@ static void writepages_finish(struct ceph_osd_request *req,
589 593
590 /* clean all pages */ 594 /* clean all pages */
591 for (i = 0; i < num_pages; i++) { 595 for (i = 0; i < num_pages; i++) {
592 page = req->r_data_out.pages[i]; 596 page = osd_data->pages[i];
593 BUG_ON(!page); 597 BUG_ON(!page);
594 WARN_ON(!PageUptodate(page)); 598 WARN_ON(!PageUptodate(page));
595 599
@@ -620,12 +624,12 @@ static void writepages_finish(struct ceph_osd_request *req,
620 dout("%p wrote+cleaned %d pages\n", inode, wrote); 624 dout("%p wrote+cleaned %d pages\n", inode, wrote);
621 ceph_put_wrbuffer_cap_refs(ci, num_pages, snapc); 625 ceph_put_wrbuffer_cap_refs(ci, num_pages, snapc);
622 626
623 ceph_release_pages(req->r_data_out.pages, num_pages); 627 ceph_release_pages(osd_data->pages, num_pages);
624 if (req->r_data_out.pages_from_pool) 628 if (osd_data->pages_from_pool)
625 mempool_free(req->r_data_out.pages, 629 mempool_free(osd_data->pages,
626 ceph_sb_to_client(inode->i_sb)->wb_pagevec_pool); 630 ceph_sb_to_client(inode->i_sb)->wb_pagevec_pool);
627 else 631 else
628 kfree(req->r_data_out.pages); 632 kfree(osd_data->pages);
629 ceph_osdc_put_request(req); 633 ceph_osdc_put_request(req);
630} 634}
631 635