summaryrefslogtreecommitdiffstats
path: root/fs/ceph/caps.c
diff options
context:
space:
mode:
authorYan, Zheng <zyan@redhat.com>2019-06-20 04:09:37 -0400
committerIlya Dryomov <idryomov@gmail.com>2019-07-08 08:01:44 -0400
commitd6cee9dbd8c841795cd672b98069866789916648 (patch)
tree9d9f9f5dbcf5f15a885ef6861876760046aa44b0 /fs/ceph/caps.c
parent054f8d41affbaeddca15ac39366a1f2f4b4f4488 (diff)
ceph: kick flushing and flush snaps before sending normal cap message
Otherwise client may send cap flush messages in wrong order. Signed-off-by: "Yan, Zheng" <zyan@redhat.com> Reviewed-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'fs/ceph/caps.c')
-rw-r--r--fs/ceph/caps.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 82a3583a0fd9..f9055cdec3c7 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -2119,6 +2119,7 @@ static int try_flush_caps(struct inode *inode, u64 *ptid)
2119 2119
2120retry: 2120retry:
2121 spin_lock(&ci->i_ceph_lock); 2121 spin_lock(&ci->i_ceph_lock);
2122retry_locked:
2122 if (ci->i_ceph_flags & CEPH_I_NOFLUSH) { 2123 if (ci->i_ceph_flags & CEPH_I_NOFLUSH) {
2123 spin_unlock(&ci->i_ceph_lock); 2124 spin_unlock(&ci->i_ceph_lock);
2124 dout("try_flush_caps skipping %p I_NOFLUSH set\n", inode); 2125 dout("try_flush_caps skipping %p I_NOFLUSH set\n", inode);
@@ -2126,8 +2127,6 @@ retry:
2126 } 2127 }
2127 if (ci->i_dirty_caps && ci->i_auth_cap) { 2128 if (ci->i_dirty_caps && ci->i_auth_cap) {
2128 struct ceph_cap *cap = ci->i_auth_cap; 2129 struct ceph_cap *cap = ci->i_auth_cap;
2129 int used = __ceph_caps_used(ci);
2130 int want = __ceph_caps_wanted(ci);
2131 int delayed; 2130 int delayed;
2132 2131
2133 if (!session || session != cap->session) { 2132 if (!session || session != cap->session) {
@@ -2143,13 +2142,24 @@ retry:
2143 goto out; 2142 goto out;
2144 } 2143 }
2145 2144
2145 if (ci->i_ceph_flags &
2146 (CEPH_I_KICK_FLUSH | CEPH_I_FLUSH_SNAPS)) {
2147 if (ci->i_ceph_flags & CEPH_I_KICK_FLUSH)
2148 __kick_flushing_caps(mdsc, session, ci, 0);
2149 if (ci->i_ceph_flags & CEPH_I_FLUSH_SNAPS)
2150 __ceph_flush_snaps(ci, session);
2151 goto retry_locked;
2152 }
2153
2146 flushing = __mark_caps_flushing(inode, session, true, 2154 flushing = __mark_caps_flushing(inode, session, true,
2147 &flush_tid, &oldest_flush_tid); 2155 &flush_tid, &oldest_flush_tid);
2148 2156
2149 /* __send_cap drops i_ceph_lock */ 2157 /* __send_cap drops i_ceph_lock */
2150 delayed = __send_cap(mdsc, cap, CEPH_CAP_OP_FLUSH, true, 2158 delayed = __send_cap(mdsc, cap, CEPH_CAP_OP_FLUSH, true,
2151 used, want, (cap->issued | cap->implemented), 2159 __ceph_caps_used(ci),
2152 flushing, flush_tid, oldest_flush_tid); 2160 __ceph_caps_wanted(ci),
2161 (cap->issued | cap->implemented),
2162 flushing, flush_tid, oldest_flush_tid);
2153 2163
2154 if (delayed) { 2164 if (delayed) {
2155 spin_lock(&ci->i_ceph_lock); 2165 spin_lock(&ci->i_ceph_lock);