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()
760 * Return true if cap has not timed out and belongs to the current
764 static int __cap_is_valid(struct ceph_cap *cap) in __cap_is_valid() argument
769 gen = atomic_read(&cap->session->s_cap_gen); in __cap_is_valid()
770 ttl = cap->session->s_cap_ttl; in __cap_is_valid()
772 if (cap->cap_gen < gen || time_after_eq(jiffies, ttl)) { in __cap_is_valid()
773 dout("__cap_is_valid %p cap %p issued %s " in __cap_is_valid()
774 "but STALE (gen %u vs %u)\n", &cap->ci->vfs_inode, in __cap_is_valid()
775 cap, ceph_cap_string(cap->issued), cap->cap_gen, gen); in __cap_is_valid()
783 * Return set of valid cap bits issued to us. Note that caps time
790 struct ceph_cap *cap; in __ceph_caps_issued() local
796 cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_caps_issued()
797 if (!__cap_is_valid(cap)) in __ceph_caps_issued()
799 dout("__ceph_caps_issued %p cap %p issued %s\n", in __ceph_caps_issued()
800 &ci->vfs_inode, cap, ceph_cap_string(cap->issued)); in __ceph_caps_issued()
801 have |= cap->issued; in __ceph_caps_issued()
803 *implemented |= cap->implemented; in __ceph_caps_issued()
811 cap = ci->i_auth_cap; in __ceph_caps_issued()
812 have &= ~cap->implemented | cap->issued; in __ceph_caps_issued()
818 * Get cap bits issued by caps other than @ocap
823 struct ceph_cap *cap; in __ceph_caps_issued_other() local
827 cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_caps_issued_other()
828 if (cap == ocap) in __ceph_caps_issued_other()
830 if (!__cap_is_valid(cap)) in __ceph_caps_issued_other()
832 have |= cap->issued; in __ceph_caps_issued_other()
838 * Move a cap to the end of the LRU (oldest caps at list head, newest
841 static void __touch_cap(struct ceph_cap *cap) in __touch_cap() argument
843 struct ceph_mds_session *s = cap->session; in __touch_cap()
847 dout("__touch_cap %p cap %p mds%d\n", &cap->ci->vfs_inode, cap, in __touch_cap()
849 list_move_tail(&cap->session_caps, &s->s_caps); in __touch_cap()
851 dout("__touch_cap %p cap %p mds%d NOP, iterating over caps\n", in __touch_cap()
852 &cap->ci->vfs_inode, cap, s->s_mds); in __touch_cap()
858 * Check if we hold the given mask. If so, move the cap(s) to the
864 struct ceph_cap *cap; in __ceph_caps_issued_mask() local
877 cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_caps_issued_mask()
878 if (!__cap_is_valid(cap)) in __ceph_caps_issued_mask()
880 if ((cap->issued & mask) == mask) { in __ceph_caps_issued_mask()
881 dout("__ceph_caps_issued_mask ino 0x%llx cap %p issued %s" in __ceph_caps_issued_mask()
882 " (mask %s)\n", ceph_ino(&ci->vfs_inode), cap, in __ceph_caps_issued_mask()
883 ceph_cap_string(cap->issued), in __ceph_caps_issued_mask()
886 __touch_cap(cap); in __ceph_caps_issued_mask()
891 have |= cap->issued; in __ceph_caps_issued_mask()
895 ceph_cap_string(cap->issued), in __ceph_caps_issued_mask()
901 __touch_cap(cap); in __ceph_caps_issued_mask()
904 cap = rb_entry(q, struct ceph_cap, in __ceph_caps_issued_mask()
906 if (!__cap_is_valid(cap)) in __ceph_caps_issued_mask()
908 if (cap->issued & mask) in __ceph_caps_issued_mask()
909 __touch_cap(cap); in __ceph_caps_issued_mask()
939 struct ceph_cap *cap; in __ceph_caps_revoking_other() local
943 cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_caps_revoking_other()
944 if (cap != ocap && in __ceph_caps_revoking_other()
945 (cap->implemented & ~cap->issued & mask)) in __ceph_caps_revoking_other()
1048 * wanted, by virtue of open file modes AND cap refs (buffered/cached data)
1070 struct ceph_cap *cap; in __ceph_caps_mds_wanted() local
1075 cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_caps_mds_wanted()
1076 if (check && !__cap_is_valid(cap)) in __ceph_caps_mds_wanted()
1078 if (cap == ci->i_auth_cap) in __ceph_caps_mds_wanted()
1079 mds_wanted |= cap->mds_wanted; in __ceph_caps_mds_wanted()
1081 mds_wanted |= (cap->mds_wanted & ~CEPH_CAP_ANY_FILE_WR); in __ceph_caps_mds_wanted()
1099 * Remove a cap. Take steps to deal with a racing iterate_session_caps.
1104 void __ceph_remove_cap(struct ceph_cap *cap, bool queue_release) in __ceph_remove_cap() argument
1106 struct ceph_mds_session *session = cap->session; in __ceph_remove_cap()
1107 struct ceph_inode_info *ci = cap->ci; in __ceph_remove_cap()
1113 dout("%s: cap inode is NULL\n", __func__); in __ceph_remove_cap()
1119 dout("__ceph_remove_cap %p from %p\n", cap, &ci->vfs_inode); in __ceph_remove_cap()
1123 /* remove from inode's cap rbtree, and clear auth cap */ in __ceph_remove_cap()
1124 rb_erase(&cap->ci_node, &ci->i_caps); in __ceph_remove_cap()
1125 if (ci->i_auth_cap == cap) in __ceph_remove_cap()
1130 if (session->s_cap_iterator == cap) { in __ceph_remove_cap()
1131 /* not yet, we are iterating over this very cap */ in __ceph_remove_cap()
1133 cap, cap->session); in __ceph_remove_cap()
1135 list_del_init(&cap->session_caps); in __ceph_remove_cap()
1138 cap->session = NULL; in __ceph_remove_cap()
1142 cap->ci = NULL; in __ceph_remove_cap()
1150 cap->cap_gen == atomic_read(&session->s_cap_gen))) { in __ceph_remove_cap()
1151 cap->queue_release = 1; in __ceph_remove_cap()
1153 __ceph_queue_cap_release(session, cap); in __ceph_remove_cap()
1157 cap->queue_release = 0; in __ceph_remove_cap()
1159 cap->cap_ino = ci->i_vino.ino; in __ceph_remove_cap()
1164 ceph_put_cap(mdsc, cap); in __ceph_remove_cap()
1178 void ceph_remove_cap(struct ceph_cap *cap, bool queue_release) in ceph_remove_cap() argument
1180 struct ceph_inode_info *ci = cap->ci; in ceph_remove_cap()
1185 dout("%s: cap inode is NULL\n", __func__); in ceph_remove_cap()
1192 WARN_ON_ONCE(ci->i_auth_cap == cap && in ceph_remove_cap()
1197 __ceph_remove_cap(cap, queue_release); in ceph_remove_cap()
1220 * cap struct size + flock buffer size + inline version + inline data size +
1226 /* Marshal up the cap msg to the MDS */
1315 * Queue cap releases when an inode is dropped from our cache.
1326 struct ceph_cap *cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_remove_caps() local
1328 ceph_remove_cap(cap, true); in __ceph_remove_caps()
1334 * Prepare to send a cap message to an MDS. Update the cap state, and populate
1336 * be done under the i_ceph_lock to guard against changes to cap state.
1341 static void __prep_cap(struct cap_msg_args *arg, struct ceph_cap *cap, in __prep_cap() argument
1345 struct ceph_inode_info *ci = cap->ci; in __prep_cap()
1351 held = cap->issued | cap->implemented; in __prep_cap()
1352 revoking = cap->implemented & ~cap->issued; in __prep_cap()
1355 dout("%s %p cap %p session %p %s -> %s (revoking %s)\n", in __prep_cap()
1356 __func__, inode, cap, cap->session, in __prep_cap()
1363 cap->issued &= retain; /* drop bits we don't want */ in __prep_cap()
1369 arg->wake = cap->implemented & ~cap->issued; in __prep_cap()
1370 cap->implemented &= cap->issued | used; in __prep_cap()
1371 cap->mds_wanted = want; in __prep_cap()
1373 arg->session = cap->session; in __prep_cap()
1375 arg->cid = cap->cap_id; in __prep_cap()
1383 if (cap == ci->i_auth_cap) { in __prep_cap()
1406 arg->caps = cap->implemented; in __prep_cap()
1410 arg->seq = cap->seq; in __prep_cap()
1411 arg->issue_seq = cap->issue_seq; in __prep_cap()
1412 arg->mseq = cap->mseq; in __prep_cap()
1436 * Send a cap msg on the given inode.
1447 pr_err("error allocating cap msg: ino (%llx.%llx) flushing %s tid %llu, requeuing cap.\n", in __send_cap()
1579 struct ceph_cap *cap = ci->i_auth_cap; in __ceph_flush_snaps() local
1583 if (!(cap && cap->session == session)) { in __ceph_flush_snaps()
1584 dout("__flush_snaps %p auth cap %p not mds%d, " in __ceph_flush_snaps()
1585 "stop\n", inode, cap, session->s_mds); in __ceph_flush_snaps()
1608 ret = __send_flush_snap(inode, session, capsnap, cap->mseq, in __ceph_flush_snaps()
1611 pr_err("__flush_snaps: error sending cap flushsnap, " in __ceph_flush_snaps()
1639 dout(" no auth cap (migrating?), doing nothing\n"); in ceph_flush_snaps()
1693 "but no auth cap (session was closed?)\n", in __ceph_mark_dirty_caps()
1713 dout(" inode %p now dirty snapc %p auth cap %p\n", in __ceph_mark_dirty_caps()
1764 * Remove cap_flush from the mdsc's or inode's flushing cap list.
1895 * CHECK_CAPS_AUTHONLY - we should only check the auth cap
1904 struct ceph_cap *cap; in ceph_check_caps() local
1948 * the exclusive cap. So that MDS does not end up in ceph_check_caps()
1949 * revoking the shared cap on every create/unlink in ceph_check_caps()
2007 cap = rb_entry(p, struct ceph_cap, ci_node); in ceph_check_caps()
2010 if (mds >= cap->mds || in ceph_check_caps()
2011 ((flags & CHECK_CAPS_AUTHONLY) && cap != ci->i_auth_cap)) in ceph_check_caps()
2015 * If we have an auth cap, we don't need to consider any in ceph_check_caps()
2019 if (ci->i_auth_cap && cap != ci->i_auth_cap) in ceph_check_caps()
2022 revoking = cap->implemented & ~cap->issued; in ceph_check_caps()
2023 dout(" mds%d cap %p used %s issued %s implemented %s revoking %s\n", in ceph_check_caps()
2024 cap->mds, cap, ceph_cap_string(cap_used), in ceph_check_caps()
2025 ceph_cap_string(cap->issued), in ceph_check_caps()
2026 ceph_cap_string(cap->implemented), in ceph_check_caps()
2029 if (cap == ci->i_auth_cap && in ceph_check_caps()
2030 (cap->issued & CEPH_CAP_FILE_WR)) { in ceph_check_caps()
2045 if (cap == ci->i_auth_cap) { in ceph_check_caps()
2059 ceph_cap_string(cap->implemented & ~cap->issued)); in ceph_check_caps()
2064 if (want & ~cap->mds_wanted) { in ceph_check_caps()
2065 if (want & ~(cap->mds_wanted | cap->issued)) in ceph_check_caps()
2067 if (!__cap_is_valid(cap)) in ceph_check_caps()
2072 if ((cap->issued & ~retain) == 0) in ceph_check_caps()
2077 session = ceph_get_mds_session(cap->session); in ceph_check_caps()
2080 * cap message */ in ceph_check_caps()
2081 if (cap == ci->i_auth_cap && in ceph_check_caps()
2092 if (cap == ci->i_auth_cap && ci->i_dirty_caps) { in ceph_check_caps()
2107 mds = cap->mds; /* remember mds, so we don't repeat */ in ceph_check_caps()
2109 __prep_cap(&arg, cap, CEPH_CAP_OP_UPDATE, mflags, cap_used, in ceph_check_caps()
2116 goto retry; /* retake i_ceph_lock and restart our cap scan. */ in ceph_check_caps()
2147 struct ceph_cap *cap = ci->i_auth_cap; in try_flush_caps() local
2149 struct ceph_mds_session *session = cap->session; in try_flush_caps()
2169 __prep_cap(&arg, cap, CEPH_CAP_OP_FLUSH, CEPH_CLIENT_CAPS_SYNC, in try_flush_caps()
2171 (cap->issued | cap->implemented), in try_flush_caps()
2415 struct ceph_cap *cap; in __kick_flushing_caps() local
2434 cap = ci->i_auth_cap; in __kick_flushing_caps()
2435 if (!(cap && cap->session == session)) { in __kick_flushing_caps()
2436 pr_err("%p auth cap %p not mds%d ???\n", in __kick_flushing_caps()
2437 inode, cap, session->s_mds); in __kick_flushing_caps()
2446 dout("kick_flushing_caps %p cap %p tid %llu %s\n", in __kick_flushing_caps()
2447 inode, cap, cf->tid, ceph_cap_string(cf->caps)); in __kick_flushing_caps()
2448 __prep_cap(&arg, cap, CEPH_CAP_OP_FLUSH, in __kick_flushing_caps()
2453 (cap->issued | cap->implemented), in __kick_flushing_caps()
2468 ret = __send_flush_snap(inode, session, capsnap, cap->mseq, in __kick_flushing_caps()
2472 "cap flushsnap, ino (%llx.%llx) " in __kick_flushing_caps()
2489 struct ceph_cap *cap; in ceph_early_kick_flushing_caps() local
2500 cap = ci->i_auth_cap; in ceph_early_kick_flushing_caps()
2501 if (!(cap && cap->session == session)) { in ceph_early_kick_flushing_caps()
2502 pr_err("%p auth cap %p not mds%d ???\n", in ceph_early_kick_flushing_caps()
2503 &ci->vfs_inode, cap, session->s_mds); in ceph_early_kick_flushing_caps()
2510 * if flushing caps were revoked, we re-send the cap flush in ceph_early_kick_flushing_caps()
2512 * the cap flush message before issuing the flushing caps to in ceph_early_kick_flushing_caps()
2515 if ((cap->issued & ci->i_flushing_caps) != in ceph_early_kick_flushing_caps()
2518 * numbers. make sure sequence numbers in cap flush in ceph_early_kick_flushing_caps()
2520 cap->seq = 0; in ceph_early_kick_flushing_caps()
2521 cap->issue_seq = 0; in ceph_early_kick_flushing_caps()
2522 cap->mseq = 0; in ceph_early_kick_flushing_caps()
2537 struct ceph_cap *cap; in ceph_kick_flushing_caps() local
2550 cap = ci->i_auth_cap; in ceph_kick_flushing_caps()
2551 if (!(cap && cap->session == session)) { in ceph_kick_flushing_caps()
2552 pr_err("%p auth cap %p not mds%d ???\n", in ceph_kick_flushing_caps()
2553 &ci->vfs_inode, cap, session->s_mds); in ceph_kick_flushing_caps()
2569 struct ceph_cap *cap = ci->i_auth_cap; in ceph_kick_flushing_inode_caps() local
2580 &cap->session->s_cap_flushing); in ceph_kick_flushing_inode_caps()
2624 * Try to grab cap references. Specify those refs we @want, and the
2852 * Wait for caps, and take cap references. If we can't get a WR cap
2961 * drop cap refs first because getattr while in ceph_get_caps()
2985 * Take cap refs. Caller must already know we hold at least one ref
3026 * Release cap refs.
3028 * If we released the last ref on any given cap, call ceph_check_caps
3031 * If we are releasing a WR cap (from a sync write), finalize any affected
3186 * auth cap in the case of a forced unmount. in ceph_put_wrbuffer_cap_refs()
3277 * Handle a cap GRANT message from the MDS. (Note that a GRANT may
3278 * actually be a revocation if it specifies a smaller cap set.)
3284 struct ceph_cap *cap, in handle_cap_grant() argument
3298 bool was_stale = cap->cap_gen < atomic_read(&session->s_cap_gen); in handle_cap_grant()
3306 dout("handle_cap_grant inode %p cap %p mds%d seq %d %s\n", in handle_cap_grant()
3307 inode, cap, session->s_mds, seq, ceph_cap_string(newcaps)); in handle_cap_grant()
3318 ((cap->issued & ~newcaps) & CEPH_CAP_FILE_CACHE) && in handle_cap_grant()
3332 cap->issued = cap->implemented = CEPH_CAP_PIN; in handle_cap_grant()
3335 * auth mds of the inode changed. we received the cap export message, in handle_cap_grant()
3336 * but still haven't received the cap import message. handle_cap_export in handle_cap_grant()
3337 * updated the new auth MDS' cap. in handle_cap_grant()
3339 * "ceph_seq_cmp(seq, cap->seq) <= 0" means we are processing a message in handle_cap_grant()
3340 * that was sent before the cap import message. So don't remove caps. in handle_cap_grant()
3342 if (ceph_seq_cmp(seq, cap->seq) <= 0) { in handle_cap_grant()
3343 WARN_ON(cap != ci->i_auth_cap); in handle_cap_grant()
3344 WARN_ON(cap->cap_id != le64_to_cpu(grant->cap_id)); in handle_cap_grant()
3345 seq = cap->seq; in handle_cap_grant()
3346 newcaps |= cap->issued; in handle_cap_grant()
3350 cap->cap_gen = atomic_read(&session->s_cap_gen); in handle_cap_grant()
3351 cap->seq = seq; in handle_cap_grant()
3353 __check_cap_issue(ci, cap, newcaps); in handle_cap_grant()
3438 if (ci->i_auth_cap == cap && (newcaps & CEPH_CAP_ANY_FILE_WR)) { in handle_cap_grant()
3451 /* check cap bits */ in handle_cap_grant()
3461 (wanted & ~(cap->mds_wanted | newcaps))) { in handle_cap_grant()
3463 * If mds is importing cap, prior cap messages that update in handle_cap_grant()
3466 * We don't send cap message to update 'wanted' if what we in handle_cap_grant()
3467 * want are already issued. If mds revokes caps, cap message in handle_cap_grant()
3476 if (cap->issued & ~newcaps) { in handle_cap_grant()
3477 int revoking = cap->issued & ~newcaps; in handle_cap_grant()
3480 ceph_cap_string(cap->issued), in handle_cap_grant()
3490 else if (cap == ci->i_auth_cap) in handle_cap_grant()
3491 check_caps = 1; /* check auth cap only */ in handle_cap_grant()
3494 cap->issued = newcaps; in handle_cap_grant()
3495 cap->implemented |= newcaps; in handle_cap_grant()
3496 } else if (cap->issued == newcaps) { in handle_cap_grant()
3498 ceph_cap_string(cap->issued), ceph_cap_string(newcaps)); in handle_cap_grant()
3500 dout("grant: %s -> %s\n", ceph_cap_string(cap->issued), in handle_cap_grant()
3503 if (cap == ci->i_auth_cap && in handle_cap_grant()
3504 __ceph_caps_revoking_other(ci, cap, newcaps)) in handle_cap_grant()
3507 cap->issued = newcaps; in handle_cap_grant()
3508 cap->implemented |= newcaps; /* add bits only, to in handle_cap_grant()
3513 BUG_ON(cap->issued & ~cap->implemented); in handle_cap_grant()
3523 if (ci->i_auth_cap == cap && in handle_cap_grant()
3578 struct ceph_cap *cap) in handle_cap_flush_ack() argument
3639 dout(" mds%d still flushing cap on %p\n", in handle_cap_flush_ack()
3805 * Handle EXPORT from MDS. Cap is being migrated _from_ this mds to a
3807 * indicated by mseq), make note of the migrating cap bits for the
3818 struct ceph_cap *cap, *tcap, *new_cap = NULL; in handle_cap_export() local
3840 cap = __get_cap_for_mds(ci, mds); in handle_cap_export()
3841 if (!cap || cap->cap_id != le64_to_cpu(ex->cap_id)) in handle_cap_export()
3845 ceph_remove_cap(cap, false); in handle_cap_export()
3850 * now we know we haven't received the cap import message yet in handle_cap_export()
3851 * because the exported cap still exist. in handle_cap_export()
3854 issued = cap->issued; in handle_cap_export()
3855 if (issued != cap->implemented) in handle_cap_export()
3859 ceph_vinop(inode), mds, cap->seq, cap->mseq, in handle_cap_export()
3861 ceph_cap_string(cap->implemented)); in handle_cap_export()
3869 dout(" updating import cap %p mds%d\n", tcap, target); in handle_cap_export()
3875 if (cap == ci->i_auth_cap) { in handle_cap_export()
3880 ceph_remove_cap(cap, false); in handle_cap_export()
3884 int flag = (cap == ci->i_auth_cap) ? CEPH_CAP_FLAG_AUTH : 0; in handle_cap_export()
3897 ceph_remove_cap(cap, false); in handle_cap_export()
3937 * Handle cap IMPORT.
3948 struct ceph_cap *cap, *ocap, *new_cap = NULL; in handle_cap_import() local
3971 cap = __get_cap_for_mds(ci, mds); in handle_cap_import()
3972 if (!cap) { in handle_cap_import()
3979 cap = new_cap; in handle_cap_import()
3995 dout(" remove export cap %p mds%d flags %d\n", in handle_cap_import()
4012 *target_cap = cap; in handle_cap_import()
4019 * based on the cap op.
4027 struct ceph_cap *cap; in ceph_handle_caps() local
4141 dout(" mds%d seq %lld cap seq %u\n", session->s_mds, session->s_seq, in ceph_handle_caps()
4148 cap = ceph_get_cap(mdsc, NULL); in ceph_handle_caps()
4149 cap->cap_ino = vino.ino; in ceph_handle_caps()
4150 cap->queue_release = 1; in ceph_handle_caps()
4151 cap->cap_id = le64_to_cpu(h->cap_id); in ceph_handle_caps()
4152 cap->mseq = mseq; in ceph_handle_caps()
4153 cap->seq = seq; in ceph_handle_caps()
4154 cap->issue_seq = seq; in ceph_handle_caps()
4156 __ceph_queue_cap_release(session, cap); in ceph_handle_caps()
4162 /* these will work even if we don't have a cap yet */ in ceph_handle_caps()
4186 &cap, &extra_info.issued); in ceph_handle_caps()
4187 handle_cap_grant(inode, session, cap, in ceph_handle_caps()
4194 /* the rest require a cap */ in ceph_handle_caps()
4196 cap = __get_cap_for_mds(ceph_inode(inode), session->s_mds); in ceph_handle_caps()
4197 if (!cap) { in ceph_handle_caps()
4198 dout(" no cap on %p ino %llx.%llx from mds%d\n", in ceph_handle_caps()
4211 handle_cap_grant(inode, session, cap, in ceph_handle_caps()
4217 h, session, cap); in ceph_handle_caps()
4229 pr_err("ceph_handle_caps: unknown cap op %d %s\n", op, in ceph_handle_caps()
4243 * send any cap release message to try to move things in ceph_handle_caps()
4245 * cap). in ceph_handle_caps()
4257 * Delayed work handler to process end of delayed cap release LRU list.
4439 * Helpers for embedding cap and dentry lease releases into mds
4450 struct ceph_cap *cap; in ceph_encode_inode_release() local
4466 cap = __get_cap_for_mds(ci, mds); in ceph_encode_inode_release()
4467 if (cap && __cap_is_valid(cap)) { in ceph_encode_inode_release()
4468 unless &= cap->issued; in ceph_encode_inode_release()
4480 if (force || (cap->issued & drop)) { in ceph_encode_inode_release()
4481 if (cap->issued & drop) { in ceph_encode_inode_release()
4483 dout("encode_inode_release %p cap %p " in ceph_encode_inode_release()
4484 "%s -> %s, wanted %s -> %s\n", inode, cap, in ceph_encode_inode_release()
4485 ceph_cap_string(cap->issued), in ceph_encode_inode_release()
4486 ceph_cap_string(cap->issued & ~drop), in ceph_encode_inode_release()
4487 ceph_cap_string(cap->mds_wanted), in ceph_encode_inode_release()
4490 cap->issued &= ~drop; in ceph_encode_inode_release()
4491 cap->implemented &= ~drop; in ceph_encode_inode_release()
4492 cap->mds_wanted = wanted; in ceph_encode_inode_release()
4493 if (cap == ci->i_auth_cap && in ceph_encode_inode_release()
4497 dout("encode_inode_release %p cap %p %s" in ceph_encode_inode_release()
4498 " (force)\n", inode, cap, in ceph_encode_inode_release()
4499 ceph_cap_string(cap->issued)); in ceph_encode_inode_release()
4503 rel->cap_id = cpu_to_le64(cap->cap_id); in ceph_encode_inode_release()
4504 rel->seq = cpu_to_le32(cap->seq); in ceph_encode_inode_release()
4505 rel->issue_seq = cpu_to_le32(cap->issue_seq); in ceph_encode_inode_release()
4506 rel->mseq = cpu_to_le32(cap->mseq); in ceph_encode_inode_release()
4507 rel->caps = cpu_to_le32(cap->implemented); in ceph_encode_inode_release()
4508 rel->wanted = cpu_to_le32(cap->mds_wanted); in ceph_encode_inode_release()
4514 dout("encode_inode_release %p cap %p %s (noop)\n", in ceph_encode_inode_release()
4515 inode, cap, ceph_cap_string(cap->issued)); in ceph_encode_inode_release()