|
@@ -356,8 +356,8 @@ static struct ceph_snap_context *__get_oldest_context(struct inode *inode,
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- if (!snapc && ci->i_snap_realm) {
|
|
|
- snapc = ceph_get_snap_context(ci->i_snap_realm->cached_context);
|
|
|
+ if (!snapc && ci->i_head_snapc) {
|
|
|
+ snapc = ceph_get_snap_context(ci->i_head_snapc);
|
|
|
dout(" head snapc %p has %d dirty pages\n",
|
|
|
snapc, ci->i_wrbuffer_ref_head);
|
|
|
}
|
|
@@ -412,7 +412,7 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)
|
|
|
dout("writepage %p page %p not dirty?\n", inode, page);
|
|
|
goto out;
|
|
|
}
|
|
|
- if (snapc != get_oldest_context(inode, &snap_size)) {
|
|
|
+ if (snapc->seq > get_oldest_context(inode, &snap_size)->seq) {
|
|
|
dout("writepage %p page %p snapc %p not writeable - noop\n",
|
|
|
inode, page, (void *)page->private);
|
|
|
/* we should only noop if called by kswapd */
|
|
@@ -557,9 +557,9 @@ static void writepages_finish(struct ceph_osd_request *req,
|
|
|
dout("inode %p skipping page %p\n", inode, page);
|
|
|
wbc->pages_skipped++;
|
|
|
}
|
|
|
+ ceph_put_snap_context((void *)page->private);
|
|
|
page->private = 0;
|
|
|
ClearPagePrivate(page);
|
|
|
- ceph_put_snap_context(snapc);
|
|
|
dout("unlocking %d %p\n", i, page);
|
|
|
end_page_writeback(page);
|
|
|
|
|
@@ -617,7 +617,7 @@ static int ceph_writepages_start(struct address_space *mapping,
|
|
|
int range_whole = 0;
|
|
|
int should_loop = 1;
|
|
|
pgoff_t max_pages = 0, max_pages_ever = 0;
|
|
|
- struct ceph_snap_context *snapc = NULL, *last_snapc = NULL;
|
|
|
+ struct ceph_snap_context *snapc = NULL, *last_snapc = NULL, *pgsnapc;
|
|
|
struct pagevec pvec;
|
|
|
int done = 0;
|
|
|
int rc = 0;
|
|
@@ -769,9 +769,10 @@ get_more_pages:
|
|
|
}
|
|
|
|
|
|
/* only if matching snap context */
|
|
|
- if (snapc != (void *)page->private) {
|
|
|
- dout("page snapc %p != oldest %p\n",
|
|
|
- (void *)page->private, snapc);
|
|
|
+ pgsnapc = (void *)page->private;
|
|
|
+ if (pgsnapc->seq > snapc->seq) {
|
|
|
+ dout("page snapc %p %lld > oldest %p %lld\n",
|
|
|
+ pgsnapc, pgsnapc->seq, snapc, snapc->seq);
|
|
|
unlock_page(page);
|
|
|
if (!locked_pages)
|
|
|
continue; /* keep looking for snap */
|
|
@@ -935,8 +936,8 @@ static int ceph_update_writeable_page(struct file *file,
|
|
|
int pos_in_page = pos & ~PAGE_CACHE_MASK;
|
|
|
int end_in_page = pos_in_page + len;
|
|
|
loff_t i_size;
|
|
|
- struct ceph_snap_context *snapc;
|
|
|
int r;
|
|
|
+ struct ceph_snap_context *snapc, *oldest;
|
|
|
|
|
|
retry_locked:
|
|
|
/* writepages currently holds page lock, but if we change that later, */
|
|
@@ -946,16 +947,16 @@ retry_locked:
|
|
|
BUG_ON(!ci->i_snap_realm);
|
|
|
down_read(&mdsc->snap_rwsem);
|
|
|
BUG_ON(!ci->i_snap_realm->cached_context);
|
|
|
- if (page->private &&
|
|
|
- (void *)page->private != ci->i_snap_realm->cached_context) {
|
|
|
+ snapc = (void *)page->private;
|
|
|
+ if (snapc && snapc != ci->i_head_snapc) {
|
|
|
/*
|
|
|
* this page is already dirty in another (older) snap
|
|
|
* context! is it writeable now?
|
|
|
*/
|
|
|
- snapc = get_oldest_context(inode, NULL);
|
|
|
+ oldest = get_oldest_context(inode, NULL);
|
|
|
up_read(&mdsc->snap_rwsem);
|
|
|
|
|
|
- if (snapc != (void *)page->private) {
|
|
|
+ if (snapc->seq > oldest->seq) {
|
|
|
dout(" page %p snapc %p not current or oldest\n",
|
|
|
page, (void *)page->private);
|
|
|
/*
|