]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
kclient: use shared_gen, not cache_gen, for I_COMPLETE tracking
authorSage Weil <sage@newdream.net>
Thu, 17 Sep 2009 21:15:39 +0000 (14:15 -0700)
committerSage Weil <sage@newdream.net>
Thu, 17 Sep 2009 21:15:39 +0000 (14:15 -0700)
src/kernel/caps.c
src/kernel/dir.c
src/kernel/inode.c
src/kernel/super.h

index 1d3ce57bdf3c891d44277db64c0688a7497cf1f6..c6d9ab72fded31356fb149e5df7e6aef31c90e5a 100644 (file)
@@ -457,6 +457,37 @@ static void __cap_delay_cancel(struct ceph_mds_client *mdsc,
        spin_unlock(&mdsc->cap_delay_lock);
 }
 
+/*
+ * Common issue checks for add_cap, handle_cap_grant.
+ */
+static void __check_cap_issue(struct ceph_inode_info *ci, struct ceph_cap *cap,
+                             unsigned issued)
+{
+       unsigned had = __ceph_caps_issued(ci, NULL);
+
+       /*
+        * Each time we receive FILE_CACHE anew, we increment
+        * i_rdcache_gen.
+        */
+       if ((issued & CEPH_CAP_FILE_CACHE) &&
+           (had & CEPH_CAP_FILE_CACHE) == 0)
+               ci->i_rdcache_gen++;
+
+       /*
+        * if we are newly issued FILE_SHARED, clear I_COMPLETE; we
+        * don't know what happened to this directory while we didn't
+        * have the cap.
+        */
+       if ((issued & CEPH_CAP_FILE_SHARED) &&
+           (had & CEPH_CAP_FILE_SHARED) == 0) {
+               ci->i_shared_gen++;
+               if (S_ISDIR(ci->vfs_inode.i_mode)) {
+                       dout(" marking %p NOT complete\n", &ci->vfs_inode);
+                       ci->i_ceph_flags &= ~CEPH_I_COMPLETE;
+               }
+       }
+}
+
 /*
  * Add a capability under the given MDS session.
  *
@@ -547,17 +578,7 @@ retry:
                }
        }
 
-       /*
-        * if we are newly issued FILE_SHARED, clear I_COMPLETE; we
-        * don't know what happened to this directory while we didn't
-        * have the cap.
-        */
-       if (S_ISDIR(inode->i_mode) &&
-           (issued & CEPH_CAP_FILE_SHARED) &&
-           (cap->issued & CEPH_CAP_FILE_SHARED) == 0) {
-               dout(" marking %p NOT complete\n", inode);
-               ci->i_ceph_flags &= ~CEPH_I_COMPLETE;
-       }
+       __check_cap_issue(ci, cap, issued);
 
        /*
         * If we are issued caps we don't want, or the mds' wanted
@@ -2112,20 +2133,7 @@ start:
 
        cap->gen = session->s_cap_gen;
 
-       /*
-        * Each time we receive CACHE anew, we increment i_rdcache_gen.
-        * Also clear I_COMPLETE: we don't know what happened to this directory
-        */
-       if ((newcaps & CEPH_CAP_FILE_CACHE) &&          /* got RDCACHE */
-           (cap->issued & CEPH_CAP_FILE_CACHE) == 0 && /* but not before */
-           (__ceph_caps_issued(ci, NULL) & CEPH_CAP_FILE_CACHE) == 0) {
-               ci->i_rdcache_gen++;
-
-               if (S_ISDIR(inode->i_mode)) {
-                       dout(" marking %p NOT complete\n", inode);
-                       ci->i_ceph_flags &= ~CEPH_I_COMPLETE;
-               }
-       }
+       __check_cap_issue(ci, cap, newcaps);
 
        /*
         * If CACHE is being revoked, and we have no dirty buffers,
index a77a81146767f64e6ee809216025aab8b05d5707..294bbb4de25c376f748f89f2a059327ee7e31ac4 100644 (file)
@@ -521,7 +521,7 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
                        spin_unlock(&dir->i_lock);
                        dout(" dir %p complete, -ENOENT\n", dir);
                        d_add(dentry, NULL);
-                       di->lease_rdcache_gen = ci->i_rdcache_gen;
+                       di->lease_shared_gen = ci->i_shared_gen;
                        return NULL;
                }
                spin_unlock(&dir->i_lock);
@@ -898,12 +898,12 @@ static int dir_lease_is_valid(struct inode *dir, struct dentry *dentry)
        int valid = 0;
 
        spin_lock(&dir->i_lock);
-       if (ci->i_rdcache_gen == di->lease_rdcache_gen)
+       if (ci->i_shared_gen == di->lease_shared_gen)
                valid = __ceph_caps_issued_mask(ci, CEPH_CAP_FILE_SHARED, 1);
        spin_unlock(&dir->i_lock);
        dout("dir_lease_is_valid dir %p v%u dentry %p v%u = %d\n",
-            dir, (unsigned)ci->i_rdcache_gen, dentry,
-            (unsigned)di->lease_rdcache_gen, valid);
+            dir, (unsigned)ci->i_shared_gen, dentry,
+            (unsigned)di->lease_shared_gen, valid);
        return valid;
 }
 
@@ -951,7 +951,7 @@ static void ceph_dentry_release(struct dentry *dentry)
                struct ceph_inode_info *ci = ceph_inode(parent_inode);
 
                spin_lock(&parent_inode->i_lock);
-               if (ci->i_rdcache_gen == di->lease_rdcache_gen) {
+               if (ci->i_shared_gen == di->lease_shared_gen) {
                        dout(" clearing %p complete (d_release)\n",
                             parent_inode);
                        ci->i_ceph_flags &= ~CEPH_I_COMPLETE;
index f425c181d130fa07f0138c6b6f47fd17505b67d4..be88250536dc164b1d040692afd9a834ebacc6a6 100644 (file)
@@ -322,6 +322,7 @@ struct inode *ceph_alloc_inode(struct super_block *sb)
        ci->i_wr_ref = 0;
        ci->i_wrbuffer_ref = 0;
        ci->i_wrbuffer_ref_head = 0;
+       ci->i_shared_gen = 0;
        ci->i_rdcache_gen = 0;
        ci->i_rdcache_revoking = 0;
 
@@ -546,6 +547,8 @@ static int fill_inode(struct inode *inode,
        queue_trunc = ceph_fill_file_size(inode, issued,
                                          le32_to_cpu(info->truncate_seq),
                                          le64_to_cpu(info->truncate_size),
+                                         S_ISDIR(inode->i_mode) ?
+                                         ci->i_rbytes :
                                          le64_to_cpu(info->size));
        ceph_fill_file_time(inode, issued,
                            le32_to_cpu(info->time_warp_seq),
@@ -739,7 +742,7 @@ static void update_dentry_lease(struct dentry *dentry,
 
        /* make lease_rdcache_gen match directory */
        dir = dentry->d_parent->d_inode;
-       di->lease_rdcache_gen = ceph_inode(dir)->i_rdcache_gen;
+       di->lease_shared_gen = ceph_inode(dir)->i_shared_gen;
 
        if (lease->mask == 0)
                goto out_unlock;
index 57cf1bfe8443f716b22b86853ece5c2070724096..6265f097a15082054dfa37237e6180c0083f4283 100644 (file)
@@ -337,9 +337,10 @@ struct ceph_inode_info {
        int i_pin_ref;
        int i_rd_ref, i_rdcache_ref, i_wr_ref;
        int i_wrbuffer_ref, i_wrbuffer_ref_head;
-       u32 i_rdcache_gen;      /* we increment this each time we get RDCACHE.
-                                  If it's non-zero, we _may_ have cached
-                                  pages. */
+       u32 i_shared_gen;       /* increment each time we get FILE_SHARED */
+       u32 i_rdcache_gen;      /* we increment this each time we get
+                                  FILE_CACHE.  If it's non-zero, we
+                                  _may_ have cached pages. */
        u32 i_rdcache_revoking; /* RDCACHE gen to async invalidate, if any */
 
        struct list_head i_unsafe_writes; /* uncommitted sync writes */
@@ -427,7 +428,7 @@ extern u32 ceph_choose_frag(struct ceph_inode_info *ci, u32 v,
  */
 struct ceph_dentry_info {
        struct ceph_mds_session *lease_session;
-       u32 lease_gen, lease_rdcache_gen;
+       u32 lease_gen, lease_shared_gen;
        u32 lease_seq;
        unsigned long lease_renew_after, lease_renew_from;
        struct list_head lru;