Lines Matching refs:ci
48 struct ceph_inode_info *ci,
433 static struct ceph_cap *__get_cap_for_mds(struct ceph_inode_info *ci, int mds) in __get_cap_for_mds() argument
436 struct rb_node *n = ci->i_caps.rb_node; in __get_cap_for_mds()
450 struct ceph_cap *ceph_get_cap_for_mds(struct ceph_inode_info *ci, int mds) in ceph_get_cap_for_mds() argument
454 spin_lock(&ci->i_ceph_lock); in ceph_get_cap_for_mds()
455 cap = __get_cap_for_mds(ci, mds); in ceph_get_cap_for_mds()
456 spin_unlock(&ci->i_ceph_lock); in ceph_get_cap_for_mds()
463 static void __insert_cap_node(struct ceph_inode_info *ci, in __insert_cap_node() argument
466 struct rb_node **p = &ci->i_caps.rb_node; in __insert_cap_node()
482 rb_insert_color(&new->ci_node, &ci->i_caps); in __insert_cap_node()
490 struct ceph_inode_info *ci) in __cap_set_timeouts() argument
494 ci->i_hold_caps_min = round_jiffies(jiffies + in __cap_set_timeouts()
496 ci->i_hold_caps_max = round_jiffies(jiffies + in __cap_set_timeouts()
498 dout("__cap_set_timeouts %p min %lu max %lu\n", &ci->vfs_inode, in __cap_set_timeouts()
499 ci->i_hold_caps_min - jiffies, ci->i_hold_caps_max - jiffies); in __cap_set_timeouts()
511 struct ceph_inode_info *ci, in __cap_delay_requeue() argument
514 dout("__cap_delay_requeue %p flags %d at %lu\n", &ci->vfs_inode, in __cap_delay_requeue()
515 ci->i_ceph_flags, ci->i_hold_caps_max); in __cap_delay_requeue()
518 if (!list_empty(&ci->i_cap_delay_list)) { in __cap_delay_requeue()
519 if (ci->i_ceph_flags & CEPH_I_FLUSH) in __cap_delay_requeue()
521 list_del_init(&ci->i_cap_delay_list); in __cap_delay_requeue()
524 __cap_set_timeouts(mdsc, ci); in __cap_delay_requeue()
525 list_add_tail(&ci->i_cap_delay_list, &mdsc->cap_delay_list); in __cap_delay_requeue()
537 struct ceph_inode_info *ci) in __cap_delay_requeue_front() argument
539 dout("__cap_delay_requeue_front %p\n", &ci->vfs_inode); in __cap_delay_requeue_front()
541 ci->i_ceph_flags |= CEPH_I_FLUSH; in __cap_delay_requeue_front()
542 if (!list_empty(&ci->i_cap_delay_list)) in __cap_delay_requeue_front()
543 list_del_init(&ci->i_cap_delay_list); in __cap_delay_requeue_front()
544 list_add(&ci->i_cap_delay_list, &mdsc->cap_delay_list); in __cap_delay_requeue_front()
554 struct ceph_inode_info *ci) in __cap_delay_cancel() argument
556 dout("__cap_delay_cancel %p\n", &ci->vfs_inode); in __cap_delay_cancel()
557 if (list_empty(&ci->i_cap_delay_list)) in __cap_delay_cancel()
560 list_del_init(&ci->i_cap_delay_list); in __cap_delay_cancel()
567 static void __check_cap_issue(struct ceph_inode_info *ci, struct ceph_cap *cap, in __check_cap_issue() argument
570 unsigned had = __ceph_caps_issued(ci, NULL); in __check_cap_issue()
578 ci->i_rdcache_gen++; in __check_cap_issue()
589 atomic_inc(&ci->i_shared_gen); in __check_cap_issue()
590 if (S_ISDIR(ci->vfs_inode.i_mode)) { in __check_cap_issue()
591 dout(" marking %p NOT complete\n", &ci->vfs_inode); in __check_cap_issue()
592 __ceph_dir_clear_complete(ci); in __check_cap_issue()
613 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_add_cap() local
619 lockdep_assert_held(&ci->i_ceph_lock); in ceph_add_cap()
635 cap = __get_cap_for_mds(ci, mds); in ceph_add_cap()
646 cap->ci = ci; in ceph_add_cap()
647 __insert_cap_node(ci, cap); in ceph_add_cap()
673 WARN_ON(cap != ci->i_auth_cap); in ceph_add_cap()
682 if (!ci->i_snap_realm || in ceph_add_cap()
684 realmino != (u64)-1 && ci->i_snap_realm->ino != realmino)) { in ceph_add_cap()
691 struct ceph_snap_realm *oldrealm = ci->i_snap_realm; in ceph_add_cap()
694 list_del_init(&ci->i_snap_realm_item); in ceph_add_cap()
699 list_add(&ci->i_snap_realm_item, in ceph_add_cap()
701 ci->i_snap_realm = realm; in ceph_add_cap()
702 if (realm->ino == ci->i_vino.ino) in ceph_add_cap()
715 __check_cap_issue(ci, cap, issued); in ceph_add_cap()
722 actual_wanted = __ceph_caps_wanted(ci); in ceph_add_cap()
728 __cap_delay_requeue(mdsc, ci, true); in ceph_add_cap()
732 if (!ci->i_auth_cap || in ceph_add_cap()
733 ceph_seq_cmp(ci->i_auth_cap->mseq, mseq) < 0) { in ceph_add_cap()
734 ci->i_auth_cap = cap; in ceph_add_cap()
738 WARN_ON(ci->i_auth_cap == cap); in ceph_add_cap()
757 __ceph_get_fmode(ci, fmode); in ceph_add_cap()
777 "but STALE (gen %u vs %u)\n", &cap->ci->vfs_inode, in __cap_is_valid()
790 int __ceph_caps_issued(struct ceph_inode_info *ci, int *implemented) in __ceph_caps_issued() argument
792 int have = ci->i_snap_caps; in __ceph_caps_issued()
798 for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) { in __ceph_caps_issued()
803 &ci->vfs_inode, cap, ceph_cap_string(cap->issued)); in __ceph_caps_issued()
813 if (ci->i_auth_cap) { in __ceph_caps_issued()
814 cap = ci->i_auth_cap; in __ceph_caps_issued()
823 int __ceph_caps_issued_other(struct ceph_inode_info *ci, struct ceph_cap *ocap) in __ceph_caps_issued_other() argument
825 int have = ci->i_snap_caps; in __ceph_caps_issued_other()
829 for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) { in __ceph_caps_issued_other()
850 dout("__touch_cap %p cap %p mds%d\n", &cap->ci->vfs_inode, cap, in __touch_cap()
855 &cap->ci->vfs_inode, cap, s->s_mds); in __touch_cap()
865 int __ceph_caps_issued_mask(struct ceph_inode_info *ci, int mask, int touch) in __ceph_caps_issued_mask() argument
869 int have = ci->i_snap_caps; in __ceph_caps_issued_mask()
873 " (mask %s)\n", ci->vfs_inode.i_ino, in __ceph_caps_issued_mask()
879 for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) { in __ceph_caps_issued_mask()
885 " (mask %s)\n", ci->vfs_inode.i_ino, cap, in __ceph_caps_issued_mask()
897 " (mask %s)\n", ci->vfs_inode.i_ino, in __ceph_caps_issued_mask()
905 for (q = rb_first(&ci->i_caps); q != p; in __ceph_caps_issued_mask()
924 int __ceph_caps_revoking_other(struct ceph_inode_info *ci, in __ceph_caps_revoking_other() argument
930 for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) { in __ceph_caps_revoking_other()
939 int ceph_caps_revoking(struct ceph_inode_info *ci, int mask) in ceph_caps_revoking() argument
941 struct inode *inode = &ci->vfs_inode; in ceph_caps_revoking()
944 spin_lock(&ci->i_ceph_lock); in ceph_caps_revoking()
945 ret = __ceph_caps_revoking_other(ci, NULL, mask); in ceph_caps_revoking()
946 spin_unlock(&ci->i_ceph_lock); in ceph_caps_revoking()
952 int __ceph_caps_used(struct ceph_inode_info *ci) in __ceph_caps_used() argument
955 if (ci->i_pin_ref) in __ceph_caps_used()
957 if (ci->i_rd_ref) in __ceph_caps_used()
959 if (ci->i_rdcache_ref || in __ceph_caps_used()
960 (!S_ISDIR(ci->vfs_inode.i_mode) && /* ignore readdir cache */ in __ceph_caps_used()
961 ci->vfs_inode.i_data.nrpages)) in __ceph_caps_used()
963 if (ci->i_wr_ref) in __ceph_caps_used()
965 if (ci->i_wb_ref || ci->i_wrbuffer_ref) in __ceph_caps_used()
973 int __ceph_caps_file_wanted(struct ceph_inode_info *ci) in __ceph_caps_file_wanted() argument
977 if (ci->i_nr_by_mode[i]) in __ceph_caps_file_wanted()
988 int __ceph_caps_mds_wanted(struct ceph_inode_info *ci, bool check) in __ceph_caps_mds_wanted() argument
994 for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) { in __ceph_caps_mds_wanted()
998 if (cap == ci->i_auth_cap) in __ceph_caps_mds_wanted()
1009 static int __ceph_is_single_caps(struct ceph_inode_info *ci) in __ceph_is_single_caps() argument
1011 return rb_first(&ci->i_caps) == rb_last(&ci->i_caps); in __ceph_is_single_caps()
1014 static int __ceph_is_any_caps(struct ceph_inode_info *ci) in __ceph_is_any_caps() argument
1016 return !RB_EMPTY_ROOT(&ci->i_caps); in __ceph_is_any_caps()
1021 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_is_any_caps() local
1024 spin_lock(&ci->i_ceph_lock); in ceph_is_any_caps()
1025 ret = __ceph_is_any_caps(ci); in ceph_is_any_caps()
1026 spin_unlock(&ci->i_ceph_lock); in ceph_is_any_caps()
1031 static void drop_inode_snap_realm(struct ceph_inode_info *ci) in drop_inode_snap_realm() argument
1033 struct ceph_snap_realm *realm = ci->i_snap_realm; in drop_inode_snap_realm()
1035 list_del_init(&ci->i_snap_realm_item); in drop_inode_snap_realm()
1036 ci->i_snap_realm_counter++; in drop_inode_snap_realm()
1037 ci->i_snap_realm = NULL; in drop_inode_snap_realm()
1038 if (realm->ino == ci->i_vino.ino) in drop_inode_snap_realm()
1041 ceph_put_snap_realm(ceph_sb_to_client(ci->vfs_inode.i_sb)->mdsc, in drop_inode_snap_realm()
1054 struct ceph_inode_info *ci = cap->ci; in __ceph_remove_cap() local
1056 ceph_sb_to_client(ci->vfs_inode.i_sb)->mdsc; 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()
1064 ci->i_auth_cap = NULL; in __ceph_remove_cap()
1079 cap->ci = NULL; in __ceph_remove_cap()
1095 cap->cap_ino = ci->i_vino.ino; in __ceph_remove_cap()
1106 if (!__ceph_is_any_caps(ci) && ci->i_wr_ref == 0 && ci->i_snap_realm) in __ceph_remove_cap()
1107 drop_inode_snap_realm(ci); in __ceph_remove_cap()
1109 if (!__ceph_is_any_real_caps(ci)) in __ceph_remove_cap()
1110 __cap_delay_cancel(mdsc, ci); in __ceph_remove_cap()
1240 void __ceph_remove_caps(struct ceph_inode_info *ci) in __ceph_remove_caps() argument
1246 spin_lock(&ci->i_ceph_lock); in __ceph_remove_caps()
1247 p = rb_first(&ci->i_caps); in __ceph_remove_caps()
1253 spin_unlock(&ci->i_ceph_lock); in __ceph_remove_caps()
1272 __releases(cap->ci->i_ceph_lock) in __send_cap()
1274 struct ceph_inode_info *ci = cap->ci; in __send_cap() local
1275 struct inode *inode = &ci->vfs_inode; in __send_cap()
1296 if ((ci->i_ceph_flags & CEPH_I_NODELAY) == 0 && in __send_cap()
1297 time_before(jiffies, ci->i_hold_caps_min)) { in __send_cap()
1307 ci->i_ceph_flags &= ~(CEPH_I_NODELAY | CEPH_I_FLUSH); in __send_cap()
1313 __cap_set_timeouts(mdsc, ci); in __send_cap()
1331 arg.follows = flushing ? ci->i_head_snapc->seq : 0; in __send_cap()
1336 ci->i_reported_size = arg.size; in __send_cap()
1337 arg.max_size = ci->i_wanted_max_size; in __send_cap()
1338 ci->i_requested_max_size = arg.max_size; in __send_cap()
1341 old_blob = __ceph_build_xattrs_blob(ci); in __send_cap()
1342 arg.xattr_version = ci->i_xattrs.version; in __send_cap()
1343 arg.xattr_buf = ci->i_xattrs.blob; in __send_cap()
1351 arg.btime = ci->i_btime; in __send_cap()
1362 arg.time_warp_seq = ci->i_time_warp_seq; in __send_cap()
1368 arg.inline_data = ci->i_inline_version != CEPH_INLINE_NONE; in __send_cap()
1370 !list_empty(&ci->i_cap_snaps)) { in __send_cap()
1372 list_for_each_entry_reverse(capsnap, &ci->i_cap_snaps, ci_item) { in __send_cap()
1383 spin_unlock(&ci->i_ceph_lock); in __send_cap()
1394 wake_up_all(&ci->i_cap_wq); in __send_cap()
1453 static void __ceph_flush_snaps(struct ceph_inode_info *ci, in __ceph_flush_snaps() argument
1455 __releases(ci->i_ceph_lock) in __ceph_flush_snaps()
1456 __acquires(ci->i_ceph_lock) in __ceph_flush_snaps()
1458 struct inode *inode = &ci->vfs_inode; in __ceph_flush_snaps()
1466 list_for_each_entry(capsnap, &ci->i_cap_snaps, ci_item) { in __ceph_flush_snaps()
1489 if (list_empty(&ci->i_flushing_item)) { in __ceph_flush_snaps()
1490 list_add_tail(&ci->i_flushing_item, in __ceph_flush_snaps()
1496 &ci->i_cap_flush_list); in __ceph_flush_snaps()
1503 ci->i_ceph_flags &= ~CEPH_I_FLUSH_SNAPS; in __ceph_flush_snaps()
1506 struct ceph_cap *cap = ci->i_auth_cap; in __ceph_flush_snaps()
1517 list_for_each_entry(cf, &ci->i_cap_flush_list, i_list) { in __ceph_flush_snaps()
1530 spin_unlock(&ci->i_ceph_lock); in __ceph_flush_snaps()
1544 spin_lock(&ci->i_ceph_lock); in __ceph_flush_snaps()
1548 void ceph_flush_snaps(struct ceph_inode_info *ci, in ceph_flush_snaps() argument
1551 struct inode *inode = &ci->vfs_inode; in ceph_flush_snaps()
1560 spin_lock(&ci->i_ceph_lock); in ceph_flush_snaps()
1561 if (!(ci->i_ceph_flags & CEPH_I_FLUSH_SNAPS)) { in ceph_flush_snaps()
1565 if (!ci->i_auth_cap) { in ceph_flush_snaps()
1570 mds = ci->i_auth_cap->session->s_mds; in ceph_flush_snaps()
1578 spin_unlock(&ci->i_ceph_lock); in ceph_flush_snaps()
1590 if (ci->i_ceph_flags & CEPH_I_KICK_FLUSH) in ceph_flush_snaps()
1591 __kick_flushing_caps(mdsc, session, ci, 0); in ceph_flush_snaps()
1593 __ceph_flush_snaps(ci, session); in ceph_flush_snaps()
1595 spin_unlock(&ci->i_ceph_lock); in ceph_flush_snaps()
1605 list_del_init(&ci->i_snap_flush_item); in ceph_flush_snaps()
1614 int __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask, in __ceph_mark_dirty_caps() argument
1618 ceph_sb_to_client(ci->vfs_inode.i_sb)->mdsc; in __ceph_mark_dirty_caps()
1619 struct inode *inode = &ci->vfs_inode; in __ceph_mark_dirty_caps()
1620 int was = ci->i_dirty_caps; in __ceph_mark_dirty_caps()
1623 if (!ci->i_auth_cap) { in __ceph_mark_dirty_caps()
1630 dout("__mark_dirty_caps %p %s dirty %s -> %s\n", &ci->vfs_inode, in __ceph_mark_dirty_caps()
1633 ci->i_dirty_caps |= mask; in __ceph_mark_dirty_caps()
1635 WARN_ON_ONCE(ci->i_prealloc_cap_flush); in __ceph_mark_dirty_caps()
1636 swap(ci->i_prealloc_cap_flush, *pcf); in __ceph_mark_dirty_caps()
1638 if (!ci->i_head_snapc) { in __ceph_mark_dirty_caps()
1640 ci->i_head_snapc = ceph_get_snap_context( in __ceph_mark_dirty_caps()
1641 ci->i_snap_realm->cached_context); in __ceph_mark_dirty_caps()
1644 &ci->vfs_inode, ci->i_head_snapc, ci->i_auth_cap); in __ceph_mark_dirty_caps()
1645 BUG_ON(!list_empty(&ci->i_dirty_item)); in __ceph_mark_dirty_caps()
1647 list_add(&ci->i_dirty_item, &mdsc->cap_dirty); in __ceph_mark_dirty_caps()
1649 if (ci->i_flushing_caps == 0) { in __ceph_mark_dirty_caps()
1654 WARN_ON_ONCE(!ci->i_prealloc_cap_flush); in __ceph_mark_dirty_caps()
1656 BUG_ON(list_empty(&ci->i_dirty_item)); in __ceph_mark_dirty_caps()
1657 if (((was | ci->i_flushing_caps) & CEPH_CAP_FILE_BUFFER) && in __ceph_mark_dirty_caps()
1660 __cap_delay_requeue(mdsc, ci, true); in __ceph_mark_dirty_caps()
1691 struct ceph_inode_info *ci, in __finish_cap_flush() argument
1704 } else if (ci) { in __finish_cap_flush()
1705 if (wake && cf->i_list.prev != &ci->i_cap_flush_list) { in __finish_cap_flush()
1728 struct ceph_inode_info *ci = ceph_inode(inode); in __mark_caps_flushing() local
1732 BUG_ON(ci->i_dirty_caps == 0); in __mark_caps_flushing()
1733 BUG_ON(list_empty(&ci->i_dirty_item)); in __mark_caps_flushing()
1734 BUG_ON(!ci->i_prealloc_cap_flush); in __mark_caps_flushing()
1736 flushing = ci->i_dirty_caps; in __mark_caps_flushing()
1739 ceph_cap_string(ci->i_flushing_caps), in __mark_caps_flushing()
1740 ceph_cap_string(ci->i_flushing_caps | flushing)); in __mark_caps_flushing()
1741 ci->i_flushing_caps |= flushing; in __mark_caps_flushing()
1742 ci->i_dirty_caps = 0; in __mark_caps_flushing()
1745 swap(cf, ci->i_prealloc_cap_flush); in __mark_caps_flushing()
1750 list_del_init(&ci->i_dirty_item); in __mark_caps_flushing()
1756 if (list_empty(&ci->i_flushing_item)) { in __mark_caps_flushing()
1757 list_add_tail(&ci->i_flushing_item, &session->s_cap_flushing); in __mark_caps_flushing()
1762 list_add_tail(&cf->i_list, &ci->i_cap_flush_list); in __mark_caps_flushing()
1772 struct ceph_inode_info *ci = ceph_inode(inode); in try_nonblocking_invalidate() local
1773 u32 invalidating_gen = ci->i_rdcache_gen; in try_nonblocking_invalidate()
1775 spin_unlock(&ci->i_ceph_lock); in try_nonblocking_invalidate()
1777 spin_lock(&ci->i_ceph_lock); in try_nonblocking_invalidate()
1780 invalidating_gen == ci->i_rdcache_gen) { in try_nonblocking_invalidate()
1784 ci->i_rdcache_revoking = ci->i_rdcache_gen - 1; in try_nonblocking_invalidate()
1791 bool __ceph_should_report_size(struct ceph_inode_info *ci) in __ceph_should_report_size() argument
1793 loff_t size = ci->vfs_inode.i_size; in __ceph_should_report_size()
1795 if (ci->i_flushing_caps & CEPH_CAP_FILE_WR) in __ceph_should_report_size()
1797 if (size >= ci->i_max_size) in __ceph_should_report_size()
1800 if (ci->i_max_size > ci->i_reported_size && in __ceph_should_report_size()
1801 (size << 1) >= ci->i_max_size + ci->i_reported_size) in __ceph_should_report_size()
1817 void ceph_check_caps(struct ceph_inode_info *ci, int flags, in ceph_check_caps() argument
1820 struct ceph_fs_client *fsc = ceph_inode_to_client(&ci->vfs_inode); in ceph_check_caps()
1822 struct inode *inode = &ci->vfs_inode; in ceph_check_caps()
1840 spin_lock(&ci->i_ceph_lock); in ceph_check_caps()
1842 if (ci->i_ceph_flags & CEPH_I_FLUSH) in ceph_check_caps()
1846 (ci->i_auth_cap && __ceph_is_single_caps(ci))) in ceph_check_caps()
1847 __cap_delay_cancel(mdsc, ci); in ceph_check_caps()
1851 spin_lock(&ci->i_ceph_lock); in ceph_check_caps()
1853 file_wanted = __ceph_caps_file_wanted(ci); in ceph_check_caps()
1854 used = __ceph_caps_used(ci); in ceph_check_caps()
1855 issued = __ceph_caps_issued(ci, &implemented); in ceph_check_caps()
1865 __ceph_dir_is_complete(ci)) { in ceph_check_caps()
1885 if (ci->i_max_size == 0) in ceph_check_caps()
1893 ceph_cap_string(used), ceph_cap_string(ci->i_dirty_caps), in ceph_check_caps()
1894 ceph_cap_string(ci->i_flushing_caps), in ceph_check_caps()
1908 !(ci->i_wb_ref || ci->i_wrbuffer_ref) && /* no dirty pages... */ in ceph_check_caps()
1917 ci->i_rdcache_revoking = ci->i_rdcache_gen; in ceph_check_caps()
1923 for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) { 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()
1935 cap_used &= ~ci->i_auth_cap->issued; in ceph_check_caps()
1944 if (cap == ci->i_auth_cap && in ceph_check_caps()
1947 if (ci->i_wanted_max_size > ci->i_max_size && in ceph_check_caps()
1948 ci->i_wanted_max_size > ci->i_requested_max_size) { in ceph_check_caps()
1954 if (__ceph_should_report_size(ci)) { in ceph_check_caps()
1960 if (cap == ci->i_auth_cap) { in ceph_check_caps()
1961 if ((flags & CHECK_CAPS_FLUSH) && ci->i_dirty_caps) { in ceph_check_caps()
1965 if (ci->i_ceph_flags & CEPH_I_FLUSH_SNAPS) { in ceph_check_caps()
1990 if ((ci->i_ceph_flags & CEPH_I_NODELAY) == 0 && in ceph_check_caps()
1991 time_before(jiffies, ci->i_hold_caps_max)) { in ceph_check_caps()
2012 spin_unlock(&ci->i_ceph_lock); in ceph_check_caps()
2024 if (cap == ci->i_auth_cap && in ceph_check_caps()
2025 (ci->i_ceph_flags & in ceph_check_caps()
2027 if (ci->i_ceph_flags & CEPH_I_KICK_FLUSH) in ceph_check_caps()
2028 __kick_flushing_caps(mdsc, session, ci, 0); in ceph_check_caps()
2029 if (ci->i_ceph_flags & CEPH_I_FLUSH_SNAPS) in ceph_check_caps()
2030 __ceph_flush_snaps(ci, session); in ceph_check_caps()
2040 spin_unlock(&ci->i_ceph_lock); in ceph_check_caps()
2048 if (cap == ci->i_auth_cap && ci->i_dirty_caps) { in ceph_check_caps()
2049 flushing = ci->i_dirty_caps; in ceph_check_caps()
2072 __cap_delay_requeue(mdsc, ci, false); in ceph_check_caps()
2074 spin_unlock(&ci->i_ceph_lock); in ceph_check_caps()
2091 struct ceph_inode_info *ci = ceph_inode(inode); in try_flush_caps() local
2097 spin_lock(&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()
2104 spin_unlock(&ci->i_ceph_lock); in try_flush_caps()
2112 spin_unlock(&ci->i_ceph_lock); in try_flush_caps()
2116 if (ci->i_ceph_flags & in try_flush_caps()
2118 if (ci->i_ceph_flags & CEPH_I_KICK_FLUSH) in try_flush_caps()
2119 __kick_flushing_caps(mdsc, session, ci, 0); in try_flush_caps()
2120 if (ci->i_ceph_flags & CEPH_I_FLUSH_SNAPS) in try_flush_caps()
2121 __ceph_flush_snaps(ci, session); in try_flush_caps()
2125 flushing = ci->i_dirty_caps; in try_flush_caps()
2132 __ceph_caps_used(ci), in try_flush_caps()
2133 __ceph_caps_wanted(ci), in try_flush_caps()
2138 spin_lock(&ci->i_ceph_lock); in try_flush_caps()
2139 __cap_delay_requeue(mdsc, ci, true); in try_flush_caps()
2140 spin_unlock(&ci->i_ceph_lock); in try_flush_caps()
2143 if (!list_empty(&ci->i_cap_flush_list)) { in try_flush_caps()
2145 list_last_entry(&ci->i_cap_flush_list, in try_flush_caps()
2150 flushing = ci->i_flushing_caps; in try_flush_caps()
2151 spin_unlock(&ci->i_ceph_lock); in try_flush_caps()
2166 struct ceph_inode_info *ci = ceph_inode(inode); in caps_are_flushed() local
2169 spin_lock(&ci->i_ceph_lock); in caps_are_flushed()
2170 if (!list_empty(&ci->i_cap_flush_list)) { in caps_are_flushed()
2172 list_first_entry(&ci->i_cap_flush_list, in caps_are_flushed()
2177 spin_unlock(&ci->i_ceph_lock); in caps_are_flushed()
2186 struct ceph_inode_info *ci = ceph_inode(inode); in unsafe_request_wait() local
2190 spin_lock(&ci->i_unsafe_lock); in unsafe_request_wait()
2191 if (S_ISDIR(inode->i_mode) && !list_empty(&ci->i_unsafe_dirops)) { in unsafe_request_wait()
2192 req1 = list_last_entry(&ci->i_unsafe_dirops, in unsafe_request_wait()
2197 if (!list_empty(&ci->i_unsafe_iops)) { in unsafe_request_wait()
2198 req2 = list_last_entry(&ci->i_unsafe_iops, in unsafe_request_wait()
2203 spin_unlock(&ci->i_unsafe_lock); in unsafe_request_wait()
2228 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_fsync() local
2250 err = wait_event_interruptible(ci->i_cap_wq, in ceph_fsync()
2257 if (errseq_check(&ci->i_meta_err, READ_ONCE(fi->meta_err))) { in ceph_fsync()
2259 err = errseq_check_and_advance(&ci->i_meta_err, in ceph_fsync()
2278 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_write_inode() local
2288 err = wait_event_interruptible(ci->i_cap_wq, in ceph_write_inode()
2294 spin_lock(&ci->i_ceph_lock); in ceph_write_inode()
2295 if (__ceph_caps_dirty(ci)) in ceph_write_inode()
2296 __cap_delay_requeue_front(mdsc, ci); in ceph_write_inode()
2297 spin_unlock(&ci->i_ceph_lock); in ceph_write_inode()
2304 struct ceph_inode_info *ci, in __kick_flushing_caps() argument
2306 __releases(ci->i_ceph_lock) in __kick_flushing_caps()
2307 __acquires(ci->i_ceph_lock) in __kick_flushing_caps()
2309 struct inode *inode = &ci->vfs_inode; in __kick_flushing_caps()
2316 ci->i_ceph_flags &= ~CEPH_I_KICK_FLUSH; in __kick_flushing_caps()
2318 list_for_each_entry_reverse(cf, &ci->i_cap_flush_list, i_list) { in __kick_flushing_caps()
2325 list_for_each_entry(cf, &ci->i_cap_flush_list, i_list) { in __kick_flushing_caps()
2329 cap = ci->i_auth_cap; in __kick_flushing_caps()
2341 ci->i_ceph_flags |= CEPH_I_NODELAY; in __kick_flushing_caps()
2346 __ceph_caps_used(ci), in __kick_flushing_caps()
2347 __ceph_caps_wanted(ci), in __kick_flushing_caps()
2366 spin_unlock(&ci->i_ceph_lock); in __kick_flushing_caps()
2381 spin_lock(&ci->i_ceph_lock); in __kick_flushing_caps()
2388 struct ceph_inode_info *ci; in ceph_early_kick_flushing_caps() local
2398 list_for_each_entry(ci, &session->s_cap_flushing, i_flushing_item) { in ceph_early_kick_flushing_caps()
2399 spin_lock(&ci->i_ceph_lock); in ceph_early_kick_flushing_caps()
2400 cap = ci->i_auth_cap; in ceph_early_kick_flushing_caps()
2403 &ci->vfs_inode, cap, session->s_mds); in ceph_early_kick_flushing_caps()
2404 spin_unlock(&ci->i_ceph_lock); in ceph_early_kick_flushing_caps()
2415 if ((cap->issued & ci->i_flushing_caps) != in ceph_early_kick_flushing_caps()
2416 ci->i_flushing_caps) { in ceph_early_kick_flushing_caps()
2423 __kick_flushing_caps(mdsc, session, ci, in ceph_early_kick_flushing_caps()
2426 ci->i_ceph_flags |= CEPH_I_KICK_FLUSH; in ceph_early_kick_flushing_caps()
2429 spin_unlock(&ci->i_ceph_lock); in ceph_early_kick_flushing_caps()
2436 struct ceph_inode_info *ci; in ceph_kick_flushing_caps() local
2446 list_for_each_entry(ci, &session->s_cap_flushing, i_flushing_item) { in ceph_kick_flushing_caps()
2447 spin_lock(&ci->i_ceph_lock); in ceph_kick_flushing_caps()
2448 cap = ci->i_auth_cap; in ceph_kick_flushing_caps()
2451 &ci->vfs_inode, cap, session->s_mds); in ceph_kick_flushing_caps()
2452 spin_unlock(&ci->i_ceph_lock); in ceph_kick_flushing_caps()
2455 if (ci->i_ceph_flags & CEPH_I_KICK_FLUSH) { in ceph_kick_flushing_caps()
2456 __kick_flushing_caps(mdsc, session, ci, in ceph_kick_flushing_caps()
2459 spin_unlock(&ci->i_ceph_lock); in ceph_kick_flushing_caps()
2466 __releases(ci->i_ceph_lock) in kick_flushing_inode_caps()
2468 struct ceph_inode_info *ci = ceph_inode(inode); in kick_flushing_inode_caps() local
2471 cap = ci->i_auth_cap; in kick_flushing_inode_caps()
2473 ceph_cap_string(ci->i_flushing_caps)); in kick_flushing_inode_caps()
2475 if (!list_empty(&ci->i_cap_flush_list)) { in kick_flushing_inode_caps()
2478 list_move_tail(&ci->i_flushing_item, in kick_flushing_inode_caps()
2483 __kick_flushing_caps(mdsc, session, ci, oldest_flush_tid); in kick_flushing_inode_caps()
2484 spin_unlock(&ci->i_ceph_lock); in kick_flushing_inode_caps()
2486 spin_unlock(&ci->i_ceph_lock); in kick_flushing_inode_caps()
2497 static void __take_cap_refs(struct ceph_inode_info *ci, int got, in __take_cap_refs() argument
2501 ci->i_pin_ref++; in __take_cap_refs()
2503 ci->i_rd_ref++; in __take_cap_refs()
2505 ci->i_rdcache_ref++; in __take_cap_refs()
2507 if (ci->i_wr_ref == 0 && !ci->i_head_snapc) { in __take_cap_refs()
2509 ci->i_head_snapc = ceph_get_snap_context( in __take_cap_refs()
2510 ci->i_snap_realm->cached_context); in __take_cap_refs()
2512 ci->i_wr_ref++; in __take_cap_refs()
2515 if (ci->i_wb_ref == 0) in __take_cap_refs()
2516 ihold(&ci->vfs_inode); in __take_cap_refs()
2517 ci->i_wb_ref++; in __take_cap_refs()
2519 &ci->vfs_inode, ci->i_wb_ref-1, ci->i_wb_ref); in __take_cap_refs()
2543 struct ceph_inode_info *ci = ceph_inode(inode); in try_get_cap_refs() local
2554 spin_lock(&ci->i_ceph_lock); in try_get_cap_refs()
2557 (ci->i_ceph_flags & CEPH_I_ERROR_FILELOCK)) { in try_get_cap_refs()
2564 file_wanted = __ceph_caps_file_wanted(ci); in try_get_cap_refs()
2573 while (ci->i_truncate_pending) { in try_get_cap_refs()
2574 spin_unlock(&ci->i_ceph_lock); in try_get_cap_refs()
2580 spin_lock(&ci->i_ceph_lock); in try_get_cap_refs()
2583 have = __ceph_caps_issued(ci, &implemented); in try_get_cap_refs()
2586 if (endoff >= 0 && endoff > (loff_t)ci->i_max_size) { in try_get_cap_refs()
2588 inode, endoff, ci->i_max_size); in try_get_cap_refs()
2589 if (endoff > ci->i_requested_max_size) in try_get_cap_refs()
2597 if (__ceph_have_pending_cap_snap(ci)) { in try_get_cap_refs()
2617 !ci->i_head_snapc && in try_get_cap_refs()
2629 spin_unlock(&ci->i_ceph_lock); in try_get_cap_refs()
2639 ceph_disable_fscache_readpage(ci); in try_get_cap_refs()
2640 __take_cap_refs(ci, *got, true); in try_get_cap_refs()
2645 if ((need & CEPH_CAP_FILE_WR) && ci->i_auth_cap) { in try_get_cap_refs()
2646 struct ceph_mds_session *s = ci->i_auth_cap->session; in try_get_cap_refs()
2653 inode, ceph_cap_string(need), ci->i_auth_cap->mds); in try_get_cap_refs()
2658 if (ci->i_ceph_flags & CEPH_I_CAP_DROPPED) { in try_get_cap_refs()
2666 mds_wanted = __ceph_caps_mds_wanted(ci, false); in try_get_cap_refs()
2674 ci->i_ceph_flags &= ~CEPH_I_CAP_DROPPED; in try_get_cap_refs()
2681 spin_unlock(&ci->i_ceph_lock); in try_get_cap_refs()
2697 struct ceph_inode_info *ci = ceph_inode(inode); in check_max_size() local
2701 spin_lock(&ci->i_ceph_lock); in check_max_size()
2702 if (endoff >= ci->i_max_size && endoff > ci->i_wanted_max_size) { in check_max_size()
2705 ci->i_wanted_max_size = endoff; in check_max_size()
2708 if (ci->i_auth_cap && in check_max_size()
2709 (ci->i_auth_cap->issued & CEPH_CAP_FILE_WR) && in check_max_size()
2710 ci->i_wanted_max_size > ci->i_max_size && in check_max_size()
2711 ci->i_wanted_max_size > ci->i_requested_max_size) in check_max_size()
2713 spin_unlock(&ci->i_ceph_lock); in check_max_size()
2715 ceph_check_caps(ci, CHECK_CAPS_AUTHONLY, NULL); in check_max_size()
2744 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_get_caps() local
2768 add_wait_queue(&ci->i_cap_wq, &wait); in ceph_get_caps()
2780 remove_wait_queue(&ci->i_cap_wq, &wait); in ceph_get_caps()
2788 ceph_put_cap_refs(ci, _got); in ceph_get_caps()
2802 if (ci->i_inline_version != CEPH_INLINE_NONE && in ceph_get_caps()
2818 ceph_put_cap_refs(ci, _got); in ceph_get_caps()
2836 ceph_fscache_revalidate_cookie(ci); in ceph_get_caps()
2846 void ceph_get_cap_refs(struct ceph_inode_info *ci, int caps) in ceph_get_cap_refs() argument
2848 spin_lock(&ci->i_ceph_lock); in ceph_get_cap_refs()
2849 __take_cap_refs(ci, caps, false); in ceph_get_cap_refs()
2850 spin_unlock(&ci->i_ceph_lock); in ceph_get_cap_refs()
2858 static int ceph_try_drop_cap_snap(struct ceph_inode_info *ci, in ceph_try_drop_cap_snap() argument
2867 if (!list_is_last(&capsnap->ci_item, &ci->i_cap_snaps)) in ceph_try_drop_cap_snap()
2868 ci->i_ceph_flags |= CEPH_I_FLUSH_SNAPS; in ceph_try_drop_cap_snap()
2886 void ceph_put_cap_refs(struct ceph_inode_info *ci, int had) in ceph_put_cap_refs() argument
2888 struct inode *inode = &ci->vfs_inode; in ceph_put_cap_refs()
2891 spin_lock(&ci->i_ceph_lock); in ceph_put_cap_refs()
2893 --ci->i_pin_ref; in ceph_put_cap_refs()
2895 if (--ci->i_rd_ref == 0) in ceph_put_cap_refs()
2898 if (--ci->i_rdcache_ref == 0) in ceph_put_cap_refs()
2901 if (--ci->i_wb_ref == 0) { in ceph_put_cap_refs()
2906 inode, ci->i_wb_ref+1, ci->i_wb_ref); in ceph_put_cap_refs()
2909 if (--ci->i_wr_ref == 0) { in ceph_put_cap_refs()
2911 if (__ceph_have_pending_cap_snap(ci)) { in ceph_put_cap_refs()
2913 list_last_entry(&ci->i_cap_snaps, in ceph_put_cap_refs()
2917 if (ceph_try_drop_cap_snap(ci, capsnap)) in ceph_put_cap_refs()
2919 else if (__ceph_finish_cap_snap(ci, capsnap)) in ceph_put_cap_refs()
2923 if (ci->i_wrbuffer_ref_head == 0 && in ceph_put_cap_refs()
2924 ci->i_dirty_caps == 0 && in ceph_put_cap_refs()
2925 ci->i_flushing_caps == 0) { in ceph_put_cap_refs()
2926 BUG_ON(!ci->i_head_snapc); in ceph_put_cap_refs()
2927 ceph_put_snap_context(ci->i_head_snapc); in ceph_put_cap_refs()
2928 ci->i_head_snapc = NULL; in ceph_put_cap_refs()
2931 if (!__ceph_is_any_caps(ci) && ci->i_snap_realm) in ceph_put_cap_refs()
2932 drop_inode_snap_realm(ci); in ceph_put_cap_refs()
2934 spin_unlock(&ci->i_ceph_lock); in ceph_put_cap_refs()
2940 ceph_check_caps(ci, 0, NULL); in ceph_put_cap_refs()
2942 ceph_flush_snaps(ci, NULL); in ceph_put_cap_refs()
2944 wake_up_all(&ci->i_cap_wq); in ceph_put_cap_refs()
2956 void ceph_put_wrbuffer_cap_refs(struct ceph_inode_info *ci, int nr, in ceph_put_wrbuffer_cap_refs() argument
2959 struct inode *inode = &ci->vfs_inode; in ceph_put_wrbuffer_cap_refs()
2967 spin_lock(&ci->i_ceph_lock); in ceph_put_wrbuffer_cap_refs()
2968 ci->i_wrbuffer_ref -= nr; in ceph_put_wrbuffer_cap_refs()
2969 if (ci->i_wrbuffer_ref == 0) { in ceph_put_wrbuffer_cap_refs()
2974 if (ci->i_head_snapc == snapc) { in ceph_put_wrbuffer_cap_refs()
2975 ci->i_wrbuffer_ref_head -= nr; in ceph_put_wrbuffer_cap_refs()
2976 if (ci->i_wrbuffer_ref_head == 0 && in ceph_put_wrbuffer_cap_refs()
2977 ci->i_wr_ref == 0 && in ceph_put_wrbuffer_cap_refs()
2978 ci->i_dirty_caps == 0 && in ceph_put_wrbuffer_cap_refs()
2979 ci->i_flushing_caps == 0) { in ceph_put_wrbuffer_cap_refs()
2980 BUG_ON(!ci->i_head_snapc); in ceph_put_wrbuffer_cap_refs()
2981 ceph_put_snap_context(ci->i_head_snapc); in ceph_put_wrbuffer_cap_refs()
2982 ci->i_head_snapc = NULL; in ceph_put_wrbuffer_cap_refs()
2986 ci->i_wrbuffer_ref+nr, ci->i_wrbuffer_ref_head+nr, in ceph_put_wrbuffer_cap_refs()
2987 ci->i_wrbuffer_ref, ci->i_wrbuffer_ref_head, in ceph_put_wrbuffer_cap_refs()
2990 list_for_each_entry(capsnap, &ci->i_cap_snaps, ci_item) { in ceph_put_wrbuffer_cap_refs()
3001 if (ceph_try_drop_cap_snap(ci, capsnap)) { in ceph_put_wrbuffer_cap_refs()
3004 ci->i_ceph_flags |= CEPH_I_FLUSH_SNAPS; in ceph_put_wrbuffer_cap_refs()
3012 ci->i_wrbuffer_ref+nr, capsnap->dirty_pages + nr, in ceph_put_wrbuffer_cap_refs()
3013 ci->i_wrbuffer_ref, capsnap->dirty_pages, in ceph_put_wrbuffer_cap_refs()
3018 spin_unlock(&ci->i_ceph_lock); in ceph_put_wrbuffer_cap_refs()
3021 ceph_check_caps(ci, CHECK_CAPS_AUTHONLY, NULL); in ceph_put_wrbuffer_cap_refs()
3023 ceph_flush_snaps(ci, NULL); in ceph_put_wrbuffer_cap_refs()
3026 wake_up_all(&ci->i_cap_wq); in ceph_put_wrbuffer_cap_refs()
3093 __releases(ci->i_ceph_lock) in handle_cap_grant()
3096 struct ceph_inode_info *ci = ceph_inode(inode); in handle_cap_grant() local
3125 !(ci->i_wrbuffer_ref || ci->i_wb_ref)) { in handle_cap_grant()
3129 if (ci->i_rdcache_revoking != ci->i_rdcache_gen) { in handle_cap_grant()
3131 ci->i_rdcache_revoking = ci->i_rdcache_gen; in handle_cap_grant()
3148 WARN_ON(cap != ci->i_auth_cap); in handle_cap_grant()
3158 __check_cap_issue(ci, cap, newcaps); in handle_cap_grant()
3167 ci->i_btime = extra_info->btime; in handle_cap_grant()
3186 if (version > ci->i_xattrs.version) { in handle_cap_grant()
3189 if (ci->i_xattrs.blob) in handle_cap_grant()
3190 ceph_buffer_put(ci->i_xattrs.blob); in handle_cap_grant()
3191 ci->i_xattrs.blob = ceph_buffer_get(xattr_buf); in handle_cap_grant()
3192 ci->i_xattrs.version = version; in handle_cap_grant()
3210 ci->i_files = extra_info->nfiles; in handle_cap_grant()
3211 ci->i_subdirs = extra_info->nsubdirs; in handle_cap_grant()
3216 s64 old_pool = ci->i_layout.pool_id; in handle_cap_grant()
3219 ceph_file_layout_from_legacy(&ci->i_layout, &grant->layout); in handle_cap_grant()
3220 old_ns = rcu_dereference_protected(ci->i_layout.pool_ns, in handle_cap_grant()
3221 lockdep_is_held(&ci->i_ceph_lock)); in handle_cap_grant()
3222 rcu_assign_pointer(ci->i_layout.pool_ns, extra_info->pool_ns); in handle_cap_grant()
3224 if (ci->i_layout.pool_id != old_pool || in handle_cap_grant()
3226 ci->i_ceph_flags &= ~CEPH_I_POOL_PERM; in handle_cap_grant()
3237 if (ci->i_auth_cap == cap && (newcaps & CEPH_CAP_ANY_FILE_WR)) { in handle_cap_grant()
3238 if (max_size != ci->i_max_size) { in handle_cap_grant()
3240 ci->i_max_size, max_size); in handle_cap_grant()
3241 ci->i_max_size = max_size; in handle_cap_grant()
3242 if (max_size >= ci->i_wanted_max_size) { in handle_cap_grant()
3243 ci->i_wanted_max_size = 0; /* reset */ in handle_cap_grant()
3244 ci->i_requested_max_size = 0; in handle_cap_grant()
3247 } else if (ci->i_wanted_max_size > ci->i_max_size && in handle_cap_grant()
3248 ci->i_wanted_max_size > ci->i_requested_max_size) { in handle_cap_grant()
3255 wanted = __ceph_caps_wanted(ci); in handle_cap_grant()
3256 used = __ceph_caps_used(ci); in handle_cap_grant()
3257 dirty = __ceph_caps_dirty(ci); in handle_cap_grant()
3292 else if (cap == ci->i_auth_cap) 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()
3318 extra_info->inline_version >= ci->i_inline_version) { in handle_cap_grant()
3319 ci->i_inline_version = extra_info->inline_version; in handle_cap_grant()
3320 if (ci->i_inline_version != CEPH_INLINE_NONE && in handle_cap_grant()
3331 spin_unlock(&ci->i_ceph_lock); in handle_cap_grant()
3353 wake_up_all(&ci->i_cap_wq); in handle_cap_grant()
3356 ceph_check_caps(ci, CHECK_CAPS_NODELAY|CHECK_CAPS_AUTHONLY, in handle_cap_grant()
3359 ceph_check_caps(ci, CHECK_CAPS_NODELAY, session); in handle_cap_grant()
3372 __releases(ci->i_ceph_lock) in handle_cap_flush_ack()
3374 struct ceph_inode_info *ci = ceph_inode(inode); in handle_cap_flush_ack() local
3385 list_for_each_entry_safe(cf, tmp_cf, &ci->i_cap_flush_list, i_list) { in handle_cap_flush_ack()
3391 if (__finish_cap_flush(NULL, ci, cf)) in handle_cap_flush_ack()
3404 ceph_cap_string(cleaned), ceph_cap_string(ci->i_flushing_caps), in handle_cap_flush_ack()
3405 ceph_cap_string(ci->i_flushing_caps & ~cleaned)); in handle_cap_flush_ack()
3410 ci->i_flushing_caps &= ~cleaned; in handle_cap_flush_ack()
3419 if (ci->i_flushing_caps == 0) { in handle_cap_flush_ack()
3420 if (list_empty(&ci->i_cap_flush_list)) { in handle_cap_flush_ack()
3421 list_del_init(&ci->i_flushing_item); in handle_cap_flush_ack()
3433 if (ci->i_dirty_caps == 0) { in handle_cap_flush_ack()
3435 BUG_ON(!list_empty(&ci->i_dirty_item)); in handle_cap_flush_ack()
3437 if (ci->i_wr_ref == 0 && in handle_cap_flush_ack()
3438 ci->i_wrbuffer_ref_head == 0) { in handle_cap_flush_ack()
3439 BUG_ON(!ci->i_head_snapc); in handle_cap_flush_ack()
3440 ceph_put_snap_context(ci->i_head_snapc); in handle_cap_flush_ack()
3441 ci->i_head_snapc = NULL; in handle_cap_flush_ack()
3444 BUG_ON(list_empty(&ci->i_dirty_item)); in handle_cap_flush_ack()
3450 spin_unlock(&ci->i_ceph_lock); in handle_cap_flush_ack()
3460 wake_up_all(&ci->i_cap_wq); in handle_cap_flush_ack()
3477 struct ceph_inode_info *ci = ceph_inode(inode); in handle_cap_flushsnap_ack() local
3486 inode, ci, session->s_mds, follows); in handle_cap_flushsnap_ack()
3488 spin_lock(&ci->i_ceph_lock); in handle_cap_flushsnap_ack()
3489 list_for_each_entry(capsnap, &ci->i_cap_snaps, ci_item) { in handle_cap_flushsnap_ack()
3509 if (__finish_cap_flush(NULL, ci, &capsnap->cap_flush)) in handle_cap_flushsnap_ack()
3514 if (list_empty(&ci->i_cap_flush_list)) in handle_cap_flushsnap_ack()
3515 list_del_init(&ci->i_flushing_item); in handle_cap_flushsnap_ack()
3522 spin_unlock(&ci->i_ceph_lock); in handle_cap_flushsnap_ack()
3527 wake_up_all(&ci->i_cap_wq); in handle_cap_flushsnap_ack()
3542 __releases(ci->i_ceph_lock) in handle_cap_trunc()
3544 struct ceph_inode_info *ci = ceph_inode(inode); in handle_cap_trunc() local
3551 int dirty = __ceph_caps_dirty(ci); in handle_cap_trunc()
3561 spin_unlock(&ci->i_ceph_lock); in handle_cap_trunc()
3582 struct ceph_inode_info *ci = ceph_inode(inode); in handle_cap_export() local
3600 inode, ci, mds, mseq, target); in handle_cap_export()
3602 spin_lock(&ci->i_ceph_lock); in handle_cap_export()
3603 cap = __get_cap_for_mds(ci, mds); in handle_cap_export()
3609 ci->i_ceph_flags |= CEPH_I_CAP_DROPPED; in handle_cap_export()
3629 tcap = __get_cap_for_mds(ci, target); in handle_cap_export()
3640 if (cap == ci->i_auth_cap) in handle_cap_export()
3641 ci->i_auth_cap = tcap; in handle_cap_export()
3643 if (!list_empty(&ci->i_cap_flush_list) && in handle_cap_export()
3644 ci->i_auth_cap == tcap) { in handle_cap_export()
3646 list_move_tail(&ci->i_flushing_item, in handle_cap_export()
3655 int flag = (cap == ci->i_auth_cap) ? CEPH_CAP_FLAG_AUTH : 0; in handle_cap_export()
3660 if (!list_empty(&ci->i_cap_flush_list) && in handle_cap_export()
3661 ci->i_auth_cap == tcap) { in handle_cap_export()
3663 list_move_tail(&ci->i_flushing_item, in handle_cap_export()
3672 spin_unlock(&ci->i_ceph_lock); in handle_cap_export()
3696 spin_unlock(&ci->i_ceph_lock); in handle_cap_export()
3716 __acquires(ci->i_ceph_lock) in handle_cap_import()
3718 struct ceph_inode_info *ci = ceph_inode(inode); in handle_cap_import() local
3740 inode, ci, mds, mseq, peer); in handle_cap_import()
3743 spin_lock(&ci->i_ceph_lock); in handle_cap_import()
3744 cap = __get_cap_for_mds(ci, mds); in handle_cap_import()
3747 spin_unlock(&ci->i_ceph_lock); in handle_cap_import()
3759 __ceph_caps_issued(ci, &issued); in handle_cap_import()
3760 issued |= __ceph_caps_dirty(ci); in handle_cap_import()
3765 ocap = peer >= 0 ? __get_cap_for_mds(ci, peer) : NULL; in handle_cap_import()
3784 ci->i_requested_max_size = 0; in handle_cap_import()
3801 struct ceph_inode_info *ci; in ceph_handle_caps() local
3912 ci = ceph_inode(inode); in ceph_handle_caps()
3971 spin_lock(&ci->i_ceph_lock); in ceph_handle_caps()
3977 spin_unlock(&ci->i_ceph_lock); in ceph_handle_caps()
3985 __ceph_caps_issued(ci, &extra_info.issued); in ceph_handle_caps()
3986 extra_info.issued |= __ceph_caps_dirty(ci); in ceph_handle_caps()
4001 spin_unlock(&ci->i_ceph_lock); in ceph_handle_caps()
4035 struct ceph_inode_info *ci; in ceph_check_delayed_caps() local
4043 ci = list_first_entry(&mdsc->cap_delay_list, in ceph_check_delayed_caps()
4046 if ((ci->i_ceph_flags & CEPH_I_FLUSH) == 0 && in ceph_check_delayed_caps()
4047 time_before(jiffies, ci->i_hold_caps_max)) in ceph_check_delayed_caps()
4049 list_del_init(&ci->i_cap_delay_list); in ceph_check_delayed_caps()
4051 inode = igrab(&ci->vfs_inode); in ceph_check_delayed_caps()
4056 ceph_check_caps(ci, flags, NULL); in ceph_check_delayed_caps()
4069 struct ceph_inode_info *ci; in ceph_flush_dirty_caps() local
4075 ci = list_first_entry(&mdsc->cap_dirty, struct ceph_inode_info, in ceph_flush_dirty_caps()
4077 inode = &ci->vfs_inode; in ceph_flush_dirty_caps()
4081 ceph_check_caps(ci, CHECK_CAPS_NODELAY|CHECK_CAPS_FLUSH, NULL); in ceph_flush_dirty_caps()
4089 void __ceph_get_fmode(struct ceph_inode_info *ci, int fmode) in __ceph_get_fmode() argument
4095 ci->i_nr_by_mode[i]++; in __ceph_get_fmode()
4104 void ceph_put_fmode(struct ceph_inode_info *ci, int fmode) in ceph_put_fmode() argument
4108 spin_lock(&ci->i_ceph_lock); in ceph_put_fmode()
4111 BUG_ON(ci->i_nr_by_mode[i] == 0); in ceph_put_fmode()
4112 if (--ci->i_nr_by_mode[i] == 0) in ceph_put_fmode()
4117 &ci->vfs_inode, fmode, in ceph_put_fmode()
4118 ci->i_nr_by_mode[0], ci->i_nr_by_mode[1], in ceph_put_fmode()
4119 ci->i_nr_by_mode[2], ci->i_nr_by_mode[3]); in ceph_put_fmode()
4120 spin_unlock(&ci->i_ceph_lock); in ceph_put_fmode()
4122 if (last && ci->i_vino.snap == CEPH_NOSNAP) in ceph_put_fmode()
4123 ceph_check_caps(ci, 0, NULL); in ceph_put_fmode()
4134 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_drop_caps_for_unlink() local
4137 spin_lock(&ci->i_ceph_lock); in ceph_drop_caps_for_unlink()
4139 drop |= ~(__ceph_caps_wanted(ci) | CEPH_CAP_PIN); in ceph_drop_caps_for_unlink()
4141 ci->i_ceph_flags |= CEPH_I_NODELAY; in ceph_drop_caps_for_unlink()
4142 if (__ceph_caps_dirty(ci)) { in ceph_drop_caps_for_unlink()
4145 __cap_delay_requeue_front(mdsc, ci); in ceph_drop_caps_for_unlink()
4148 spin_unlock(&ci->i_ceph_lock); in ceph_drop_caps_for_unlink()
4163 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_encode_inode_release() local
4169 spin_lock(&ci->i_ceph_lock); in ceph_encode_inode_release()
4170 used = __ceph_caps_used(ci); in ceph_encode_inode_release()
4171 dirty = __ceph_caps_dirty(ci); in ceph_encode_inode_release()
4180 cap = __get_cap_for_mds(ci, mds); in ceph_encode_inode_release()
4196 int wanted = __ceph_caps_wanted(ci); in ceph_encode_inode_release()
4197 if ((ci->i_ceph_flags & CEPH_I_NODELAY) == 0) in ceph_encode_inode_release()
4231 spin_unlock(&ci->i_ceph_lock); in ceph_encode_inode_release()