Lines Matching full:cap

30  * If the client holds a *_SHARED cap, the client has a coherent value
54 * Generate readable cap strings for debugging output.
137 struct ceph_cap *cap; in ceph_caps_finalize() local
141 cap = list_first_entry(&mdsc->caps_list, in ceph_caps_finalize()
143 list_del(&cap->caps_item); in ceph_caps_finalize()
144 kmem_cache_free(ceph_cap_cachep, cap); in ceph_caps_finalize()
170 struct ceph_cap *cap; in __ceph_unreserve_caps() local
180 cap = list_first_entry(&mdsc->caps_list, in __ceph_unreserve_caps()
182 list_del(&cap->caps_item); in __ceph_unreserve_caps()
183 kmem_cache_free(ceph_cap_cachep, cap); in __ceph_unreserve_caps()
206 struct ceph_cap *cap; in ceph_reserve_caps() local
231 cap = kmem_cache_alloc(ceph_cap_cachep, GFP_NOFS); in ceph_reserve_caps()
232 if (cap) { in ceph_reserve_caps()
233 list_add(&cap->caps_item, &newcaps); in ceph_reserve_caps()
331 struct ceph_cap *cap = NULL; in ceph_get_cap() local
333 /* temporary, until we do something about cap import/export */ in ceph_get_cap()
335 cap = kmem_cache_alloc(ceph_cap_cachep, GFP_NOFS); in ceph_get_cap()
336 if (cap) { in ceph_get_cap()
348 cap = list_first_entry(&mdsc->caps_list, in ceph_get_cap()
350 list_del(&cap->caps_item); in ceph_get_cap()
358 return cap; in ceph_get_cap()
374 cap = list_first_entry(&mdsc->caps_list, struct ceph_cap, caps_item); in ceph_get_cap()
375 list_del(&cap->caps_item); in ceph_get_cap()
380 return cap; in ceph_get_cap()
383 void ceph_put_cap(struct ceph_mds_client *mdsc, struct ceph_cap *cap) in ceph_put_cap() argument
387 cap, mdsc->caps_total_count, mdsc->caps_use_count, in ceph_put_cap()
397 kmem_cache_free(ceph_cap_cachep, cap); in ceph_put_cap()
400 list_add(&cap->caps_item, &mdsc->caps_list); in ceph_put_cap()
437 struct ceph_cap *cap; in __get_cap_for_mds() local
441 cap = rb_entry(n, struct ceph_cap, ci_node); in __get_cap_for_mds()
442 if (mds < cap->mds) in __get_cap_for_mds()
444 else if (mds > cap->mds) in __get_cap_for_mds()
447 return cap; in __get_cap_for_mds()
454 struct ceph_cap *cap; in ceph_get_cap_for_mds() local
457 cap = __get_cap_for_mds(ci, mds); in ceph_get_cap_for_mds()
459 return cap; in ceph_get_cap_for_mds()
470 struct ceph_cap *cap = NULL; in __insert_cap_node() local
474 cap = rb_entry(parent, struct ceph_cap, ci_node); in __insert_cap_node()
475 if (new->mds < cap->mds) in __insert_cap_node()
477 else if (new->mds > cap->mds) in __insert_cap_node()
488 * (re)set cap hold timeouts, which control the delayed release
489 * of unused caps back to the MDS. Should be called on cap use.
502 * (Re)queue cap at the end of the delayed cap release list.
530 * indicating we should send a cap message to flush dirty metadata
531 * asap, and move to the front of the delayed cap list.
546 * Cancel delayed work on cap.
562 static void __check_cap_issue(struct ceph_inode_info *ci, struct ceph_cap *cap, in __check_cap_issue() argument
581 * know what happened to this directory while we didn't have the cap. in __check_cap_issue()
629 * it is < 0. (This is so we can atomically add the cap and add an
640 struct ceph_cap *cap; in ceph_add_cap() local
647 dout("add_cap %p mds%d cap %llx %s seq %d\n", inode, in ceph_add_cap()
652 cap = __get_cap_for_mds(ci, mds); in ceph_add_cap()
653 if (!cap) { in ceph_add_cap()
654 cap = *new_cap; in ceph_add_cap()
657 cap->issued = 0; in ceph_add_cap()
658 cap->implemented = 0; in ceph_add_cap()
659 cap->mds = mds; in ceph_add_cap()
660 cap->mds_wanted = 0; in ceph_add_cap()
661 cap->mseq = 0; in ceph_add_cap()
663 cap->ci = ci; in ceph_add_cap()
664 __insert_cap_node(ci, cap); in ceph_add_cap()
666 /* add to session cap list */ in ceph_add_cap()
667 cap->session = session; in ceph_add_cap()
669 list_add_tail(&cap->session_caps, &session->s_caps); in ceph_add_cap()
675 list_move_tail(&cap->session_caps, &session->s_caps); in ceph_add_cap()
678 if (cap->cap_gen < gen) in ceph_add_cap()
679 cap->issued = cap->implemented = CEPH_CAP_PIN; in ceph_add_cap()
682 * auth mds of the inode changed. we received the cap export in ceph_add_cap()
683 * message, but still haven't received the cap import message. in ceph_add_cap()
684 * handle_cap_export() updated the new auth MDS' cap. in ceph_add_cap()
686 * "ceph_seq_cmp(seq, cap->seq) <= 0" means we are processing in ceph_add_cap()
687 * a message that was send before the cap import message. So in ceph_add_cap()
690 if (ceph_seq_cmp(seq, cap->seq) <= 0) { in ceph_add_cap()
691 WARN_ON(cap != ci->i_auth_cap); in ceph_add_cap()
692 WARN_ON(cap->cap_id != cap_id); in ceph_add_cap()
693 seq = cap->seq; in ceph_add_cap()
694 mseq = cap->mseq; in ceph_add_cap()
695 issued |= cap->issued; in ceph_add_cap()
716 __check_cap_issue(ci, cap, issued); in ceph_add_cap()
736 ci->i_auth_cap->session != cap->session) in ceph_add_cap()
737 change_auth_cap_ses(ci, cap->session); in ceph_add_cap()
738 ci->i_auth_cap = cap; in ceph_add_cap()
739 cap->mds_wanted = wanted; in ceph_add_cap()
742 WARN_ON(ci->i_auth_cap == cap); in ceph_add_cap()
745 dout("add_cap inode %p (%llx.%llx) cap %p %s now %s seq %d mds%d\n", in ceph_add_cap()
746 inode, ceph_vinop(inode), cap, ceph_cap_string(issued), in ceph_add_cap()
747 ceph_cap_string(issued|cap->issued), seq, mds); in ceph_add_cap()
748 cap->cap_id = cap_id; in ceph_add_cap()
749 cap->issued = issued; in ceph_add_cap()
750 cap->implemented |= issued; in ceph_add_cap()
751 if (ceph_seq_cmp(mseq, cap->mseq) > 0) in ceph_add_cap()
752 cap->mds_wanted = wanted; in ceph_add_cap()
754 cap->mds_wanted |= wanted; in ceph_add_cap()
755 cap->seq = seq; in ceph_add_cap()
756 cap->issue_seq = seq; in ceph_add_cap()
757 cap->mseq = mseq; in ceph_add_cap()
758 cap->cap_gen = gen; in ceph_add_cap()
763 * Return true if cap has not timed out and belongs to the current
767 static int __cap_is_valid(struct ceph_cap *cap) in __cap_is_valid() argument
772 gen = atomic_read(&cap->session->s_cap_gen); in __cap_is_valid()
773 ttl = cap->session->s_cap_ttl; in __cap_is_valid()
775 if (cap->cap_gen < gen || time_after_eq(jiffies, ttl)) { in __cap_is_valid()
776 dout("__cap_is_valid %p cap %p issued %s " in __cap_is_valid()
777 "but STALE (gen %u vs %u)\n", &cap->ci->netfs.inode, in __cap_is_valid()
778 cap, ceph_cap_string(cap->issued), cap->cap_gen, gen); in __cap_is_valid()
786 * Return set of valid cap bits issued to us. Note that caps time
793 struct ceph_cap *cap; in __ceph_caps_issued() local
799 cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_caps_issued()
800 if (!__cap_is_valid(cap)) in __ceph_caps_issued()
802 dout("__ceph_caps_issued %p cap %p issued %s\n", in __ceph_caps_issued()
803 &ci->netfs.inode, cap, ceph_cap_string(cap->issued)); in __ceph_caps_issued()
804 have |= cap->issued; in __ceph_caps_issued()
806 *implemented |= cap->implemented; in __ceph_caps_issued()
814 cap = ci->i_auth_cap; in __ceph_caps_issued()
815 have &= ~cap->implemented | cap->issued; in __ceph_caps_issued()
821 * Get cap bits issued by caps other than @ocap
826 struct ceph_cap *cap; in __ceph_caps_issued_other() local
830 cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_caps_issued_other()
831 if (cap == ocap) in __ceph_caps_issued_other()
833 if (!__cap_is_valid(cap)) in __ceph_caps_issued_other()
835 have |= cap->issued; in __ceph_caps_issued_other()
841 * Move a cap to the end of the LRU (oldest caps at list head, newest
844 static void __touch_cap(struct ceph_cap *cap) in __touch_cap() argument
846 struct ceph_mds_session *s = cap->session; in __touch_cap()
850 dout("__touch_cap %p cap %p mds%d\n", &cap->ci->netfs.inode, cap, in __touch_cap()
852 list_move_tail(&cap->session_caps, &s->s_caps); in __touch_cap()
854 dout("__touch_cap %p cap %p mds%d NOP, iterating over caps\n", in __touch_cap()
855 &cap->ci->netfs.inode, cap, s->s_mds); in __touch_cap()
861 * Check if we hold the given mask. If so, move the cap(s) to the
867 struct ceph_cap *cap; in __ceph_caps_issued_mask() local
880 cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_caps_issued_mask()
881 if (!__cap_is_valid(cap)) in __ceph_caps_issued_mask()
883 if ((cap->issued & mask) == mask) { in __ceph_caps_issued_mask()
884 dout("__ceph_caps_issued_mask ino 0x%llx cap %p issued %s" in __ceph_caps_issued_mask()
885 " (mask %s)\n", ceph_ino(&ci->netfs.inode), cap, in __ceph_caps_issued_mask()
886 ceph_cap_string(cap->issued), in __ceph_caps_issued_mask()
889 __touch_cap(cap); in __ceph_caps_issued_mask()
894 have |= cap->issued; in __ceph_caps_issued_mask()
898 ceph_cap_string(cap->issued), in __ceph_caps_issued_mask()
904 __touch_cap(cap); in __ceph_caps_issued_mask()
907 cap = rb_entry(q, struct ceph_cap, in __ceph_caps_issued_mask()
909 if (!__cap_is_valid(cap)) in __ceph_caps_issued_mask()
911 if (cap->issued & mask) in __ceph_caps_issued_mask()
912 __touch_cap(cap); in __ceph_caps_issued_mask()
942 struct ceph_cap *cap; in __ceph_caps_revoking_other() local
946 cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_caps_revoking_other()
947 if (cap != ocap && in __ceph_caps_revoking_other()
948 (cap->implemented & ~cap->issued & mask)) in __ceph_caps_revoking_other()
1051 * wanted, by virtue of open file modes AND cap refs (buffered/cached data)
1073 struct ceph_cap *cap; in __ceph_caps_mds_wanted() local
1078 cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_caps_mds_wanted()
1079 if (check && !__cap_is_valid(cap)) in __ceph_caps_mds_wanted()
1081 if (cap == ci->i_auth_cap) in __ceph_caps_mds_wanted()
1082 mds_wanted |= cap->mds_wanted; in __ceph_caps_mds_wanted()
1084 mds_wanted |= (cap->mds_wanted & ~CEPH_CAP_ANY_FILE_WR); in __ceph_caps_mds_wanted()
1102 * Remove a cap. Take steps to deal with a racing iterate_session_caps.
1107 void __ceph_remove_cap(struct ceph_cap *cap, bool queue_release) in __ceph_remove_cap() argument
1109 struct ceph_mds_session *session = cap->session; in __ceph_remove_cap()
1110 struct ceph_inode_info *ci = cap->ci; in __ceph_remove_cap()
1116 dout("%s: cap inode is NULL\n", __func__); in __ceph_remove_cap()
1122 dout("__ceph_remove_cap %p from %p\n", cap, &ci->netfs.inode); in __ceph_remove_cap()
1126 /* remove from inode's cap rbtree, and clear auth cap */ in __ceph_remove_cap()
1127 rb_erase(&cap->ci_node, &ci->i_caps); in __ceph_remove_cap()
1128 if (ci->i_auth_cap == cap) in __ceph_remove_cap()
1133 if (session->s_cap_iterator == cap) { in __ceph_remove_cap()
1134 /* not yet, we are iterating over this very cap */ in __ceph_remove_cap()
1136 cap, cap->session); in __ceph_remove_cap()
1138 list_del_init(&cap->session_caps); in __ceph_remove_cap()
1141 cap->session = NULL; in __ceph_remove_cap()
1145 cap->ci = NULL; in __ceph_remove_cap()
1153 cap->cap_gen == atomic_read(&session->s_cap_gen))) { in __ceph_remove_cap()
1154 cap->queue_release = 1; in __ceph_remove_cap()
1156 __ceph_queue_cap_release(session, cap); in __ceph_remove_cap()
1160 cap->queue_release = 0; in __ceph_remove_cap()
1162 cap->cap_ino = ci->i_vino.ino; in __ceph_remove_cap()
1167 ceph_put_cap(mdsc, cap); in __ceph_remove_cap()
1181 void ceph_remove_cap(struct ceph_mds_client *mdsc, struct ceph_cap *cap, in ceph_remove_cap() argument
1184 struct ceph_inode_info *ci = cap->ci; in ceph_remove_cap()
1189 dout("%s: cap inode is NULL\n", __func__); in ceph_remove_cap()
1196 WARN_ON_ONCE(ci->i_auth_cap == cap && in ceph_remove_cap()
1201 __ceph_remove_cap(cap, queue_release); in ceph_remove_cap()
1226 /* Marshal up the cap msg to the MDS */
1342 * Queue cap releases when an inode is dropped from our cache.
1355 struct ceph_cap *cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_remove_caps() local
1357 ceph_remove_cap(mdsc, cap, true); in __ceph_remove_caps()
1363 * Prepare to send a cap message to an MDS. Update the cap state, and populate
1365 * be done under the i_ceph_lock to guard against changes to cap state.
1370 static void __prep_cap(struct cap_msg_args *arg, struct ceph_cap *cap, in __prep_cap() argument
1374 struct ceph_inode_info *ci = cap->ci; in __prep_cap()
1380 held = cap->issued | cap->implemented; in __prep_cap()
1381 revoking = cap->implemented & ~cap->issued; in __prep_cap()
1384 dout("%s %p cap %p session %p %s -> %s (revoking %s)\n", in __prep_cap()
1385 __func__, inode, cap, cap->session, in __prep_cap()
1392 cap->issued &= retain; /* drop bits we don't want */ in __prep_cap()
1398 arg->wake = cap->implemented & ~cap->issued; in __prep_cap()
1399 cap->implemented &= cap->issued | used; in __prep_cap()
1400 cap->mds_wanted = want; in __prep_cap()
1402 arg->session = cap->session; in __prep_cap()
1404 arg->cid = cap->cap_id; in __prep_cap()
1411 if (cap == ci->i_auth_cap) { in __prep_cap()
1434 arg->caps = cap->implemented; in __prep_cap()
1438 arg->seq = cap->seq; in __prep_cap()
1439 arg->issue_seq = cap->issue_seq; in __prep_cap()
1440 arg->mseq = cap->mseq; in __prep_cap()
1495 * Send a cap msg on the given inode.
1507 pr_err("error allocating cap msg: ino (%llx.%llx) flushing %s tid %llu, requeuing cap.\n", in __send_cap()
1645 struct ceph_cap *cap = ci->i_auth_cap; in __ceph_flush_snaps() local
1649 if (!(cap && cap->session == session)) { in __ceph_flush_snaps()
1650 dout("__flush_snaps %p auth cap %p not mds%d, " in __ceph_flush_snaps()
1651 "stop\n", inode, cap, session->s_mds); in __ceph_flush_snaps()
1675 ret = __send_flush_snap(inode, session, capsnap, cap->mseq, in __ceph_flush_snaps()
1678 pr_err("__flush_snaps: error sending cap flushsnap, " in __ceph_flush_snaps()
1707 dout(" no auth cap (migrating?), doing nothing\n"); in ceph_flush_snaps()
1766 "but no auth cap (session was closed?)\n", in __ceph_mark_dirty_caps()
1786 dout(" inode %p now dirty snapc %p auth cap %p\n", in __ceph_mark_dirty_caps()
1837 * Remove cap_flush from the mdsc's or inode's flushing cap list.
1968 * CHECK_CAPS_AUTHONLY - we should only check the auth cap
1976 struct ceph_cap *cap; in ceph_check_caps() local
2027 * the exclusive cap. So that MDS does not end up in ceph_check_caps()
2028 * revoking the shared cap on every create/unlink in ceph_check_caps()
2088 cap = rb_entry(p, struct ceph_cap, ci_node); in ceph_check_caps()
2091 if (mds >= cap->mds || in ceph_check_caps()
2092 ((flags & CHECK_CAPS_AUTHONLY) && cap != ci->i_auth_cap)) in ceph_check_caps()
2096 * If we have an auth cap, we don't need to consider any in ceph_check_caps()
2100 if (ci->i_auth_cap && cap != ci->i_auth_cap) in ceph_check_caps()
2103 revoking = cap->implemented & ~cap->issued; in ceph_check_caps()
2104 dout(" mds%d cap %p used %s issued %s implemented %s revoking %s\n", in ceph_check_caps()
2105 cap->mds, cap, ceph_cap_string(cap_used), in ceph_check_caps()
2106 ceph_cap_string(cap->issued), in ceph_check_caps()
2107 ceph_cap_string(cap->implemented), in ceph_check_caps()
2110 if (cap == ci->i_auth_cap && in ceph_check_caps()
2111 (cap->issued & CEPH_CAP_FILE_WR)) { in ceph_check_caps()
2126 if (cap == ci->i_auth_cap) { in ceph_check_caps()
2141 ceph_cap_string(cap->implemented & ~cap->issued)); in ceph_check_caps()
2162 if (want & ~cap->mds_wanted) { in ceph_check_caps()
2163 if (want & ~(cap->mds_wanted | cap->issued)) in ceph_check_caps()
2165 if (!__cap_is_valid(cap)) in ceph_check_caps()
2170 if ((cap->issued & ~retain) == 0) in ceph_check_caps()
2175 session = ceph_get_mds_session(cap->session); in ceph_check_caps()
2178 * cap message */ in ceph_check_caps()
2179 if (cap == ci->i_auth_cap && in ceph_check_caps()
2190 if (cap == ci->i_auth_cap && ci->i_dirty_caps) { in ceph_check_caps()
2205 mds = cap->mds; /* remember mds, so we don't repeat */ in ceph_check_caps()
2207 __prep_cap(&arg, cap, CEPH_CAP_OP_UPDATE, mflags, cap_used, in ceph_check_caps()
2214 goto retry; /* retake i_ceph_lock and restart our cap scan. */ in ceph_check_caps()
2247 struct ceph_cap *cap = ci->i_auth_cap; in try_flush_caps() local
2249 struct ceph_mds_session *session = cap->session; in try_flush_caps()
2269 __prep_cap(&arg, cap, CEPH_CAP_OP_FLUSH, CEPH_CLIENT_CAPS_SYNC, in try_flush_caps()
2271 (cap->issued | cap->implemented), in try_flush_caps()
2518 struct ceph_cap *cap; in __kick_flushing_caps() local
2541 cap = ci->i_auth_cap; in __kick_flushing_caps()
2542 if (!(cap && cap->session == session)) { in __kick_flushing_caps()
2543 pr_err("%p auth cap %p not mds%d ???\n", in __kick_flushing_caps()
2544 inode, cap, session->s_mds); in __kick_flushing_caps()
2553 dout("kick_flushing_caps %p cap %p tid %llu %s\n", in __kick_flushing_caps()
2554 inode, cap, cf->tid, ceph_cap_string(cf->caps)); in __kick_flushing_caps()
2555 __prep_cap(&arg, cap, CEPH_CAP_OP_FLUSH, in __kick_flushing_caps()
2560 (cap->issued | cap->implemented), in __kick_flushing_caps()
2575 ret = __send_flush_snap(inode, session, capsnap, cap->mseq, in __kick_flushing_caps()
2579 "cap flushsnap, ino (%llx.%llx) " in __kick_flushing_caps()
2596 struct ceph_cap *cap; in ceph_early_kick_flushing_caps() local
2607 cap = ci->i_auth_cap; in ceph_early_kick_flushing_caps()
2608 if (!(cap && cap->session == session)) { in ceph_early_kick_flushing_caps()
2609 pr_err("%p auth cap %p not mds%d ???\n", in ceph_early_kick_flushing_caps()
2610 &ci->netfs.inode, cap, session->s_mds); in ceph_early_kick_flushing_caps()
2617 * if flushing caps were revoked, we re-send the cap flush in ceph_early_kick_flushing_caps()
2619 * the cap flush message before issuing the flushing caps to in ceph_early_kick_flushing_caps()
2622 if ((cap->issued & ci->i_flushing_caps) != in ceph_early_kick_flushing_caps()
2625 * numbers. make sure sequence numbers in cap flush in ceph_early_kick_flushing_caps()
2627 cap->seq = 0; in ceph_early_kick_flushing_caps()
2628 cap->issue_seq = 0; in ceph_early_kick_flushing_caps()
2629 cap->mseq = 0; in ceph_early_kick_flushing_caps()
2644 struct ceph_cap *cap; in ceph_kick_flushing_caps() local
2657 cap = ci->i_auth_cap; in ceph_kick_flushing_caps()
2658 if (!(cap && cap->session == session)) { in ceph_kick_flushing_caps()
2659 pr_err("%p auth cap %p not mds%d ???\n", in ceph_kick_flushing_caps()
2660 &ci->netfs.inode, cap, session->s_mds); in ceph_kick_flushing_caps()
2676 struct ceph_cap *cap = ci->i_auth_cap; in ceph_kick_flushing_inode_caps() local
2687 &cap->session->s_cap_flushing); in ceph_kick_flushing_inode_caps()
2731 * Try to grab cap references. Specify those refs we @want, and the
2963 * Wait for caps, and take cap references. If we can't get a WR cap
3071 * drop cap refs first because getattr while in __ceph_get_caps()
3104 * Take cap refs. Caller must already know we hold at least one ref
3145 * Release cap refs.
3147 * If we released the last ref on any given cap, call ceph_check_caps
3150 * If we are releasing a WR cap (from a sync write), finalize any affected
3310 * auth cap in the case of a forced unmount. in ceph_put_wrbuffer_cap_refs()
3404 * Handle a cap GRANT message from the MDS. (Note that a GRANT may
3405 * actually be a revocation if it specifies a smaller cap set.)
3411 struct ceph_cap *cap, in handle_cap_grant() argument
3425 bool was_stale = cap->cap_gen < atomic_read(&session->s_cap_gen); in handle_cap_grant()
3441 dout("handle_cap_grant inode %p cap %p mds%d seq %d %s\n", in handle_cap_grant()
3442 inode, cap, session->s_mds, seq, ceph_cap_string(newcaps)); in handle_cap_grant()
3453 ((cap->issued & ~newcaps) & CEPH_CAP_FILE_CACHE) && in handle_cap_grant()
3467 cap->issued = cap->implemented = CEPH_CAP_PIN; in handle_cap_grant()
3470 * auth mds of the inode changed. we received the cap export message, in handle_cap_grant()
3471 * but still haven't received the cap import message. handle_cap_export in handle_cap_grant()
3472 * updated the new auth MDS' cap. in handle_cap_grant()
3474 * "ceph_seq_cmp(seq, cap->seq) <= 0" means we are processing a message in handle_cap_grant()
3475 * that was sent before the cap import message. So don't remove caps. in handle_cap_grant()
3477 if (ceph_seq_cmp(seq, cap->seq) <= 0) { in handle_cap_grant()
3478 WARN_ON(cap != ci->i_auth_cap); in handle_cap_grant()
3479 WARN_ON(cap->cap_id != le64_to_cpu(grant->cap_id)); in handle_cap_grant()
3480 seq = cap->seq; in handle_cap_grant()
3481 newcaps |= cap->issued; in handle_cap_grant()
3485 cap->cap_gen = atomic_read(&session->s_cap_gen); in handle_cap_grant()
3486 cap->seq = seq; in handle_cap_grant()
3488 __check_cap_issue(ci, cap, newcaps); in handle_cap_grant()
3511 …pr_warn_ratelimited("%s: cap grant attempt to change fscrypt_auth on non-I_NEW inode (old len %d n… in handle_cap_grant()
3580 if (ci->i_auth_cap == cap && (newcaps & CEPH_CAP_ANY_FILE_WR)) { in handle_cap_grant()
3593 /* check cap bits */ in handle_cap_grant()
3603 (wanted & ~(cap->mds_wanted | newcaps))) { in handle_cap_grant()
3605 * If mds is importing cap, prior cap messages that update in handle_cap_grant()
3608 * We don't send cap message to update 'wanted' if what we in handle_cap_grant()
3609 * want are already issued. If mds revokes caps, cap message in handle_cap_grant()
3618 if (cap->issued & ~newcaps) { in handle_cap_grant()
3619 int revoking = cap->issued & ~newcaps; in handle_cap_grant()
3622 ceph_cap_string(cap->issued), in handle_cap_grant()
3632 else if (cap == ci->i_auth_cap) in handle_cap_grant()
3633 check_caps = 1; /* check auth cap only */ in handle_cap_grant()
3637 if (~cap->issued & newcaps) in handle_cap_grant()
3639 cap->issued = newcaps; in handle_cap_grant()
3640 cap->implemented |= newcaps; in handle_cap_grant()
3641 } else if (cap->issued == newcaps) { in handle_cap_grant()
3643 ceph_cap_string(cap->issued), ceph_cap_string(newcaps)); in handle_cap_grant()
3645 dout("grant: %s -> %s\n", ceph_cap_string(cap->issued), in handle_cap_grant()
3648 if (cap == ci->i_auth_cap && in handle_cap_grant()
3649 __ceph_caps_revoking_other(ci, cap, newcaps)) in handle_cap_grant()
3652 cap->issued = newcaps; in handle_cap_grant()
3653 cap->implemented |= newcaps; /* add bits only, to in handle_cap_grant()
3658 BUG_ON(cap->issued & ~cap->implemented); in handle_cap_grant()
3662 cap->mds_wanted = 0; in handle_cap_grant()
3663 if (cap == ci->i_auth_cap) in handle_cap_grant()
3664 check_caps = 1; /* check auth cap only */ in handle_cap_grant()
3678 if (ci->i_auth_cap == cap) { in handle_cap_grant()
3730 struct ceph_cap *cap) in handle_cap_flush_ack() argument
3791 dout(" mds%d still flushing cap on %p\n", in handle_cap_flush_ack()
3965 * Handle EXPORT from MDS. Cap is being migrated _from_ this mds to a
3967 * indicated by mseq), make note of the migrating cap bits for the
3978 struct ceph_cap *cap, *tcap, *new_cap = NULL; in handle_cap_export() local
4001 cap = __get_cap_for_mds(ci, mds); in handle_cap_export()
4002 if (!cap || cap->cap_id != le64_to_cpu(ex->cap_id)) in handle_cap_export()
4006 ceph_remove_cap(mdsc, cap, false); in handle_cap_export()
4011 * now we know we haven't received the cap import message yet in handle_cap_export()
4012 * because the exported cap still exist. in handle_cap_export()
4015 issued = cap->issued; in handle_cap_export()
4016 if (issued != cap->implemented) in handle_cap_export()
4020 ceph_vinop(inode), mds, cap->seq, cap->mseq, in handle_cap_export()
4022 ceph_cap_string(cap->implemented)); in handle_cap_export()
4030 dout(" updating import cap %p mds%d\n", tcap, target); in handle_cap_export()
4036 if (cap == ci->i_auth_cap) { in handle_cap_export()
4041 ceph_remove_cap(mdsc, cap, false); in handle_cap_export()
4045 int flag = (cap == ci->i_auth_cap) ? CEPH_CAP_FLAG_AUTH : 0; in handle_cap_export()
4058 ceph_remove_cap(mdsc, cap, false); in handle_cap_export()
4100 * Handle cap IMPORT.
4111 struct ceph_cap *cap, *ocap, *new_cap = NULL; in handle_cap_import() local
4134 cap = __get_cap_for_mds(ci, mds); in handle_cap_import()
4135 if (!cap) { in handle_cap_import()
4142 cap = new_cap; in handle_cap_import()
4158 dout(" remove export cap %p mds%d flags %d\n", in handle_cap_import()
4175 *target_cap = cap; in handle_cap_import()
4228 * based on the cap op.
4236 struct ceph_cap *cap; in ceph_handle_caps() local
4358 dout(" mds%d seq %lld cap seq %u\n", session->s_mds, session->s_seq, in ceph_handle_caps()
4377 /* these will work even if we don't have a cap yet */ in ceph_handle_caps()
4405 &cap, &extra_info.issued); in ceph_handle_caps()
4406 handle_cap_grant(inode, session, cap, in ceph_handle_caps()
4413 /* the rest require a cap */ in ceph_handle_caps()
4415 cap = __get_cap_for_mds(ceph_inode(inode), session->s_mds); in ceph_handle_caps()
4416 if (!cap) { in ceph_handle_caps()
4417 dout(" no cap on %p ino %llx.%llx from mds%d\n", in ceph_handle_caps()
4438 handle_cap_grant(inode, session, cap, in ceph_handle_caps()
4444 h, session, cap); in ceph_handle_caps()
4457 pr_err("ceph_handle_caps: unknown cap op %d %s\n", op, in ceph_handle_caps()
4479 * send any cap release message to try to move things in ceph_handle_caps()
4481 * cap). in ceph_handle_caps()
4484 cap = ceph_get_cap(mdsc, NULL); in ceph_handle_caps()
4485 cap->cap_ino = vino.ino; in ceph_handle_caps()
4486 cap->queue_release = 1; in ceph_handle_caps()
4487 cap->cap_id = le64_to_cpu(h->cap_id); in ceph_handle_caps()
4488 cap->mseq = mseq; in ceph_handle_caps()
4489 cap->seq = seq; in ceph_handle_caps()
4490 cap->issue_seq = seq; in ceph_handle_caps()
4492 __ceph_queue_cap_release(session, cap); in ceph_handle_caps()
4505 * Delayed work handler to process end of delayed cap release LRU list.
4688 * Helpers for embedding cap and dentry lease releases into mds
4699 struct ceph_cap *cap; in ceph_encode_inode_release() local
4715 cap = __get_cap_for_mds(ci, mds); in ceph_encode_inode_release()
4716 if (cap && __cap_is_valid(cap)) { in ceph_encode_inode_release()
4717 unless &= cap->issued; in ceph_encode_inode_release()
4729 if (force || (cap->issued & drop)) { in ceph_encode_inode_release()
4730 if (cap->issued & drop) { in ceph_encode_inode_release()
4732 dout("encode_inode_release %p cap %p " in ceph_encode_inode_release()
4733 "%s -> %s, wanted %s -> %s\n", inode, cap, in ceph_encode_inode_release()
4734 ceph_cap_string(cap->issued), in ceph_encode_inode_release()
4735 ceph_cap_string(cap->issued & ~drop), in ceph_encode_inode_release()
4736 ceph_cap_string(cap->mds_wanted), in ceph_encode_inode_release()
4739 cap->issued &= ~drop; in ceph_encode_inode_release()
4740 cap->implemented &= ~drop; in ceph_encode_inode_release()
4741 cap->mds_wanted = wanted; in ceph_encode_inode_release()
4742 if (cap == ci->i_auth_cap && in ceph_encode_inode_release()
4746 dout("encode_inode_release %p cap %p %s" in ceph_encode_inode_release()
4747 " (force)\n", inode, cap, in ceph_encode_inode_release()
4748 ceph_cap_string(cap->issued)); in ceph_encode_inode_release()
4752 rel->cap_id = cpu_to_le64(cap->cap_id); in ceph_encode_inode_release()
4753 rel->seq = cpu_to_le32(cap->seq); in ceph_encode_inode_release()
4754 rel->issue_seq = cpu_to_le32(cap->issue_seq); in ceph_encode_inode_release()
4755 rel->mseq = cpu_to_le32(cap->mseq); in ceph_encode_inode_release()
4756 rel->caps = cpu_to_le32(cap->implemented); in ceph_encode_inode_release()
4757 rel->wanted = cpu_to_le32(cap->mds_wanted); in ceph_encode_inode_release()
4763 dout("encode_inode_release %p cap %p %s (noop)\n", in ceph_encode_inode_release()
4764 inode, cap, ceph_cap_string(cap->issued)); in ceph_encode_inode_release()
4857 int ceph_purge_inode_cap(struct inode *inode, struct ceph_cap *cap, bool *invalidate) in ceph_purge_inode_cap() argument
4868 dout("removing cap %p, ci is %p, inode is %p\n", in ceph_purge_inode_cap()
4869 cap, ci, &ci->netfs.inode); in ceph_purge_inode_cap()
4871 is_auth = (cap == ci->i_auth_cap); in ceph_purge_inode_cap()
4872 __ceph_remove_cap(cap, false); in ceph_purge_inode_cap()
4885 /* trash all of the cap flushes for this inode */ in ceph_purge_inode_cap()