summaryrefslogtreecommitdiffstats
path: root/fs/ceph/caps.c
diff options
context:
space:
mode:
authorYan, Zheng <zyan@redhat.com>2018-12-10 03:35:09 -0500
committerIlya Dryomov <idryomov@gmail.com>2018-12-26 10:08:36 -0500
commitd2f8bb27c87945ab696bdaea25b0465dee94fb6d (patch)
tree30fb1b0d4e6d29fb939ad52b68ad1294d63ca537 /fs/ceph/caps.c
parentfdac94fab7995ebc52ff9c5b6247133c67a7564a (diff)
ceph: update wanted caps after resuming stale session
mds contains an optimization, it does not re-issue stale caps if client does not want any cap. A special case of the optimization is that client wants some caps, but skipped updating 'wanted'. For this case, client needs to update 'wanted' when stale session get renewed. Signed-off-by: "Yan, Zheng" <zyan@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'fs/ceph/caps.c')
-rw-r--r--fs/ceph/caps.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 92643b828c50..94c026bba2c2 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -657,6 +657,9 @@ void ceph_add_cap(struct inode *inode,
657 session->s_nr_caps++; 657 session->s_nr_caps++;
658 spin_unlock(&session->s_cap_lock); 658 spin_unlock(&session->s_cap_lock);
659 } else { 659 } else {
660 if (cap->cap_gen < session->s_cap_gen)
661 cap->issued = cap->implemented = CEPH_CAP_PIN;
662
660 /* 663 /*
661 * auth mds of the inode changed. we received the cap export 664 * auth mds of the inode changed. we received the cap export
662 * message, but still haven't received the cap import message. 665 * message, but still haven't received the cap import message.
@@ -3066,21 +3069,6 @@ static void handle_cap_grant(struct inode *inode,
3066 3069
3067 3070
3068 /* 3071 /*
3069 * auth mds of the inode changed. we received the cap export message,
3070 * but still haven't received the cap import message. handle_cap_export
3071 * updated the new auth MDS' cap.
3072 *
3073 * "ceph_seq_cmp(seq, cap->seq) <= 0" means we are processing a message
3074 * that was sent before the cap import message. So don't remove caps.
3075 */
3076 if (ceph_seq_cmp(seq, cap->seq) <= 0) {
3077 WARN_ON(cap != ci->i_auth_cap);
3078 WARN_ON(cap->cap_id != le64_to_cpu(grant->cap_id));
3079 seq = cap->seq;
3080 newcaps |= cap->issued;
3081 }
3082
3083 /*
3084 * If CACHE is being revoked, and we have no dirty buffers, 3072 * If CACHE is being revoked, and we have no dirty buffers,
3085 * try to invalidate (once). (If there are dirty buffers, we 3073 * try to invalidate (once). (If there are dirty buffers, we
3086 * will invalidate _after_ writeback.) 3074 * will invalidate _after_ writeback.)
@@ -3099,6 +3087,24 @@ static void handle_cap_grant(struct inode *inode,
3099 } 3087 }
3100 } 3088 }
3101 3089
3090 if (was_stale)
3091 cap->issued = cap->implemented = CEPH_CAP_PIN;
3092
3093 /*
3094 * auth mds of the inode changed. we received the cap export message,
3095 * but still haven't received the cap import message. handle_cap_export
3096 * updated the new auth MDS' cap.
3097 *
3098 * "ceph_seq_cmp(seq, cap->seq) <= 0" means we are processing a message
3099 * that was sent before the cap import message. So don't remove caps.
3100 */
3101 if (ceph_seq_cmp(seq, cap->seq) <= 0) {
3102 WARN_ON(cap != ci->i_auth_cap);
3103 WARN_ON(cap->cap_id != le64_to_cpu(grant->cap_id));
3104 seq = cap->seq;
3105 newcaps |= cap->issued;
3106 }
3107
3102 /* side effects now are allowed */ 3108 /* side effects now are allowed */
3103 cap->cap_gen = session->s_cap_gen; 3109 cap->cap_gen = session->s_cap_gen;
3104 cap->seq = seq; 3110 cap->seq = seq;
@@ -3549,9 +3555,9 @@ retry:
3549 goto out_unlock; 3555 goto out_unlock;
3550 3556
3551 if (target < 0) { 3557 if (target < 0) {
3552 __ceph_remove_cap(cap, false); 3558 if (cap->mds_wanted | cap->issued)
3553 if (!ci->i_auth_cap)
3554 ci->i_ceph_flags |= CEPH_I_CAP_DROPPED; 3559 ci->i_ceph_flags |= CEPH_I_CAP_DROPPED;
3560 __ceph_remove_cap(cap, false);
3555 goto out_unlock; 3561 goto out_unlock;
3556 } 3562 }
3557 3563