struct inode *inode = filp->f_dentry->d_inode;
struct ceph_inode_info *ci = ceph_inode(inode);
struct ceph_osd_client *osdc = &ceph_inode_to_client(inode)->osdc;
- void *kaddr;
int err = 0;
dout(10, "readpage inode %p file %p page %p index %lu\n",
inode, filp, page, page->index);
- kaddr = kmap(page);
err = ceph_osdc_readpage(osdc, ceph_ino(inode), &ci->i_layout,
page->index << PAGE_SHIFT, PAGE_SIZE, page);
- if (err < 0)
+ if (unlikely(err < 0))
goto out;
- if (err < PAGE_CACHE_SIZE) {
+ if (unlikely(err < PAGE_CACHE_SIZE)) {
+ void *kaddr = kmap_atomic(page, KM_USER0);
dout(10, "readpage zeroing tail %d bytes of page %p\n",
(int)PAGE_CACHE_SIZE - err, page);
memset(kaddr + err, 0, PAGE_CACHE_SIZE - err);
+ kunmap_atomic(kaddr, KM_USER0);
}
SetPageUptodate(page);
out:
- kunmap(page);
unlock_page(page);
return err;
}
continue;
}
dout(10, "readpages adding page %p\n", page);
- kunmap(page);
flush_dcache_page(page);
SetPageUptodate(page);
unlock_page(page);
con->in_tag = CEPH_MSGR_TAG_READY;
return 0;
}
- //p = kmap_atomic(m->pages[con->in_msg_pos.page], KM_USER1);
- p = page_address(m->pages[con->in_msg_pos.page]);
+ p = kmap(m->pages[con->in_msg_pos.page]);
ret = ceph_tcp_recvmsg(con->sock, p + con->in_msg_pos.page_pos,
left);
- //kunmap_atomic(p, KM_USER1);
+ kunmap(m->pages[con->in_msg_pos.page]);
mutex_unlock(&m->page_mutex);
if (ret <= 0)
return ret;
struct page *page;
pgoff_t next_index;
int contig_pages;
- int rc;
+ int rc = 0;
/*
* for now, our strategy is simple: start with the
* we can that falls within the range specified by
* nr_pages.
*/
-
dout(10, "readpages on ino %llx on %llu~%llu\n", ino, off, len);
- /* alloc request, w/ page vector */
+ /* alloc request, w/ optimistically-sized page vector */
reqm = new_request_msg(osdc, CEPH_OSD_OP_READ);
if (IS_ERR(reqm))
return PTR_ERR(reqm);
contig_pages = 0;
list_for_each_entry_reverse(page, page_list, lru) {
if (page->index == next_index) {
- kmap(page);
req->r_pages[contig_pages] = page;
contig_pages++;
next_index++;
break;
}
dout(10, "readpages found %d/%d contig\n", contig_pages, nr_pages);
- if (contig_pages == 0) {
- put_request(req);
- return 0;
- }
+ if (contig_pages == 0)
+ goto out;
len = min((contig_pages << PAGE_CACHE_SHIFT) - (off & ~PAGE_CACHE_MASK),
len);
dout(10, "readpages contig page extent is %llu~%llu\n", off, len);
/* request msg */
len = calc_layout(osdc, ino, layout, off, len, req);
req->r_nr_pages = calc_pages_for(off, len);
-
dout(10, "readpages final extent is %llu~%llu -> %d pages\n",
off, len, req->r_nr_pages);
-
rc = do_request(osdc, req);
+
+out:
put_request(req);
dout(10, "readpages result %d\n", rc);
+ if (rc < 0)
+ dout(10, "hrm!\n");
return rc;
}