Lines Matching refs:ci

47 				 struct ceph_inode_info *ci,
413 static struct ceph_cap *__get_cap_for_mds(struct ceph_inode_info *ci, int mds) in __get_cap_for_mds() argument
416 struct rb_node *n = ci->i_caps.rb_node; in __get_cap_for_mds()
430 struct ceph_cap *ceph_get_cap_for_mds(struct ceph_inode_info *ci, int mds) in ceph_get_cap_for_mds() argument
434 spin_lock(&ci->i_ceph_lock); in ceph_get_cap_for_mds()
435 cap = __get_cap_for_mds(ci, mds); in ceph_get_cap_for_mds()
436 spin_unlock(&ci->i_ceph_lock); in ceph_get_cap_for_mds()
443 static int __ceph_get_cap_mds(struct ceph_inode_info *ci) in __ceph_get_cap_mds() argument
450 for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) { in __ceph_get_cap_mds()
463 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_get_cap_mds() local
465 spin_lock(&ci->i_ceph_lock); in ceph_get_cap_mds()
467 spin_unlock(&ci->i_ceph_lock); in ceph_get_cap_mds()
474 static void __insert_cap_node(struct ceph_inode_info *ci, in __insert_cap_node() argument
477 struct rb_node **p = &ci->i_caps.rb_node; in __insert_cap_node()
493 rb_insert_color(&new->ci_node, &ci->i_caps); in __insert_cap_node()
501 struct ceph_inode_info *ci) in __cap_set_timeouts() argument
505 ci->i_hold_caps_min = round_jiffies(jiffies + in __cap_set_timeouts()
507 ci->i_hold_caps_max = round_jiffies(jiffies + in __cap_set_timeouts()
509 dout("__cap_set_timeouts %p min %lu max %lu\n", &ci->vfs_inode, in __cap_set_timeouts()
510 ci->i_hold_caps_min - jiffies, ci->i_hold_caps_max - jiffies); in __cap_set_timeouts()
522 struct ceph_inode_info *ci) in __cap_delay_requeue() argument
524 __cap_set_timeouts(mdsc, ci); in __cap_delay_requeue()
525 dout("__cap_delay_requeue %p flags %d at %lu\n", &ci->vfs_inode, in __cap_delay_requeue()
526 ci->i_ceph_flags, ci->i_hold_caps_max); in __cap_delay_requeue()
529 if (!list_empty(&ci->i_cap_delay_list)) { in __cap_delay_requeue()
530 if (ci->i_ceph_flags & CEPH_I_FLUSH) in __cap_delay_requeue()
532 list_del_init(&ci->i_cap_delay_list); in __cap_delay_requeue()
534 list_add_tail(&ci->i_cap_delay_list, &mdsc->cap_delay_list); in __cap_delay_requeue()
546 struct ceph_inode_info *ci) in __cap_delay_requeue_front() argument
548 dout("__cap_delay_requeue_front %p\n", &ci->vfs_inode); in __cap_delay_requeue_front()
550 ci->i_ceph_flags |= CEPH_I_FLUSH; in __cap_delay_requeue_front()
551 if (!list_empty(&ci->i_cap_delay_list)) in __cap_delay_requeue_front()
552 list_del_init(&ci->i_cap_delay_list); in __cap_delay_requeue_front()
553 list_add(&ci->i_cap_delay_list, &mdsc->cap_delay_list); in __cap_delay_requeue_front()
563 struct ceph_inode_info *ci) in __cap_delay_cancel() argument
565 dout("__cap_delay_cancel %p\n", &ci->vfs_inode); in __cap_delay_cancel()
566 if (list_empty(&ci->i_cap_delay_list)) in __cap_delay_cancel()
569 list_del_init(&ci->i_cap_delay_list); in __cap_delay_cancel()
576 static void __check_cap_issue(struct ceph_inode_info *ci, struct ceph_cap *cap, in __check_cap_issue() argument
579 unsigned had = __ceph_caps_issued(ci, NULL); in __check_cap_issue()
587 ci->i_rdcache_gen++; in __check_cap_issue()
598 atomic_inc(&ci->i_shared_gen); in __check_cap_issue()
599 if (S_ISDIR(ci->vfs_inode.i_mode)) { in __check_cap_issue()
600 dout(" marking %p NOT complete\n", &ci->vfs_inode); in __check_cap_issue()
601 __ceph_dir_clear_complete(ci); in __check_cap_issue()
622 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_add_cap() local
637 cap = __get_cap_for_mds(ci, mds); in ceph_add_cap()
648 cap->ci = ci; in ceph_add_cap()
649 __insert_cap_node(ci, cap); in ceph_add_cap()
668 WARN_ON(cap != ci->i_auth_cap); in ceph_add_cap()
677 if (!ci->i_snap_realm || in ceph_add_cap()
679 realmino != (u64)-1 && ci->i_snap_realm->ino != realmino)) { in ceph_add_cap()
686 struct ceph_snap_realm *oldrealm = ci->i_snap_realm; in ceph_add_cap()
689 list_del_init(&ci->i_snap_realm_item); in ceph_add_cap()
694 list_add(&ci->i_snap_realm_item, in ceph_add_cap()
696 ci->i_snap_realm = realm; in ceph_add_cap()
697 if (realm->ino == ci->i_vino.ino) in ceph_add_cap()
710 __check_cap_issue(ci, cap, issued); in ceph_add_cap()
717 actual_wanted = __ceph_caps_wanted(ci); in ceph_add_cap()
723 __cap_delay_requeue(mdsc, ci); in ceph_add_cap()
727 if (!ci->i_auth_cap || in ceph_add_cap()
728 ceph_seq_cmp(ci->i_auth_cap->mseq, mseq) < 0) { in ceph_add_cap()
729 ci->i_auth_cap = cap; in ceph_add_cap()
733 WARN_ON(ci->i_auth_cap == cap); in ceph_add_cap()
752 __ceph_get_fmode(ci, fmode); in ceph_add_cap()
772 "but STALE (gen %u vs %u)\n", &cap->ci->vfs_inode, in __cap_is_valid()
785 int __ceph_caps_issued(struct ceph_inode_info *ci, int *implemented) in __ceph_caps_issued() argument
787 int have = ci->i_snap_caps; in __ceph_caps_issued()
793 for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) { in __ceph_caps_issued()
798 &ci->vfs_inode, cap, ceph_cap_string(cap->issued)); in __ceph_caps_issued()
808 if (ci->i_auth_cap) { in __ceph_caps_issued()
809 cap = ci->i_auth_cap; in __ceph_caps_issued()
818 int __ceph_caps_issued_other(struct ceph_inode_info *ci, struct ceph_cap *ocap) in __ceph_caps_issued_other() argument
820 int have = ci->i_snap_caps; in __ceph_caps_issued_other()
824 for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) { in __ceph_caps_issued_other()
845 dout("__touch_cap %p cap %p mds%d\n", &cap->ci->vfs_inode, cap, in __touch_cap()
850 &cap->ci->vfs_inode, cap, s->s_mds); in __touch_cap()
860 int __ceph_caps_issued_mask(struct ceph_inode_info *ci, int mask, int touch) in __ceph_caps_issued_mask() argument
864 int have = ci->i_snap_caps; in __ceph_caps_issued_mask()
868 " (mask %s)\n", &ci->vfs_inode, in __ceph_caps_issued_mask()
874 for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) { in __ceph_caps_issued_mask()
880 " (mask %s)\n", &ci->vfs_inode, cap, in __ceph_caps_issued_mask()
892 " (mask %s)\n", &ci->vfs_inode, in __ceph_caps_issued_mask()
900 for (q = rb_first(&ci->i_caps); q != p; in __ceph_caps_issued_mask()
919 int __ceph_caps_revoking_other(struct ceph_inode_info *ci, in __ceph_caps_revoking_other() argument
925 for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) { in __ceph_caps_revoking_other()
934 int ceph_caps_revoking(struct ceph_inode_info *ci, int mask) in ceph_caps_revoking() argument
936 struct inode *inode = &ci->vfs_inode; in ceph_caps_revoking()
939 spin_lock(&ci->i_ceph_lock); in ceph_caps_revoking()
940 ret = __ceph_caps_revoking_other(ci, NULL, mask); in ceph_caps_revoking()
941 spin_unlock(&ci->i_ceph_lock); in ceph_caps_revoking()
947 int __ceph_caps_used(struct ceph_inode_info *ci) in __ceph_caps_used() argument
950 if (ci->i_pin_ref) in __ceph_caps_used()
952 if (ci->i_rd_ref) in __ceph_caps_used()
954 if (ci->i_rdcache_ref || in __ceph_caps_used()
955 (!S_ISDIR(ci->vfs_inode.i_mode) && /* ignore readdir cache */ in __ceph_caps_used()
956 ci->vfs_inode.i_data.nrpages)) in __ceph_caps_used()
958 if (ci->i_wr_ref) in __ceph_caps_used()
960 if (ci->i_wb_ref || ci->i_wrbuffer_ref) in __ceph_caps_used()
968 int __ceph_caps_file_wanted(struct ceph_inode_info *ci) in __ceph_caps_file_wanted() argument
972 if (ci->i_nr_by_mode[i]) in __ceph_caps_file_wanted()
983 int __ceph_caps_mds_wanted(struct ceph_inode_info *ci, bool check) in __ceph_caps_mds_wanted() argument
989 for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) { in __ceph_caps_mds_wanted()
993 if (cap == ci->i_auth_cap) in __ceph_caps_mds_wanted()
1004 static int __ceph_is_single_caps(struct ceph_inode_info *ci) in __ceph_is_single_caps() argument
1006 return rb_first(&ci->i_caps) == rb_last(&ci->i_caps); in __ceph_is_single_caps()
1009 static int __ceph_is_any_caps(struct ceph_inode_info *ci) in __ceph_is_any_caps() argument
1011 return !RB_EMPTY_ROOT(&ci->i_caps); in __ceph_is_any_caps()
1016 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_is_any_caps() local
1019 spin_lock(&ci->i_ceph_lock); in ceph_is_any_caps()
1020 ret = __ceph_is_any_caps(ci); in ceph_is_any_caps()
1021 spin_unlock(&ci->i_ceph_lock); in ceph_is_any_caps()
1026 static void drop_inode_snap_realm(struct ceph_inode_info *ci) in drop_inode_snap_realm() argument
1028 struct ceph_snap_realm *realm = ci->i_snap_realm; in drop_inode_snap_realm()
1030 list_del_init(&ci->i_snap_realm_item); in drop_inode_snap_realm()
1031 ci->i_snap_realm_counter++; in drop_inode_snap_realm()
1032 ci->i_snap_realm = NULL; in drop_inode_snap_realm()
1034 ceph_put_snap_realm(ceph_sb_to_client(ci->vfs_inode.i_sb)->mdsc, in drop_inode_snap_realm()
1047 struct ceph_inode_info *ci = cap->ci; in __ceph_remove_cap() local
1049 ceph_sb_to_client(ci->vfs_inode.i_sb)->mdsc; in __ceph_remove_cap()
1052 dout("__ceph_remove_cap %p from %p\n", cap, &ci->vfs_inode); in __ceph_remove_cap()
1067 cap->ci = NULL; in __ceph_remove_cap()
1085 cap->cap_ino = ci->i_vino.ino; in __ceph_remove_cap()
1090 rb_erase(&cap->ci_node, &ci->i_caps); in __ceph_remove_cap()
1091 if (ci->i_auth_cap == cap) in __ceph_remove_cap()
1092 ci->i_auth_cap = NULL; in __ceph_remove_cap()
1101 if (!__ceph_is_any_caps(ci) && ci->i_wr_ref == 0 && ci->i_snap_realm) in __ceph_remove_cap()
1102 drop_inode_snap_realm(ci); in __ceph_remove_cap()
1104 if (!__ceph_is_any_real_caps(ci)) in __ceph_remove_cap()
1105 __cap_delay_cancel(mdsc, ci); in __ceph_remove_cap()
1243 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_queue_caps_release() local
1246 p = rb_first(&ci->i_caps); in ceph_queue_caps_release()
1274 __releases(cap->ci->i_ceph_lock) in __send_cap()
1276 struct ceph_inode_info *ci = cap->ci; in __send_cap() local
1277 struct inode *inode = &ci->vfs_inode; in __send_cap()
1297 if ((ci->i_ceph_flags & CEPH_I_NODELAY) == 0 && in __send_cap()
1298 time_before(jiffies, ci->i_hold_caps_min)) { in __send_cap()
1308 ci->i_ceph_flags &= ~(CEPH_I_NODELAY | CEPH_I_FLUSH); in __send_cap()
1314 __cap_set_timeouts(mdsc, ci); in __send_cap()
1332 arg.follows = flushing ? ci->i_head_snapc->seq : 0; in __send_cap()
1337 ci->i_reported_size = arg.size; in __send_cap()
1338 arg.max_size = ci->i_wanted_max_size; in __send_cap()
1339 ci->i_requested_max_size = arg.max_size; in __send_cap()
1342 __ceph_build_xattrs_blob(ci); in __send_cap()
1343 arg.xattr_version = ci->i_xattrs.version; in __send_cap()
1344 arg.xattr_buf = ci->i_xattrs.blob; in __send_cap()
1361 arg.time_warp_seq = ci->i_time_warp_seq; in __send_cap()
1367 arg.inline_data = ci->i_inline_version != CEPH_INLINE_NONE; in __send_cap()
1368 if (list_empty(&ci->i_cap_snaps)) in __send_cap()
1375 spin_unlock(&ci->i_ceph_lock); in __send_cap()
1384 wake_up_all(&ci->i_cap_wq); in __send_cap()
1441 static void __ceph_flush_snaps(struct ceph_inode_info *ci, in __ceph_flush_snaps() argument
1443 __releases(ci->i_ceph_lock) in __ceph_flush_snaps()
1444 __acquires(ci->i_ceph_lock) in __ceph_flush_snaps()
1446 struct inode *inode = &ci->vfs_inode; in __ceph_flush_snaps()
1454 list_for_each_entry(capsnap, &ci->i_cap_snaps, ci_item) { in __ceph_flush_snaps()
1477 if (list_empty(&ci->i_flushing_item)) { in __ceph_flush_snaps()
1478 list_add_tail(&ci->i_flushing_item, in __ceph_flush_snaps()
1484 &ci->i_cap_flush_list); in __ceph_flush_snaps()
1491 ci->i_ceph_flags &= ~CEPH_I_FLUSH_SNAPS; in __ceph_flush_snaps()
1494 struct ceph_cap *cap = ci->i_auth_cap; in __ceph_flush_snaps()
1505 list_for_each_entry(cf, &ci->i_cap_flush_list, i_list) { in __ceph_flush_snaps()
1518 spin_unlock(&ci->i_ceph_lock); in __ceph_flush_snaps()
1532 spin_lock(&ci->i_ceph_lock); in __ceph_flush_snaps()
1536 void ceph_flush_snaps(struct ceph_inode_info *ci, in ceph_flush_snaps() argument
1539 struct inode *inode = &ci->vfs_inode; in ceph_flush_snaps()
1548 spin_lock(&ci->i_ceph_lock); in ceph_flush_snaps()
1549 if (!(ci->i_ceph_flags & CEPH_I_FLUSH_SNAPS)) { in ceph_flush_snaps()
1553 if (!ci->i_auth_cap) { in ceph_flush_snaps()
1558 mds = ci->i_auth_cap->session->s_mds; in ceph_flush_snaps()
1566 spin_unlock(&ci->i_ceph_lock); in ceph_flush_snaps()
1578 if (ci->i_ceph_flags & CEPH_I_KICK_FLUSH) { in ceph_flush_snaps()
1579 __kick_flushing_caps(mdsc, session, ci, 0); in ceph_flush_snaps()
1580 ci->i_ceph_flags &= ~CEPH_I_KICK_FLUSH; in ceph_flush_snaps()
1583 __ceph_flush_snaps(ci, session); in ceph_flush_snaps()
1585 spin_unlock(&ci->i_ceph_lock); in ceph_flush_snaps()
1595 list_del_init(&ci->i_snap_flush_item); in ceph_flush_snaps()
1604 int __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask, in __ceph_mark_dirty_caps() argument
1608 ceph_sb_to_client(ci->vfs_inode.i_sb)->mdsc; in __ceph_mark_dirty_caps()
1609 struct inode *inode = &ci->vfs_inode; in __ceph_mark_dirty_caps()
1610 int was = ci->i_dirty_caps; in __ceph_mark_dirty_caps()
1613 if (!ci->i_auth_cap) { in __ceph_mark_dirty_caps()
1620 dout("__mark_dirty_caps %p %s dirty %s -> %s\n", &ci->vfs_inode, in __ceph_mark_dirty_caps()
1623 ci->i_dirty_caps |= mask; in __ceph_mark_dirty_caps()
1625 WARN_ON_ONCE(ci->i_prealloc_cap_flush); in __ceph_mark_dirty_caps()
1626 swap(ci->i_prealloc_cap_flush, *pcf); in __ceph_mark_dirty_caps()
1628 if (!ci->i_head_snapc) { in __ceph_mark_dirty_caps()
1630 ci->i_head_snapc = ceph_get_snap_context( in __ceph_mark_dirty_caps()
1631 ci->i_snap_realm->cached_context); in __ceph_mark_dirty_caps()
1634 &ci->vfs_inode, ci->i_head_snapc, ci->i_auth_cap); in __ceph_mark_dirty_caps()
1635 BUG_ON(!list_empty(&ci->i_dirty_item)); in __ceph_mark_dirty_caps()
1637 list_add(&ci->i_dirty_item, &mdsc->cap_dirty); in __ceph_mark_dirty_caps()
1639 if (ci->i_flushing_caps == 0) { in __ceph_mark_dirty_caps()
1644 WARN_ON_ONCE(!ci->i_prealloc_cap_flush); in __ceph_mark_dirty_caps()
1646 BUG_ON(list_empty(&ci->i_dirty_item)); in __ceph_mark_dirty_caps()
1647 if (((was | ci->i_flushing_caps) & CEPH_CAP_FILE_BUFFER) && in __ceph_mark_dirty_caps()
1650 __cap_delay_requeue(mdsc, ci); in __ceph_mark_dirty_caps()
1681 struct ceph_inode_info *ci, in __finish_cap_flush() argument
1694 } else if (ci) { in __finish_cap_flush()
1695 if (wake && cf->i_list.prev != &ci->i_cap_flush_list) { in __finish_cap_flush()
1718 struct ceph_inode_info *ci = ceph_inode(inode); in __mark_caps_flushing() local
1722 BUG_ON(ci->i_dirty_caps == 0); in __mark_caps_flushing()
1723 BUG_ON(list_empty(&ci->i_dirty_item)); in __mark_caps_flushing()
1724 BUG_ON(!ci->i_prealloc_cap_flush); in __mark_caps_flushing()
1726 flushing = ci->i_dirty_caps; in __mark_caps_flushing()
1729 ceph_cap_string(ci->i_flushing_caps), in __mark_caps_flushing()
1730 ceph_cap_string(ci->i_flushing_caps | flushing)); in __mark_caps_flushing()
1731 ci->i_flushing_caps |= flushing; in __mark_caps_flushing()
1732 ci->i_dirty_caps = 0; in __mark_caps_flushing()
1735 swap(cf, ci->i_prealloc_cap_flush); in __mark_caps_flushing()
1740 list_del_init(&ci->i_dirty_item); in __mark_caps_flushing()
1746 if (list_empty(&ci->i_flushing_item)) { in __mark_caps_flushing()
1747 list_add_tail(&ci->i_flushing_item, &session->s_cap_flushing); in __mark_caps_flushing()
1752 list_add_tail(&cf->i_list, &ci->i_cap_flush_list); in __mark_caps_flushing()
1763 struct ceph_inode_info *ci = ceph_inode(inode); in try_nonblocking_invalidate() local
1764 u32 invalidating_gen = ci->i_rdcache_gen; in try_nonblocking_invalidate()
1766 spin_unlock(&ci->i_ceph_lock); in try_nonblocking_invalidate()
1768 spin_lock(&ci->i_ceph_lock); in try_nonblocking_invalidate()
1771 invalidating_gen == ci->i_rdcache_gen) { in try_nonblocking_invalidate()
1775 ci->i_rdcache_revoking = ci->i_rdcache_gen - 1; in try_nonblocking_invalidate()
1782 bool __ceph_should_report_size(struct ceph_inode_info *ci) in __ceph_should_report_size() argument
1784 loff_t size = ci->vfs_inode.i_size; in __ceph_should_report_size()
1786 if (ci->i_flushing_caps & CEPH_CAP_FILE_WR) in __ceph_should_report_size()
1788 if (size >= ci->i_max_size) in __ceph_should_report_size()
1791 if (ci->i_max_size > ci->i_reported_size && in __ceph_should_report_size()
1792 (size << 1) >= ci->i_max_size + ci->i_reported_size) in __ceph_should_report_size()
1808 void ceph_check_caps(struct ceph_inode_info *ci, int flags, in ceph_check_caps() argument
1811 struct ceph_fs_client *fsc = ceph_inode_to_client(&ci->vfs_inode); in ceph_check_caps()
1813 struct inode *inode = &ci->vfs_inode; in ceph_check_caps()
1831 spin_lock(&ci->i_ceph_lock); in ceph_check_caps()
1833 if (ci->i_ceph_flags & CEPH_I_FLUSH) in ceph_check_caps()
1837 (ci->i_auth_cap && __ceph_is_single_caps(ci))) in ceph_check_caps()
1838 __cap_delay_cancel(mdsc, ci); in ceph_check_caps()
1842 spin_lock(&ci->i_ceph_lock); in ceph_check_caps()
1844 file_wanted = __ceph_caps_file_wanted(ci); in ceph_check_caps()
1845 used = __ceph_caps_used(ci); in ceph_check_caps()
1846 issued = __ceph_caps_issued(ci, &implemented); in ceph_check_caps()
1856 __ceph_dir_is_complete(ci)) { in ceph_check_caps()
1873 if (ci->i_max_size == 0) in ceph_check_caps()
1881 ceph_cap_string(used), ceph_cap_string(ci->i_dirty_caps), in ceph_check_caps()
1882 ceph_cap_string(ci->i_flushing_caps), in ceph_check_caps()
1896 !(ci->i_wb_ref || ci->i_wrbuffer_ref) && /* no dirty pages... */ in ceph_check_caps()
1905 ci->i_rdcache_revoking = ci->i_rdcache_gen; in ceph_check_caps()
1911 for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) { in ceph_check_caps()
1916 ((flags & CHECK_CAPS_AUTHONLY) && cap != ci->i_auth_cap)) in ceph_check_caps()
1922 if (ci->i_auth_cap && cap != ci->i_auth_cap) in ceph_check_caps()
1923 cap_used &= ~ci->i_auth_cap->issued; in ceph_check_caps()
1932 if (cap == ci->i_auth_cap && in ceph_check_caps()
1935 if (ci->i_wanted_max_size > ci->i_max_size && in ceph_check_caps()
1936 ci->i_wanted_max_size > ci->i_requested_max_size) { in ceph_check_caps()
1942 if (__ceph_should_report_size(ci)) { in ceph_check_caps()
1948 if (cap == ci->i_auth_cap) { in ceph_check_caps()
1949 if ((flags & CHECK_CAPS_FLUSH) && ci->i_dirty_caps) { in ceph_check_caps()
1953 if (ci->i_ceph_flags & CEPH_I_FLUSH_SNAPS) { in ceph_check_caps()
1979 if ((ci->i_ceph_flags & CEPH_I_NODELAY) == 0 && in ceph_check_caps()
1980 time_before(jiffies, ci->i_hold_caps_max)) { in ceph_check_caps()
1991 if (ci->i_ceph_flags & CEPH_I_NOFLUSH) { in ceph_check_caps()
2006 spin_unlock(&ci->i_ceph_lock); in ceph_check_caps()
2018 if (cap == ci->i_auth_cap && in ceph_check_caps()
2019 (ci->i_ceph_flags & in ceph_check_caps()
2021 if (ci->i_ceph_flags & CEPH_I_KICK_FLUSH) { in ceph_check_caps()
2022 __kick_flushing_caps(mdsc, session, ci, 0); in ceph_check_caps()
2023 ci->i_ceph_flags &= ~CEPH_I_KICK_FLUSH; in ceph_check_caps()
2025 if (ci->i_ceph_flags & CEPH_I_FLUSH_SNAPS) in ceph_check_caps()
2026 __ceph_flush_snaps(ci, session); in ceph_check_caps()
2036 spin_unlock(&ci->i_ceph_lock); in ceph_check_caps()
2044 if (cap == ci->i_auth_cap && ci->i_dirty_caps) { in ceph_check_caps()
2068 __cap_delay_requeue(mdsc, ci); in ceph_check_caps()
2070 spin_unlock(&ci->i_ceph_lock); in ceph_check_caps()
2087 struct ceph_inode_info *ci = ceph_inode(inode); in try_flush_caps() local
2093 spin_lock(&ci->i_ceph_lock); in try_flush_caps()
2094 if (ci->i_ceph_flags & CEPH_I_NOFLUSH) { in try_flush_caps()
2095 spin_unlock(&ci->i_ceph_lock); in try_flush_caps()
2099 if (ci->i_dirty_caps && ci->i_auth_cap) { in try_flush_caps()
2100 struct ceph_cap *cap = ci->i_auth_cap; in try_flush_caps()
2101 int used = __ceph_caps_used(ci); in try_flush_caps()
2102 int want = __ceph_caps_wanted(ci); in try_flush_caps()
2106 spin_unlock(&ci->i_ceph_lock); in try_flush_caps()
2114 spin_unlock(&ci->i_ceph_lock); in try_flush_caps()
2127 spin_lock(&ci->i_ceph_lock); in try_flush_caps()
2128 __cap_delay_requeue(mdsc, ci); in try_flush_caps()
2129 spin_unlock(&ci->i_ceph_lock); in try_flush_caps()
2132 if (!list_empty(&ci->i_cap_flush_list)) { in try_flush_caps()
2134 list_last_entry(&ci->i_cap_flush_list, in try_flush_caps()
2139 flushing = ci->i_flushing_caps; in try_flush_caps()
2140 spin_unlock(&ci->i_ceph_lock); in try_flush_caps()
2155 struct ceph_inode_info *ci = ceph_inode(inode); in caps_are_flushed() local
2158 spin_lock(&ci->i_ceph_lock); in caps_are_flushed()
2159 if (!list_empty(&ci->i_cap_flush_list)) { in caps_are_flushed()
2161 list_first_entry(&ci->i_cap_flush_list, in caps_are_flushed()
2166 spin_unlock(&ci->i_ceph_lock); in caps_are_flushed()
2175 struct ceph_inode_info *ci = ceph_inode(inode); in unsafe_request_wait() local
2179 spin_lock(&ci->i_unsafe_lock); in unsafe_request_wait()
2180 if (S_ISDIR(inode->i_mode) && !list_empty(&ci->i_unsafe_dirops)) { in unsafe_request_wait()
2181 req1 = list_last_entry(&ci->i_unsafe_dirops, in unsafe_request_wait()
2186 if (!list_empty(&ci->i_unsafe_iops)) { in unsafe_request_wait()
2187 req2 = list_last_entry(&ci->i_unsafe_iops, in unsafe_request_wait()
2192 spin_unlock(&ci->i_unsafe_lock); in unsafe_request_wait()
2216 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_fsync() local
2243 ret = wait_event_interruptible(ci->i_cap_wq, in ceph_fsync()
2260 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_write_inode() local
2270 err = wait_event_interruptible(ci->i_cap_wq, in ceph_write_inode()
2276 spin_lock(&ci->i_ceph_lock); in ceph_write_inode()
2277 if (__ceph_caps_dirty(ci)) in ceph_write_inode()
2278 __cap_delay_requeue_front(mdsc, ci); in ceph_write_inode()
2279 spin_unlock(&ci->i_ceph_lock); in ceph_write_inode()
2286 struct ceph_inode_info *ci, in __kick_flushing_caps() argument
2288 __releases(ci->i_ceph_lock) in __kick_flushing_caps()
2289 __acquires(ci->i_ceph_lock) in __kick_flushing_caps()
2291 struct inode *inode = &ci->vfs_inode; in __kick_flushing_caps()
2297 list_for_each_entry(cf, &ci->i_cap_flush_list, i_list) { in __kick_flushing_caps()
2301 cap = ci->i_auth_cap; in __kick_flushing_caps()
2313 ci->i_ceph_flags |= CEPH_I_NODELAY; in __kick_flushing_caps()
2315 false, __ceph_caps_used(ci), in __kick_flushing_caps()
2316 __ceph_caps_wanted(ci), in __kick_flushing_caps()
2335 spin_unlock(&ci->i_ceph_lock); in __kick_flushing_caps()
2350 spin_lock(&ci->i_ceph_lock); in __kick_flushing_caps()
2357 struct ceph_inode_info *ci; in ceph_early_kick_flushing_caps() local
2367 list_for_each_entry(ci, &session->s_cap_flushing, i_flushing_item) { in ceph_early_kick_flushing_caps()
2368 spin_lock(&ci->i_ceph_lock); in ceph_early_kick_flushing_caps()
2369 cap = ci->i_auth_cap; in ceph_early_kick_flushing_caps()
2372 &ci->vfs_inode, cap, session->s_mds); in ceph_early_kick_flushing_caps()
2373 spin_unlock(&ci->i_ceph_lock); in ceph_early_kick_flushing_caps()
2384 if ((cap->issued & ci->i_flushing_caps) != in ceph_early_kick_flushing_caps()
2385 ci->i_flushing_caps) { in ceph_early_kick_flushing_caps()
2386 ci->i_ceph_flags &= ~CEPH_I_KICK_FLUSH; in ceph_early_kick_flushing_caps()
2387 __kick_flushing_caps(mdsc, session, ci, in ceph_early_kick_flushing_caps()
2390 ci->i_ceph_flags |= CEPH_I_KICK_FLUSH; in ceph_early_kick_flushing_caps()
2393 spin_unlock(&ci->i_ceph_lock); in ceph_early_kick_flushing_caps()
2400 struct ceph_inode_info *ci; in ceph_kick_flushing_caps() local
2410 list_for_each_entry(ci, &session->s_cap_flushing, i_flushing_item) { in ceph_kick_flushing_caps()
2411 spin_lock(&ci->i_ceph_lock); in ceph_kick_flushing_caps()
2412 cap = ci->i_auth_cap; in ceph_kick_flushing_caps()
2415 &ci->vfs_inode, cap, session->s_mds); in ceph_kick_flushing_caps()
2416 spin_unlock(&ci->i_ceph_lock); in ceph_kick_flushing_caps()
2419 if (ci->i_ceph_flags & CEPH_I_KICK_FLUSH) { in ceph_kick_flushing_caps()
2420 ci->i_ceph_flags &= ~CEPH_I_KICK_FLUSH; in ceph_kick_flushing_caps()
2421 __kick_flushing_caps(mdsc, session, ci, in ceph_kick_flushing_caps()
2424 spin_unlock(&ci->i_ceph_lock); in ceph_kick_flushing_caps()
2431 __releases(ci->i_ceph_lock) in kick_flushing_inode_caps()
2433 struct ceph_inode_info *ci = ceph_inode(inode); in kick_flushing_inode_caps() local
2436 cap = ci->i_auth_cap; in kick_flushing_inode_caps()
2438 ceph_cap_string(ci->i_flushing_caps)); in kick_flushing_inode_caps()
2440 if (!list_empty(&ci->i_cap_flush_list)) { in kick_flushing_inode_caps()
2443 list_move_tail(&ci->i_flushing_item, in kick_flushing_inode_caps()
2448 ci->i_ceph_flags &= ~CEPH_I_KICK_FLUSH; in kick_flushing_inode_caps()
2449 __kick_flushing_caps(mdsc, session, ci, oldest_flush_tid); in kick_flushing_inode_caps()
2450 spin_unlock(&ci->i_ceph_lock); in kick_flushing_inode_caps()
2452 spin_unlock(&ci->i_ceph_lock); in kick_flushing_inode_caps()
2463 static void __take_cap_refs(struct ceph_inode_info *ci, int got, in __take_cap_refs() argument
2467 ci->i_pin_ref++; in __take_cap_refs()
2469 ci->i_rd_ref++; in __take_cap_refs()
2471 ci->i_rdcache_ref++; in __take_cap_refs()
2473 if (ci->i_wr_ref == 0 && !ci->i_head_snapc) { in __take_cap_refs()
2475 ci->i_head_snapc = ceph_get_snap_context( in __take_cap_refs()
2476 ci->i_snap_realm->cached_context); in __take_cap_refs()
2478 ci->i_wr_ref++; in __take_cap_refs()
2481 if (ci->i_wb_ref == 0) in __take_cap_refs()
2482 ihold(&ci->vfs_inode); in __take_cap_refs()
2483 ci->i_wb_ref++; in __take_cap_refs()
2485 &ci->vfs_inode, ci->i_wb_ref-1, ci->i_wb_ref); in __take_cap_refs()
2496 static int try_get_cap_refs(struct ceph_inode_info *ci, int need, int want, in try_get_cap_refs() argument
2499 struct inode *inode = &ci->vfs_inode; in try_get_cap_refs()
2510 spin_lock(&ci->i_ceph_lock); in try_get_cap_refs()
2513 file_wanted = __ceph_caps_file_wanted(ci); in try_get_cap_refs()
2523 while (ci->i_truncate_pending) { in try_get_cap_refs()
2524 spin_unlock(&ci->i_ceph_lock); in try_get_cap_refs()
2530 spin_lock(&ci->i_ceph_lock); in try_get_cap_refs()
2533 have = __ceph_caps_issued(ci, &implemented); in try_get_cap_refs()
2536 if (endoff >= 0 && endoff > (loff_t)ci->i_max_size) { in try_get_cap_refs()
2538 inode, endoff, ci->i_max_size); in try_get_cap_refs()
2539 if (endoff > ci->i_requested_max_size) { in try_get_cap_refs()
2549 if (__ceph_have_pending_cap_snap(ci)) { in try_get_cap_refs()
2569 !ci->i_head_snapc && in try_get_cap_refs()
2582 spin_unlock(&ci->i_ceph_lock); in try_get_cap_refs()
2592 ceph_disable_fscache_readpage(ci); in try_get_cap_refs()
2593 __take_cap_refs(ci, *got, true); in try_get_cap_refs()
2598 if ((need & CEPH_CAP_FILE_WR) && ci->i_auth_cap) { in try_get_cap_refs()
2599 struct ceph_mds_session *s = ci->i_auth_cap->session; in try_get_cap_refs()
2606 inode, ceph_cap_string(need), ci->i_auth_cap->mds); in try_get_cap_refs()
2612 if (ci->i_ceph_flags & CEPH_I_CAP_DROPPED) { in try_get_cap_refs()
2621 mds_wanted = __ceph_caps_mds_wanted(ci, false); in try_get_cap_refs()
2630 ci->i_ceph_flags &= ~CEPH_I_CAP_DROPPED; in try_get_cap_refs()
2637 spin_unlock(&ci->i_ceph_lock); in try_get_cap_refs()
2653 struct ceph_inode_info *ci = ceph_inode(inode); in check_max_size() local
2657 spin_lock(&ci->i_ceph_lock); in check_max_size()
2658 if (endoff >= ci->i_max_size && endoff > ci->i_wanted_max_size) { in check_max_size()
2661 ci->i_wanted_max_size = endoff; in check_max_size()
2664 if (ci->i_auth_cap && in check_max_size()
2665 (ci->i_auth_cap->issued & CEPH_CAP_FILE_WR) && in check_max_size()
2666 ci->i_wanted_max_size > ci->i_max_size && in check_max_size()
2667 ci->i_wanted_max_size > ci->i_requested_max_size) in check_max_size()
2669 spin_unlock(&ci->i_ceph_lock); in check_max_size()
2671 ceph_check_caps(ci, CHECK_CAPS_AUTHONLY, NULL); in check_max_size()
2674 int ceph_try_get_caps(struct ceph_inode_info *ci, int need, int want, int *got) in ceph_try_get_caps() argument
2680 ret = ceph_pool_perm_check(ci, need); in ceph_try_get_caps()
2684 ret = try_get_cap_refs(ci, need, want, 0, true, got, &err); in ceph_try_get_caps()
2700 int ceph_get_caps(struct ceph_inode_info *ci, int need, int want, in ceph_get_caps() argument
2705 ret = ceph_pool_perm_check(ci, need); in ceph_get_caps()
2711 check_max_size(&ci->vfs_inode, endoff); in ceph_get_caps()
2715 ret = try_get_cap_refs(ci, need, want, endoff, in ceph_get_caps()
2724 add_wait_queue(&ci->i_cap_wq, &wait); in ceph_get_caps()
2726 while (!try_get_cap_refs(ci, need, want, endoff, in ceph_get_caps()
2735 remove_wait_queue(&ci->i_cap_wq, &wait); in ceph_get_caps()
2745 ret = ceph_renew_caps(&ci->vfs_inode); in ceph_get_caps()
2752 if (ci->i_inline_version != CEPH_INLINE_NONE && in ceph_get_caps()
2754 i_size_read(&ci->vfs_inode) > 0) { in ceph_get_caps()
2756 find_get_page(ci->vfs_inode.i_mapping, 0); in ceph_get_caps()
2768 ceph_put_cap_refs(ci, _got); in ceph_get_caps()
2775 ret = __ceph_do_getattr(&ci->vfs_inode, NULL, in ceph_get_caps()
2786 ceph_fscache_revalidate_cookie(ci); in ceph_get_caps()
2796 void ceph_get_cap_refs(struct ceph_inode_info *ci, int caps) in ceph_get_cap_refs() argument
2798 spin_lock(&ci->i_ceph_lock); in ceph_get_cap_refs()
2799 __take_cap_refs(ci, caps, false); in ceph_get_cap_refs()
2800 spin_unlock(&ci->i_ceph_lock); in ceph_get_cap_refs()
2808 static int ceph_try_drop_cap_snap(struct ceph_inode_info *ci, in ceph_try_drop_cap_snap() argument
2817 if (!list_is_last(&capsnap->ci_item, &ci->i_cap_snaps)) in ceph_try_drop_cap_snap()
2818 ci->i_ceph_flags |= CEPH_I_FLUSH_SNAPS; in ceph_try_drop_cap_snap()
2836 void ceph_put_cap_refs(struct ceph_inode_info *ci, int had) in ceph_put_cap_refs() argument
2838 struct inode *inode = &ci->vfs_inode; in ceph_put_cap_refs()
2841 spin_lock(&ci->i_ceph_lock); in ceph_put_cap_refs()
2843 --ci->i_pin_ref; in ceph_put_cap_refs()
2845 if (--ci->i_rd_ref == 0) in ceph_put_cap_refs()
2848 if (--ci->i_rdcache_ref == 0) in ceph_put_cap_refs()
2851 if (--ci->i_wb_ref == 0) { in ceph_put_cap_refs()
2856 inode, ci->i_wb_ref+1, ci->i_wb_ref); in ceph_put_cap_refs()
2859 if (--ci->i_wr_ref == 0) { in ceph_put_cap_refs()
2861 if (__ceph_have_pending_cap_snap(ci)) { in ceph_put_cap_refs()
2863 list_last_entry(&ci->i_cap_snaps, in ceph_put_cap_refs()
2867 if (ceph_try_drop_cap_snap(ci, capsnap)) in ceph_put_cap_refs()
2869 else if (__ceph_finish_cap_snap(ci, capsnap)) in ceph_put_cap_refs()
2873 if (ci->i_wrbuffer_ref_head == 0 && in ceph_put_cap_refs()
2874 ci->i_dirty_caps == 0 && in ceph_put_cap_refs()
2875 ci->i_flushing_caps == 0) { in ceph_put_cap_refs()
2876 BUG_ON(!ci->i_head_snapc); in ceph_put_cap_refs()
2877 ceph_put_snap_context(ci->i_head_snapc); in ceph_put_cap_refs()
2878 ci->i_head_snapc = NULL; in ceph_put_cap_refs()
2881 if (!__ceph_is_any_caps(ci) && ci->i_snap_realm) in ceph_put_cap_refs()
2882 drop_inode_snap_realm(ci); in ceph_put_cap_refs()
2884 spin_unlock(&ci->i_ceph_lock); in ceph_put_cap_refs()
2890 ceph_check_caps(ci, 0, NULL); in ceph_put_cap_refs()
2892 ceph_flush_snaps(ci, NULL); in ceph_put_cap_refs()
2894 wake_up_all(&ci->i_cap_wq); in ceph_put_cap_refs()
2906 void ceph_put_wrbuffer_cap_refs(struct ceph_inode_info *ci, int nr, in ceph_put_wrbuffer_cap_refs() argument
2909 struct inode *inode = &ci->vfs_inode; in ceph_put_wrbuffer_cap_refs()
2917 spin_lock(&ci->i_ceph_lock); in ceph_put_wrbuffer_cap_refs()
2918 ci->i_wrbuffer_ref -= nr; in ceph_put_wrbuffer_cap_refs()
2919 if (ci->i_wrbuffer_ref == 0) { in ceph_put_wrbuffer_cap_refs()
2924 if (ci->i_head_snapc == snapc) { in ceph_put_wrbuffer_cap_refs()
2925 ci->i_wrbuffer_ref_head -= nr; in ceph_put_wrbuffer_cap_refs()
2926 if (ci->i_wrbuffer_ref_head == 0 && in ceph_put_wrbuffer_cap_refs()
2927 ci->i_wr_ref == 0 && in ceph_put_wrbuffer_cap_refs()
2928 ci->i_dirty_caps == 0 && in ceph_put_wrbuffer_cap_refs()
2929 ci->i_flushing_caps == 0) { in ceph_put_wrbuffer_cap_refs()
2930 BUG_ON(!ci->i_head_snapc); in ceph_put_wrbuffer_cap_refs()
2931 ceph_put_snap_context(ci->i_head_snapc); in ceph_put_wrbuffer_cap_refs()
2932 ci->i_head_snapc = NULL; in ceph_put_wrbuffer_cap_refs()
2936 ci->i_wrbuffer_ref+nr, ci->i_wrbuffer_ref_head+nr, in ceph_put_wrbuffer_cap_refs()
2937 ci->i_wrbuffer_ref, ci->i_wrbuffer_ref_head, in ceph_put_wrbuffer_cap_refs()
2940 list_for_each_entry(capsnap, &ci->i_cap_snaps, ci_item) { in ceph_put_wrbuffer_cap_refs()
2951 if (ceph_try_drop_cap_snap(ci, capsnap)) { in ceph_put_wrbuffer_cap_refs()
2954 ci->i_ceph_flags |= CEPH_I_FLUSH_SNAPS; in ceph_put_wrbuffer_cap_refs()
2962 ci->i_wrbuffer_ref+nr, capsnap->dirty_pages + nr, in ceph_put_wrbuffer_cap_refs()
2963 ci->i_wrbuffer_ref, capsnap->dirty_pages, in ceph_put_wrbuffer_cap_refs()
2968 spin_unlock(&ci->i_ceph_lock); in ceph_put_wrbuffer_cap_refs()
2971 ceph_check_caps(ci, CHECK_CAPS_AUTHONLY, NULL); in ceph_put_wrbuffer_cap_refs()
2973 ceph_flush_snaps(ci, NULL); in ceph_put_wrbuffer_cap_refs()
2976 wake_up_all(&ci->i_cap_wq); in ceph_put_wrbuffer_cap_refs()
3039 __releases(ci->i_ceph_lock) in handle_cap_grant()
3042 struct ceph_inode_info *ci = ceph_inode(inode); in handle_cap_grant() local
3071 WARN_ON(cap != ci->i_auth_cap); in handle_cap_grant()
3085 !(ci->i_wrbuffer_ref || ci->i_wb_ref)) { in handle_cap_grant()
3089 if (ci->i_rdcache_revoking != ci->i_rdcache_gen) { in handle_cap_grant()
3091 ci->i_rdcache_revoking = ci->i_rdcache_gen; in handle_cap_grant()
3100 __check_cap_issue(ci, cap, newcaps); in handle_cap_grant()
3125 if (version > ci->i_xattrs.version) { in handle_cap_grant()
3128 if (ci->i_xattrs.blob) in handle_cap_grant()
3129 ceph_buffer_put(ci->i_xattrs.blob); in handle_cap_grant()
3130 ci->i_xattrs.blob = ceph_buffer_get(xattr_buf); in handle_cap_grant()
3131 ci->i_xattrs.version = version; in handle_cap_grant()
3148 ci->i_files = extra_info->nfiles; in handle_cap_grant()
3149 ci->i_subdirs = extra_info->nsubdirs; in handle_cap_grant()
3154 s64 old_pool = ci->i_layout.pool_id; in handle_cap_grant()
3157 ceph_file_layout_from_legacy(&ci->i_layout, &grant->layout); in handle_cap_grant()
3158 old_ns = rcu_dereference_protected(ci->i_layout.pool_ns, in handle_cap_grant()
3159 lockdep_is_held(&ci->i_ceph_lock)); in handle_cap_grant()
3160 rcu_assign_pointer(ci->i_layout.pool_ns, extra_info->pool_ns); in handle_cap_grant()
3162 if (ci->i_layout.pool_id != old_pool || in handle_cap_grant()
3164 ci->i_ceph_flags &= ~CEPH_I_POOL_PERM; in handle_cap_grant()
3175 if (ci->i_auth_cap == cap && (newcaps & CEPH_CAP_ANY_FILE_WR)) { in handle_cap_grant()
3176 if (max_size != ci->i_max_size) { in handle_cap_grant()
3178 ci->i_max_size, max_size); in handle_cap_grant()
3179 ci->i_max_size = max_size; in handle_cap_grant()
3180 if (max_size >= ci->i_wanted_max_size) { in handle_cap_grant()
3181 ci->i_wanted_max_size = 0; /* reset */ in handle_cap_grant()
3182 ci->i_requested_max_size = 0; in handle_cap_grant()
3185 } else if (ci->i_wanted_max_size > ci->i_max_size && in handle_cap_grant()
3186 ci->i_wanted_max_size > ci->i_requested_max_size) { in handle_cap_grant()
3193 wanted = __ceph_caps_wanted(ci); in handle_cap_grant()
3194 used = __ceph_caps_used(ci); in handle_cap_grant()
3195 dirty = __ceph_caps_dirty(ci); in handle_cap_grant()
3223 else if (cap == ci->i_auth_cap) in handle_cap_grant()
3236 if (cap == ci->i_auth_cap && in handle_cap_grant()
3237 __ceph_caps_revoking_other(ci, cap, newcaps)) in handle_cap_grant()
3249 extra_info->inline_version >= ci->i_inline_version) { in handle_cap_grant()
3250 ci->i_inline_version = extra_info->inline_version; in handle_cap_grant()
3251 if (ci->i_inline_version != CEPH_INLINE_NONE && in handle_cap_grant()
3262 spin_unlock(&ci->i_ceph_lock); in handle_cap_grant()
3284 wake_up_all(&ci->i_cap_wq); in handle_cap_grant()
3287 ceph_check_caps(ci, CHECK_CAPS_NODELAY|CHECK_CAPS_AUTHONLY, in handle_cap_grant()
3290 ceph_check_caps(ci, CHECK_CAPS_NODELAY, session); in handle_cap_grant()
3303 __releases(ci->i_ceph_lock) in handle_cap_flush_ack()
3305 struct ceph_inode_info *ci = ceph_inode(inode); in handle_cap_flush_ack() local
3316 list_for_each_entry_safe(cf, tmp_cf, &ci->i_cap_flush_list, i_list) { in handle_cap_flush_ack()
3322 if (__finish_cap_flush(NULL, ci, cf)) in handle_cap_flush_ack()
3335 ceph_cap_string(cleaned), ceph_cap_string(ci->i_flushing_caps), in handle_cap_flush_ack()
3336 ceph_cap_string(ci->i_flushing_caps & ~cleaned)); in handle_cap_flush_ack()
3341 ci->i_flushing_caps &= ~cleaned; in handle_cap_flush_ack()
3350 if (ci->i_flushing_caps == 0) { in handle_cap_flush_ack()
3351 if (list_empty(&ci->i_cap_flush_list)) { in handle_cap_flush_ack()
3352 list_del_init(&ci->i_flushing_item); in handle_cap_flush_ack()
3364 if (ci->i_dirty_caps == 0) { in handle_cap_flush_ack()
3366 BUG_ON(!list_empty(&ci->i_dirty_item)); in handle_cap_flush_ack()
3368 if (ci->i_wr_ref == 0 && in handle_cap_flush_ack()
3369 ci->i_wrbuffer_ref_head == 0) { in handle_cap_flush_ack()
3370 BUG_ON(!ci->i_head_snapc); in handle_cap_flush_ack()
3371 ceph_put_snap_context(ci->i_head_snapc); in handle_cap_flush_ack()
3372 ci->i_head_snapc = NULL; in handle_cap_flush_ack()
3375 BUG_ON(list_empty(&ci->i_dirty_item)); in handle_cap_flush_ack()
3381 spin_unlock(&ci->i_ceph_lock); in handle_cap_flush_ack()
3391 wake_up_all(&ci->i_cap_wq); in handle_cap_flush_ack()
3408 struct ceph_inode_info *ci = ceph_inode(inode); in handle_cap_flushsnap_ack() local
3417 inode, ci, session->s_mds, follows); in handle_cap_flushsnap_ack()
3419 spin_lock(&ci->i_ceph_lock); in handle_cap_flushsnap_ack()
3420 list_for_each_entry(capsnap, &ci->i_cap_snaps, ci_item) { in handle_cap_flushsnap_ack()
3440 if (__finish_cap_flush(NULL, ci, &capsnap->cap_flush)) in handle_cap_flushsnap_ack()
3445 if (list_empty(&ci->i_cap_flush_list)) in handle_cap_flushsnap_ack()
3446 list_del_init(&ci->i_flushing_item); in handle_cap_flushsnap_ack()
3453 spin_unlock(&ci->i_ceph_lock); in handle_cap_flushsnap_ack()
3458 wake_up_all(&ci->i_cap_wq); in handle_cap_flushsnap_ack()
3473 __releases(ci->i_ceph_lock) in handle_cap_trunc()
3475 struct ceph_inode_info *ci = ceph_inode(inode); in handle_cap_trunc() local
3482 int dirty = __ceph_caps_dirty(ci); in handle_cap_trunc()
3492 spin_unlock(&ci->i_ceph_lock); in handle_cap_trunc()
3513 struct ceph_inode_info *ci = ceph_inode(inode); in handle_cap_export() local
3531 inode, ci, mds, mseq, target); in handle_cap_export()
3533 spin_lock(&ci->i_ceph_lock); in handle_cap_export()
3534 cap = __get_cap_for_mds(ci, mds); in handle_cap_export()
3540 if (!ci->i_auth_cap) in handle_cap_export()
3541 ci->i_ceph_flags |= CEPH_I_CAP_DROPPED; in handle_cap_export()
3560 tcap = __get_cap_for_mds(ci, target); in handle_cap_export()
3572 if (cap == ci->i_auth_cap) in handle_cap_export()
3573 ci->i_auth_cap = tcap; in handle_cap_export()
3575 if (!list_empty(&ci->i_cap_flush_list) && in handle_cap_export()
3576 ci->i_auth_cap == tcap) { in handle_cap_export()
3578 list_move_tail(&ci->i_flushing_item, in handle_cap_export()
3587 int flag = (cap == ci->i_auth_cap) ? CEPH_CAP_FLAG_AUTH : 0; in handle_cap_export()
3592 if (!list_empty(&ci->i_cap_flush_list) && in handle_cap_export()
3593 ci->i_auth_cap == tcap) { in handle_cap_export()
3595 list_move_tail(&ci->i_flushing_item, in handle_cap_export()
3604 spin_unlock(&ci->i_ceph_lock); in handle_cap_export()
3628 spin_unlock(&ci->i_ceph_lock); in handle_cap_export()
3648 __acquires(ci->i_ceph_lock) in handle_cap_import()
3650 struct ceph_inode_info *ci = ceph_inode(inode); in handle_cap_import() local
3672 inode, ci, mds, mseq, peer); in handle_cap_import()
3675 spin_lock(&ci->i_ceph_lock); in handle_cap_import()
3676 cap = __get_cap_for_mds(ci, mds); in handle_cap_import()
3679 spin_unlock(&ci->i_ceph_lock); in handle_cap_import()
3691 __ceph_caps_issued(ci, &issued); in handle_cap_import()
3692 issued |= __ceph_caps_dirty(ci); in handle_cap_import()
3697 ocap = peer >= 0 ? __get_cap_for_mds(ci, peer) : NULL; in handle_cap_import()
3716 ci->i_requested_max_size = 0; in handle_cap_import()
3733 struct ceph_inode_info *ci; in ceph_handle_caps() local
3842 ci = ceph_inode(inode); in ceph_handle_caps()
3903 spin_lock(&ci->i_ceph_lock); in ceph_handle_caps()
3909 spin_unlock(&ci->i_ceph_lock); in ceph_handle_caps()
3917 __ceph_caps_issued(ci, &extra_info.issued); in ceph_handle_caps()
3918 extra_info.issued |= __ceph_caps_dirty(ci); in ceph_handle_caps()
3933 spin_unlock(&ci->i_ceph_lock); in ceph_handle_caps()
3967 struct ceph_inode_info *ci; in ceph_check_delayed_caps() local
3975 ci = list_first_entry(&mdsc->cap_delay_list, in ceph_check_delayed_caps()
3978 if ((ci->i_ceph_flags & CEPH_I_FLUSH) == 0 && in ceph_check_delayed_caps()
3979 time_before(jiffies, ci->i_hold_caps_max)) in ceph_check_delayed_caps()
3981 list_del_init(&ci->i_cap_delay_list); in ceph_check_delayed_caps()
3983 inode = igrab(&ci->vfs_inode); in ceph_check_delayed_caps()
3988 ceph_check_caps(ci, flags, NULL); in ceph_check_delayed_caps()
4000 struct ceph_inode_info *ci; in ceph_flush_dirty_caps() local
4006 ci = list_first_entry(&mdsc->cap_dirty, struct ceph_inode_info, in ceph_flush_dirty_caps()
4008 inode = &ci->vfs_inode; in ceph_flush_dirty_caps()
4012 ceph_check_caps(ci, CHECK_CAPS_NODELAY|CHECK_CAPS_FLUSH, NULL); in ceph_flush_dirty_caps()
4020 void __ceph_get_fmode(struct ceph_inode_info *ci, int fmode) in __ceph_get_fmode() argument
4026 ci->i_nr_by_mode[i]++; in __ceph_get_fmode()
4035 void ceph_put_fmode(struct ceph_inode_info *ci, int fmode) in ceph_put_fmode() argument
4039 spin_lock(&ci->i_ceph_lock); in ceph_put_fmode()
4042 BUG_ON(ci->i_nr_by_mode[i] == 0); in ceph_put_fmode()
4043 if (--ci->i_nr_by_mode[i] == 0) in ceph_put_fmode()
4048 &ci->vfs_inode, fmode, in ceph_put_fmode()
4049 ci->i_nr_by_mode[0], ci->i_nr_by_mode[1], in ceph_put_fmode()
4050 ci->i_nr_by_mode[2], ci->i_nr_by_mode[3]); in ceph_put_fmode()
4051 spin_unlock(&ci->i_ceph_lock); in ceph_put_fmode()
4053 if (last && ci->i_vino.snap == CEPH_NOSNAP) in ceph_put_fmode()
4054 ceph_check_caps(ci, 0, NULL); in ceph_put_fmode()
4065 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_drop_caps_for_unlink() local
4068 spin_lock(&ci->i_ceph_lock); in ceph_drop_caps_for_unlink()
4070 drop |= ~(__ceph_caps_wanted(ci) | CEPH_CAP_PIN); in ceph_drop_caps_for_unlink()
4072 ci->i_ceph_flags |= CEPH_I_NODELAY; in ceph_drop_caps_for_unlink()
4073 if (__ceph_caps_dirty(ci)) { in ceph_drop_caps_for_unlink()
4076 __cap_delay_requeue_front(mdsc, ci); in ceph_drop_caps_for_unlink()
4079 spin_unlock(&ci->i_ceph_lock); in ceph_drop_caps_for_unlink()
4094 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_encode_inode_release() local
4100 spin_lock(&ci->i_ceph_lock); in ceph_encode_inode_release()
4101 used = __ceph_caps_used(ci); in ceph_encode_inode_release()
4102 dirty = __ceph_caps_dirty(ci); in ceph_encode_inode_release()
4111 cap = __get_cap_for_mds(ci, mds); in ceph_encode_inode_release()
4127 int wanted = __ceph_caps_wanted(ci); in ceph_encode_inode_release()
4128 if ((ci->i_ceph_flags & CEPH_I_NODELAY) == 0) in ceph_encode_inode_release()
4162 spin_unlock(&ci->i_ceph_lock); in ceph_encode_inode_release()