From: Sage Weil Date: Thu, 17 Sep 2009 21:15:39 +0000 (-0700) Subject: kclient: use shared_gen, not cache_gen, for I_COMPLETE tracking X-Git-Tag: v0.15~51 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ee0f1588b94fb8fd0f6fe51aa85e376a21f284c4;p=ceph.git kclient: use shared_gen, not cache_gen, for I_COMPLETE tracking --- diff --git a/src/kernel/caps.c b/src/kernel/caps.c index 1d3ce57bdf3c8..c6d9ab72fded3 100644 --- a/src/kernel/caps.c +++ b/src/kernel/caps.c @@ -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, diff --git a/src/kernel/dir.c b/src/kernel/dir.c index a77a81146767f..294bbb4de25c3 100644 --- a/src/kernel/dir.c +++ b/src/kernel/dir.c @@ -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; diff --git a/src/kernel/inode.c b/src/kernel/inode.c index f425c181d130f..be88250536dc1 100644 --- a/src/kernel/inode.c +++ b/src/kernel/inode.c @@ -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; diff --git a/src/kernel/super.h b/src/kernel/super.h index 57cf1bfe8443f..6265f097a1508 100644 --- a/src/kernel/super.h +++ b/src/kernel/super.h @@ -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;