diff options
author | Yan, Zheng <zheng.z.yan@intel.com> | 2013-11-29 23:47:41 -0500 |
---|---|---|
committer | Yan, Zheng <zheng.z.yan@intel.com> | 2014-01-21 00:29:33 -0500 |
commit | 9215aeea622fec7ca8123c6bd6f03a1753e2b0b3 (patch) | |
tree | 00c4aaae67c7891553f8331b6e0b6e54bf95d08f /fs | |
parent | ca18bede048e95a749d13410ce1da4ad0ffa7938 (diff) |
ceph: check inode caps in ceph_d_revalidate
Some inodes in readdir reply may have no caps. Getattr mds request
for these inodes can return -ESTALE. The fix is consider dentry that
links to inode with no caps as invalid. Invalid dentry causes a
lookup request to send to the mds, the MDS will send caps back.
Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ceph/caps.c | 12 | ||||
-rw-r--r-- | fs/ceph/dir.c | 11 | ||||
-rw-r--r-- | fs/ceph/super.h | 1 |
3 files changed, 21 insertions, 3 deletions
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index d2154d63f671..d65ff334901c 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c | |||
@@ -891,6 +891,18 @@ static int __ceph_is_any_caps(struct ceph_inode_info *ci) | |||
891 | return !RB_EMPTY_ROOT(&ci->i_caps) || ci->i_cap_exporting_mds >= 0; | 891 | return !RB_EMPTY_ROOT(&ci->i_caps) || ci->i_cap_exporting_mds >= 0; |
892 | } | 892 | } |
893 | 893 | ||
894 | int ceph_is_any_caps(struct inode *inode) | ||
895 | { | ||
896 | struct ceph_inode_info *ci = ceph_inode(inode); | ||
897 | int ret; | ||
898 | |||
899 | spin_lock(&ci->i_ceph_lock); | ||
900 | ret = __ceph_is_any_caps(ci); | ||
901 | spin_unlock(&ci->i_ceph_lock); | ||
902 | |||
903 | return ret; | ||
904 | } | ||
905 | |||
894 | /* | 906 | /* |
895 | * Remove a cap. Take steps to deal with a racing iterate_session_caps. | 907 | * Remove a cap. Take steps to deal with a racing iterate_session_caps. |
896 | * | 908 | * |
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index b629e9d59a35..619616d585b0 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c | |||
@@ -1041,14 +1041,19 @@ static int ceph_d_revalidate(struct dentry *dentry, unsigned int flags) | |||
1041 | valid = 1; | 1041 | valid = 1; |
1042 | } else if (dentry_lease_is_valid(dentry) || | 1042 | } else if (dentry_lease_is_valid(dentry) || |
1043 | dir_lease_is_valid(dir, dentry)) { | 1043 | dir_lease_is_valid(dir, dentry)) { |
1044 | valid = 1; | 1044 | if (dentry->d_inode) |
1045 | valid = ceph_is_any_caps(dentry->d_inode); | ||
1046 | else | ||
1047 | valid = 1; | ||
1045 | } | 1048 | } |
1046 | 1049 | ||
1047 | dout("d_revalidate %p %s\n", dentry, valid ? "valid" : "invalid"); | 1050 | dout("d_revalidate %p %s\n", dentry, valid ? "valid" : "invalid"); |
1048 | if (valid) | 1051 | if (valid) { |
1049 | ceph_dentry_lru_touch(dentry); | 1052 | ceph_dentry_lru_touch(dentry); |
1050 | else | 1053 | } else { |
1054 | ceph_dir_clear_complete(dir); | ||
1051 | d_drop(dentry); | 1055 | d_drop(dentry); |
1056 | } | ||
1052 | iput(dir); | 1057 | iput(dir); |
1053 | return valid; | 1058 | return valid; |
1054 | } | 1059 | } |
diff --git a/fs/ceph/super.h b/fs/ceph/super.h index 891cda8c72aa..a6ba32fb0d49 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h | |||
@@ -782,6 +782,7 @@ extern int ceph_add_cap(struct inode *inode, | |||
782 | extern void __ceph_remove_cap(struct ceph_cap *cap, bool queue_release); | 782 | extern void __ceph_remove_cap(struct ceph_cap *cap, bool queue_release); |
783 | extern void ceph_put_cap(struct ceph_mds_client *mdsc, | 783 | extern void ceph_put_cap(struct ceph_mds_client *mdsc, |
784 | struct ceph_cap *cap); | 784 | struct ceph_cap *cap); |
785 | extern int ceph_is_any_caps(struct inode *inode); | ||
785 | 786 | ||
786 | extern void __queue_cap_release(struct ceph_mds_session *session, u64 ino, | 787 | extern void __queue_cap_release(struct ceph_mds_session *session, u64 ino, |
787 | u64 cap_id, u32 migrate_seq, u32 issue_seq); | 788 | u64 cap_id, u32 migrate_seq, u32 issue_seq); |