summaryrefslogtreecommitdiff
path: root/fs/ceph
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@hq.newdream.net>2010-02-19 00:07:01 +0000
committerSage Weil <sage@newdream.net>2010-02-19 14:34:18 -0800
commite63dc5c780ba32d6d8b3662eecce2b8d96489b41 (patch)
treeed6ee7f557c479934b6d8a70b7ccba86b13ae670 /fs/ceph
parent5ecad6fd7bfd30b3eaea51345f546b81de7a6473 (diff)
ceph: remove page upon writeback completion if lost cache cap
This page should have been removed earlier when the cache cap was revoked, but a writeback was in flight, so it was skipped. We truncate it here just as the writeback finishes, while it's still locked. Signed-off-by: Yehuda Sadeh <yehuda@hq.newdream.net> Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph')
-rw-r--r--fs/ceph/addr.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 71f5ad1c1e26..25360d517d1b 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -514,6 +514,7 @@ static void writepages_finish(struct ceph_osd_request *req,
u64 bytes = 0;
struct ceph_client *client = ceph_inode_to_client(inode);
long writeback_stat;
+ unsigned issued = __ceph_caps_issued(ci, NULL);
/* parse reply */
replyhead = msg->front.iov_base;
@@ -559,6 +560,16 @@ static void writepages_finish(struct ceph_osd_request *req,
ceph_put_snap_context(snapc);
dout("unlocking %d %p\n", i, page);
end_page_writeback(page);
+
+ /*
+ * We lost the cache cap, need to truncate the page before
+ * it is unlocked, otherwise we'd truncate it later in the
+ * page truncation thread, possibly losing some data that
+ * raced its way in
+ */
+ if ((issued & CEPH_CAP_FILE_CACHE) == 0)
+ generic_error_remove_page(inode->i_mapping, page);
+
unlock_page(page);
}
dout("%p wrote+cleaned %d pages\n", inode, wrote);