Lines Matching full:cap

28  * If the client holds a *_SHARED cap, the client has a coherent value
52 * Generate readable cap strings for debugging output.
135 struct ceph_cap *cap; in ceph_caps_finalize() local
139 cap = list_first_entry(&mdsc->caps_list, in ceph_caps_finalize()
141 list_del(&cap->caps_item); in ceph_caps_finalize()
142 kmem_cache_free(ceph_cap_cachep, cap); in ceph_caps_finalize()
168 struct ceph_cap *cap; in __ceph_unreserve_caps() local
178 cap = list_first_entry(&mdsc->caps_list, in __ceph_unreserve_caps()
180 list_del(&cap->caps_item); in __ceph_unreserve_caps()
181 kmem_cache_free(ceph_cap_cachep, cap); in __ceph_unreserve_caps()
204 struct ceph_cap *cap; in ceph_reserve_caps() local
229 cap = kmem_cache_alloc(ceph_cap_cachep, GFP_NOFS); in ceph_reserve_caps()
230 if (cap) { in ceph_reserve_caps()
231 list_add(&cap->caps_item, &newcaps); in ceph_reserve_caps()
329 struct ceph_cap *cap = NULL; in ceph_get_cap() local
331 /* temporary, until we do something about cap import/export */ in ceph_get_cap()
333 cap = kmem_cache_alloc(ceph_cap_cachep, GFP_NOFS); in ceph_get_cap()
334 if (cap) { in ceph_get_cap()
346 cap = list_first_entry(&mdsc->caps_list, in ceph_get_cap()
348 list_del(&cap->caps_item); in ceph_get_cap()
356 return cap; in ceph_get_cap()
372 cap = list_first_entry(&mdsc->caps_list, struct ceph_cap, caps_item); in ceph_get_cap()
373 list_del(&cap->caps_item); in ceph_get_cap()
378 return cap; in ceph_get_cap()
381 void ceph_put_cap(struct ceph_mds_client *mdsc, struct ceph_cap *cap) in ceph_put_cap() argument
385 cap, mdsc->caps_total_count, mdsc->caps_use_count, in ceph_put_cap()
395 kmem_cache_free(ceph_cap_cachep, cap); in ceph_put_cap()
398 list_add(&cap->caps_item, &mdsc->caps_list); in ceph_put_cap()
435 struct ceph_cap *cap; in __get_cap_for_mds() local
439 cap = rb_entry(n, struct ceph_cap, ci_node); in __get_cap_for_mds()
440 if (mds < cap->mds) in __get_cap_for_mds()
442 else if (mds > cap->mds) in __get_cap_for_mds()
445 return cap; in __get_cap_for_mds()
452 struct ceph_cap *cap; in ceph_get_cap_for_mds() local
455 cap = __get_cap_for_mds(ci, mds); in ceph_get_cap_for_mds()
457 return cap; in ceph_get_cap_for_mds()
468 struct ceph_cap *cap = NULL; in __insert_cap_node() local
472 cap = rb_entry(parent, struct ceph_cap, ci_node); in __insert_cap_node()
473 if (new->mds < cap->mds) in __insert_cap_node()
475 else if (new->mds > cap->mds) in __insert_cap_node()
486 * (re)set cap hold timeouts, which control the delayed release
487 * of unused caps back to the MDS. Should be called on cap use.
500 * (Re)queue cap at the end of the delayed cap release list.
528 * indicating we should send a cap message to flush dirty metadata
529 * asap, and move to the front of the delayed cap list.
544 * Cancel delayed work on cap.
560 static void __check_cap_issue(struct ceph_inode_info *ci, struct ceph_cap *cap, in __check_cap_issue() argument
579 * know what happened to this directory while we didn't have the cap. in __check_cap_issue()
627 * it is < 0. (This is so we can atomically add the cap and add an
638 struct ceph_cap *cap; in ceph_add_cap() local
645 dout("add_cap %p mds%d cap %llx %s seq %d\n", inode, in ceph_add_cap()
650 cap = __get_cap_for_mds(ci, mds); in ceph_add_cap()
651 if (!cap) { in ceph_add_cap()
652 cap = *new_cap; in ceph_add_cap()
655 cap->issued = 0; in ceph_add_cap()
656 cap->implemented = 0; in ceph_add_cap()
657 cap->mds = mds; in ceph_add_cap()
658 cap->mds_wanted = 0; in ceph_add_cap()
659 cap->mseq = 0; in ceph_add_cap()
661 cap->ci = ci; in ceph_add_cap()
662 __insert_cap_node(ci, cap); in ceph_add_cap()
664 /* add to session cap list */ in ceph_add_cap()
665 cap->session = session; in ceph_add_cap()
667 list_add_tail(&cap->session_caps, &session->s_caps); in ceph_add_cap()
673 list_move_tail(&cap->session_caps, &session->s_caps); in ceph_add_cap()
676 if (cap->cap_gen < gen) in ceph_add_cap()
677 cap->issued = cap->implemented = CEPH_CAP_PIN; in ceph_add_cap()
680 * auth mds of the inode changed. we received the cap export in ceph_add_cap()
681 * message, but still haven't received the cap import message. in ceph_add_cap()
682 * handle_cap_export() updated the new auth MDS' cap. in ceph_add_cap()
684 * "ceph_seq_cmp(seq, cap->seq) <= 0" means we are processing in ceph_add_cap()
685 * a message that was send before the cap import message. So in ceph_add_cap()
688 if (ceph_seq_cmp(seq, cap->seq) <= 0) { in ceph_add_cap()
689 WARN_ON(cap != ci->i_auth_cap); in ceph_add_cap()
690 WARN_ON(cap->cap_id != cap_id); in ceph_add_cap()
691 seq = cap->seq; in ceph_add_cap()
692 mseq = cap->mseq; in ceph_add_cap()
693 issued |= cap->issued; in ceph_add_cap()
714 __check_cap_issue(ci, cap, issued); in ceph_add_cap()
734 ci->i_auth_cap->session != cap->session) in ceph_add_cap()
735 change_auth_cap_ses(ci, cap->session); in ceph_add_cap()
736 ci->i_auth_cap = cap; in ceph_add_cap()
737 cap->mds_wanted = wanted; in ceph_add_cap()
740 WARN_ON(ci->i_auth_cap == cap); in ceph_add_cap()
743 dout("add_cap inode %p (%llx.%llx) cap %p %s now %s seq %d mds%d\n", in ceph_add_cap()
744 inode, ceph_vinop(inode), cap, ceph_cap_string(issued), in ceph_add_cap()
745 ceph_cap_string(issued|cap->issued), seq, mds); in ceph_add_cap()
746 cap->cap_id = cap_id; in ceph_add_cap()
747 cap->issued = issued; in ceph_add_cap()
748 cap->implemented |= issued; in ceph_add_cap()
749 if (ceph_seq_cmp(mseq, cap->mseq) > 0) in ceph_add_cap()
750 cap->mds_wanted = wanted; in ceph_add_cap()
752 cap->mds_wanted |= wanted; in ceph_add_cap()
753 cap->seq = seq; in ceph_add_cap()
754 cap->issue_seq = seq; in ceph_add_cap()
755 cap->mseq = mseq; in ceph_add_cap()
756 cap->cap_gen = gen; in ceph_add_cap()
761 * Return true if cap has not timed out and belongs to the current
765 static int __cap_is_valid(struct ceph_cap *cap) in __cap_is_valid() argument
770 gen = atomic_read(&cap->session->s_cap_gen); in __cap_is_valid()
771 ttl = cap->session->s_cap_ttl; in __cap_is_valid()
773 if (cap->cap_gen < gen || time_after_eq(jiffies, ttl)) { in __cap_is_valid()
774 dout("__cap_is_valid %p cap %p issued %s " in __cap_is_valid()
775 "but STALE (gen %u vs %u)\n", &cap->ci->netfs.inode, in __cap_is_valid()
776 cap, ceph_cap_string(cap->issued), cap->cap_gen, gen); in __cap_is_valid()
784 * Return set of valid cap bits issued to us. Note that caps time
791 struct ceph_cap *cap; in __ceph_caps_issued() local
797 cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_caps_issued()
798 if (!__cap_is_valid(cap)) in __ceph_caps_issued()
800 dout("__ceph_caps_issued %p cap %p issued %s\n", in __ceph_caps_issued()
801 &ci->netfs.inode, cap, ceph_cap_string(cap->issued)); in __ceph_caps_issued()
802 have |= cap->issued; in __ceph_caps_issued()
804 *implemented |= cap->implemented; in __ceph_caps_issued()
812 cap = ci->i_auth_cap; in __ceph_caps_issued()
813 have &= ~cap->implemented | cap->issued; in __ceph_caps_issued()
819 * Get cap bits issued by caps other than @ocap
824 struct ceph_cap *cap; in __ceph_caps_issued_other() local
828 cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_caps_issued_other()
829 if (cap == ocap) in __ceph_caps_issued_other()
831 if (!__cap_is_valid(cap)) in __ceph_caps_issued_other()
833 have |= cap->issued; in __ceph_caps_issued_other()
839 * Move a cap to the end of the LRU (oldest caps at list head, newest
842 static void __touch_cap(struct ceph_cap *cap) in __touch_cap() argument
844 struct ceph_mds_session *s = cap->session; in __touch_cap()
848 dout("__touch_cap %p cap %p mds%d\n", &cap->ci->netfs.inode, cap, in __touch_cap()
850 list_move_tail(&cap->session_caps, &s->s_caps); in __touch_cap()
852 dout("__touch_cap %p cap %p mds%d NOP, iterating over caps\n", in __touch_cap()
853 &cap->ci->netfs.inode, cap, s->s_mds); in __touch_cap()
859 * Check if we hold the given mask. If so, move the cap(s) to the
865 struct ceph_cap *cap; in __ceph_caps_issued_mask() local
878 cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_caps_issued_mask()
879 if (!__cap_is_valid(cap)) in __ceph_caps_issued_mask()
881 if ((cap->issued & mask) == mask) { in __ceph_caps_issued_mask()
882 dout("__ceph_caps_issued_mask ino 0x%llx cap %p issued %s" in __ceph_caps_issued_mask()
883 " (mask %s)\n", ceph_ino(&ci->netfs.inode), cap, in __ceph_caps_issued_mask()
884 ceph_cap_string(cap->issued), in __ceph_caps_issued_mask()
887 __touch_cap(cap); in __ceph_caps_issued_mask()
892 have |= cap->issued; in __ceph_caps_issued_mask()
896 ceph_cap_string(cap->issued), in __ceph_caps_issued_mask()
902 __touch_cap(cap); in __ceph_caps_issued_mask()
905 cap = rb_entry(q, struct ceph_cap, in __ceph_caps_issued_mask()
907 if (!__cap_is_valid(cap)) in __ceph_caps_issued_mask()
909 if (cap->issued & mask) in __ceph_caps_issued_mask()
910 __touch_cap(cap); in __ceph_caps_issued_mask()
940 struct ceph_cap *cap; in __ceph_caps_revoking_other() local
944 cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_caps_revoking_other()
945 if (cap != ocap && in __ceph_caps_revoking_other()
946 (cap->implemented & ~cap->issued & mask)) in __ceph_caps_revoking_other()
1049 * wanted, by virtue of open file modes AND cap refs (buffered/cached data)
1071 struct ceph_cap *cap; in __ceph_caps_mds_wanted() local
1076 cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_caps_mds_wanted()
1077 if (check && !__cap_is_valid(cap)) in __ceph_caps_mds_wanted()
1079 if (cap == ci->i_auth_cap) in __ceph_caps_mds_wanted()
1080 mds_wanted |= cap->mds_wanted; in __ceph_caps_mds_wanted()
1082 mds_wanted |= (cap->mds_wanted & ~CEPH_CAP_ANY_FILE_WR); in __ceph_caps_mds_wanted()
1100 * Remove a cap. Take steps to deal with a racing iterate_session_caps.
1105 void __ceph_remove_cap(struct ceph_cap *cap, bool queue_release) in __ceph_remove_cap() argument
1107 struct ceph_mds_session *session = cap->session; in __ceph_remove_cap()
1108 struct ceph_inode_info *ci = cap->ci; in __ceph_remove_cap()
1114 dout("%s: cap inode is NULL\n", __func__); in __ceph_remove_cap()
1120 dout("__ceph_remove_cap %p from %p\n", cap, &ci->netfs.inode); in __ceph_remove_cap()
1124 /* remove from inode's cap rbtree, and clear auth cap */ in __ceph_remove_cap()
1125 rb_erase(&cap->ci_node, &ci->i_caps); in __ceph_remove_cap()
1126 if (ci->i_auth_cap == cap) in __ceph_remove_cap()
1131 if (session->s_cap_iterator == cap) { in __ceph_remove_cap()
1132 /* not yet, we are iterating over this very cap */ in __ceph_remove_cap()
1134 cap, cap->session); in __ceph_remove_cap()
1136 list_del_init(&cap->session_caps); in __ceph_remove_cap()
1139 cap->session = NULL; in __ceph_remove_cap()
1143 cap->ci = NULL; in __ceph_remove_cap()
1151 cap->cap_gen == atomic_read(&session->s_cap_gen))) { in __ceph_remove_cap()
1152 cap->queue_release = 1; in __ceph_remove_cap()
1154 __ceph_queue_cap_release(session, cap); in __ceph_remove_cap()
1158 cap->queue_release = 0; in __ceph_remove_cap()
1160 cap->cap_ino = ci->i_vino.ino; in __ceph_remove_cap()
1165 ceph_put_cap(mdsc, cap); in __ceph_remove_cap()
1179 void ceph_remove_cap(struct ceph_cap *cap, bool queue_release) in ceph_remove_cap() argument
1181 struct ceph_inode_info *ci = cap->ci; in ceph_remove_cap()
1186 dout("%s: cap inode is NULL\n", __func__); in ceph_remove_cap()
1193 WARN_ON_ONCE(ci->i_auth_cap == cap && in ceph_remove_cap()
1198 __ceph_remove_cap(cap, queue_release); in ceph_remove_cap()
1221 * cap struct size + flock buffer size + inline version + inline data size +
1227 /* Marshal up the cap msg to the MDS */
1316 * Queue cap releases when an inode is dropped from our cache.
1327 struct ceph_cap *cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_remove_caps() local
1329 ceph_remove_cap(cap, true); in __ceph_remove_caps()
1335 * Prepare to send a cap message to an MDS. Update the cap state, and populate
1337 * be done under the i_ceph_lock to guard against changes to cap state.
1342 static void __prep_cap(struct cap_msg_args *arg, struct ceph_cap *cap, in __prep_cap() argument
1346 struct ceph_inode_info *ci = cap->ci; in __prep_cap()
1352 held = cap->issued | cap->implemented; in __prep_cap()
1353 revoking = cap->implemented & ~cap->issued; in __prep_cap()
1356 dout("%s %p cap %p session %p %s -> %s (revoking %s)\n", in __prep_cap()
1357 __func__, inode, cap, cap->session, in __prep_cap()
1364 cap->issued &= retain; /* drop bits we don't want */ in __prep_cap()
1370 arg->wake = cap->implemented & ~cap->issued; in __prep_cap()
1371 cap->implemented &= cap->issued | used; in __prep_cap()
1372 cap->mds_wanted = want; in __prep_cap()
1374 arg->session = cap->session; in __prep_cap()
1376 arg->cid = cap->cap_id; in __prep_cap()
1384 if (cap == ci->i_auth_cap) { in __prep_cap()
1407 arg->caps = cap->implemented; in __prep_cap()
1411 arg->seq = cap->seq; in __prep_cap()
1412 arg->issue_seq = cap->issue_seq; in __prep_cap()
1413 arg->mseq = cap->mseq; in __prep_cap()
1437 * Send a cap msg on the given inode.
1448 pr_err("error allocating cap msg: ino (%llx.%llx) flushing %s tid %llu, requeuing cap.\n", in __send_cap()
1580 struct ceph_cap *cap = ci->i_auth_cap; in __ceph_flush_snaps() local
1584 if (!(cap && cap->session == session)) { in __ceph_flush_snaps()
1585 dout("__flush_snaps %p auth cap %p not mds%d, " in __ceph_flush_snaps()
1586 "stop\n", inode, cap, session->s_mds); in __ceph_flush_snaps()
1610 ret = __send_flush_snap(inode, session, capsnap, cap->mseq, in __ceph_flush_snaps()
1613 pr_err("__flush_snaps: error sending cap flushsnap, " in __ceph_flush_snaps()
1641 dout(" no auth cap (migrating?), doing nothing\n"); in ceph_flush_snaps()
1695 "but no auth cap (session was closed?)\n", in __ceph_mark_dirty_caps()
1715 dout(" inode %p now dirty snapc %p auth cap %p\n", in __ceph_mark_dirty_caps()
1766 * Remove cap_flush from the mdsc's or inode's flushing cap list.
1897 * CHECK_CAPS_AUTHONLY - we should only check the auth cap
1906 struct ceph_cap *cap; in ceph_check_caps() local
1958 * the exclusive cap. So that MDS does not end up in ceph_check_caps()
1959 * revoking the shared cap on every create/unlink in ceph_check_caps()
2019 cap = rb_entry(p, struct ceph_cap, ci_node); in ceph_check_caps()
2022 if (mds >= cap->mds || in ceph_check_caps()
2023 ((flags & CHECK_CAPS_AUTHONLY) && cap != ci->i_auth_cap)) in ceph_check_caps()
2027 * If we have an auth cap, we don't need to consider any in ceph_check_caps()
2031 if (ci->i_auth_cap && cap != ci->i_auth_cap) in ceph_check_caps()
2034 revoking = cap->implemented & ~cap->issued; in ceph_check_caps()
2035 dout(" mds%d cap %p used %s issued %s implemented %s revoking %s\n", in ceph_check_caps()
2036 cap->mds, cap, ceph_cap_string(cap_used), in ceph_check_caps()
2037 ceph_cap_string(cap->issued), in ceph_check_caps()
2038 ceph_cap_string(cap->implemented), in ceph_check_caps()
2041 if (cap == ci->i_auth_cap && in ceph_check_caps()
2042 (cap->issued & CEPH_CAP_FILE_WR)) { in ceph_check_caps()
2057 if (cap == ci->i_auth_cap) { in ceph_check_caps()
2072 ceph_cap_string(cap->implemented & ~cap->issued)); in ceph_check_caps()
2093 if (want & ~cap->mds_wanted) { in ceph_check_caps()
2094 if (want & ~(cap->mds_wanted | cap->issued)) in ceph_check_caps()
2096 if (!__cap_is_valid(cap)) in ceph_check_caps()
2101 if ((cap->issued & ~retain) == 0) in ceph_check_caps()
2106 session = ceph_get_mds_session(cap->session); in ceph_check_caps()
2109 * cap message */ in ceph_check_caps()
2110 if (cap == ci->i_auth_cap && in ceph_check_caps()
2121 if (cap == ci->i_auth_cap && ci->i_dirty_caps) { in ceph_check_caps()
2136 mds = cap->mds; /* remember mds, so we don't repeat */ in ceph_check_caps()
2138 __prep_cap(&arg, cap, CEPH_CAP_OP_UPDATE, mflags, cap_used, in ceph_check_caps()
2145 goto retry; /* retake i_ceph_lock and restart our cap scan. */ in ceph_check_caps()
2178 struct ceph_cap *cap = ci->i_auth_cap; in try_flush_caps() local
2180 struct ceph_mds_session *session = cap->session; in try_flush_caps()
2200 __prep_cap(&arg, cap, CEPH_CAP_OP_FLUSH, CEPH_CLIENT_CAPS_SYNC, in try_flush_caps()
2202 (cap->issued | cap->implemented), in try_flush_caps()
2449 struct ceph_cap *cap; in __kick_flushing_caps() local
2472 cap = ci->i_auth_cap; in __kick_flushing_caps()
2473 if (!(cap && cap->session == session)) { in __kick_flushing_caps()
2474 pr_err("%p auth cap %p not mds%d ???\n", in __kick_flushing_caps()
2475 inode, cap, session->s_mds); in __kick_flushing_caps()
2484 dout("kick_flushing_caps %p cap %p tid %llu %s\n", in __kick_flushing_caps()
2485 inode, cap, cf->tid, ceph_cap_string(cf->caps)); in __kick_flushing_caps()
2486 __prep_cap(&arg, cap, CEPH_CAP_OP_FLUSH, in __kick_flushing_caps()
2491 (cap->issued | cap->implemented), in __kick_flushing_caps()
2506 ret = __send_flush_snap(inode, session, capsnap, cap->mseq, in __kick_flushing_caps()
2510 "cap flushsnap, ino (%llx.%llx) " in __kick_flushing_caps()
2527 struct ceph_cap *cap; in ceph_early_kick_flushing_caps() local
2538 cap = ci->i_auth_cap; in ceph_early_kick_flushing_caps()
2539 if (!(cap && cap->session == session)) { in ceph_early_kick_flushing_caps()
2540 pr_err("%p auth cap %p not mds%d ???\n", in ceph_early_kick_flushing_caps()
2541 &ci->netfs.inode, cap, session->s_mds); in ceph_early_kick_flushing_caps()
2548 * if flushing caps were revoked, we re-send the cap flush in ceph_early_kick_flushing_caps()
2550 * the cap flush message before issuing the flushing caps to in ceph_early_kick_flushing_caps()
2553 if ((cap->issued & ci->i_flushing_caps) != in ceph_early_kick_flushing_caps()
2556 * numbers. make sure sequence numbers in cap flush in ceph_early_kick_flushing_caps()
2558 cap->seq = 0; in ceph_early_kick_flushing_caps()
2559 cap->issue_seq = 0; in ceph_early_kick_flushing_caps()
2560 cap->mseq = 0; in ceph_early_kick_flushing_caps()
2575 struct ceph_cap *cap; in ceph_kick_flushing_caps() local
2588 cap = ci->i_auth_cap; in ceph_kick_flushing_caps()
2589 if (!(cap && cap->session == session)) { in ceph_kick_flushing_caps()
2590 pr_err("%p auth cap %p not mds%d ???\n", in ceph_kick_flushing_caps()
2591 &ci->netfs.inode, cap, session->s_mds); in ceph_kick_flushing_caps()
2607 struct ceph_cap *cap = ci->i_auth_cap; in ceph_kick_flushing_inode_caps() local
2618 &cap->session->s_cap_flushing); in ceph_kick_flushing_inode_caps()
2662 * Try to grab cap references. Specify those refs we @want, and the
2894 * Wait for caps, and take cap references. If we can't get a WR cap
3003 * drop cap refs first because getattr while in ceph_get_caps()
3027 * Take cap refs. Caller must already know we hold at least one ref
3068 * Release cap refs.
3070 * If we released the last ref on any given cap, call ceph_check_caps
3073 * If we are releasing a WR cap (from a sync write), finalize any affected
3227 * auth cap in the case of a forced unmount. in ceph_put_wrbuffer_cap_refs()
3318 * Handle a cap GRANT message from the MDS. (Note that a GRANT may
3319 * actually be a revocation if it specifies a smaller cap set.)
3325 struct ceph_cap *cap, in handle_cap_grant() argument
3339 bool was_stale = cap->cap_gen < atomic_read(&session->s_cap_gen); in handle_cap_grant()
3347 dout("handle_cap_grant inode %p cap %p mds%d seq %d %s\n", in handle_cap_grant()
3348 inode, cap, session->s_mds, seq, ceph_cap_string(newcaps)); in handle_cap_grant()
3359 ((cap->issued & ~newcaps) & CEPH_CAP_FILE_CACHE) && in handle_cap_grant()
3373 cap->issued = cap->implemented = CEPH_CAP_PIN; in handle_cap_grant()
3376 * auth mds of the inode changed. we received the cap export message, in handle_cap_grant()
3377 * but still haven't received the cap import message. handle_cap_export in handle_cap_grant()
3378 * updated the new auth MDS' cap. in handle_cap_grant()
3380 * "ceph_seq_cmp(seq, cap->seq) <= 0" means we are processing a message in handle_cap_grant()
3381 * that was sent before the cap import message. So don't remove caps. in handle_cap_grant()
3383 if (ceph_seq_cmp(seq, cap->seq) <= 0) { in handle_cap_grant()
3384 WARN_ON(cap != ci->i_auth_cap); in handle_cap_grant()
3385 WARN_ON(cap->cap_id != le64_to_cpu(grant->cap_id)); in handle_cap_grant()
3386 seq = cap->seq; in handle_cap_grant()
3387 newcaps |= cap->issued; in handle_cap_grant()
3391 cap->cap_gen = atomic_read(&session->s_cap_gen); in handle_cap_grant()
3392 cap->seq = seq; in handle_cap_grant()
3394 __check_cap_issue(ci, cap, newcaps); in handle_cap_grant()
3478 if (ci->i_auth_cap == cap && (newcaps & CEPH_CAP_ANY_FILE_WR)) { in handle_cap_grant()
3491 /* check cap bits */ in handle_cap_grant()
3501 (wanted & ~(cap->mds_wanted | newcaps))) { in handle_cap_grant()
3503 * If mds is importing cap, prior cap messages that update in handle_cap_grant()
3506 * We don't send cap message to update 'wanted' if what we in handle_cap_grant()
3507 * want are already issued. If mds revokes caps, cap message in handle_cap_grant()
3516 if (cap->issued & ~newcaps) { in handle_cap_grant()
3517 int revoking = cap->issued & ~newcaps; in handle_cap_grant()
3520 ceph_cap_string(cap->issued), in handle_cap_grant()
3530 else if (cap == ci->i_auth_cap) in handle_cap_grant()
3531 check_caps = 1; /* check auth cap only */ in handle_cap_grant()
3535 if (~cap->issued & newcaps) in handle_cap_grant()
3537 cap->issued = newcaps; in handle_cap_grant()
3538 cap->implemented |= newcaps; in handle_cap_grant()
3539 } else if (cap->issued == newcaps) { in handle_cap_grant()
3541 ceph_cap_string(cap->issued), ceph_cap_string(newcaps)); in handle_cap_grant()
3543 dout("grant: %s -> %s\n", ceph_cap_string(cap->issued), in handle_cap_grant()
3546 if (cap == ci->i_auth_cap && in handle_cap_grant()
3547 __ceph_caps_revoking_other(ci, cap, newcaps)) in handle_cap_grant()
3550 cap->issued = newcaps; in handle_cap_grant()
3551 cap->implemented |= newcaps; /* add bits only, to in handle_cap_grant()
3556 BUG_ON(cap->issued & ~cap->implemented); in handle_cap_grant()
3567 if (ci->i_auth_cap == cap) { in handle_cap_grant()
3620 struct ceph_cap *cap) in handle_cap_flush_ack() argument
3681 dout(" mds%d still flushing cap on %p\n", in handle_cap_flush_ack()
3846 * Handle EXPORT from MDS. Cap is being migrated _from_ this mds to a
3848 * indicated by mseq), make note of the migrating cap bits for the
3859 struct ceph_cap *cap, *tcap, *new_cap = NULL; in handle_cap_export() local
3882 cap = __get_cap_for_mds(ci, mds); in handle_cap_export()
3883 if (!cap || cap->cap_id != le64_to_cpu(ex->cap_id)) in handle_cap_export()
3887 ceph_remove_cap(cap, false); in handle_cap_export()
3892 * now we know we haven't received the cap import message yet in handle_cap_export()
3893 * because the exported cap still exist. in handle_cap_export()
3896 issued = cap->issued; in handle_cap_export()
3897 if (issued != cap->implemented) in handle_cap_export()
3901 ceph_vinop(inode), mds, cap->seq, cap->mseq, in handle_cap_export()
3903 ceph_cap_string(cap->implemented)); in handle_cap_export()
3911 dout(" updating import cap %p mds%d\n", tcap, target); in handle_cap_export()
3917 if (cap == ci->i_auth_cap) { in handle_cap_export()
3922 ceph_remove_cap(cap, false); in handle_cap_export()
3926 int flag = (cap == ci->i_auth_cap) ? CEPH_CAP_FLAG_AUTH : 0; in handle_cap_export()
3939 ceph_remove_cap(cap, false); in handle_cap_export()
3981 * Handle cap IMPORT.
3992 struct ceph_cap *cap, *ocap, *new_cap = NULL; in handle_cap_import() local
4015 cap = __get_cap_for_mds(ci, mds); in handle_cap_import()
4016 if (!cap) { in handle_cap_import()
4023 cap = new_cap; in handle_cap_import()
4039 dout(" remove export cap %p mds%d flags %d\n", in handle_cap_import()
4056 *target_cap = cap; in handle_cap_import()
4063 * based on the cap op.
4071 struct ceph_cap *cap; in ceph_handle_caps() local
4184 dout(" mds%d seq %lld cap seq %u\n", session->s_mds, session->s_seq, in ceph_handle_caps()
4191 cap = ceph_get_cap(mdsc, NULL); in ceph_handle_caps()
4192 cap->cap_ino = vino.ino; in ceph_handle_caps()
4193 cap->queue_release = 1; in ceph_handle_caps()
4194 cap->cap_id = le64_to_cpu(h->cap_id); in ceph_handle_caps()
4195 cap->mseq = mseq; in ceph_handle_caps()
4196 cap->seq = seq; in ceph_handle_caps()
4197 cap->issue_seq = seq; in ceph_handle_caps()
4199 __ceph_queue_cap_release(session, cap); in ceph_handle_caps()
4206 /* these will work even if we don't have a cap yet */ in ceph_handle_caps()
4230 &cap, &extra_info.issued); in ceph_handle_caps()
4231 handle_cap_grant(inode, session, cap, in ceph_handle_caps()
4238 /* the rest require a cap */ in ceph_handle_caps()
4240 cap = __get_cap_for_mds(ceph_inode(inode), session->s_mds); in ceph_handle_caps()
4241 if (!cap) { in ceph_handle_caps()
4242 dout(" no cap on %p ino %llx.%llx from mds%d\n", in ceph_handle_caps()
4255 handle_cap_grant(inode, session, cap, in ceph_handle_caps()
4261 h, session, cap); in ceph_handle_caps()
4273 pr_err("ceph_handle_caps: unknown cap op %d %s\n", op, in ceph_handle_caps()
4287 * send any cap release message to try to move things in ceph_handle_caps()
4289 * cap). in ceph_handle_caps()
4301 * Delayed work handler to process end of delayed cap release LRU list.
4484 * Helpers for embedding cap and dentry lease releases into mds
4495 struct ceph_cap *cap; in ceph_encode_inode_release() local
4511 cap = __get_cap_for_mds(ci, mds); in ceph_encode_inode_release()
4512 if (cap && __cap_is_valid(cap)) { in ceph_encode_inode_release()
4513 unless &= cap->issued; in ceph_encode_inode_release()
4525 if (force || (cap->issued & drop)) { in ceph_encode_inode_release()
4526 if (cap->issued & drop) { in ceph_encode_inode_release()
4528 dout("encode_inode_release %p cap %p " in ceph_encode_inode_release()
4529 "%s -> %s, wanted %s -> %s\n", inode, cap, in ceph_encode_inode_release()
4530 ceph_cap_string(cap->issued), in ceph_encode_inode_release()
4531 ceph_cap_string(cap->issued & ~drop), in ceph_encode_inode_release()
4532 ceph_cap_string(cap->mds_wanted), in ceph_encode_inode_release()
4535 cap->issued &= ~drop; in ceph_encode_inode_release()
4536 cap->implemented &= ~drop; in ceph_encode_inode_release()
4537 cap->mds_wanted = wanted; in ceph_encode_inode_release()
4538 if (cap == ci->i_auth_cap && in ceph_encode_inode_release()
4542 dout("encode_inode_release %p cap %p %s" in ceph_encode_inode_release()
4543 " (force)\n", inode, cap, in ceph_encode_inode_release()
4544 ceph_cap_string(cap->issued)); in ceph_encode_inode_release()
4548 rel->cap_id = cpu_to_le64(cap->cap_id); in ceph_encode_inode_release()
4549 rel->seq = cpu_to_le32(cap->seq); in ceph_encode_inode_release()
4550 rel->issue_seq = cpu_to_le32(cap->issue_seq); in ceph_encode_inode_release()
4551 rel->mseq = cpu_to_le32(cap->mseq); in ceph_encode_inode_release()
4552 rel->caps = cpu_to_le32(cap->implemented); in ceph_encode_inode_release()
4553 rel->wanted = cpu_to_le32(cap->mds_wanted); in ceph_encode_inode_release()
4559 dout("encode_inode_release %p cap %p %s (noop)\n", in ceph_encode_inode_release()
4560 inode, cap, ceph_cap_string(cap->issued)); in ceph_encode_inode_release()
4632 int ceph_purge_inode_cap(struct inode *inode, struct ceph_cap *cap, bool *invalidate) in ceph_purge_inode_cap() argument
4643 dout("removing cap %p, ci is %p, inode is %p\n", in ceph_purge_inode_cap()
4644 cap, ci, &ci->netfs.inode); in ceph_purge_inode_cap()
4646 is_auth = (cap == ci->i_auth_cap); in ceph_purge_inode_cap()
4647 __ceph_remove_cap(cap, false); in ceph_purge_inode_cap()
4660 /* trash all of the cap flushes for this inode */ in ceph_purge_inode_cap()