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()
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()
733 __check_cap_issue(ci, cap, issued); in ceph_add_cap()
753 ci->i_auth_cap->session != cap->session) in ceph_add_cap()
754 change_auth_cap_ses(ci, cap->session); in ceph_add_cap()
755 ci->i_auth_cap = cap; in ceph_add_cap()
756 cap->mds_wanted = wanted; in ceph_add_cap()
759 WARN_ON(ci->i_auth_cap == cap); in ceph_add_cap()
762 dout("add_cap inode %p (%llx.%llx) cap %p %s now %s seq %d mds%d\n", in ceph_add_cap()
763 inode, ceph_vinop(inode), cap, ceph_cap_string(issued), in ceph_add_cap()
764 ceph_cap_string(issued|cap->issued), seq, mds); in ceph_add_cap()
765 cap->cap_id = cap_id; in ceph_add_cap()
766 cap->issued = issued; in ceph_add_cap()
767 cap->implemented |= issued; in ceph_add_cap()
768 if (ceph_seq_cmp(mseq, cap->mseq) > 0) in ceph_add_cap()
769 cap->mds_wanted = wanted; in ceph_add_cap()
771 cap->mds_wanted |= wanted; in ceph_add_cap()
772 cap->seq = seq; in ceph_add_cap()
773 cap->issue_seq = seq; in ceph_add_cap()
774 cap->mseq = mseq; in ceph_add_cap()
775 cap->cap_gen = gen; in ceph_add_cap()
779 * Return true if cap has not timed out and belongs to the current
783 static int __cap_is_valid(struct ceph_cap *cap) in __cap_is_valid() argument
788 spin_lock(&cap->session->s_gen_ttl_lock); in __cap_is_valid()
789 gen = cap->session->s_cap_gen; in __cap_is_valid()
790 ttl = cap->session->s_cap_ttl; in __cap_is_valid()
791 spin_unlock(&cap->session->s_gen_ttl_lock); in __cap_is_valid()
793 if (cap->cap_gen < gen || time_after_eq(jiffies, ttl)) { in __cap_is_valid()
794 dout("__cap_is_valid %p cap %p issued %s " in __cap_is_valid()
795 "but STALE (gen %u vs %u)\n", &cap->ci->vfs_inode, in __cap_is_valid()
796 cap, ceph_cap_string(cap->issued), cap->cap_gen, gen); in __cap_is_valid()
804 * Return set of valid cap bits issued to us. Note that caps time
811 struct ceph_cap *cap; in __ceph_caps_issued() local
817 cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_caps_issued()
818 if (!__cap_is_valid(cap)) in __ceph_caps_issued()
820 dout("__ceph_caps_issued %p cap %p issued %s\n", in __ceph_caps_issued()
821 &ci->vfs_inode, cap, ceph_cap_string(cap->issued)); in __ceph_caps_issued()
822 have |= cap->issued; in __ceph_caps_issued()
824 *implemented |= cap->implemented; in __ceph_caps_issued()
832 cap = ci->i_auth_cap; in __ceph_caps_issued()
833 have &= ~cap->implemented | cap->issued; in __ceph_caps_issued()
839 * Get cap bits issued by caps other than @ocap
844 struct ceph_cap *cap; in __ceph_caps_issued_other() local
848 cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_caps_issued_other()
849 if (cap == ocap) in __ceph_caps_issued_other()
851 if (!__cap_is_valid(cap)) in __ceph_caps_issued_other()
853 have |= cap->issued; in __ceph_caps_issued_other()
859 * Move a cap to the end of the LRU (oldest caps at list head, newest
862 static void __touch_cap(struct ceph_cap *cap) in __touch_cap() argument
864 struct ceph_mds_session *s = cap->session; in __touch_cap()
868 dout("__touch_cap %p cap %p mds%d\n", &cap->ci->vfs_inode, cap, in __touch_cap()
870 list_move_tail(&cap->session_caps, &s->s_caps); in __touch_cap()
872 dout("__touch_cap %p cap %p mds%d NOP, iterating over caps\n", in __touch_cap()
873 &cap->ci->vfs_inode, cap, s->s_mds); in __touch_cap()
879 * Check if we hold the given mask. If so, move the cap(s) to the
885 struct ceph_cap *cap; in __ceph_caps_issued_mask() local
898 cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_caps_issued_mask()
899 if (!__cap_is_valid(cap)) in __ceph_caps_issued_mask()
901 if ((cap->issued & mask) == mask) { in __ceph_caps_issued_mask()
902 dout("__ceph_caps_issued_mask ino 0x%llx cap %p issued %s" in __ceph_caps_issued_mask()
903 " (mask %s)\n", ceph_ino(&ci->vfs_inode), cap, in __ceph_caps_issued_mask()
904 ceph_cap_string(cap->issued), in __ceph_caps_issued_mask()
907 __touch_cap(cap); in __ceph_caps_issued_mask()
912 have |= cap->issued; in __ceph_caps_issued_mask()
916 ceph_cap_string(cap->issued), in __ceph_caps_issued_mask()
922 __touch_cap(cap); in __ceph_caps_issued_mask()
925 cap = rb_entry(q, struct ceph_cap, in __ceph_caps_issued_mask()
927 if (!__cap_is_valid(cap)) in __ceph_caps_issued_mask()
929 if (cap->issued & mask) in __ceph_caps_issued_mask()
930 __touch_cap(cap); in __ceph_caps_issued_mask()
960 struct ceph_cap *cap; in __ceph_caps_revoking_other() local
964 cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_caps_revoking_other()
965 if (cap != ocap && in __ceph_caps_revoking_other()
966 (cap->implemented & ~cap->issued & mask)) in __ceph_caps_revoking_other()
1069 * wanted, by virtue of open file modes AND cap refs (buffered/cached data)
1091 struct ceph_cap *cap; in __ceph_caps_mds_wanted() local
1096 cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_caps_mds_wanted()
1097 if (check && !__cap_is_valid(cap)) in __ceph_caps_mds_wanted()
1099 if (cap == ci->i_auth_cap) in __ceph_caps_mds_wanted()
1100 mds_wanted |= cap->mds_wanted; in __ceph_caps_mds_wanted()
1102 mds_wanted |= (cap->mds_wanted & ~CEPH_CAP_ANY_FILE_WR); in __ceph_caps_mds_wanted()
1134 * Remove a cap. Take steps to deal with a racing iterate_session_caps.
1139 void __ceph_remove_cap(struct ceph_cap *cap, bool queue_release) in __ceph_remove_cap() argument
1141 struct ceph_mds_session *session = cap->session; in __ceph_remove_cap()
1142 struct ceph_inode_info *ci = cap->ci; in __ceph_remove_cap()
1147 dout("__ceph_remove_cap %p from %p\n", cap, &ci->vfs_inode); in __ceph_remove_cap()
1149 /* remove from inode's cap rbtree, and clear auth cap */ in __ceph_remove_cap()
1150 rb_erase(&cap->ci_node, &ci->i_caps); in __ceph_remove_cap()
1151 if (ci->i_auth_cap == cap) { in __ceph_remove_cap()
1158 if (session->s_cap_iterator == cap) { in __ceph_remove_cap()
1159 /* not yet, we are iterating over this very cap */ in __ceph_remove_cap()
1161 cap, cap->session); in __ceph_remove_cap()
1163 list_del_init(&cap->session_caps); in __ceph_remove_cap()
1166 cap->session = NULL; in __ceph_remove_cap()
1170 cap->ci = NULL; in __ceph_remove_cap()
1177 (!session->s_cap_reconnect || cap->cap_gen == session->s_cap_gen)) { in __ceph_remove_cap()
1178 cap->queue_release = 1; in __ceph_remove_cap()
1180 __ceph_queue_cap_release(session, cap); in __ceph_remove_cap()
1184 cap->queue_release = 0; in __ceph_remove_cap()
1186 cap->cap_ino = ci->i_vino.ino; in __ceph_remove_cap()
1191 ceph_put_cap(mdsc, cap); in __ceph_remove_cap()
1225 * cap struct size + flock buffer size + inline version + inline data size +
1231 /* Marshal up the cap msg to the MDS */
1320 * Queue cap releases when an inode is dropped from our cache.
1331 struct ceph_cap *cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_remove_caps() local
1333 __ceph_remove_cap(cap, true); in __ceph_remove_caps()
1339 * Prepare to send a cap message to an MDS. Update the cap state, and populate
1341 * be done under the i_ceph_lock to guard against changes to cap state.
1346 static void __prep_cap(struct cap_msg_args *arg, struct ceph_cap *cap, in __prep_cap() argument
1350 struct ceph_inode_info *ci = cap->ci; in __prep_cap()
1356 held = cap->issued | cap->implemented; in __prep_cap()
1357 revoking = cap->implemented & ~cap->issued; in __prep_cap()
1360 dout("%s %p cap %p session %p %s -> %s (revoking %s)\n", in __prep_cap()
1361 __func__, inode, cap, cap->session, in __prep_cap()
1368 cap->issued &= retain; /* drop bits we don't want */ in __prep_cap()
1374 arg->wake = cap->implemented & ~cap->issued; in __prep_cap()
1375 cap->implemented &= cap->issued | used; in __prep_cap()
1376 cap->mds_wanted = want; in __prep_cap()
1378 arg->session = cap->session; in __prep_cap()
1380 arg->cid = cap->cap_id; in __prep_cap()
1388 if (cap == ci->i_auth_cap) { in __prep_cap()
1411 arg->caps = cap->implemented; in __prep_cap()
1415 arg->seq = cap->seq; in __prep_cap()
1416 arg->issue_seq = cap->issue_seq; in __prep_cap()
1417 arg->mseq = cap->mseq; in __prep_cap()
1441 * Send a cap msg on the given inode.
1452 pr_err("error allocating cap msg: ino (%llx.%llx) flushing %s tid %llu, requeuing cap.\n", in __send_cap()
1584 struct ceph_cap *cap = ci->i_auth_cap; in __ceph_flush_snaps() local
1588 if (!(cap && cap->session == session)) { in __ceph_flush_snaps()
1589 dout("__flush_snaps %p auth cap %p not mds%d, " in __ceph_flush_snaps()
1590 "stop\n", inode, cap, session->s_mds); in __ceph_flush_snaps()
1613 ret = __send_flush_snap(inode, session, capsnap, cap->mseq, in __ceph_flush_snaps()
1616 pr_err("__flush_snaps: error sending cap flushsnap, " in __ceph_flush_snaps()
1644 dout(" no auth cap (migrating?), doing nothing\n"); in ceph_flush_snaps()
1705 "but no auth cap (session was closed?)\n", in __ceph_mark_dirty_caps()
1725 dout(" inode %p now dirty snapc %p auth cap %p\n", in __ceph_mark_dirty_caps()
1769 * 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
1952 * the exclusive cap. So that MDS does not end up in ceph_check_caps()
1953 * revoking the shared cap on every create/unlink in ceph_check_caps()
2011 cap = rb_entry(p, struct ceph_cap, ci_node); in ceph_check_caps()
2014 if (mds >= cap->mds || in ceph_check_caps()
2015 ((flags & CHECK_CAPS_AUTHONLY) && cap != ci->i_auth_cap)) in ceph_check_caps()
2021 * If we have an auth cap, we don't need to consider any in ceph_check_caps()
2025 if (ci->i_auth_cap && cap != ci->i_auth_cap) in ceph_check_caps()
2028 revoking = cap->implemented & ~cap->issued; in ceph_check_caps()
2029 dout(" mds%d cap %p used %s issued %s implemented %s revoking %s\n", in ceph_check_caps()
2030 cap->mds, cap, ceph_cap_string(cap_used), in ceph_check_caps()
2031 ceph_cap_string(cap->issued), in ceph_check_caps()
2032 ceph_cap_string(cap->implemented), in ceph_check_caps()
2035 if (cap == ci->i_auth_cap && in ceph_check_caps()
2036 (cap->issued & CEPH_CAP_FILE_WR)) { in ceph_check_caps()
2051 if (cap == ci->i_auth_cap) { in ceph_check_caps()
2065 ceph_cap_string(cap->implemented & ~cap->issued)); in ceph_check_caps()
2070 if (want & ~cap->mds_wanted) { in ceph_check_caps()
2071 if (want & ~(cap->mds_wanted | cap->issued)) in ceph_check_caps()
2073 if (!__cap_is_valid(cap)) in ceph_check_caps()
2078 if ((cap->issued & ~retain) == 0) in ceph_check_caps()
2082 if (session && session != cap->session) { in ceph_check_caps()
2088 session = cap->session; in ceph_check_caps()
2115 * cap message */ in ceph_check_caps()
2116 if (cap == ci->i_auth_cap && in ceph_check_caps()
2140 if (cap == ci->i_auth_cap && ci->i_dirty_caps) { in ceph_check_caps()
2155 mds = cap->mds; /* remember mds, so we don't repeat */ in ceph_check_caps()
2157 __prep_cap(&arg, cap, CEPH_CAP_OP_UPDATE, mflags, cap_used, in ceph_check_caps()
2163 goto retry; /* retake i_ceph_lock and restart our cap scan. */ in ceph_check_caps()
2200 struct ceph_cap *cap = ci->i_auth_cap; in try_flush_caps() local
2203 if (session != cap->session) { in try_flush_caps()
2207 session = cap->session; in try_flush_caps()
2211 if (cap->session->s_state < CEPH_MDS_SESSION_OPEN) { in try_flush_caps()
2229 __prep_cap(&arg, cap, CEPH_CAP_OP_FLUSH, CEPH_CLIENT_CAPS_SYNC, in try_flush_caps()
2231 (cap->issued | cap->implemented), in try_flush_caps()
2408 struct ceph_cap *cap; in __kick_flushing_caps() local
2427 cap = ci->i_auth_cap; in __kick_flushing_caps()
2428 if (!(cap && cap->session == session)) { in __kick_flushing_caps()
2429 pr_err("%p auth cap %p not mds%d ???\n", in __kick_flushing_caps()
2430 inode, cap, session->s_mds); in __kick_flushing_caps()
2439 dout("kick_flushing_caps %p cap %p tid %llu %s\n", in __kick_flushing_caps()
2440 inode, cap, cf->tid, ceph_cap_string(cf->caps)); in __kick_flushing_caps()
2441 __prep_cap(&arg, cap, CEPH_CAP_OP_FLUSH, in __kick_flushing_caps()
2446 (cap->issued | cap->implemented), in __kick_flushing_caps()
2461 ret = __send_flush_snap(inode, session, capsnap, cap->mseq, in __kick_flushing_caps()
2465 "cap flushsnap, ino (%llx.%llx) " in __kick_flushing_caps()
2482 struct ceph_cap *cap; in ceph_early_kick_flushing_caps() local
2493 cap = ci->i_auth_cap; in ceph_early_kick_flushing_caps()
2494 if (!(cap && cap->session == session)) { in ceph_early_kick_flushing_caps()
2495 pr_err("%p auth cap %p not mds%d ???\n", in ceph_early_kick_flushing_caps()
2496 &ci->vfs_inode, cap, session->s_mds); in ceph_early_kick_flushing_caps()
2503 * if flushing caps were revoked, we re-send the cap flush in ceph_early_kick_flushing_caps()
2505 * the cap flush message before issuing the flushing caps to in ceph_early_kick_flushing_caps()
2508 if ((cap->issued & ci->i_flushing_caps) != in ceph_early_kick_flushing_caps()
2511 * numbers. make sure sequence numbers in cap flush in ceph_early_kick_flushing_caps()
2513 cap->seq = 0; in ceph_early_kick_flushing_caps()
2514 cap->issue_seq = 0; in ceph_early_kick_flushing_caps()
2515 cap->mseq = 0; in ceph_early_kick_flushing_caps()
2530 struct ceph_cap *cap; in ceph_kick_flushing_caps() local
2543 cap = ci->i_auth_cap; in ceph_kick_flushing_caps()
2544 if (!(cap && cap->session == session)) { in ceph_kick_flushing_caps()
2545 pr_err("%p auth cap %p not mds%d ???\n", in ceph_kick_flushing_caps()
2546 &ci->vfs_inode, cap, session->s_mds); in ceph_kick_flushing_caps()
2562 struct ceph_cap *cap = ci->i_auth_cap; in ceph_kick_flushing_inode_caps() local
2573 &cap->session->s_cap_flushing); in ceph_kick_flushing_inode_caps()
2617 * Try to grab cap references. Specify those refs we @want, and the
2849 * Wait for caps, and take cap references. If we can't get a WR cap
2959 * drop cap refs first because getattr while in ceph_get_caps()
2988 * Take cap refs. Caller must already know we hold at least one ref
3023 * Release cap refs.
3025 * If we released the last ref on any given cap, call ceph_check_caps
3028 * If we are releasing a WR cap (from a sync write), finalize any affected
3241 * Handle a cap GRANT message from the MDS. (Note that a GRANT may
3242 * actually be a revocation if it specifies a smaller cap set.)
3248 struct ceph_cap *cap, in handle_cap_grant() argument
3262 bool was_stale = cap->cap_gen < session->s_cap_gen; in handle_cap_grant()
3270 dout("handle_cap_grant inode %p cap %p mds%d seq %d %s\n", in handle_cap_grant()
3271 inode, cap, session->s_mds, seq, ceph_cap_string(newcaps)); in handle_cap_grant()
3282 ((cap->issued & ~newcaps) & CEPH_CAP_FILE_CACHE) && in handle_cap_grant()
3296 cap->issued = cap->implemented = CEPH_CAP_PIN; in handle_cap_grant()
3299 * auth mds of the inode changed. we received the cap export message, in handle_cap_grant()
3300 * but still haven't received the cap import message. handle_cap_export in handle_cap_grant()
3301 * updated the new auth MDS' cap. in handle_cap_grant()
3303 * "ceph_seq_cmp(seq, cap->seq) <= 0" means we are processing a message in handle_cap_grant()
3304 * that was sent before the cap import message. So don't remove caps. in handle_cap_grant()
3306 if (ceph_seq_cmp(seq, cap->seq) <= 0) { in handle_cap_grant()
3307 WARN_ON(cap != ci->i_auth_cap); in handle_cap_grant()
3308 WARN_ON(cap->cap_id != le64_to_cpu(grant->cap_id)); in handle_cap_grant()
3309 seq = cap->seq; in handle_cap_grant()
3310 newcaps |= cap->issued; in handle_cap_grant()
3314 cap->cap_gen = session->s_cap_gen; in handle_cap_grant()
3315 cap->seq = seq; in handle_cap_grant()
3317 __check_cap_issue(ci, cap, newcaps); in handle_cap_grant()
3396 if (ci->i_auth_cap == cap && (newcaps & CEPH_CAP_ANY_FILE_WR)) { in handle_cap_grant()
3409 /* check cap bits */ in handle_cap_grant()
3419 (wanted & ~(cap->mds_wanted | newcaps))) { in handle_cap_grant()
3421 * If mds is importing cap, prior cap messages that update in handle_cap_grant()
3424 * We don't send cap message to update 'wanted' if what we in handle_cap_grant()
3425 * want are already issued. If mds revokes caps, cap message in handle_cap_grant()
3434 if (cap->issued & ~newcaps) { in handle_cap_grant()
3435 int revoking = cap->issued & ~newcaps; in handle_cap_grant()
3438 ceph_cap_string(cap->issued), in handle_cap_grant()
3448 else if (cap == ci->i_auth_cap) in handle_cap_grant()
3449 check_caps = 1; /* check auth cap only */ in handle_cap_grant()
3452 cap->issued = newcaps; in handle_cap_grant()
3453 cap->implemented |= newcaps; in handle_cap_grant()
3454 } else if (cap->issued == newcaps) { in handle_cap_grant()
3456 ceph_cap_string(cap->issued), ceph_cap_string(newcaps)); in handle_cap_grant()
3458 dout("grant: %s -> %s\n", ceph_cap_string(cap->issued), in handle_cap_grant()
3461 if (cap == ci->i_auth_cap && in handle_cap_grant()
3462 __ceph_caps_revoking_other(ci, cap, newcaps)) in handle_cap_grant()
3465 cap->issued = newcaps; in handle_cap_grant()
3466 cap->implemented |= newcaps; /* add bits only, to in handle_cap_grant()
3471 BUG_ON(cap->issued & ~cap->implemented); in handle_cap_grant()
3481 if (ci->i_auth_cap == cap && in handle_cap_grant()
3537 struct ceph_cap *cap) in handle_cap_flush_ack() argument
3598 dout(" mds%d still flushing cap on %p\n", in handle_cap_flush_ack()
3739 * Handle EXPORT from MDS. Cap is being migrated _from_ this mds to a
3741 * indicated by mseq), make note of the migrating cap bits for the
3752 struct ceph_cap *cap, *tcap, *new_cap = NULL; in handle_cap_export() local
3774 cap = __get_cap_for_mds(ci, mds); in handle_cap_export()
3775 if (!cap || cap->cap_id != le64_to_cpu(ex->cap_id)) in handle_cap_export()
3779 __ceph_remove_cap(cap, false); in handle_cap_export()
3784 * now we know we haven't received the cap import message yet in handle_cap_export()
3785 * because the exported cap still exist. in handle_cap_export()
3788 issued = cap->issued; in handle_cap_export()
3789 if (issued != cap->implemented) in handle_cap_export()
3793 ceph_vinop(inode), mds, cap->seq, cap->mseq, in handle_cap_export()
3795 ceph_cap_string(cap->implemented)); in handle_cap_export()
3803 dout(" updating import cap %p mds%d\n", tcap, target); in handle_cap_export()
3809 if (cap == ci->i_auth_cap) { in handle_cap_export()
3814 __ceph_remove_cap(cap, false); in handle_cap_export()
3818 int flag = (cap == ci->i_auth_cap) ? CEPH_CAP_FLAG_AUTH : 0; in handle_cap_export()
3831 __ceph_remove_cap(cap, false); in handle_cap_export()
3871 * Handle cap IMPORT.
3882 struct ceph_cap *cap, *ocap, *new_cap = NULL; in handle_cap_import() local
3905 cap = __get_cap_for_mds(ci, mds); in handle_cap_import()
3906 if (!cap) { in handle_cap_import()
3913 cap = new_cap; in handle_cap_import()
3929 dout(" remove export cap %p mds%d flags %d\n", in handle_cap_import()
3946 *target_cap = cap; in handle_cap_import()
3953 * based on the cap op.
3961 struct ceph_cap *cap; in ceph_handle_caps() local
4078 dout(" mds%d seq %lld cap seq %u\n", session->s_mds, session->s_seq, in ceph_handle_caps()
4085 cap = ceph_get_cap(mdsc, NULL); in ceph_handle_caps()
4086 cap->cap_ino = vino.ino; in ceph_handle_caps()
4087 cap->queue_release = 1; in ceph_handle_caps()
4088 cap->cap_id = le64_to_cpu(h->cap_id); in ceph_handle_caps()
4089 cap->mseq = mseq; in ceph_handle_caps()
4090 cap->seq = seq; in ceph_handle_caps()
4091 cap->issue_seq = seq; in ceph_handle_caps()
4093 __ceph_queue_cap_release(session, cap); in ceph_handle_caps()
4099 /* these will work even if we don't have a cap yet */ in ceph_handle_caps()
4123 &cap, &extra_info.issued); in ceph_handle_caps()
4124 handle_cap_grant(inode, session, cap, in ceph_handle_caps()
4131 /* the rest require a cap */ in ceph_handle_caps()
4133 cap = __get_cap_for_mds(ceph_inode(inode), session->s_mds); in ceph_handle_caps()
4134 if (!cap) { in ceph_handle_caps()
4135 dout(" no cap on %p ino %llx.%llx from mds%d\n", in ceph_handle_caps()
4148 handle_cap_grant(inode, session, cap, in ceph_handle_caps()
4154 h, session, cap); in ceph_handle_caps()
4166 pr_err("ceph_handle_caps: unknown cap op %d %s\n", op, in ceph_handle_caps()
4180 * send any cap release message to try to move things in ceph_handle_caps()
4182 * cap). in ceph_handle_caps()
4194 * Delayed work handler to process end of delayed cap release LRU list.
4386 * Helpers for embedding cap and dentry lease releases into mds
4397 struct ceph_cap *cap; in ceph_encode_inode_release() local
4413 cap = __get_cap_for_mds(ci, mds); in ceph_encode_inode_release()
4414 if (cap && __cap_is_valid(cap)) { in ceph_encode_inode_release()
4415 unless &= cap->issued; in ceph_encode_inode_release()
4427 if (force || (cap->issued & drop)) { in ceph_encode_inode_release()
4428 if (cap->issued & drop) { in ceph_encode_inode_release()
4430 dout("encode_inode_release %p cap %p " in ceph_encode_inode_release()
4431 "%s -> %s, wanted %s -> %s\n", inode, cap, in ceph_encode_inode_release()
4432 ceph_cap_string(cap->issued), in ceph_encode_inode_release()
4433 ceph_cap_string(cap->issued & ~drop), in ceph_encode_inode_release()
4434 ceph_cap_string(cap->mds_wanted), in ceph_encode_inode_release()
4437 cap->issued &= ~drop; in ceph_encode_inode_release()
4438 cap->implemented &= ~drop; in ceph_encode_inode_release()
4439 cap->mds_wanted = wanted; in ceph_encode_inode_release()
4440 if (cap == ci->i_auth_cap && in ceph_encode_inode_release()
4444 dout("encode_inode_release %p cap %p %s" in ceph_encode_inode_release()
4445 " (force)\n", inode, cap, in ceph_encode_inode_release()
4446 ceph_cap_string(cap->issued)); in ceph_encode_inode_release()
4450 rel->cap_id = cpu_to_le64(cap->cap_id); in ceph_encode_inode_release()
4451 rel->seq = cpu_to_le32(cap->seq); in ceph_encode_inode_release()
4452 rel->issue_seq = cpu_to_le32(cap->issue_seq); in ceph_encode_inode_release()
4453 rel->mseq = cpu_to_le32(cap->mseq); in ceph_encode_inode_release()
4454 rel->caps = cpu_to_le32(cap->implemented); in ceph_encode_inode_release()
4455 rel->wanted = cpu_to_le32(cap->mds_wanted); in ceph_encode_inode_release()
4461 dout("encode_inode_release %p cap %p %s (noop)\n", in ceph_encode_inode_release()
4462 inode, cap, ceph_cap_string(cap->issued)); in ceph_encode_inode_release()