aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ceph/caps.c
diff options
context:
space:
mode:
authorSage Weil <sage@newdream.net>2010-05-27 13:40:43 -0400
committerSage Weil <sage@newdream.net>2010-08-01 23:11:39 -0400
commit2962507ca204f886967e1a089d9bec206d427c22 (patch)
treee9cec16b13ad1d8e41c288658e62fb3bf1c66859 /fs/ceph/caps.c
parent33caad324b88f75f42d836735d86feaafb3b40cf (diff)
ceph: perform lazy reads when file mode and caps permit
If the file mode is marked as "lazy," perform cached/buffered reads when the caps permit it. Adjust the rdcache_gen and invalidation logic accordingly so that we manage our cache based on the FILE_CACHE -or- FILE_LAZYIO cap bits. Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph/caps.c')
-rw-r--r--fs/ceph/caps.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 1a70a3ebf013..b28915d5f404 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -482,8 +482,8 @@ static void __check_cap_issue(struct ceph_inode_info *ci, struct ceph_cap *cap,
482 * Each time we receive FILE_CACHE anew, we increment 482 * Each time we receive FILE_CACHE anew, we increment
483 * i_rdcache_gen. 483 * i_rdcache_gen.
484 */ 484 */
485 if ((issued & CEPH_CAP_FILE_CACHE) && 485 if ((issued & (CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO)) &&
486 (had & CEPH_CAP_FILE_CACHE) == 0) 486 (had & (CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO)) == 0)
487 ci->i_rdcache_gen++; 487 ci->i_rdcache_gen++;
488 488
489 /* 489 /*
@@ -1509,11 +1509,13 @@ retry_locked:
1509 ci->i_wrbuffer_ref == 0 && /* no dirty pages... */ 1509 ci->i_wrbuffer_ref == 0 && /* no dirty pages... */
1510 ci->i_rdcache_gen && /* may have cached pages */ 1510 ci->i_rdcache_gen && /* may have cached pages */
1511 (file_wanted == 0 || /* no open files */ 1511 (file_wanted == 0 || /* no open files */
1512 (revoking & CEPH_CAP_FILE_CACHE)) && /* or revoking cache */ 1512 (revoking & (CEPH_CAP_FILE_CACHE|
1513 CEPH_CAP_FILE_LAZYIO))) && /* or revoking cache */
1513 !tried_invalidate) { 1514 !tried_invalidate) {
1514 dout("check_caps trying to invalidate on %p\n", inode); 1515 dout("check_caps trying to invalidate on %p\n", inode);
1515 if (try_nonblocking_invalidate(inode) < 0) { 1516 if (try_nonblocking_invalidate(inode) < 0) {
1516 if (revoking & CEPH_CAP_FILE_CACHE) { 1517 if (revoking & (CEPH_CAP_FILE_CACHE|
1518 CEPH_CAP_FILE_LAZYIO)) {
1517 dout("check_caps queuing invalidate\n"); 1519 dout("check_caps queuing invalidate\n");
1518 queue_invalidate = 1; 1520 queue_invalidate = 1;
1519 ci->i_rdcache_revoking = ci->i_rdcache_gen; 1521 ci->i_rdcache_revoking = ci->i_rdcache_gen;
@@ -2276,7 +2278,8 @@ static void handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant,
2276 * try to invalidate (once). (If there are dirty buffers, we 2278 * try to invalidate (once). (If there are dirty buffers, we
2277 * will invalidate _after_ writeback.) 2279 * will invalidate _after_ writeback.)
2278 */ 2280 */
2279 if (((cap->issued & ~newcaps) & CEPH_CAP_FILE_CACHE) && 2281 if (((cap->issued & ~newcaps) & (CEPH_CAP_FILE_CACHE|
2282 CEPH_CAP_FILE_LAZYIO)) &&
2280 !ci->i_wrbuffer_ref) { 2283 !ci->i_wrbuffer_ref) {
2281 if (try_nonblocking_invalidate(inode) == 0) { 2284 if (try_nonblocking_invalidate(inode) == 0) {
2282 revoked_rdcache = 1; 2285 revoked_rdcache = 1;
@@ -2374,7 +2377,8 @@ static void handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant,
2374 writeback = 1; /* will delay ack */ 2377 writeback = 1; /* will delay ack */
2375 else if (dirty & ~newcaps) 2378 else if (dirty & ~newcaps)
2376 check_caps = 1; /* initiate writeback in check_caps */ 2379 check_caps = 1; /* initiate writeback in check_caps */
2377 else if (((used & ~newcaps) & CEPH_CAP_FILE_CACHE) == 0 || 2380 else if (((used & ~newcaps) & (CEPH_CAP_FILE_CACHE|
2381 CEPH_CAP_FILE_LAZYIO)) == 0 ||
2378 revoked_rdcache) 2382 revoked_rdcache)
2379 check_caps = 2; /* send revoke ack in check_caps */ 2383 check_caps = 2; /* send revoke ack in check_caps */
2380 cap->issued = newcaps; 2384 cap->issued = newcaps;