summaryrefslogtreecommitdiffstats
path: root/fs/ceph/caps.c
diff options
context:
space:
mode:
authorYan, Zheng <zyan@redhat.com>2016-05-18 08:31:55 -0400
committerIlya Dryomov <idryomov@gmail.com>2016-06-01 04:31:50 -0400
commitf7f7e7a0635dedd5064fba255cb3facfa87b06d6 (patch)
tree3e18ffcddf422deba5b7a10948b15b827defd441 /fs/ceph/caps.c
parent46b59b2be05a71d80d76883d2f495f182d768f47 (diff)
ceph: improve fscache revalidation
There are several issues in fscache revalidation code. - In ceph_revalidate_work(), fscache_invalidate() is called when fscache_check_consistency() return 0. This is complete wrong because 0 means cache is valid. - Handle_cap_grant() calls ceph_queue_revalidate() if client already has CAP_FILE_CACHE. This code is confusing. Client should revalidate the cache each time it got CAP_FILE_CACHE anew. - In Handle_cap_grant(), fscache_invalidate() is called if MDS revokes CAP_FILE_CACHE. This is inconsistency with the case that inode get evicted. In the later case, the cache is not discarded. Client may use the cache when inode is reloaded. This patch moves the fscache revalidation into ceph_get_caps(). Client revalidates the cache after it gets CAP_FILE_CACHE. i_rdcache_gen should keep constance while CAP_FILE_CACHE is used. If i_fscache_gen is not equal to i_rdcache_gen, client needs to check cache's consistency. Signed-off-by: Yan, Zheng <zyan@redhat.com>
Diffstat (limited to 'fs/ceph/caps.c')
-rw-r--r--fs/ceph/caps.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 7bdf7d59a36d..6f60d0a3d0f9 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -2393,6 +2393,9 @@ again:
2393 snap_rwsem_locked = true; 2393 snap_rwsem_locked = true;
2394 } 2394 }
2395 *got = need | (have & want); 2395 *got = need | (have & want);
2396 if ((need & CEPH_CAP_FILE_RD) &&
2397 !(*got & CEPH_CAP_FILE_CACHE))
2398 ceph_disable_fscache_readpage(ci);
2396 __take_cap_refs(ci, *got, true); 2399 __take_cap_refs(ci, *got, true);
2397 ret = 1; 2400 ret = 1;
2398 } 2401 }
@@ -2554,6 +2557,9 @@ int ceph_get_caps(struct ceph_inode_info *ci, int need, int want,
2554 break; 2557 break;
2555 } 2558 }
2556 2559
2560 if ((_got & CEPH_CAP_FILE_RD) && (_got & CEPH_CAP_FILE_CACHE))
2561 ceph_fscache_revalidate_cookie(ci);
2562
2557 *got = _got; 2563 *got = _got;
2558 return 0; 2564 return 0;
2559} 2565}
@@ -2795,7 +2801,6 @@ static void handle_cap_grant(struct ceph_mds_client *mdsc,
2795 bool writeback = false; 2801 bool writeback = false;
2796 bool queue_trunc = false; 2802 bool queue_trunc = false;
2797 bool queue_invalidate = false; 2803 bool queue_invalidate = false;
2798 bool queue_revalidate = false;
2799 bool deleted_inode = false; 2804 bool deleted_inode = false;
2800 bool fill_inline = false; 2805 bool fill_inline = false;
2801 2806
@@ -2837,8 +2842,6 @@ static void handle_cap_grant(struct ceph_mds_client *mdsc,
2837 ci->i_rdcache_revoking = ci->i_rdcache_gen; 2842 ci->i_rdcache_revoking = ci->i_rdcache_gen;
2838 } 2843 }
2839 } 2844 }
2840
2841 ceph_fscache_invalidate(inode);
2842 } 2845 }
2843 2846
2844 /* side effects now are allowed */ 2847 /* side effects now are allowed */
@@ -2880,11 +2883,6 @@ static void handle_cap_grant(struct ceph_mds_client *mdsc,
2880 } 2883 }
2881 } 2884 }
2882 2885
2883 /* Do we need to revalidate our fscache cookie. Don't bother on the
2884 * first cache cap as we already validate at cookie creation time. */
2885 if ((issued & CEPH_CAP_FILE_CACHE) && ci->i_rdcache_gen > 1)
2886 queue_revalidate = true;
2887
2888 if (newcaps & CEPH_CAP_ANY_RD) { 2886 if (newcaps & CEPH_CAP_ANY_RD) {
2889 /* ctime/mtime/atime? */ 2887 /* ctime/mtime/atime? */
2890 ceph_decode_timespec(&mtime, &grant->mtime); 2888 ceph_decode_timespec(&mtime, &grant->mtime);
@@ -2995,8 +2993,6 @@ static void handle_cap_grant(struct ceph_mds_client *mdsc,
2995 2993
2996 if (queue_trunc) 2994 if (queue_trunc)
2997 ceph_queue_vmtruncate(inode); 2995 ceph_queue_vmtruncate(inode);
2998 else if (queue_revalidate)
2999 ceph_queue_revalidate(inode);
3000 2996
3001 if (writeback) 2997 if (writeback)
3002 /* 2998 /*