• Home
  • Raw
  • Download

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_cap *cap, bool queue_release) in ceph_remove_cap() argument
1183 struct ceph_inode_info *ci = cap->ci; in ceph_remove_cap()
1188 dout("%s: cap inode is NULL\n", __func__); in ceph_remove_cap()
1195 WARN_ON_ONCE(ci->i_auth_cap == cap && in ceph_remove_cap()
1200 __ceph_remove_cap(cap, queue_release); in ceph_remove_cap()
1225 /* Marshal up the cap msg to the MDS */
1341 * Queue cap releases when an inode is dropped from our cache.
1352 struct ceph_cap *cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_remove_caps() local
1354 ceph_remove_cap(cap, true); in __ceph_remove_caps()
1360 * Prepare to send a cap message to an MDS. Update the cap state, and populate
1362 * be done under the i_ceph_lock to guard against changes to cap state.
1367 static void __prep_cap(struct cap_msg_args *arg, struct ceph_cap *cap, in __prep_cap() argument
1371 struct ceph_inode_info *ci = cap->ci; in __prep_cap()
1377 held = cap->issued | cap->implemented; in __prep_cap()
1378 revoking = cap->implemented & ~cap->issued; in __prep_cap()
1381 dout("%s %p cap %p session %p %s -> %s (revoking %s)\n", in __prep_cap()
1382 __func__, inode, cap, cap->session, in __prep_cap()
1389 cap->issued &= retain; /* drop bits we don't want */ in __prep_cap()
1395 arg->wake = cap->implemented & ~cap->issued; in __prep_cap()
1396 cap->implemented &= cap->issued | used; in __prep_cap()
1397 cap->mds_wanted = want; in __prep_cap()
1399 arg->session = cap->session; in __prep_cap()
1401 arg->cid = cap->cap_id; in __prep_cap()
1408 if (cap == ci->i_auth_cap) { in __prep_cap()
1431 arg->caps = cap->implemented; in __prep_cap()
1435 arg->seq = cap->seq; in __prep_cap()
1436 arg->issue_seq = cap->issue_seq; in __prep_cap()
1437 arg->mseq = cap->mseq; in __prep_cap()
1492 * Send a cap msg on the given inode.
1504 pr_err("error allocating cap msg: ino (%llx.%llx) flushing %s tid %llu, requeuing cap.\n", in __send_cap()
1642 struct ceph_cap *cap = ci->i_auth_cap; in __ceph_flush_snaps() local
1646 if (!(cap && cap->session == session)) { in __ceph_flush_snaps()
1647 dout("__flush_snaps %p auth cap %p not mds%d, " in __ceph_flush_snaps()
1648 "stop\n", inode, cap, session->s_mds); in __ceph_flush_snaps()
1672 ret = __send_flush_snap(inode, session, capsnap, cap->mseq, in __ceph_flush_snaps()
1675 pr_err("__flush_snaps: error sending cap flushsnap, " in __ceph_flush_snaps()
1704 dout(" no auth cap (migrating?), doing nothing\n"); in ceph_flush_snaps()
1763 "but no auth cap (session was closed?)\n", in __ceph_mark_dirty_caps()
1783 dout(" inode %p now dirty snapc %p auth cap %p\n", in __ceph_mark_dirty_caps()
1834 * Remove cap_flush from the mdsc's or inode's flushing cap list.
1965 * CHECK_CAPS_AUTHONLY - we should only check the auth cap
1973 struct ceph_cap *cap; in ceph_check_caps() local
2024 * the exclusive cap. So that MDS does not end up in ceph_check_caps()
2025 * revoking the shared cap on every create/unlink in ceph_check_caps()
2085 cap = rb_entry(p, struct ceph_cap, ci_node); in ceph_check_caps()
2088 if (mds >= cap->mds || in ceph_check_caps()
2089 ((flags & CHECK_CAPS_AUTHONLY) && cap != ci->i_auth_cap)) in ceph_check_caps()
2093 * If we have an auth cap, we don't need to consider any in ceph_check_caps()
2097 if (ci->i_auth_cap && cap != ci->i_auth_cap) in ceph_check_caps()
2100 revoking = cap->implemented & ~cap->issued; in ceph_check_caps()
2101 dout(" mds%d cap %p used %s issued %s implemented %s revoking %s\n", in ceph_check_caps()
2102 cap->mds, cap, ceph_cap_string(cap_used), in ceph_check_caps()
2103 ceph_cap_string(cap->issued), in ceph_check_caps()
2104 ceph_cap_string(cap->implemented), in ceph_check_caps()
2107 if (cap == ci->i_auth_cap && in ceph_check_caps()
2108 (cap->issued & CEPH_CAP_FILE_WR)) { in ceph_check_caps()
2123 if (cap == ci->i_auth_cap) { in ceph_check_caps()
2138 ceph_cap_string(cap->implemented & ~cap->issued)); in ceph_check_caps()
2159 if (want & ~cap->mds_wanted) { in ceph_check_caps()
2160 if (want & ~(cap->mds_wanted | cap->issued)) in ceph_check_caps()
2162 if (!__cap_is_valid(cap)) in ceph_check_caps()
2167 if ((cap->issued & ~retain) == 0) in ceph_check_caps()
2172 session = ceph_get_mds_session(cap->session); in ceph_check_caps()
2175 * cap message */ in ceph_check_caps()
2176 if (cap == ci->i_auth_cap && in ceph_check_caps()
2187 if (cap == ci->i_auth_cap && ci->i_dirty_caps) { in ceph_check_caps()
2202 mds = cap->mds; /* remember mds, so we don't repeat */ in ceph_check_caps()
2204 __prep_cap(&arg, cap, CEPH_CAP_OP_UPDATE, mflags, cap_used, in ceph_check_caps()
2211 goto retry; /* retake i_ceph_lock and restart our cap scan. */ in ceph_check_caps()
2244 struct ceph_cap *cap = ci->i_auth_cap; in try_flush_caps() local
2246 struct ceph_mds_session *session = cap->session; in try_flush_caps()
2266 __prep_cap(&arg, cap, CEPH_CAP_OP_FLUSH, CEPH_CLIENT_CAPS_SYNC, in try_flush_caps()
2268 (cap->issued | cap->implemented), in try_flush_caps()
2515 struct ceph_cap *cap; in __kick_flushing_caps() local
2538 cap = ci->i_auth_cap; in __kick_flushing_caps()
2539 if (!(cap && cap->session == session)) { in __kick_flushing_caps()
2540 pr_err("%p auth cap %p not mds%d ???\n", in __kick_flushing_caps()
2541 inode, cap, session->s_mds); in __kick_flushing_caps()
2550 dout("kick_flushing_caps %p cap %p tid %llu %s\n", in __kick_flushing_caps()
2551 inode, cap, cf->tid, ceph_cap_string(cf->caps)); in __kick_flushing_caps()
2552 __prep_cap(&arg, cap, CEPH_CAP_OP_FLUSH, in __kick_flushing_caps()
2557 (cap->issued | cap->implemented), in __kick_flushing_caps()
2572 ret = __send_flush_snap(inode, session, capsnap, cap->mseq, in __kick_flushing_caps()
2576 "cap flushsnap, ino (%llx.%llx) " in __kick_flushing_caps()
2593 struct ceph_cap *cap; in ceph_early_kick_flushing_caps() local
2604 cap = ci->i_auth_cap; in ceph_early_kick_flushing_caps()
2605 if (!(cap && cap->session == session)) { in ceph_early_kick_flushing_caps()
2606 pr_err("%p auth cap %p not mds%d ???\n", in ceph_early_kick_flushing_caps()
2607 &ci->netfs.inode, cap, session->s_mds); in ceph_early_kick_flushing_caps()
2614 * if flushing caps were revoked, we re-send the cap flush in ceph_early_kick_flushing_caps()
2616 * the cap flush message before issuing the flushing caps to in ceph_early_kick_flushing_caps()
2619 if ((cap->issued & ci->i_flushing_caps) != in ceph_early_kick_flushing_caps()
2622 * numbers. make sure sequence numbers in cap flush in ceph_early_kick_flushing_caps()
2624 cap->seq = 0; in ceph_early_kick_flushing_caps()
2625 cap->issue_seq = 0; in ceph_early_kick_flushing_caps()
2626 cap->mseq = 0; in ceph_early_kick_flushing_caps()
2641 struct ceph_cap *cap; in ceph_kick_flushing_caps() local
2654 cap = ci->i_auth_cap; in ceph_kick_flushing_caps()
2655 if (!(cap && cap->session == session)) { in ceph_kick_flushing_caps()
2656 pr_err("%p auth cap %p not mds%d ???\n", in ceph_kick_flushing_caps()
2657 &ci->netfs.inode, cap, session->s_mds); in ceph_kick_flushing_caps()
2673 struct ceph_cap *cap = ci->i_auth_cap; in ceph_kick_flushing_inode_caps() local
2684 &cap->session->s_cap_flushing); in ceph_kick_flushing_inode_caps()
2728 * Try to grab cap references. Specify those refs we @want, and the
2960 * Wait for caps, and take cap references. If we can't get a WR cap
3068 * drop cap refs first because getattr while in __ceph_get_caps()
3101 * Take cap refs. Caller must already know we hold at least one ref
3142 * Release cap refs.
3144 * If we released the last ref on any given cap, call ceph_check_caps
3147 * If we are releasing a WR cap (from a sync write), finalize any affected
3307 * auth cap in the case of a forced unmount. in ceph_put_wrbuffer_cap_refs()
3401 * Handle a cap GRANT message from the MDS. (Note that a GRANT may
3402 * actually be a revocation if it specifies a smaller cap set.)
3408 struct ceph_cap *cap, in handle_cap_grant() argument
3422 bool was_stale = cap->cap_gen < atomic_read(&session->s_cap_gen); in handle_cap_grant()
3438 dout("handle_cap_grant inode %p cap %p mds%d seq %d %s\n", in handle_cap_grant()
3439 inode, cap, session->s_mds, seq, ceph_cap_string(newcaps)); in handle_cap_grant()
3450 ((cap->issued & ~newcaps) & CEPH_CAP_FILE_CACHE) && in handle_cap_grant()
3464 cap->issued = cap->implemented = CEPH_CAP_PIN; in handle_cap_grant()
3467 * auth mds of the inode changed. we received the cap export message, in handle_cap_grant()
3468 * but still haven't received the cap import message. handle_cap_export in handle_cap_grant()
3469 * updated the new auth MDS' cap. in handle_cap_grant()
3471 * "ceph_seq_cmp(seq, cap->seq) <= 0" means we are processing a message in handle_cap_grant()
3472 * that was sent before the cap import message. So don't remove caps. in handle_cap_grant()
3474 if (ceph_seq_cmp(seq, cap->seq) <= 0) { in handle_cap_grant()
3475 WARN_ON(cap != ci->i_auth_cap); in handle_cap_grant()
3476 WARN_ON(cap->cap_id != le64_to_cpu(grant->cap_id)); in handle_cap_grant()
3477 seq = cap->seq; in handle_cap_grant()
3478 newcaps |= cap->issued; in handle_cap_grant()
3482 cap->cap_gen = atomic_read(&session->s_cap_gen); in handle_cap_grant()
3483 cap->seq = seq; in handle_cap_grant()
3485 __check_cap_issue(ci, cap, newcaps); in handle_cap_grant()
3508 …pr_warn_ratelimited("%s: cap grant attempt to change fscrypt_auth on non-I_NEW inode (old len %d n… in handle_cap_grant()
3577 if (ci->i_auth_cap == cap && (newcaps & CEPH_CAP_ANY_FILE_WR)) { in handle_cap_grant()
3590 /* check cap bits */ in handle_cap_grant()
3600 (wanted & ~(cap->mds_wanted | newcaps))) { in handle_cap_grant()
3602 * If mds is importing cap, prior cap messages that update in handle_cap_grant()
3605 * We don't send cap message to update 'wanted' if what we in handle_cap_grant()
3606 * want are already issued. If mds revokes caps, cap message in handle_cap_grant()
3615 if (cap->issued & ~newcaps) { in handle_cap_grant()
3616 int revoking = cap->issued & ~newcaps; in handle_cap_grant()
3619 ceph_cap_string(cap->issued), in handle_cap_grant()
3629 else if (cap == ci->i_auth_cap) in handle_cap_grant()
3630 check_caps = 1; /* check auth cap only */ in handle_cap_grant()
3634 if (~cap->issued & newcaps) in handle_cap_grant()
3636 cap->issued = newcaps; in handle_cap_grant()
3637 cap->implemented |= newcaps; in handle_cap_grant()
3638 } else if (cap->issued == newcaps) { in handle_cap_grant()
3640 ceph_cap_string(cap->issued), ceph_cap_string(newcaps)); in handle_cap_grant()
3642 dout("grant: %s -> %s\n", ceph_cap_string(cap->issued), in handle_cap_grant()
3645 if (cap == ci->i_auth_cap && in handle_cap_grant()
3646 __ceph_caps_revoking_other(ci, cap, newcaps)) in handle_cap_grant()
3649 cap->issued = newcaps; in handle_cap_grant()
3650 cap->implemented |= newcaps; /* add bits only, to in handle_cap_grant()
3655 BUG_ON(cap->issued & ~cap->implemented); in handle_cap_grant()
3659 cap->mds_wanted = 0; in handle_cap_grant()
3660 if (cap == ci->i_auth_cap) in handle_cap_grant()
3661 check_caps = 1; /* check auth cap only */ in handle_cap_grant()
3675 if (ci->i_auth_cap == cap) { in handle_cap_grant()
3727 struct ceph_cap *cap) in handle_cap_flush_ack() argument
3788 dout(" mds%d still flushing cap on %p\n", in handle_cap_flush_ack()
3962 * Handle EXPORT from MDS. Cap is being migrated _from_ this mds to a
3964 * indicated by mseq), make note of the migrating cap bits for the
3975 struct ceph_cap *cap, *tcap, *new_cap = NULL; in handle_cap_export() local
3998 cap = __get_cap_for_mds(ci, mds); in handle_cap_export()
3999 if (!cap || cap->cap_id != le64_to_cpu(ex->cap_id)) in handle_cap_export()
4003 ceph_remove_cap(cap, false); in handle_cap_export()
4008 * now we know we haven't received the cap import message yet in handle_cap_export()
4009 * because the exported cap still exist. in handle_cap_export()
4012 issued = cap->issued; in handle_cap_export()
4013 if (issued != cap->implemented) in handle_cap_export()
4017 ceph_vinop(inode), mds, cap->seq, cap->mseq, in handle_cap_export()
4019 ceph_cap_string(cap->implemented)); in handle_cap_export()
4027 dout(" updating import cap %p mds%d\n", tcap, target); in handle_cap_export()
4033 if (cap == ci->i_auth_cap) { in handle_cap_export()
4038 ceph_remove_cap(cap, false); in handle_cap_export()
4042 int flag = (cap == ci->i_auth_cap) ? CEPH_CAP_FLAG_AUTH : 0; in handle_cap_export()
4055 ceph_remove_cap(cap, false); in handle_cap_export()
4097 * Handle cap IMPORT.
4108 struct ceph_cap *cap, *ocap, *new_cap = NULL; in handle_cap_import() local
4131 cap = __get_cap_for_mds(ci, mds); in handle_cap_import()
4132 if (!cap) { in handle_cap_import()
4139 cap = new_cap; in handle_cap_import()
4155 dout(" remove export cap %p mds%d flags %d\n", in handle_cap_import()
4172 *target_cap = cap; in handle_cap_import()
4225 * based on the cap op.
4233 struct ceph_cap *cap; in ceph_handle_caps() local
4355 dout(" mds%d seq %lld cap seq %u\n", session->s_mds, session->s_seq, in ceph_handle_caps()
4374 /* these will work even if we don't have a cap yet */ in ceph_handle_caps()
4402 &cap, &extra_info.issued); in ceph_handle_caps()
4403 handle_cap_grant(inode, session, cap, in ceph_handle_caps()
4410 /* the rest require a cap */ in ceph_handle_caps()
4412 cap = __get_cap_for_mds(ceph_inode(inode), session->s_mds); in ceph_handle_caps()
4413 if (!cap) { in ceph_handle_caps()
4414 dout(" no cap on %p ino %llx.%llx from mds%d\n", in ceph_handle_caps()
4435 handle_cap_grant(inode, session, cap, in ceph_handle_caps()
4441 h, session, cap); in ceph_handle_caps()
4454 pr_err("ceph_handle_caps: unknown cap op %d %s\n", op, in ceph_handle_caps()
4476 * send any cap release message to try to move things in ceph_handle_caps()
4478 * cap). in ceph_handle_caps()
4481 cap = ceph_get_cap(mdsc, NULL); in ceph_handle_caps()
4482 cap->cap_ino = vino.ino; in ceph_handle_caps()
4483 cap->queue_release = 1; in ceph_handle_caps()
4484 cap->cap_id = le64_to_cpu(h->cap_id); in ceph_handle_caps()
4485 cap->mseq = mseq; in ceph_handle_caps()
4486 cap->seq = seq; in ceph_handle_caps()
4487 cap->issue_seq = seq; in ceph_handle_caps()
4489 __ceph_queue_cap_release(session, cap); in ceph_handle_caps()
4502 * Delayed work handler to process end of delayed cap release LRU list.
4685 * Helpers for embedding cap and dentry lease releases into mds
4696 struct ceph_cap *cap; in ceph_encode_inode_release() local
4712 cap = __get_cap_for_mds(ci, mds); in ceph_encode_inode_release()
4713 if (cap && __cap_is_valid(cap)) { in ceph_encode_inode_release()
4714 unless &= cap->issued; in ceph_encode_inode_release()
4726 if (force || (cap->issued & drop)) { in ceph_encode_inode_release()
4727 if (cap->issued & drop) { in ceph_encode_inode_release()
4729 dout("encode_inode_release %p cap %p " in ceph_encode_inode_release()
4730 "%s -> %s, wanted %s -> %s\n", inode, cap, in ceph_encode_inode_release()
4731 ceph_cap_string(cap->issued), in ceph_encode_inode_release()
4732 ceph_cap_string(cap->issued & ~drop), in ceph_encode_inode_release()
4733 ceph_cap_string(cap->mds_wanted), in ceph_encode_inode_release()
4736 cap->issued &= ~drop; in ceph_encode_inode_release()
4737 cap->implemented &= ~drop; in ceph_encode_inode_release()
4738 cap->mds_wanted = wanted; in ceph_encode_inode_release()
4739 if (cap == ci->i_auth_cap && in ceph_encode_inode_release()
4743 dout("encode_inode_release %p cap %p %s" in ceph_encode_inode_release()
4744 " (force)\n", inode, cap, in ceph_encode_inode_release()
4745 ceph_cap_string(cap->issued)); in ceph_encode_inode_release()
4749 rel->cap_id = cpu_to_le64(cap->cap_id); in ceph_encode_inode_release()
4750 rel->seq = cpu_to_le32(cap->seq); in ceph_encode_inode_release()
4751 rel->issue_seq = cpu_to_le32(cap->issue_seq); in ceph_encode_inode_release()
4752 rel->mseq = cpu_to_le32(cap->mseq); in ceph_encode_inode_release()
4753 rel->caps = cpu_to_le32(cap->implemented); in ceph_encode_inode_release()
4754 rel->wanted = cpu_to_le32(cap->mds_wanted); in ceph_encode_inode_release()
4760 dout("encode_inode_release %p cap %p %s (noop)\n", in ceph_encode_inode_release()
4761 inode, cap, ceph_cap_string(cap->issued)); in ceph_encode_inode_release()
4854 int ceph_purge_inode_cap(struct inode *inode, struct ceph_cap *cap, bool *invalidate) in ceph_purge_inode_cap() argument
4865 dout("removing cap %p, ci is %p, inode is %p\n", in ceph_purge_inode_cap()
4866 cap, ci, &ci->netfs.inode); in ceph_purge_inode_cap()
4868 is_auth = (cap == ci->i_auth_cap); in ceph_purge_inode_cap()
4869 __ceph_remove_cap(cap, false); in ceph_purge_inode_cap()
4882 /* trash all of the cap flushes for this inode */ in ceph_purge_inode_cap()