Lines Matching full:cap

31  * If the client holds a *_SHARED cap, the client has a coherent value
55 * Generate readable cap strings for debugging output.
138 struct ceph_cap *cap; in ceph_caps_finalize() local
142 cap = list_first_entry(&mdsc->caps_list, in ceph_caps_finalize()
144 list_del(&cap->caps_item); in ceph_caps_finalize()
145 kmem_cache_free(ceph_cap_cachep, cap); in ceph_caps_finalize()
171 struct ceph_cap *cap; in __ceph_unreserve_caps() local
181 cap = list_first_entry(&mdsc->caps_list, in __ceph_unreserve_caps()
183 list_del(&cap->caps_item); in __ceph_unreserve_caps()
184 kmem_cache_free(ceph_cap_cachep, cap); in __ceph_unreserve_caps()
208 struct ceph_cap *cap; in ceph_reserve_caps() local
233 cap = kmem_cache_alloc(ceph_cap_cachep, GFP_NOFS); in ceph_reserve_caps()
234 if (cap) { in ceph_reserve_caps()
235 list_add(&cap->caps_item, &newcaps); in ceph_reserve_caps()
335 struct ceph_cap *cap = NULL; in ceph_get_cap() local
337 /* temporary, until we do something about cap import/export */ in ceph_get_cap()
339 cap = kmem_cache_alloc(ceph_cap_cachep, GFP_NOFS); in ceph_get_cap()
340 if (cap) { in ceph_get_cap()
352 cap = list_first_entry(&mdsc->caps_list, in ceph_get_cap()
354 list_del(&cap->caps_item); in ceph_get_cap()
362 return cap; in ceph_get_cap()
378 cap = list_first_entry(&mdsc->caps_list, struct ceph_cap, caps_item); in ceph_get_cap()
379 list_del(&cap->caps_item); in ceph_get_cap()
384 return cap; in ceph_get_cap()
387 void ceph_put_cap(struct ceph_mds_client *mdsc, struct ceph_cap *cap) in ceph_put_cap() argument
392 doutc(cl, "%p %d = %d used + %d resv + %d avail\n", cap, in ceph_put_cap()
403 kmem_cache_free(ceph_cap_cachep, cap); in ceph_put_cap()
406 list_add(&cap->caps_item, &mdsc->caps_list); in ceph_put_cap()
443 struct ceph_cap *cap; in __get_cap_for_mds() local
447 cap = rb_entry(n, struct ceph_cap, ci_node); in __get_cap_for_mds()
448 if (mds < cap->mds) in __get_cap_for_mds()
450 else if (mds > cap->mds) in __get_cap_for_mds()
453 return cap; in __get_cap_for_mds()
460 struct ceph_cap *cap; in ceph_get_cap_for_mds() local
463 cap = __get_cap_for_mds(ci, mds); in ceph_get_cap_for_mds()
465 return cap; in ceph_get_cap_for_mds()
476 struct ceph_cap *cap = NULL; in __insert_cap_node() local
480 cap = rb_entry(parent, struct ceph_cap, ci_node); in __insert_cap_node()
481 if (new->mds < cap->mds) in __insert_cap_node()
483 else if (new->mds > cap->mds) in __insert_cap_node()
494 * (re)set cap hold timeouts, which control the delayed release
495 * of unused caps back to the MDS. Should be called on cap use.
510 * (Re)queue cap at the end of the delayed cap release list.
541 * indicating we should send a cap message to flush dirty metadata
542 * asap, and move to the front of the delayed cap list.
559 * Cancel delayed work on cap.
577 static void __check_cap_issue(struct ceph_inode_info *ci, struct ceph_cap *cap, in __check_cap_issue() argument
599 * know what happened to this directory while we didn't have the cap. in __check_cap_issue()
647 * it is < 0. (This is so we can atomically add the cap and add an
659 struct ceph_cap *cap; in ceph_add_cap() local
666 doutc(cl, "%p %llx.%llx mds%d cap %llx %s seq %d\n", inode, in ceph_add_cap()
672 cap = __get_cap_for_mds(ci, mds); in ceph_add_cap()
673 if (!cap) { in ceph_add_cap()
674 cap = *new_cap; in ceph_add_cap()
677 cap->issued = 0; in ceph_add_cap()
678 cap->implemented = 0; in ceph_add_cap()
679 cap->mds = mds; in ceph_add_cap()
680 cap->mds_wanted = 0; in ceph_add_cap()
681 cap->mseq = 0; in ceph_add_cap()
683 cap->ci = ci; in ceph_add_cap()
684 __insert_cap_node(ci, cap); in ceph_add_cap()
686 /* add to session cap list */ in ceph_add_cap()
687 cap->session = session; in ceph_add_cap()
689 list_add_tail(&cap->session_caps, &session->s_caps); in ceph_add_cap()
695 list_move_tail(&cap->session_caps, &session->s_caps); in ceph_add_cap()
698 if (cap->cap_gen < gen) in ceph_add_cap()
699 cap->issued = cap->implemented = CEPH_CAP_PIN; in ceph_add_cap()
702 * auth mds of the inode changed. we received the cap export in ceph_add_cap()
703 * message, but still haven't received the cap import message. in ceph_add_cap()
704 * handle_cap_export() updated the new auth MDS' cap. in ceph_add_cap()
706 * "ceph_seq_cmp(seq, cap->seq) <= 0" means we are processing in ceph_add_cap()
707 * a message that was send before the cap import message. So in ceph_add_cap()
710 if (ceph_seq_cmp(seq, cap->seq) <= 0) { in ceph_add_cap()
711 WARN_ON(cap != ci->i_auth_cap); in ceph_add_cap()
712 WARN_ON(cap->cap_id != cap_id); in ceph_add_cap()
713 seq = cap->seq; in ceph_add_cap()
714 mseq = cap->mseq; in ceph_add_cap()
715 issued |= cap->issued; in ceph_add_cap()
736 __check_cap_issue(ci, cap, issued); in ceph_add_cap()
756 ci->i_auth_cap->session != cap->session) in ceph_add_cap()
757 change_auth_cap_ses(ci, cap->session); in ceph_add_cap()
758 ci->i_auth_cap = cap; in ceph_add_cap()
759 cap->mds_wanted = wanted; in ceph_add_cap()
762 WARN_ON(ci->i_auth_cap == cap); in ceph_add_cap()
765 doutc(cl, "inode %p %llx.%llx cap %p %s now %s seq %d mds%d\n", in ceph_add_cap()
766 inode, ceph_vinop(inode), cap, ceph_cap_string(issued), in ceph_add_cap()
767 ceph_cap_string(issued|cap->issued), seq, mds); in ceph_add_cap()
768 cap->cap_id = cap_id; in ceph_add_cap()
769 cap->issued = issued; in ceph_add_cap()
770 cap->implemented |= issued; in ceph_add_cap()
771 if (ceph_seq_cmp(mseq, cap->mseq) > 0) in ceph_add_cap()
772 cap->mds_wanted = wanted; in ceph_add_cap()
774 cap->mds_wanted |= wanted; in ceph_add_cap()
775 cap->seq = seq; in ceph_add_cap()
776 cap->issue_seq = seq; in ceph_add_cap()
777 cap->mseq = mseq; in ceph_add_cap()
778 cap->cap_gen = gen; in ceph_add_cap()
783 * Return true if cap has not timed out and belongs to the current
787 static int __cap_is_valid(struct ceph_cap *cap) in __cap_is_valid() argument
789 struct inode *inode = &cap->ci->netfs.inode; in __cap_is_valid()
790 struct ceph_client *cl = cap->session->s_mdsc->fsc->client; in __cap_is_valid()
794 gen = atomic_read(&cap->session->s_cap_gen); in __cap_is_valid()
795 ttl = cap->session->s_cap_ttl; in __cap_is_valid()
797 if (cap->cap_gen < gen || time_after_eq(jiffies, ttl)) { in __cap_is_valid()
798 doutc(cl, "%p %llx.%llx cap %p issued %s but STALE (gen %u vs %u)\n", in __cap_is_valid()
799 inode, ceph_vinop(inode), cap, in __cap_is_valid()
800 ceph_cap_string(cap->issued), cap->cap_gen, gen); in __cap_is_valid()
808 * Return set of valid cap bits issued to us. Note that caps time
817 struct ceph_cap *cap; in __ceph_caps_issued() local
823 cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_caps_issued()
824 if (!__cap_is_valid(cap)) in __ceph_caps_issued()
826 doutc(cl, "%p %llx.%llx cap %p issued %s\n", inode, in __ceph_caps_issued()
827 ceph_vinop(inode), cap, ceph_cap_string(cap->issued)); in __ceph_caps_issued()
828 have |= cap->issued; in __ceph_caps_issued()
830 *implemented |= cap->implemented; in __ceph_caps_issued()
838 cap = ci->i_auth_cap; in __ceph_caps_issued()
839 have &= ~cap->implemented | cap->issued; in __ceph_caps_issued()
845 * Get cap bits issued by caps other than @ocap
850 struct ceph_cap *cap; in __ceph_caps_issued_other() local
854 cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_caps_issued_other()
855 if (cap == ocap) in __ceph_caps_issued_other()
857 if (!__cap_is_valid(cap)) in __ceph_caps_issued_other()
859 have |= cap->issued; in __ceph_caps_issued_other()
865 * Move a cap to the end of the LRU (oldest caps at list head, newest
868 static void __touch_cap(struct ceph_cap *cap) in __touch_cap() argument
870 struct inode *inode = &cap->ci->netfs.inode; in __touch_cap()
871 struct ceph_mds_session *s = cap->session; in __touch_cap()
876 doutc(cl, "%p %llx.%llx cap %p mds%d\n", inode, in __touch_cap()
877 ceph_vinop(inode), cap, s->s_mds); in __touch_cap()
878 list_move_tail(&cap->session_caps, &s->s_caps); in __touch_cap()
880 doutc(cl, "%p %llx.%llx cap %p mds%d NOP, iterating over caps\n", in __touch_cap()
881 inode, ceph_vinop(inode), cap, s->s_mds); in __touch_cap()
887 * Check if we hold the given mask. If so, move the cap(s) to the
895 struct ceph_cap *cap; in __ceph_caps_issued_mask() local
907 cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_caps_issued_mask()
908 if (!__cap_is_valid(cap)) in __ceph_caps_issued_mask()
910 if ((cap->issued & mask) == mask) { in __ceph_caps_issued_mask()
911 doutc(cl, "mask %p %llx.%llx cap %p issued %s (mask %s)\n", in __ceph_caps_issued_mask()
912 inode, ceph_vinop(inode), cap, in __ceph_caps_issued_mask()
913 ceph_cap_string(cap->issued), in __ceph_caps_issued_mask()
916 __touch_cap(cap); in __ceph_caps_issued_mask()
921 have |= cap->issued; in __ceph_caps_issued_mask()
925 ceph_cap_string(cap->issued), in __ceph_caps_issued_mask()
931 __touch_cap(cap); in __ceph_caps_issued_mask()
934 cap = rb_entry(q, struct ceph_cap, in __ceph_caps_issued_mask()
936 if (!__cap_is_valid(cap)) in __ceph_caps_issued_mask()
938 if (cap->issued & mask) in __ceph_caps_issued_mask()
939 __touch_cap(cap); in __ceph_caps_issued_mask()
969 struct ceph_cap *cap; in __ceph_caps_revoking_other() local
973 cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_caps_revoking_other()
974 if (cap != ocap && in __ceph_caps_revoking_other()
975 (cap->implemented & ~cap->issued & mask)) in __ceph_caps_revoking_other()
1065 * wanted, by virtue of open file modes AND cap refs (buffered/cached data)
1087 struct ceph_cap *cap; in __ceph_caps_mds_wanted() local
1092 cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_caps_mds_wanted()
1093 if (check && !__cap_is_valid(cap)) in __ceph_caps_mds_wanted()
1095 if (cap == ci->i_auth_cap) in __ceph_caps_mds_wanted()
1096 mds_wanted |= cap->mds_wanted; in __ceph_caps_mds_wanted()
1098 mds_wanted |= (cap->mds_wanted & ~CEPH_CAP_ANY_FILE_WR); in __ceph_caps_mds_wanted()
1116 * Remove a cap. Take steps to deal with a racing iterate_session_caps.
1121 void __ceph_remove_cap(struct ceph_cap *cap, bool queue_release) in __ceph_remove_cap() argument
1123 struct ceph_mds_session *session = cap->session; in __ceph_remove_cap()
1125 struct ceph_inode_info *ci = cap->ci; in __ceph_remove_cap()
1138 doutc(cl, "%p from %p %llx.%llx\n", cap, inode, ceph_vinop(inode)); in __ceph_remove_cap()
1142 /* remove from inode's cap rbtree, and clear auth cap */ in __ceph_remove_cap()
1143 rb_erase(&cap->ci_node, &ci->i_caps); in __ceph_remove_cap()
1144 if (ci->i_auth_cap == cap) in __ceph_remove_cap()
1149 if (session->s_cap_iterator == cap) { in __ceph_remove_cap()
1150 /* not yet, we are iterating over this very cap */ in __ceph_remove_cap()
1151 doutc(cl, "delaying %p removal from session %p\n", cap, in __ceph_remove_cap()
1152 cap->session); in __ceph_remove_cap()
1154 list_del_init(&cap->session_caps); in __ceph_remove_cap()
1157 cap->session = NULL; in __ceph_remove_cap()
1161 cap->ci = NULL; in __ceph_remove_cap()
1169 cap->cap_gen == atomic_read(&session->s_cap_gen))) { in __ceph_remove_cap()
1170 cap->queue_release = 1; in __ceph_remove_cap()
1172 __ceph_queue_cap_release(session, cap); in __ceph_remove_cap()
1176 cap->queue_release = 0; in __ceph_remove_cap()
1178 cap->cap_ino = ci->i_vino.ino; in __ceph_remove_cap()
1183 ceph_put_cap(mdsc, cap); in __ceph_remove_cap()
1197 void ceph_remove_cap(struct ceph_mds_client *mdsc, struct ceph_cap *cap, in ceph_remove_cap() argument
1200 struct ceph_inode_info *ci = cap->ci; in ceph_remove_cap()
1212 WARN_ON_ONCE(ci->i_auth_cap == cap && in ceph_remove_cap()
1217 __ceph_remove_cap(cap, queue_release); in ceph_remove_cap()
1242 /* Marshal up the cap msg to the MDS */
1362 * Queue cap releases when an inode is dropped from our cache.
1375 struct ceph_cap *cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_remove_caps() local
1377 ceph_remove_cap(mdsc, cap, true); in __ceph_remove_caps()
1383 * Prepare to send a cap message to an MDS. Update the cap state, and populate
1385 * be done under the i_ceph_lock to guard against changes to cap state.
1390 static void __prep_cap(struct cap_msg_args *arg, struct ceph_cap *cap, in __prep_cap() argument
1394 struct ceph_inode_info *ci = cap->ci; in __prep_cap()
1401 held = cap->issued | cap->implemented; in __prep_cap()
1402 revoking = cap->implemented & ~cap->issued; in __prep_cap()
1405 doutc(cl, "%p %llx.%llx cap %p session %p %s -> %s (revoking %s)\n", in __prep_cap()
1406 inode, ceph_vinop(inode), cap, cap->session, in __prep_cap()
1413 cap->issued &= retain; /* drop bits we don't want */ in __prep_cap()
1419 arg->wake = cap->implemented & ~cap->issued; in __prep_cap()
1420 cap->implemented &= cap->issued | used; in __prep_cap()
1421 cap->mds_wanted = want; in __prep_cap()
1423 arg->session = cap->session; in __prep_cap()
1425 arg->cid = cap->cap_id; in __prep_cap()
1432 if (cap == ci->i_auth_cap) { in __prep_cap()
1455 arg->caps = cap->implemented; in __prep_cap()
1459 arg->seq = cap->seq; in __prep_cap()
1460 arg->issue_seq = cap->issue_seq; in __prep_cap()
1461 arg->mseq = cap->mseq; in __prep_cap()
1516 * Send a cap msg on the given inode.
1530 "error allocating cap msg: ino (%llx.%llx)" in __send_cap()
1531 " flushing %s tid %llu, requeuing cap.\n", in __send_cap()
1671 struct ceph_cap *cap = ci->i_auth_cap; in __ceph_flush_snaps() local
1675 if (!(cap && cap->session == session)) { in __ceph_flush_snaps()
1676 doutc(cl, "%p %llx.%llx auth cap %p not mds%d, stop\n", in __ceph_flush_snaps()
1677 inode, ceph_vinop(inode), cap, session->s_mds); in __ceph_flush_snaps()
1702 ret = __send_flush_snap(inode, session, capsnap, cap->mseq, in __ceph_flush_snaps()
1705 pr_err_client(cl, "error sending cap flushsnap, " in __ceph_flush_snaps()
1736 doutc(cl, " no auth cap (migrating?), doing nothing\n"); in ceph_flush_snaps()
1796 "but no auth cap (session was closed?)\n", in __ceph_mark_dirty_caps()
1817 doutc(cl, "%p %llx.%llx now dirty snapc %p auth cap %p\n", in __ceph_mark_dirty_caps()
1869 * Remove cap_flush from the mdsc's or inode's flushing cap list.
2003 * CHECK_CAPS_AUTHONLY - we should only check the auth cap
2014 struct ceph_cap *cap; in ceph_check_caps() local
2065 * the exclusive cap. So that MDS does not end up in ceph_check_caps()
2066 * revoking the shared cap on every create/unlink in ceph_check_caps()
2127 cap = rb_entry(p, struct ceph_cap, ci_node); in ceph_check_caps()
2130 if (mds >= cap->mds || in ceph_check_caps()
2131 ((flags & CHECK_CAPS_AUTHONLY) && cap != ci->i_auth_cap)) in ceph_check_caps()
2135 * If we have an auth cap, we don't need to consider any in ceph_check_caps()
2139 if (ci->i_auth_cap && cap != ci->i_auth_cap) in ceph_check_caps()
2142 revoking = cap->implemented & ~cap->issued; in ceph_check_caps()
2143 doutc(cl, " mds%d cap %p used %s issued %s implemented %s revoking %s\n", in ceph_check_caps()
2144 cap->mds, cap, ceph_cap_string(cap_used), in ceph_check_caps()
2145 ceph_cap_string(cap->issued), in ceph_check_caps()
2146 ceph_cap_string(cap->implemented), in ceph_check_caps()
2153 ceph_cap_string(cap->implemented & ~cap->issued)); in ceph_check_caps()
2178 if (cap == ci->i_auth_cap && in ceph_check_caps()
2179 (cap->issued & CEPH_CAP_FILE_WR)) { in ceph_check_caps()
2194 if (cap == ci->i_auth_cap) { in ceph_check_caps()
2206 if (want & ~cap->mds_wanted) { in ceph_check_caps()
2207 if (want & ~(cap->mds_wanted | cap->issued)) in ceph_check_caps()
2209 if (!__cap_is_valid(cap)) in ceph_check_caps()
2214 if ((cap->issued & ~retain) == 0) in ceph_check_caps()
2219 session = ceph_get_mds_session(cap->session); in ceph_check_caps()
2222 * cap message */ in ceph_check_caps()
2223 if (cap == ci->i_auth_cap && in ceph_check_caps()
2234 if (cap == ci->i_auth_cap && ci->i_dirty_caps) { in ceph_check_caps()
2249 mds = cap->mds; /* remember mds, so we don't repeat */ in ceph_check_caps()
2251 __prep_cap(&arg, cap, CEPH_CAP_OP_UPDATE, mflags, cap_used, in ceph_check_caps()
2258 goto retry; /* retake i_ceph_lock and restart our cap scan. */ in ceph_check_caps()
2291 struct ceph_cap *cap = ci->i_auth_cap; in try_flush_caps() local
2293 struct ceph_mds_session *session = cap->session; in try_flush_caps()
2313 __prep_cap(&arg, cap, CEPH_CAP_OP_FLUSH, CEPH_CLIENT_CAPS_SYNC, in try_flush_caps()
2315 (cap->issued | cap->implemented), in try_flush_caps()
2569 struct ceph_cap *cap; in __kick_flushing_caps() local
2592 cap = ci->i_auth_cap; in __kick_flushing_caps()
2593 if (!(cap && cap->session == session)) { in __kick_flushing_caps()
2594 pr_err_client(cl, "%p auth cap %p not mds%d ???\n", in __kick_flushing_caps()
2595 inode, cap, session->s_mds); in __kick_flushing_caps()
2604 doutc(cl, "%p %llx.%llx cap %p tid %llu %s\n", in __kick_flushing_caps()
2605 inode, ceph_vinop(inode), cap, cf->tid, in __kick_flushing_caps()
2607 __prep_cap(&arg, cap, CEPH_CAP_OP_FLUSH, in __kick_flushing_caps()
2612 (cap->issued | cap->implemented), in __kick_flushing_caps()
2627 ret = __send_flush_snap(inode, session, capsnap, cap->mseq, in __kick_flushing_caps()
2630 pr_err_client(cl, "error sending cap flushsnap," in __kick_flushing_caps()
2648 struct ceph_cap *cap; in ceph_early_kick_flushing_caps() local
2661 cap = ci->i_auth_cap; in ceph_early_kick_flushing_caps()
2662 if (!(cap && cap->session == session)) { in ceph_early_kick_flushing_caps()
2663 pr_err_client(cl, "%p %llx.%llx auth cap %p not mds%d ???\n", in ceph_early_kick_flushing_caps()
2664 inode, ceph_vinop(inode), cap, in ceph_early_kick_flushing_caps()
2672 * if flushing caps were revoked, we re-send the cap flush in ceph_early_kick_flushing_caps()
2674 * the cap flush message before issuing the flushing caps to in ceph_early_kick_flushing_caps()
2677 if ((cap->issued & ci->i_flushing_caps) != in ceph_early_kick_flushing_caps()
2680 * numbers. make sure sequence numbers in cap flush in ceph_early_kick_flushing_caps()
2682 cap->seq = 0; in ceph_early_kick_flushing_caps()
2683 cap->issue_seq = 0; in ceph_early_kick_flushing_caps()
2684 cap->mseq = 0; in ceph_early_kick_flushing_caps()
2700 struct ceph_cap *cap; in ceph_kick_flushing_caps() local
2715 cap = ci->i_auth_cap; in ceph_kick_flushing_caps()
2716 if (!(cap && cap->session == session)) { in ceph_kick_flushing_caps()
2717 pr_err_client(cl, "%p %llx.%llx auth cap %p not mds%d ???\n", in ceph_kick_flushing_caps()
2718 inode, ceph_vinop(inode), cap, in ceph_kick_flushing_caps()
2735 struct ceph_cap *cap = ci->i_auth_cap; in ceph_kick_flushing_inode_caps() local
2748 &cap->session->s_cap_flushing); in ceph_kick_flushing_inode_caps()
2795 * Try to grab cap references. Specify those refs we @want, and the
3035 * Wait for caps, and take cap references. If we can't get a WR cap
3149 * drop cap refs first because getattr while in __ceph_get_caps()
3182 * Take cap refs. Caller must already know we hold at least one ref
3224 * Release cap refs.
3226 * If we released the last ref on any given cap, call ceph_check_caps
3229 * If we are releasing a WR cap (from a sync write), finalize any affected
3385 * auth cap in the case of a forced unmount. in ceph_put_wrbuffer_cap_refs()
3479 * Handle a cap GRANT message from the MDS. (Note that a GRANT may
3480 * actually be a revocation if it specifies a smaller cap set.)
3486 struct ceph_cap *cap, in handle_cap_grant() argument
3501 bool was_stale = cap->cap_gen < atomic_read(&session->s_cap_gen); in handle_cap_grant()
3519 doutc(cl, "%p %llx.%llx cap %p mds%d seq %d %s\n", inode, in handle_cap_grant()
3520 ceph_vinop(inode), cap, session->s_mds, seq, in handle_cap_grant()
3532 ((cap->issued & ~newcaps) & CEPH_CAP_FILE_CACHE) && in handle_cap_grant()
3546 cap->issued = cap->implemented = CEPH_CAP_PIN; in handle_cap_grant()
3549 * auth mds of the inode changed. we received the cap export message, in handle_cap_grant()
3550 * but still haven't received the cap import message. handle_cap_export in handle_cap_grant()
3551 * updated the new auth MDS' cap. in handle_cap_grant()
3553 * "ceph_seq_cmp(seq, cap->seq) <= 0" means we are processing a message in handle_cap_grant()
3554 * that was sent before the cap import message. So don't remove caps. in handle_cap_grant()
3556 if (ceph_seq_cmp(seq, cap->seq) <= 0) { in handle_cap_grant()
3557 WARN_ON(cap != ci->i_auth_cap); in handle_cap_grant()
3558 WARN_ON(cap->cap_id != le64_to_cpu(grant->cap_id)); in handle_cap_grant()
3559 seq = cap->seq; in handle_cap_grant()
3560 newcaps |= cap->issued; in handle_cap_grant()
3564 cap->cap_gen = atomic_read(&session->s_cap_gen); in handle_cap_grant()
3565 cap->seq = seq; in handle_cap_grant()
3567 __check_cap_issue(ci, cap, newcaps); in handle_cap_grant()
3592 "cap grant attempt to change fscrypt_auth on non-I_NEW inode (old len %d new len %d)\n", in handle_cap_grant()
3661 if (ci->i_auth_cap == cap && (newcaps & CEPH_CAP_ANY_FILE_WR)) { in handle_cap_grant()
3674 /* check cap bits */ in handle_cap_grant()
3683 (wanted & ~(cap->mds_wanted | newcaps))) { in handle_cap_grant()
3685 * If mds is importing cap, prior cap messages that update in handle_cap_grant()
3688 * We don't send cap message to update 'wanted' if what we in handle_cap_grant()
3689 * want are already issued. If mds revokes caps, cap message in handle_cap_grant()
3698 if (cap->issued & ~newcaps) { in handle_cap_grant()
3699 int revoking = cap->issued & ~newcaps; in handle_cap_grant()
3702 ceph_cap_string(cap->issued), ceph_cap_string(newcaps), in handle_cap_grant()
3712 } else if (cap == ci->i_auth_cap) { in handle_cap_grant()
3713 check_caps = 1; /* check auth cap only */ in handle_cap_grant()
3718 if (~cap->issued & newcaps) in handle_cap_grant()
3720 cap->issued = newcaps; in handle_cap_grant()
3721 cap->implemented |= newcaps; in handle_cap_grant()
3722 } else if (cap->issued == newcaps) { in handle_cap_grant()
3724 ceph_cap_string(cap->issued), in handle_cap_grant()
3727 doutc(cl, "grant: %s -> %s\n", ceph_cap_string(cap->issued), in handle_cap_grant()
3730 if (cap == ci->i_auth_cap && in handle_cap_grant()
3731 __ceph_caps_revoking_other(ci, cap, newcaps)) in handle_cap_grant()
3734 cap->issued = newcaps; in handle_cap_grant()
3735 cap->implemented |= newcaps; /* add bits only, to in handle_cap_grant()
3740 BUG_ON(cap->issued & ~cap->implemented); in handle_cap_grant()
3744 cap->mds_wanted = 0; in handle_cap_grant()
3746 if (cap == ci->i_auth_cap) in handle_cap_grant()
3747 check_caps = 1; /* check auth cap only */ in handle_cap_grant()
3761 if (ci->i_auth_cap == cap) { in handle_cap_grant()
3813 struct ceph_cap *cap) in handle_cap_flush_ack() argument
3879 doutc(cl, " mds%d still flushing cap on %p %llx.%llx\n", in handle_cap_flush_ack()
4057 * Handle EXPORT from MDS. Cap is being migrated _from_ this mds to a
4059 * indicated by mseq), make note of the migrating cap bits for the
4071 struct ceph_cap *cap, *tcap, *new_cap = NULL; in handle_cap_export() local
4088 doutc(cl, " cap %llx.%llx export to peer %d piseq %u pmseq %u\n", in handle_cap_export()
4093 cap = __get_cap_for_mds(ci, mds); in handle_cap_export()
4094 if (!cap || cap->cap_id != le64_to_cpu(ex->cap_id)) in handle_cap_export()
4098 ceph_remove_cap(mdsc, cap, false); in handle_cap_export()
4103 * now we know we haven't received the cap import message yet in handle_cap_export()
4104 * because the exported cap still exist. in handle_cap_export()
4107 issued = cap->issued; in handle_cap_export()
4108 if (issued != cap->implemented) in handle_cap_export()
4113 cap->seq, cap->mseq, in handle_cap_export()
4115 ceph_cap_string(cap->implemented)); in handle_cap_export()
4123 doutc(cl, " updating import cap %p mds%d\n", tcap, in handle_cap_export()
4130 if (cap == ci->i_auth_cap) { in handle_cap_export()
4135 ceph_remove_cap(mdsc, cap, false); in handle_cap_export()
4139 int flag = (cap == ci->i_auth_cap) ? CEPH_CAP_FLAG_AUTH : 0; in handle_cap_export()
4152 ceph_remove_cap(mdsc, cap, false); in handle_cap_export()
4194 * Handle cap IMPORT.
4206 struct ceph_cap *cap, *ocap, *new_cap = NULL; in handle_cap_import() local
4230 doutc(cl, " cap %llx.%llx import from peer %d piseq %u pmseq %u\n", in handle_cap_import()
4233 cap = __get_cap_for_mds(ci, mds); in handle_cap_import()
4234 if (!cap) { in handle_cap_import()
4241 cap = new_cap; in handle_cap_import()
4257 doutc(cl, " remove export cap %p mds%d flags %d\n", in handle_cap_import()
4272 *target_cap = cap; in handle_cap_import()
4325 * based on the cap op.
4334 struct ceph_cap *cap; in ceph_handle_caps() local
4473 /* these will work even if we don't have a cap yet */ in ceph_handle_caps()
4501 &cap, &extra_info.issued); in ceph_handle_caps()
4502 handle_cap_grant(inode, session, cap, in ceph_handle_caps()
4509 /* the rest require a cap */ in ceph_handle_caps()
4511 cap = __get_cap_for_mds(ceph_inode(inode), session->s_mds); in ceph_handle_caps()
4512 if (!cap) { in ceph_handle_caps()
4513 doutc(cl, " no cap on %p ino %llx.%llx from mds%d\n", in ceph_handle_caps()
4534 handle_cap_grant(inode, session, cap, in ceph_handle_caps()
4540 h, session, cap); in ceph_handle_caps()
4553 pr_err_client(cl, "unknown cap op %d %s\n", op, in ceph_handle_caps()
4575 * send any cap release message to try to move things in ceph_handle_caps()
4577 * cap). in ceph_handle_caps()
4580 cap = ceph_get_cap(mdsc, NULL); in ceph_handle_caps()
4581 cap->cap_ino = vino.ino; in ceph_handle_caps()
4582 cap->queue_release = 1; in ceph_handle_caps()
4583 cap->cap_id = le64_to_cpu(h->cap_id); in ceph_handle_caps()
4584 cap->mseq = mseq; in ceph_handle_caps()
4585 cap->seq = seq; in ceph_handle_caps()
4586 cap->issue_seq = seq; in ceph_handle_caps()
4588 __ceph_queue_cap_release(session, cap); in ceph_handle_caps()
4601 * Delayed work handler to process end of delayed cap release LRU list.
4691 * Flush all cap releases to the mds
4833 * Helpers for embedding cap and dentry lease releases into mds
4845 struct ceph_cap *cap; in ceph_encode_inode_release() local
4861 cap = __get_cap_for_mds(ci, mds); in ceph_encode_inode_release()
4862 if (cap && __cap_is_valid(cap)) { in ceph_encode_inode_release()
4863 unless &= cap->issued; in ceph_encode_inode_release()
4875 if (force || (cap->issued & drop)) { in ceph_encode_inode_release()
4876 if (cap->issued & drop) { in ceph_encode_inode_release()
4878 doutc(cl, "%p %llx.%llx cap %p %s -> %s, " in ceph_encode_inode_release()
4880 ceph_vinop(inode), cap, in ceph_encode_inode_release()
4881 ceph_cap_string(cap->issued), in ceph_encode_inode_release()
4882 ceph_cap_string(cap->issued & ~drop), in ceph_encode_inode_release()
4883 ceph_cap_string(cap->mds_wanted), in ceph_encode_inode_release()
4886 cap->issued &= ~drop; in ceph_encode_inode_release()
4887 cap->implemented &= ~drop; in ceph_encode_inode_release()
4888 cap->mds_wanted = wanted; in ceph_encode_inode_release()
4889 if (cap == ci->i_auth_cap && in ceph_encode_inode_release()
4893 doutc(cl, "%p %llx.%llx cap %p %s (force)\n", in ceph_encode_inode_release()
4894 inode, ceph_vinop(inode), cap, in ceph_encode_inode_release()
4895 ceph_cap_string(cap->issued)); in ceph_encode_inode_release()
4899 rel->cap_id = cpu_to_le64(cap->cap_id); in ceph_encode_inode_release()
4900 rel->seq = cpu_to_le32(cap->seq); in ceph_encode_inode_release()
4901 rel->issue_seq = cpu_to_le32(cap->issue_seq); in ceph_encode_inode_release()
4902 rel->mseq = cpu_to_le32(cap->mseq); in ceph_encode_inode_release()
4903 rel->caps = cpu_to_le32(cap->implemented); in ceph_encode_inode_release()
4904 rel->wanted = cpu_to_le32(cap->mds_wanted); in ceph_encode_inode_release()
4910 doutc(cl, "%p %llx.%llx cap %p %s (noop)\n", in ceph_encode_inode_release()
4911 inode, ceph_vinop(inode), cap, in ceph_encode_inode_release()
4912 ceph_cap_string(cap->issued)); in ceph_encode_inode_release()
5009 int ceph_purge_inode_cap(struct inode *inode, struct ceph_cap *cap, bool *invalidate) in ceph_purge_inode_cap() argument
5021 doutc(cl, "removing cap %p, ci is %p, %p %llx.%llx\n", in ceph_purge_inode_cap()
5022 cap, ci, inode, ceph_vinop(inode)); in ceph_purge_inode_cap()
5024 is_auth = (cap == ci->i_auth_cap); in ceph_purge_inode_cap()
5025 __ceph_remove_cap(cap, false); in ceph_purge_inode_cap()
5038 /* trash all of the cap flushes for this inode */ in ceph_purge_inode_cap()