Commit d45156bf authored by Jeff Layton's avatar Jeff Layton Committed by Ilya Dryomov

ceph: don't call ceph_update_writeable_page from page_mkwrite

page_mkwrite should only be called with Uptodate pages, so we should
only need to flush incompatible snap contexts.
Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
parent 18d620f0
...@@ -1300,7 +1300,6 @@ static int context_is_writeable_or_written(struct inode *inode, ...@@ -1300,7 +1300,6 @@ static int context_is_writeable_or_written(struct inode *inode,
/** /**
* ceph_find_incompatible - find an incompatible context and return it * ceph_find_incompatible - find an incompatible context and return it
* @inode: inode associated with page
* @page: page being dirtied * @page: page being dirtied
* *
* We are only allowed to write into/dirty a page if the page is * We are only allowed to write into/dirty a page if the page is
...@@ -1311,8 +1310,9 @@ static int context_is_writeable_or_written(struct inode *inode, ...@@ -1311,8 +1310,9 @@ static int context_is_writeable_or_written(struct inode *inode,
* Must be called with page lock held. * Must be called with page lock held.
*/ */
static struct ceph_snap_context * static struct ceph_snap_context *
ceph_find_incompatible(struct inode *inode, struct page *page) ceph_find_incompatible(struct page *page)
{ {
struct inode *inode = page->mapping->host;
struct ceph_fs_client *fsc = ceph_inode_to_client(inode); struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
struct ceph_inode_info *ci = ceph_inode(inode); struct ceph_inode_info *ci = ceph_inode(inode);
...@@ -1376,7 +1376,7 @@ static int ceph_update_writeable_page(struct file *file, ...@@ -1376,7 +1376,7 @@ static int ceph_update_writeable_page(struct file *file,
int r; int r;
retry_locked: retry_locked:
snapc = ceph_find_incompatible(inode, page); snapc = ceph_find_incompatible(page);
if (snapc) { if (snapc) {
if (IS_ERR(snapc)) { if (IS_ERR(snapc)) {
r = PTR_ERR(snapc); r = PTR_ERR(snapc);
...@@ -1689,6 +1689,8 @@ static vm_fault_t ceph_page_mkwrite(struct vm_fault *vmf) ...@@ -1689,6 +1689,8 @@ static vm_fault_t ceph_page_mkwrite(struct vm_fault *vmf)
inode_inc_iversion_raw(inode); inode_inc_iversion_raw(inode);
do { do {
struct ceph_snap_context *snapc;
lock_page(page); lock_page(page);
if (page_mkwrite_check_truncate(page, inode) < 0) { if (page_mkwrite_check_truncate(page, inode) < 0) {
...@@ -1697,13 +1699,26 @@ static vm_fault_t ceph_page_mkwrite(struct vm_fault *vmf) ...@@ -1697,13 +1699,26 @@ static vm_fault_t ceph_page_mkwrite(struct vm_fault *vmf)
break; break;
} }
err = ceph_update_writeable_page(vma->vm_file, off, len, page); snapc = ceph_find_incompatible(page);
if (err >= 0) { if (!snapc) {
/* success. we'll keep the page locked. */ /* success. we'll keep the page locked. */
set_page_dirty(page); set_page_dirty(page);
ret = VM_FAULT_LOCKED; ret = VM_FAULT_LOCKED;
break;
}
unlock_page(page);
if (IS_ERR(snapc)) {
ret = VM_FAULT_SIGBUS;
break;
} }
} while (err == -EAGAIN);
ceph_queue_writeback(inode);
err = wait_event_killable(ci->i_cap_wq,
context_is_writeable_or_written(inode, snapc));
ceph_put_snap_context(snapc);
} while (err == 0);
if (ret == VM_FAULT_LOCKED || if (ret == VM_FAULT_LOCKED ||
ci->i_inline_version != CEPH_INLINE_NONE) { ci->i_inline_version != CEPH_INLINE_NONE) {
......
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