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 */
+ BUG_ON(req->r_data.type != CEPH_OSD_DATA_TYPE_PAGES);
for (i = 0; i < req->r_data.num_pages; i++, bytes -= PAGE_CACHE_SIZE) {
struct page *page = req->r_data.pages[i];
}
pages[i] = page;
}
+ req->r_data.type = CEPH_OSD_DATA_TYPE_PAGES;
req->r_data.pages = pages;
req->r_data.num_pages = nr_pages;
req->r_data.alignment = 0;
long writeback_stat;
unsigned issued = ceph_caps_issued(ci);
+ BUG_ON(req->r_data.type != CEPH_OSD_DATA_TYPE_PAGES);
if (rc >= 0) {
/*
* Assume we wrote the pages we originally sent. The
break;
}
+ req->r_data.type = CEPH_OSD_DATA_TYPE_PAGES;
req->r_data.num_pages = calc_pages_for(0, len);
req->r_data.alignment = 0;
max_pages = req->r_data.num_pages;
}
if (req->r_reply)
ceph_msg_put(req->r_reply);
- if (req->r_data.own_pages)
+ if (req->r_data.type == CEPH_OSD_DATA_TYPE_PAGES &&
+ req->r_data.own_pages)
ceph_release_page_vector(req->r_data.pages,
req->r_data.num_pages);
ceph_put_snap_context(req->r_snapc);
}
req->r_reply = msg;
+ req->r_data.type = CEPH_OSD_DATA_TYPE_NONE;
ceph_pagelist_init(&req->r_trail);
/* create request message; allow space for oid */
{
int rc = 0;
- req->r_request->pages = req->r_data.pages;
- req->r_request->page_count = req->r_data.num_pages;
- req->r_request->page_alignment = req->r_data.alignment;
+ if (req->r_data.type == CEPH_OSD_DATA_TYPE_PAGES) {
+ req->r_request->pages = req->r_data.pages;
+ req->r_request->page_count = req->r_data.num_pages;
+ req->r_request->page_alignment = req->r_data.alignment;
#ifdef CONFIG_BLOCK
- req->r_request->bio = req->r_data.bio;
+ } else if (req->r_data.type == CEPH_OSD_DATA_TYPE_BIO) {
+ req->r_request->bio = req->r_data.bio;
#endif
+ } else {
+ pr_err("unknown request data type %d\n", req->r_data.type);
+ }
req->r_request->trail = &req->r_trail;
register_request(osdc, req);
return PTR_ERR(req);
/* it may be a short read due to an object boundary */
+ req->r_data.type = CEPH_OSD_DATA_TYPE_PAGES;
req->r_data.pages = pages;
req->r_data.num_pages = calc_pages_for(page_align, *plen);
req->r_data.alignment = page_align;
return PTR_ERR(req);
/* it may be a short write due to an object boundary */
+ req->r_data.type = CEPH_OSD_DATA_TYPE_PAGES;
req->r_data.pages = pages;
req->r_data.num_pages = calc_pages_for(page_align, len);
req->r_data.alignment = page_align;
m = ceph_msg_get(req->r_reply);
if (data_len > 0) {
- int want = calc_pages_for(req->r_data.alignment, data_len);
-
- if (req->r_data.pages && unlikely(req->r_data.num_pages < want)) {
- pr_warning("tid %lld reply has %d bytes %d pages, we"
- " had only %d pages ready\n", tid, data_len,
- want, req->r_data.num_pages);
- *skip = 1;
- ceph_msg_put(m);
- m = NULL;
- goto out;
- }
- m->pages = req->r_data.pages;
- m->page_count = req->r_data.num_pages;
- m->page_alignment = req->r_data.alignment;
+ if (req->r_data.type == CEPH_OSD_DATA_TYPE_PAGES) {
+ int want;
+
+ want = calc_pages_for(req->r_data.alignment, data_len);
+ if (req->r_data.pages &&
+ unlikely(req->r_data.num_pages < want)) {
+
+ pr_warning("tid %lld reply has %d bytes %d "
+ "pages, we had only %d pages ready\n",
+ tid, data_len, want,
+ req->r_data.num_pages);
+ *skip = 1;
+ ceph_msg_put(m);
+ m = NULL;
+ goto out;
+ }
+ m->pages = req->r_data.pages;
+ m->page_count = req->r_data.num_pages;
+ m->page_alignment = req->r_data.alignment;
#ifdef CONFIG_BLOCK
- m->bio = req->r_data.bio;
+ } else if (req->r_data.type == CEPH_OSD_DATA_TYPE_BIO) {
+ m->bio = req->r_data.bio;
#endif
+ }
}
*skip = 0;
req->r_con_filling_msg = con->ops->get(con);