summaryrefslogtreecommitdiffstats
path: root/fs/ceph/caps.c
diff options
context:
space:
mode:
authorMilosz Tanski <milosz@adfin.com>2013-08-21 17:29:54 -0400
committerMilosz Tanski <milosz@adfin.com>2013-09-06 12:50:11 -0400
commit99ccbd229cf7453206bc858e795ec1f0345ff258 (patch)
tree343ab082d154d7c970d90bf44c9887fdb0251cdb /fs/ceph/caps.c
parentcd0a2df681ec2af45f50c555c2a39dc92a4dff71 (diff)
ceph: use fscache as a local presisent cache
Adding support for fscache to the Ceph filesystem. This would bring it to on par with some of the other network filesystems in Linux (like NFS, AFS, etc...) In order to mount the filesystem with fscache the 'fsc' mount option must be passed. Signed-off-by: Milosz Tanski <milosz@adfin.com> Signed-off-by: Sage Weil <sage@inktank.com>
Diffstat (limited to 'fs/ceph/caps.c')
-rw-r--r--fs/ceph/caps.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 5a26bc1dd799..7b451eb7d123 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -10,6 +10,7 @@
10 10
11#include "super.h" 11#include "super.h"
12#include "mds_client.h" 12#include "mds_client.h"
13#include "cache.h"
13#include <linux/ceph/decode.h> 14#include <linux/ceph/decode.h>
14#include <linux/ceph/messenger.h> 15#include <linux/ceph/messenger.h>
15 16
@@ -479,8 +480,9 @@ static void __check_cap_issue(struct ceph_inode_info *ci, struct ceph_cap *cap,
479 * i_rdcache_gen. 480 * i_rdcache_gen.
480 */ 481 */
481 if ((issued & (CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO)) && 482 if ((issued & (CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO)) &&
482 (had & (CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO)) == 0) 483 (had & (CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO)) == 0) {
483 ci->i_rdcache_gen++; 484 ci->i_rdcache_gen++;
485 }
484 486
485 /* 487 /*
486 * if we are newly issued FILE_SHARED, mark dir not complete; we 488 * if we are newly issued FILE_SHARED, mark dir not complete; we
@@ -2395,6 +2397,7 @@ static void handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant,
2395 int writeback = 0; 2397 int writeback = 0;
2396 int queue_invalidate = 0; 2398 int queue_invalidate = 0;
2397 int deleted_inode = 0; 2399 int deleted_inode = 0;
2400 int queue_revalidate = 0;
2398 2401
2399 dout("handle_cap_grant inode %p cap %p mds%d seq %d %s\n", 2402 dout("handle_cap_grant inode %p cap %p mds%d seq %d %s\n",
2400 inode, cap, mds, seq, ceph_cap_string(newcaps)); 2403 inode, cap, mds, seq, ceph_cap_string(newcaps));
@@ -2417,6 +2420,8 @@ static void handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant,
2417 ci->i_rdcache_revoking = ci->i_rdcache_gen; 2420 ci->i_rdcache_revoking = ci->i_rdcache_gen;
2418 } 2421 }
2419 } 2422 }
2423
2424 ceph_fscache_invalidate(inode);
2420 } 2425 }
2421 2426
2422 /* side effects now are allowed */ 2427 /* side effects now are allowed */
@@ -2458,6 +2463,11 @@ static void handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant,
2458 } 2463 }
2459 } 2464 }
2460 2465
2466 /* Do we need to revalidate our fscache cookie. Don't bother on the
2467 * first cache cap as we already validate at cookie creation time. */
2468 if ((issued & CEPH_CAP_FILE_CACHE) && ci->i_rdcache_gen > 1)
2469 queue_revalidate = 1;
2470
2461 /* size/ctime/mtime/atime? */ 2471 /* size/ctime/mtime/atime? */
2462 ceph_fill_file_size(inode, issued, 2472 ceph_fill_file_size(inode, issued,
2463 le32_to_cpu(grant->truncate_seq), 2473 le32_to_cpu(grant->truncate_seq),
@@ -2542,6 +2552,7 @@ static void handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant,
2542 BUG_ON(cap->issued & ~cap->implemented); 2552 BUG_ON(cap->issued & ~cap->implemented);
2543 2553
2544 spin_unlock(&ci->i_ceph_lock); 2554 spin_unlock(&ci->i_ceph_lock);
2555
2545 if (writeback) 2556 if (writeback)
2546 /* 2557 /*
2547 * queue inode for writeback: we can't actually call 2558 * queue inode for writeback: we can't actually call
@@ -2553,6 +2564,8 @@ static void handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant,
2553 ceph_queue_invalidate(inode); 2564 ceph_queue_invalidate(inode);
2554 if (deleted_inode) 2565 if (deleted_inode)
2555 invalidate_aliases(inode); 2566 invalidate_aliases(inode);
2567 if (queue_revalidate)
2568 ceph_queue_revalidate(inode);
2556 if (wake) 2569 if (wake)
2557 wake_up_all(&ci->i_cap_wq); 2570 wake_up_all(&ci->i_cap_wq);
2558 2571
@@ -2709,8 +2722,10 @@ static void handle_cap_trunc(struct inode *inode,
2709 truncate_seq, truncate_size, size); 2722 truncate_seq, truncate_size, size);
2710 spin_unlock(&ci->i_ceph_lock); 2723 spin_unlock(&ci->i_ceph_lock);
2711 2724
2712 if (queue_trunc) 2725 if (queue_trunc) {
2713 ceph_queue_vmtruncate(inode); 2726 ceph_queue_vmtruncate(inode);
2727 ceph_fscache_invalidate(inode);
2728 }
2714} 2729}
2715 2730
2716/* 2731/*