Lines Matching refs:cap
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
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()
567 static void __check_cap_issue(struct ceph_inode_info *ci, struct ceph_cap *cap, in __check_cap_issue() argument
614 struct ceph_cap *cap; in ceph_add_cap() local
635 cap = __get_cap_for_mds(ci, mds); in ceph_add_cap()
636 if (!cap) { in ceph_add_cap()
637 cap = *new_cap; in ceph_add_cap()
640 cap->issued = 0; in ceph_add_cap()
641 cap->implemented = 0; in ceph_add_cap()
642 cap->mds = mds; in ceph_add_cap()
643 cap->mds_wanted = 0; in ceph_add_cap()
644 cap->mseq = 0; in ceph_add_cap()
646 cap->ci = ci; in ceph_add_cap()
647 __insert_cap_node(ci, cap); in ceph_add_cap()
650 cap->session = session; in ceph_add_cap()
652 list_add_tail(&cap->session_caps, &session->s_caps); in ceph_add_cap()
657 list_move_tail(&cap->session_caps, &session->s_caps); in ceph_add_cap()
660 if (cap->cap_gen < gen) in ceph_add_cap()
661 cap->issued = cap->implemented = CEPH_CAP_PIN; in ceph_add_cap()
672 if (ceph_seq_cmp(seq, cap->seq) <= 0) { in ceph_add_cap()
673 WARN_ON(cap != ci->i_auth_cap); in ceph_add_cap()
674 WARN_ON(cap->cap_id != cap_id); in ceph_add_cap()
675 seq = cap->seq; in ceph_add_cap()
676 mseq = cap->mseq; in ceph_add_cap()
677 issued |= cap->issued; in ceph_add_cap()
715 __check_cap_issue(ci, cap, issued); in ceph_add_cap()
734 ci->i_auth_cap = cap; in ceph_add_cap()
735 cap->mds_wanted = wanted; in ceph_add_cap()
738 WARN_ON(ci->i_auth_cap == cap); in ceph_add_cap()
742 inode, ceph_vinop(inode), cap, ceph_cap_string(issued), in ceph_add_cap()
743 ceph_cap_string(issued|cap->issued), seq, mds); in ceph_add_cap()
744 cap->cap_id = cap_id; in ceph_add_cap()
745 cap->issued = issued; in ceph_add_cap()
746 cap->implemented |= issued; in ceph_add_cap()
747 if (ceph_seq_cmp(mseq, cap->mseq) > 0) in ceph_add_cap()
748 cap->mds_wanted = wanted; in ceph_add_cap()
750 cap->mds_wanted |= wanted; in ceph_add_cap()
751 cap->seq = seq; in ceph_add_cap()
752 cap->issue_seq = seq; in ceph_add_cap()
753 cap->mseq = mseq; in ceph_add_cap()
754 cap->cap_gen = gen; in ceph_add_cap()
765 static int __cap_is_valid(struct ceph_cap *cap) in __cap_is_valid() argument
770 spin_lock(&cap->session->s_gen_ttl_lock); in __cap_is_valid()
771 gen = cap->session->s_cap_gen; in __cap_is_valid()
772 ttl = cap->session->s_cap_ttl; in __cap_is_valid()
773 spin_unlock(&cap->session->s_gen_ttl_lock); in __cap_is_valid()
775 if (cap->cap_gen < gen || time_after_eq(jiffies, ttl)) { in __cap_is_valid()
777 "but STALE (gen %u vs %u)\n", &cap->ci->vfs_inode, in __cap_is_valid()
778 cap, ceph_cap_string(cap->issued), cap->cap_gen, gen); in __cap_is_valid()
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()
803 &ci->vfs_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()
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()
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->vfs_inode, cap, in __touch_cap()
852 list_move_tail(&cap->session_caps, &s->s_caps); in __touch_cap()
855 &cap->ci->vfs_inode, cap, s->s_mds); in __touch_cap()
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()
885 " (mask %s)\n", ci->vfs_inode.i_ino, 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 __touch_cap(cap); in __ceph_caps_issued_mask()
927 struct ceph_cap *cap; in __ceph_caps_revoking_other() local
931 cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_caps_revoking_other()
932 if (cap != ocap && in __ceph_caps_revoking_other()
933 (cap->implemented & ~cap->issued & mask)) in __ceph_caps_revoking_other()
990 struct ceph_cap *cap; in __ceph_caps_mds_wanted() local
995 cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_caps_mds_wanted()
996 if (check && !__cap_is_valid(cap)) in __ceph_caps_mds_wanted()
998 if (cap == ci->i_auth_cap) in __ceph_caps_mds_wanted()
999 mds_wanted |= cap->mds_wanted; in __ceph_caps_mds_wanted()
1001 mds_wanted |= (cap->mds_wanted & ~CEPH_CAP_ANY_FILE_WR); in __ceph_caps_mds_wanted()
1051 void __ceph_remove_cap(struct ceph_cap *cap, bool queue_release) in __ceph_remove_cap() argument
1053 struct ceph_mds_session *session = cap->session; in __ceph_remove_cap()
1054 struct ceph_inode_info *ci = cap->ci; in __ceph_remove_cap()
1059 dout("__ceph_remove_cap %p from %p\n", cap, &ci->vfs_inode); in __ceph_remove_cap()
1062 rb_erase(&cap->ci_node, &ci->i_caps); in __ceph_remove_cap()
1063 if (ci->i_auth_cap == cap) in __ceph_remove_cap()
1068 if (session->s_cap_iterator == cap) { in __ceph_remove_cap()
1071 cap, cap->session); in __ceph_remove_cap()
1073 list_del_init(&cap->session_caps); in __ceph_remove_cap()
1075 cap->session = NULL; in __ceph_remove_cap()
1079 cap->ci = NULL; in __ceph_remove_cap()
1086 (!session->s_cap_reconnect || cap->cap_gen == session->s_cap_gen)) { in __ceph_remove_cap()
1087 cap->queue_release = 1; in __ceph_remove_cap()
1089 __ceph_queue_cap_release(session, cap); in __ceph_remove_cap()
1093 cap->queue_release = 0; in __ceph_remove_cap()
1095 cap->cap_ino = ci->i_vino.ino; in __ceph_remove_cap()
1100 ceph_put_cap(mdsc, cap); in __ceph_remove_cap()
1249 struct ceph_cap *cap = rb_entry(p, struct ceph_cap, ci_node); in __ceph_remove_caps() local
1251 __ceph_remove_cap(cap, true); in __ceph_remove_caps()
1269 static int __send_cap(struct ceph_mds_client *mdsc, struct ceph_cap *cap, in __send_cap() argument
1272 __releases(cap->ci->i_ceph_lock) in __send_cap()
1274 struct ceph_inode_info *ci = cap->ci; in __send_cap()
1283 held = cap->issued | cap->implemented; in __send_cap()
1284 revoking = cap->implemented & ~cap->issued; in __send_cap()
1288 inode, cap, cap->session, in __send_cap()
1293 arg.session = cap->session; in __send_cap()
1299 ceph_cap_string(cap->issued), in __send_cap()
1300 ceph_cap_string(cap->issued & retain), in __send_cap()
1301 ceph_cap_string(cap->mds_wanted), in __send_cap()
1303 want |= cap->mds_wanted; in __send_cap()
1304 retain |= cap->issued; in __send_cap()
1308 if (want & ~cap->mds_wanted) { in __send_cap()
1316 cap->issued &= retain; /* drop bits we don't want */ in __send_cap()
1317 if (cap->implemented & ~cap->issued) { in __send_cap()
1326 cap->implemented &= cap->issued | used; in __send_cap()
1327 cap->mds_wanted = want; in __send_cap()
1330 arg.cid = cap->cap_id; in __send_cap()
1355 arg.caps = cap->implemented; in __send_cap()
1359 arg.seq = cap->seq; in __send_cap()
1360 arg.issue_seq = cap->issue_seq; in __send_cap()
1361 arg.mseq = cap->mseq; in __send_cap()
1506 struct ceph_cap *cap = ci->i_auth_cap; in __ceph_flush_snaps() local
1510 if (!(cap && cap->session == session)) { in __ceph_flush_snaps()
1512 "stop\n", inode, cap, session->s_mds); in __ceph_flush_snaps()
1535 ret = __send_flush_snap(inode, session, capsnap, cap->mseq, in __ceph_flush_snaps()
1823 struct ceph_cap *cap; in ceph_check_caps() local
1924 cap = rb_entry(p, struct ceph_cap, ci_node); in ceph_check_caps()
1927 if (mds >= cap->mds || in ceph_check_caps()
1928 ((flags & CHECK_CAPS_AUTHONLY) && cap != ci->i_auth_cap)) in ceph_check_caps()
1934 if (ci->i_auth_cap && cap != ci->i_auth_cap) in ceph_check_caps()
1937 revoking = cap->implemented & ~cap->issued; in ceph_check_caps()
1939 cap->mds, cap, ceph_cap_string(cap_used), in ceph_check_caps()
1940 ceph_cap_string(cap->issued), in ceph_check_caps()
1941 ceph_cap_string(cap->implemented), in ceph_check_caps()
1944 if (cap == ci->i_auth_cap && in ceph_check_caps()
1945 (cap->issued & CEPH_CAP_FILE_WR)) { in ceph_check_caps()
1960 if (cap == ci->i_auth_cap) { in ceph_check_caps()
1974 ceph_cap_string(cap->implemented & ~cap->issued)); in ceph_check_caps()
1979 if (want & ~(cap->mds_wanted | cap->issued)) in ceph_check_caps()
1983 if ((cap->issued & ~retain) == 0) in ceph_check_caps()
1993 ceph_cap_string(cap->issued), in ceph_check_caps()
1994 ceph_cap_string(cap->issued & retain), in ceph_check_caps()
1995 ceph_cap_string(cap->mds_wanted), in ceph_check_caps()
2002 if (session && session != cap->session) { in ceph_check_caps()
2008 session = cap->session; in ceph_check_caps()
2024 if (cap == ci->i_auth_cap && in ceph_check_caps()
2048 if (cap == ci->i_auth_cap && ci->i_dirty_caps) { in ceph_check_caps()
2060 mds = cap->mds; /* remember mds, so we don't repeat */ in ceph_check_caps()
2064 delayed += __send_cap(mdsc, cap, CEPH_CAP_OP_UPDATE, 0, in ceph_check_caps()
2100 struct ceph_cap *cap = ci->i_auth_cap; in try_flush_caps() local
2103 if (session != cap->session) { in try_flush_caps()
2107 session = cap->session; in try_flush_caps()
2111 if (cap->session->s_state < CEPH_MDS_SESSION_OPEN) { in try_flush_caps()
2130 delayed = __send_cap(mdsc, cap, CEPH_CAP_OP_FLUSH, in try_flush_caps()
2134 (cap->issued | cap->implemented), in try_flush_caps()
2310 struct ceph_cap *cap; in __kick_flushing_caps() local
2329 cap = ci->i_auth_cap; in __kick_flushing_caps()
2330 if (!(cap && cap->session == session)) { in __kick_flushing_caps()
2332 inode, cap, session->s_mds); in __kick_flushing_caps()
2340 inode, cap, cf->tid, ceph_cap_string(cf->caps)); in __kick_flushing_caps()
2343 ret = __send_cap(mdsc, cap, CEPH_CAP_OP_FLUSH, in __kick_flushing_caps()
2348 (cap->issued | cap->implemented), in __kick_flushing_caps()
2368 ret = __send_flush_snap(inode, session, capsnap, cap->mseq, in __kick_flushing_caps()
2389 struct ceph_cap *cap; in ceph_early_kick_flushing_caps() local
2400 cap = ci->i_auth_cap; in ceph_early_kick_flushing_caps()
2401 if (!(cap && cap->session == session)) { in ceph_early_kick_flushing_caps()
2403 &ci->vfs_inode, cap, session->s_mds); in ceph_early_kick_flushing_caps()
2415 if ((cap->issued & ci->i_flushing_caps) != in ceph_early_kick_flushing_caps()
2420 cap->seq = 0; in ceph_early_kick_flushing_caps()
2421 cap->issue_seq = 0; in ceph_early_kick_flushing_caps()
2422 cap->mseq = 0; in ceph_early_kick_flushing_caps()
2437 struct ceph_cap *cap; in ceph_kick_flushing_caps() local
2448 cap = ci->i_auth_cap; in ceph_kick_flushing_caps()
2449 if (!(cap && cap->session == session)) { in ceph_kick_flushing_caps()
2451 &ci->vfs_inode, cap, session->s_mds); in ceph_kick_flushing_caps()
2469 struct ceph_cap *cap; in kick_flushing_inode_caps() local
2471 cap = ci->i_auth_cap; in kick_flushing_inode_caps()
2479 &cap->session->s_cap_flushing); in kick_flushing_inode_caps()
3089 struct ceph_cap *cap, in handle_cap_grant() argument
3103 bool was_stale = cap->cap_gen < session->s_cap_gen; in handle_cap_grant()
3112 inode, cap, session->s_mds, seq, ceph_cap_string(newcaps)); in handle_cap_grant()
3123 ((cap->issued & ~newcaps) & CEPH_CAP_FILE_CACHE) && in handle_cap_grant()
3137 cap->issued = cap->implemented = CEPH_CAP_PIN; in handle_cap_grant()
3147 if (ceph_seq_cmp(seq, cap->seq) <= 0) { in handle_cap_grant()
3148 WARN_ON(cap != ci->i_auth_cap); in handle_cap_grant()
3149 WARN_ON(cap->cap_id != le64_to_cpu(grant->cap_id)); in handle_cap_grant()
3150 seq = cap->seq; in handle_cap_grant()
3151 newcaps |= cap->issued; in handle_cap_grant()
3155 cap->cap_gen = session->s_cap_gen; in handle_cap_grant()
3156 cap->seq = seq; in handle_cap_grant()
3158 __check_cap_issue(ci, cap, newcaps); in handle_cap_grant()
3237 if (ci->i_auth_cap == cap && (newcaps & CEPH_CAP_ANY_FILE_WR)) { in handle_cap_grant()
3264 (wanted & ~(cap->mds_wanted | newcaps))) { in handle_cap_grant()
3279 if (cap->issued & ~newcaps) { in handle_cap_grant()
3280 int revoking = cap->issued & ~newcaps; in handle_cap_grant()
3283 ceph_cap_string(cap->issued), in handle_cap_grant()
3292 else if (cap == ci->i_auth_cap) in handle_cap_grant()
3296 cap->issued = newcaps; in handle_cap_grant()
3297 cap->implemented |= newcaps; in handle_cap_grant()
3298 } else if (cap->issued == newcaps) { in handle_cap_grant()
3300 ceph_cap_string(cap->issued), ceph_cap_string(newcaps)); in handle_cap_grant()
3302 dout("grant: %s -> %s\n", ceph_cap_string(cap->issued), in handle_cap_grant()
3305 if (cap == ci->i_auth_cap && in handle_cap_grant()
3306 __ceph_caps_revoking_other(ci, cap, newcaps)) in handle_cap_grant()
3309 cap->issued = newcaps; in handle_cap_grant()
3310 cap->implemented |= newcaps; /* add bits only, to in handle_cap_grant()
3315 BUG_ON(cap->issued & ~cap->implemented); in handle_cap_grant()
3371 struct ceph_cap *cap) in handle_cap_flush_ack() argument
3581 struct ceph_cap *cap, *tcap, *new_cap = NULL; in handle_cap_export() local
3603 cap = __get_cap_for_mds(ci, mds); in handle_cap_export()
3604 if (!cap || cap->cap_id != le64_to_cpu(ex->cap_id)) in handle_cap_export()
3608 if (cap->mds_wanted | cap->issued) in handle_cap_export()
3610 __ceph_remove_cap(cap, false); in handle_cap_export()
3619 issued = cap->issued; in handle_cap_export()
3620 if (issued != cap->implemented) in handle_cap_export()
3624 ceph_vinop(inode), mds, cap->seq, cap->mseq, in handle_cap_export()
3626 ceph_cap_string(cap->implemented)); in handle_cap_export()
3640 if (cap == ci->i_auth_cap) in handle_cap_export()
3651 __ceph_remove_cap(cap, false); in handle_cap_export()
3655 int flag = (cap == ci->i_auth_cap) ? CEPH_CAP_FLAG_AUTH : 0; in handle_cap_export()
3668 __ceph_remove_cap(cap, false); in handle_cap_export()
3719 struct ceph_cap *cap, *ocap, *new_cap = NULL; in handle_cap_import() local
3744 cap = __get_cap_for_mds(ci, mds); in handle_cap_import()
3745 if (!cap) { in handle_cap_import()
3751 cap = new_cap; in handle_cap_import()
3787 *target_cap = cap; in handle_cap_import()
3802 struct ceph_cap *cap; in ceph_handle_caps() local
3925 cap = ceph_get_cap(mdsc, NULL); in ceph_handle_caps()
3926 cap->cap_ino = vino.ino; in ceph_handle_caps()
3927 cap->queue_release = 1; in ceph_handle_caps()
3928 cap->cap_id = le64_to_cpu(h->cap_id); in ceph_handle_caps()
3929 cap->mseq = mseq; in ceph_handle_caps()
3930 cap->seq = seq; in ceph_handle_caps()
3931 cap->issue_seq = seq; in ceph_handle_caps()
3933 __ceph_queue_cap_release(session, cap); in ceph_handle_caps()
3962 &cap, &extra_info.issued); in ceph_handle_caps()
3963 handle_cap_grant(inode, session, cap, in ceph_handle_caps()
3972 cap = __get_cap_for_mds(ceph_inode(inode), session->s_mds); in ceph_handle_caps()
3973 if (!cap) { in ceph_handle_caps()
3987 handle_cap_grant(inode, session, cap, in ceph_handle_caps()
3993 h, session, cap); in ceph_handle_caps()
4164 struct ceph_cap *cap; in ceph_encode_inode_release() local
4180 cap = __get_cap_for_mds(ci, mds); in ceph_encode_inode_release()
4181 if (cap && __cap_is_valid(cap)) { in ceph_encode_inode_release()
4182 unless &= cap->issued; in ceph_encode_inode_release()
4194 if (force || (cap->issued & drop)) { in ceph_encode_inode_release()
4195 if (cap->issued & drop) { in ceph_encode_inode_release()
4198 wanted |= cap->mds_wanted; in ceph_encode_inode_release()
4200 "%s -> %s, wanted %s -> %s\n", inode, cap, in ceph_encode_inode_release()
4201 ceph_cap_string(cap->issued), in ceph_encode_inode_release()
4202 ceph_cap_string(cap->issued & ~drop), in ceph_encode_inode_release()
4203 ceph_cap_string(cap->mds_wanted), in ceph_encode_inode_release()
4206 cap->issued &= ~drop; in ceph_encode_inode_release()
4207 cap->implemented &= ~drop; in ceph_encode_inode_release()
4208 cap->mds_wanted = wanted; in ceph_encode_inode_release()
4211 " (force)\n", inode, cap, in ceph_encode_inode_release()
4212 ceph_cap_string(cap->issued)); in ceph_encode_inode_release()
4216 rel->cap_id = cpu_to_le64(cap->cap_id); in ceph_encode_inode_release()
4217 rel->seq = cpu_to_le32(cap->seq); in ceph_encode_inode_release()
4218 rel->issue_seq = cpu_to_le32(cap->issue_seq); in ceph_encode_inode_release()
4219 rel->mseq = cpu_to_le32(cap->mseq); in ceph_encode_inode_release()
4220 rel->caps = cpu_to_le32(cap->implemented); in ceph_encode_inode_release()
4221 rel->wanted = cpu_to_le32(cap->mds_wanted); in ceph_encode_inode_release()
4228 inode, cap, ceph_cap_string(cap->issued)); in ceph_encode_inode_release()