Commit 87060c10 authored by Alex Elder's avatar Alex Elder Committed by Sage Weil

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: default avatarAlex Elder <elder@inktank.com>
Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
parent 23c08a9c
...@@ -236,6 +236,7 @@ static int ceph_readpage(struct file *filp, struct page *page) ...@@ -236,6 +236,7 @@ static int ceph_readpage(struct file *filp, struct page *page)
static void finish_read(struct ceph_osd_request *req, struct ceph_msg *msg) static void finish_read(struct ceph_osd_request *req, struct ceph_msg *msg)
{ {
struct inode *inode = req->r_inode; struct inode *inode = req->r_inode;
struct ceph_osd_data *osd_data;
int rc = req->r_result; int rc = req->r_result;
int bytes = le32_to_cpu(msg->hdr.data_len); int bytes = le32_to_cpu(msg->hdr.data_len);
int num_pages; int num_pages;
...@@ -244,11 +245,12 @@ static void finish_read(struct ceph_osd_request *req, struct ceph_msg *msg) ...@@ -244,11 +245,12 @@ static void finish_read(struct ceph_osd_request *req, struct ceph_msg *msg)
dout("finish_read %p req %p rc %d bytes %d\n", inode, req, rc, bytes); dout("finish_read %p req %p rc %d bytes %d\n", inode, req, rc, bytes);
/* unlock all pages, zeroing any data we didn't read */ /* unlock all pages, zeroing any data we didn't read */
BUG_ON(req->r_data_in.type != CEPH_OSD_DATA_TYPE_PAGES); osd_data = &req->r_data_in;
num_pages = calc_pages_for((u64)req->r_data_in.alignment, BUG_ON(osd_data->type != CEPH_OSD_DATA_TYPE_PAGES);
(u64)req->r_data_in.length); num_pages = calc_pages_for((u64)osd_data->alignment,
(u64)osd_data->length);
for (i = 0; i < num_pages; i++) { for (i = 0; i < num_pages; i++) {
struct page *page = req->r_data_in.pages[i]; struct page *page = osd_data->pages[i];
if (bytes < (int)PAGE_CACHE_SIZE) { if (bytes < (int)PAGE_CACHE_SIZE) {
/* zero (remainder of) page */ /* zero (remainder of) page */
...@@ -263,7 +265,7 @@ static void finish_read(struct ceph_osd_request *req, struct ceph_msg *msg) ...@@ -263,7 +265,7 @@ static void finish_read(struct ceph_osd_request *req, struct ceph_msg *msg)
page_cache_release(page); page_cache_release(page);
bytes -= PAGE_CACHE_SIZE; bytes -= PAGE_CACHE_SIZE;
} }
kfree(req->r_data_in.pages); kfree(osd_data->pages);
} }
static void ceph_unlock_page_vector(struct page **pages, int num_pages) static 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,6 +559,7 @@ static void writepages_finish(struct ceph_osd_request *req,
{ {
struct inode *inode = req->r_inode; struct inode *inode = req->r_inode;
struct ceph_inode_info *ci = ceph_inode(inode); struct ceph_inode_info *ci = ceph_inode(inode);
struct ceph_osd_data *osd_data;
unsigned wrote; unsigned wrote;
struct page *page; struct page *page;
int num_pages; int num_pages;
...@@ -569,9 +572,10 @@ static void writepages_finish(struct ceph_osd_request *req, ...@@ -569,9 +572,10 @@ static void writepages_finish(struct ceph_osd_request *req,
long writeback_stat; long writeback_stat;
unsigned issued = ceph_caps_issued(ci); unsigned issued = ceph_caps_issued(ci);
BUG_ON(req->r_data_out.type != CEPH_OSD_DATA_TYPE_PAGES); osd_data = &req->r_data_out;
num_pages = calc_pages_for((u64)req->r_data_out.alignment, BUG_ON(osd_data->type != CEPH_OSD_DATA_TYPE_PAGES);
(u64)req->r_data_out.length); num_pages = calc_pages_for((u64)osd_data->alignment,
(u64)osd_data->length);
if (rc >= 0) { if (rc >= 0) {
/* /*
* Assume we wrote the pages we originally sent. The * Assume we wrote the pages we originally sent. The
...@@ -589,7 +593,7 @@ static void writepages_finish(struct ceph_osd_request *req, ...@@ -589,7 +593,7 @@ static void writepages_finish(struct ceph_osd_request *req,
/* clean all pages */ /* clean all pages */
for (i = 0; i < num_pages; i++) { for (i = 0; i < num_pages; i++) {
page = req->r_data_out.pages[i]; page = osd_data->pages[i];
BUG_ON(!page); BUG_ON(!page);
WARN_ON(!PageUptodate(page)); WARN_ON(!PageUptodate(page));
...@@ -620,12 +624,12 @@ static void writepages_finish(struct ceph_osd_request *req, ...@@ -620,12 +624,12 @@ static void writepages_finish(struct ceph_osd_request *req,
dout("%p wrote+cleaned %d pages\n", inode, wrote); dout("%p wrote+cleaned %d pages\n", inode, wrote);
ceph_put_wrbuffer_cap_refs(ci, num_pages, snapc); ceph_put_wrbuffer_cap_refs(ci, num_pages, snapc);
ceph_release_pages(req->r_data_out.pages, num_pages); ceph_release_pages(osd_data->pages, num_pages);
if (req->r_data_out.pages_from_pool) if (osd_data->pages_from_pool)
mempool_free(req->r_data_out.pages, mempool_free(osd_data->pages,
ceph_sb_to_client(inode->i_sb)->wb_pagevec_pool); ceph_sb_to_client(inode->i_sb)->wb_pagevec_pool);
else else
kfree(req->r_data_out.pages); kfree(osd_data->pages);
ceph_osdc_put_request(req); ceph_osdc_put_request(req);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment