Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b150f5c1 authored by Milosz Tanski's avatar Milosz Tanski Committed by Sage Weil
Browse files

ceph: cleanup the logic in ceph_invalidatepage



The invalidatepage code bails if it encounters a non-zero page offset. The
current logic that does is non-obvious with multiple if statements.

This should be logically and functionally equivalent.

Signed-off-by: default avatarMilosz Tanski <milosz@adfin.com>
Reviewed-by: default avatarSage Weil <sage@inktank.com>
parent ee3e542f
Loading
Loading
Loading
Loading
+15 −14
Original line number Diff line number Diff line
@@ -151,6 +151,13 @@ static void ceph_invalidatepage(struct page *page, unsigned int offset,
	struct ceph_snap_context *snapc = page_snap_context(page);

	inode = page->mapping->host;
	ci = ceph_inode(inode);

	if (offset != 0 || length != PAGE_CACHE_SIZE) {
		dout("%p invalidatepage %p idx %lu partial dirty page %u~%u\n",
		     inode, page, page->index, offset, length);
		return;
	}

	/*
	 * We can get non-dirty pages here due to races between
@@ -160,21 +167,15 @@ static void ceph_invalidatepage(struct page *page, unsigned int offset,
	if (!PageDirty(page))
		pr_err("%p invalidatepage %p page not dirty\n", inode, page);

	if (offset == 0 && length == PAGE_CACHE_SIZE)
	ClearPageChecked(page);

	ci = ceph_inode(inode);
	if (offset == 0 && length == PAGE_CACHE_SIZE) {
	dout("%p invalidatepage %p idx %lu full dirty page\n",
	     inode, page, page->index);

	ceph_put_wrbuffer_cap_refs(ci, 1, snapc);
	ceph_put_snap_context(snapc);
	page->private = 0;
	ClearPagePrivate(page);
	} else {
		dout("%p invalidatepage %p idx %lu partial dirty page %u(%u)\n",
		     inode, page, page->index, offset, length);
	}
}

/* just a sanity check */