Commit 8ff2d290 authored by Jeff Layton's avatar Jeff Layton Committed by Ilya Dryomov

ceph: convert some PAGE_SIZE invocations to thp_size()

Start preparing to allow the use of THPs in the pagecache with ceph by
making it use thp_size() in lieu of PAGE_SIZE in the appropriate places.
Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
parent e7f72952
...@@ -154,7 +154,7 @@ static void ceph_invalidatepage(struct page *page, unsigned int offset, ...@@ -154,7 +154,7 @@ static void ceph_invalidatepage(struct page *page, unsigned int offset,
inode = page->mapping->host; inode = page->mapping->host;
ci = ceph_inode(inode); ci = ceph_inode(inode);
if (offset != 0 || length != PAGE_SIZE) { if (offset != 0 || length != thp_size(page)) {
dout("%p invalidatepage %p idx %lu partial dirty page %u~%u\n", dout("%p invalidatepage %p idx %lu partial dirty page %u~%u\n",
inode, page, page->index, offset, length); inode, page, page->index, offset, length);
return; return;
...@@ -331,7 +331,7 @@ static int ceph_readpage(struct file *file, struct page *page) ...@@ -331,7 +331,7 @@ static int ceph_readpage(struct file *file, struct page *page)
struct ceph_inode_info *ci = ceph_inode(inode); struct ceph_inode_info *ci = ceph_inode(inode);
struct ceph_vino vino = ceph_vino(inode); struct ceph_vino vino = ceph_vino(inode);
u64 off = page_offset(page); u64 off = page_offset(page);
u64 len = PAGE_SIZE; u64 len = thp_size(page);
if (ci->i_inline_version != CEPH_INLINE_NONE) { if (ci->i_inline_version != CEPH_INLINE_NONE) {
/* /*
...@@ -342,7 +342,7 @@ static int ceph_readpage(struct file *file, struct page *page) ...@@ -342,7 +342,7 @@ static int ceph_readpage(struct file *file, struct page *page)
unlock_page(page); unlock_page(page);
return -EINVAL; return -EINVAL;
} }
zero_user_segment(page, 0, PAGE_SIZE); zero_user_segment(page, 0, thp_size(page));
SetPageUptodate(page); SetPageUptodate(page);
unlock_page(page); unlock_page(page);
return 0; return 0;
...@@ -477,8 +477,8 @@ static u64 get_writepages_data_length(struct inode *inode, ...@@ -477,8 +477,8 @@ static u64 get_writepages_data_length(struct inode *inode,
spin_unlock(&ci->i_ceph_lock); spin_unlock(&ci->i_ceph_lock);
WARN_ON(!found); WARN_ON(!found);
} }
if (end > page_offset(page) + PAGE_SIZE) if (end > page_offset(page) + thp_size(page))
end = page_offset(page) + PAGE_SIZE; end = page_offset(page) + thp_size(page);
return end > start ? end - start : 0; return end > start ? end - start : 0;
} }
...@@ -496,7 +496,7 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc) ...@@ -496,7 +496,7 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)
struct ceph_snap_context *snapc, *oldest; struct ceph_snap_context *snapc, *oldest;
loff_t page_off = page_offset(page); loff_t page_off = page_offset(page);
int err; int err;
loff_t len = PAGE_SIZE; loff_t len = thp_size(page);
struct ceph_writeback_ctl ceph_wbc; struct ceph_writeback_ctl ceph_wbc;
struct ceph_osd_client *osdc = &fsc->client->osdc; struct ceph_osd_client *osdc = &fsc->client->osdc;
struct ceph_osd_request *req; struct ceph_osd_request *req;
...@@ -524,7 +524,7 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc) ...@@ -524,7 +524,7 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)
/* is this a partial page at end of file? */ /* is this a partial page at end of file? */
if (page_off >= ceph_wbc.i_size) { if (page_off >= ceph_wbc.i_size) {
dout("%p page eof %llu\n", page, ceph_wbc.i_size); dout("%p page eof %llu\n", page, ceph_wbc.i_size);
page->mapping->a_ops->invalidatepage(page, 0, PAGE_SIZE); page->mapping->a_ops->invalidatepage(page, 0, thp_size(page));
return 0; return 0;
} }
...@@ -550,7 +550,7 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc) ...@@ -550,7 +550,7 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)
} }
/* it may be a short write due to an object boundary */ /* it may be a short write due to an object boundary */
WARN_ON_ONCE(len > PAGE_SIZE); WARN_ON_ONCE(len > thp_size(page));
osd_req_op_extent_osd_data_pages(req, 0, &page, len, 0, false, false); osd_req_op_extent_osd_data_pages(req, 0, &page, len, 0, false, false);
dout("writepage %llu~%llu (%llu bytes)\n", page_off, len, len); dout("writepage %llu~%llu (%llu bytes)\n", page_off, len, len);
...@@ -839,7 +839,7 @@ static int ceph_writepages_start(struct address_space *mapping, ...@@ -839,7 +839,7 @@ static int ceph_writepages_start(struct address_space *mapping,
page_offset(page) >= i_size_read(inode)) && page_offset(page) >= i_size_read(inode)) &&
clear_page_dirty_for_io(page)) clear_page_dirty_for_io(page))
mapping->a_ops->invalidatepage(page, mapping->a_ops->invalidatepage(page,
0, PAGE_SIZE); 0, thp_size(page));
unlock_page(page); unlock_page(page);
continue; continue;
} }
...@@ -928,7 +928,7 @@ static int ceph_writepages_start(struct address_space *mapping, ...@@ -928,7 +928,7 @@ static int ceph_writepages_start(struct address_space *mapping,
pages[locked_pages++] = page; pages[locked_pages++] = page;
pvec.pages[i] = NULL; pvec.pages[i] = NULL;
len += PAGE_SIZE; len += thp_size(page);
} }
/* did we get anything? */ /* did we get anything? */
...@@ -977,7 +977,7 @@ static int ceph_writepages_start(struct address_space *mapping, ...@@ -977,7 +977,7 @@ static int ceph_writepages_start(struct address_space *mapping,
BUG_ON(IS_ERR(req)); BUG_ON(IS_ERR(req));
} }
BUG_ON(len < page_offset(pages[locked_pages - 1]) + BUG_ON(len < page_offset(pages[locked_pages - 1]) +
PAGE_SIZE - offset); thp_size(page) - offset);
req->r_callback = writepages_finish; req->r_callback = writepages_finish;
req->r_inode = inode; req->r_inode = inode;
...@@ -1007,7 +1007,7 @@ static int ceph_writepages_start(struct address_space *mapping, ...@@ -1007,7 +1007,7 @@ static int ceph_writepages_start(struct address_space *mapping,
} }
set_page_writeback(pages[i]); set_page_writeback(pages[i]);
len += PAGE_SIZE; len += thp_size(page);
} }
if (ceph_wbc.size_stable) { if (ceph_wbc.size_stable) {
...@@ -1016,7 +1016,7 @@ static int ceph_writepages_start(struct address_space *mapping, ...@@ -1016,7 +1016,7 @@ static int ceph_writepages_start(struct address_space *mapping,
/* writepages_finish() clears writeback pages /* writepages_finish() clears writeback pages
* according to the data length, so make sure * according to the data length, so make sure
* data length covers all locked pages */ * data length covers all locked pages */
u64 min_len = len + 1 - PAGE_SIZE; u64 min_len = len + 1 - thp_size(page);
len = get_writepages_data_length(inode, pages[i - 1], len = get_writepages_data_length(inode, pages[i - 1],
offset); offset);
len = max(len, min_len); len = max(len, min_len);
...@@ -1253,7 +1253,7 @@ static int ceph_write_begin(struct file *file, struct address_space *mapping, ...@@ -1253,7 +1253,7 @@ static int ceph_write_begin(struct file *file, struct address_space *mapping,
} }
goto out; goto out;
} }
zero_user_segment(page, 0, PAGE_SIZE); zero_user_segment(page, 0, thp_size(page));
SetPageUptodate(page); SetPageUptodate(page);
goto out; goto out;
} }
...@@ -1364,8 +1364,8 @@ static vm_fault_t ceph_filemap_fault(struct vm_fault *vmf) ...@@ -1364,8 +1364,8 @@ static vm_fault_t ceph_filemap_fault(struct vm_fault *vmf)
ceph_block_sigs(&oldset); ceph_block_sigs(&oldset);
dout("filemap_fault %p %llx.%llx %llu~%zd trying to get caps\n", dout("filemap_fault %p %llx.%llx %llu trying to get caps\n",
inode, ceph_vinop(inode), off, (size_t)PAGE_SIZE); inode, ceph_vinop(inode), off);
if (fi->fmode & CEPH_FILE_MODE_LAZY) if (fi->fmode & CEPH_FILE_MODE_LAZY)
want = CEPH_CAP_FILE_CACHE | CEPH_CAP_FILE_LAZYIO; want = CEPH_CAP_FILE_CACHE | CEPH_CAP_FILE_LAZYIO;
else else
...@@ -1376,8 +1376,8 @@ static vm_fault_t ceph_filemap_fault(struct vm_fault *vmf) ...@@ -1376,8 +1376,8 @@ static vm_fault_t ceph_filemap_fault(struct vm_fault *vmf)
if (err < 0) if (err < 0)
goto out_restore; goto out_restore;
dout("filemap_fault %p %llu~%zd got cap refs on %s\n", dout("filemap_fault %p %llu got cap refs on %s\n",
inode, off, (size_t)PAGE_SIZE, ceph_cap_string(got)); inode, off, ceph_cap_string(got));
if ((got & (CEPH_CAP_FILE_CACHE | CEPH_CAP_FILE_LAZYIO)) || if ((got & (CEPH_CAP_FILE_CACHE | CEPH_CAP_FILE_LAZYIO)) ||
ci->i_inline_version == CEPH_INLINE_NONE) { ci->i_inline_version == CEPH_INLINE_NONE) {
...@@ -1385,9 +1385,8 @@ static vm_fault_t ceph_filemap_fault(struct vm_fault *vmf) ...@@ -1385,9 +1385,8 @@ static vm_fault_t ceph_filemap_fault(struct vm_fault *vmf)
ceph_add_rw_context(fi, &rw_ctx); ceph_add_rw_context(fi, &rw_ctx);
ret = filemap_fault(vmf); ret = filemap_fault(vmf);
ceph_del_rw_context(fi, &rw_ctx); ceph_del_rw_context(fi, &rw_ctx);
dout("filemap_fault %p %llu~%zd drop cap refs %s ret %x\n", dout("filemap_fault %p %llu drop cap refs %s ret %x\n",
inode, off, (size_t)PAGE_SIZE, inode, off, ceph_cap_string(got), ret);
ceph_cap_string(got), ret);
} else } else
err = -EAGAIN; err = -EAGAIN;
...@@ -1425,8 +1424,8 @@ static vm_fault_t ceph_filemap_fault(struct vm_fault *vmf) ...@@ -1425,8 +1424,8 @@ static vm_fault_t ceph_filemap_fault(struct vm_fault *vmf)
vmf->page = page; vmf->page = page;
ret = VM_FAULT_MAJOR | VM_FAULT_LOCKED; ret = VM_FAULT_MAJOR | VM_FAULT_LOCKED;
out_inline: out_inline:
dout("filemap_fault %p %llu~%zd read inline data ret %x\n", dout("filemap_fault %p %llu read inline data ret %x\n",
inode, off, (size_t)PAGE_SIZE, ret); inode, off, ret);
} }
out_restore: out_restore:
ceph_restore_sigs(&oldset); ceph_restore_sigs(&oldset);
...@@ -1471,10 +1470,10 @@ static vm_fault_t ceph_page_mkwrite(struct vm_fault *vmf) ...@@ -1471,10 +1470,10 @@ static vm_fault_t ceph_page_mkwrite(struct vm_fault *vmf)
goto out_free; goto out_free;
} }
if (off + PAGE_SIZE <= size) if (off + thp_size(page) <= size)
len = PAGE_SIZE; len = thp_size(page);
else else
len = size & ~PAGE_MASK; len = offset_in_thp(page, size);
dout("page_mkwrite %p %llx.%llx %llu~%zd getting caps i_size %llu\n", dout("page_mkwrite %p %llx.%llx %llu~%zd getting caps i_size %llu\n",
inode, ceph_vinop(inode), off, len, size); inode, ceph_vinop(inode), off, len, size);
......
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