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
493 ci->i_hold_caps_max = round_jiffies(jiffies + in __cap_set_timeouts()
495 dout("__cap_set_timeouts %p %lu\n", &ci->vfs_inode, in __cap_set_timeouts()
496 ci->i_hold_caps_max - jiffies); in __cap_set_timeouts()
508 struct ceph_inode_info *ci) in __cap_delay_requeue() argument
510 dout("__cap_delay_requeue %p flags 0x%lx at %lu\n", &ci->vfs_inode, in __cap_delay_requeue()
511 ci->i_ceph_flags, ci->i_hold_caps_max); in __cap_delay_requeue()
514 if (!list_empty(&ci->i_cap_delay_list)) { in __cap_delay_requeue()
515 if (ci->i_ceph_flags & CEPH_I_FLUSH) in __cap_delay_requeue()
517 list_del_init(&ci->i_cap_delay_list); in __cap_delay_requeue()
519 __cap_set_timeouts(mdsc, ci); in __cap_delay_requeue()
520 list_add_tail(&ci->i_cap_delay_list, &mdsc->cap_delay_list); in __cap_delay_requeue()
532 struct ceph_inode_info *ci) in __cap_delay_requeue_front() argument
534 dout("__cap_delay_requeue_front %p\n", &ci->vfs_inode); in __cap_delay_requeue_front()
536 ci->i_ceph_flags |= CEPH_I_FLUSH; in __cap_delay_requeue_front()
537 if (!list_empty(&ci->i_cap_delay_list)) in __cap_delay_requeue_front()
538 list_del_init(&ci->i_cap_delay_list); in __cap_delay_requeue_front()
539 list_add(&ci->i_cap_delay_list, &mdsc->cap_delay_list); in __cap_delay_requeue_front()
549 struct ceph_inode_info *ci) in __cap_delay_cancel() argument
551 dout("__cap_delay_cancel %p\n", &ci->vfs_inode); in __cap_delay_cancel()
552 if (list_empty(&ci->i_cap_delay_list)) in __cap_delay_cancel()
555 list_del_init(&ci->i_cap_delay_list); in __cap_delay_cancel()
560 static void __check_cap_issue(struct ceph_inode_info *ci, struct ceph_cap *cap, in __check_cap_issue() argument
563 unsigned had = __ceph_caps_issued(ci, NULL); in __check_cap_issue()
565 lockdep_assert_held(&ci->i_ceph_lock); in __check_cap_issue()
571 if (S_ISREG(ci->vfs_inode.i_mode) && in __check_cap_issue()
574 ci->i_rdcache_gen++; in __check_cap_issue()
585 atomic_inc(&ci->i_shared_gen); in __check_cap_issue()
586 if (S_ISDIR(ci->vfs_inode.i_mode)) { in __check_cap_issue()
587 dout(" marking %p NOT complete\n", &ci->vfs_inode); in __check_cap_issue()
588 __ceph_dir_clear_complete(ci); in __check_cap_issue()
593 if (S_ISDIR(ci->vfs_inode.i_mode) && (had & CEPH_CAP_DIR_CREATE) && in __check_cap_issue()
595 ceph_put_string(rcu_dereference_raw(ci->i_cached_layout.pool_ns)); in __check_cap_issue()
596 memset(&ci->i_cached_layout, 0, sizeof(ci->i_cached_layout)); in __check_cap_issue()
605 static void change_auth_cap_ses(struct ceph_inode_info *ci, in change_auth_cap_ses() argument
608 lockdep_assert_held(&ci->i_ceph_lock); in change_auth_cap_ses()
610 if (list_empty(&ci->i_dirty_item) && list_empty(&ci->i_flushing_item)) in change_auth_cap_ses()
614 if (!list_empty(&ci->i_dirty_item)) in change_auth_cap_ses()
615 list_move(&ci->i_dirty_item, &session->s_cap_dirty); in change_auth_cap_ses()
616 if (!list_empty(&ci->i_flushing_item)) in change_auth_cap_ses()
617 list_move_tail(&ci->i_flushing_item, &session->s_cap_flushing); in change_auth_cap_ses()
637 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_add_cap() local
643 lockdep_assert_held(&ci->i_ceph_lock); in ceph_add_cap()
650 cap = __get_cap_for_mds(ci, mds); in ceph_add_cap()
661 cap->ci = ci; in ceph_add_cap()
662 __insert_cap_node(ci, cap); in ceph_add_cap()
689 WARN_ON(cap != ci->i_auth_cap); in ceph_add_cap()
698 if (!ci->i_snap_realm || in ceph_add_cap()
700 realmino != (u64)-1 && ci->i_snap_realm->ino != realmino)) { in ceph_add_cap()
710 __func__, realmino, ci->i_vino.ino, in ceph_add_cap()
711 ci->i_snap_realm ? ci->i_snap_realm->ino : 0); in ceph_add_cap()
714 __check_cap_issue(ci, cap, issued); in ceph_add_cap()
721 actual_wanted = __ceph_caps_wanted(ci); in ceph_add_cap()
727 __cap_delay_requeue(mdsc, ci); in ceph_add_cap()
731 if (!ci->i_auth_cap || in ceph_add_cap()
732 ceph_seq_cmp(ci->i_auth_cap->mseq, mseq) < 0) { in ceph_add_cap()
733 if (ci->i_auth_cap && in ceph_add_cap()
734 ci->i_auth_cap->session != cap->session) in ceph_add_cap()
735 change_auth_cap_ses(ci, cap->session); in ceph_add_cap()
736 ci->i_auth_cap = cap; in ceph_add_cap()
740 WARN_ON(ci->i_auth_cap == cap); in ceph_add_cap()
774 "but STALE (gen %u vs %u)\n", &cap->ci->vfs_inode, in __cap_is_valid()
787 int __ceph_caps_issued(struct ceph_inode_info *ci, int *implemented) in __ceph_caps_issued() argument
789 int have = ci->i_snap_caps; in __ceph_caps_issued()
795 for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) { in __ceph_caps_issued()
800 &ci->vfs_inode, cap, ceph_cap_string(cap->issued)); in __ceph_caps_issued()
810 if (ci->i_auth_cap) { in __ceph_caps_issued()
811 cap = ci->i_auth_cap; in __ceph_caps_issued()
820 int __ceph_caps_issued_other(struct ceph_inode_info *ci, struct ceph_cap *ocap) in __ceph_caps_issued_other() argument
822 int have = ci->i_snap_caps; in __ceph_caps_issued_other()
826 for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) { in __ceph_caps_issued_other()
847 dout("__touch_cap %p cap %p mds%d\n", &cap->ci->vfs_inode, cap, in __touch_cap()
852 &cap->ci->vfs_inode, cap, s->s_mds); in __touch_cap()
862 int __ceph_caps_issued_mask(struct ceph_inode_info *ci, int mask, int touch) in __ceph_caps_issued_mask() argument
866 int have = ci->i_snap_caps; in __ceph_caps_issued_mask()
870 " (mask %s)\n", ceph_ino(&ci->vfs_inode), in __ceph_caps_issued_mask()
876 for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) { in __ceph_caps_issued_mask()
882 " (mask %s)\n", ceph_ino(&ci->vfs_inode), cap, in __ceph_caps_issued_mask()
894 " (mask %s)\n", ceph_ino(&ci->vfs_inode), in __ceph_caps_issued_mask()
902 for (q = rb_first(&ci->i_caps); q != p; in __ceph_caps_issued_mask()
919 int __ceph_caps_issued_mask_metric(struct ceph_inode_info *ci, int mask, in __ceph_caps_issued_mask_metric() argument
922 struct ceph_fs_client *fsc = ceph_sb_to_client(ci->vfs_inode.i_sb); in __ceph_caps_issued_mask_metric()
925 r = __ceph_caps_issued_mask(ci, mask, touch); in __ceph_caps_issued_mask_metric()
936 int __ceph_caps_revoking_other(struct ceph_inode_info *ci, in __ceph_caps_revoking_other() argument
942 for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) { in __ceph_caps_revoking_other()
951 int ceph_caps_revoking(struct ceph_inode_info *ci, int mask) in ceph_caps_revoking() argument
953 struct inode *inode = &ci->vfs_inode; in ceph_caps_revoking()
956 spin_lock(&ci->i_ceph_lock); in ceph_caps_revoking()
957 ret = __ceph_caps_revoking_other(ci, NULL, mask); in ceph_caps_revoking()
958 spin_unlock(&ci->i_ceph_lock); in ceph_caps_revoking()
964 int __ceph_caps_used(struct ceph_inode_info *ci) in __ceph_caps_used() argument
967 if (ci->i_pin_ref) in __ceph_caps_used()
969 if (ci->i_rd_ref) in __ceph_caps_used()
971 if (ci->i_rdcache_ref || in __ceph_caps_used()
972 (S_ISREG(ci->vfs_inode.i_mode) && in __ceph_caps_used()
973 ci->vfs_inode.i_data.nrpages)) in __ceph_caps_used()
975 if (ci->i_wr_ref) in __ceph_caps_used()
977 if (ci->i_wb_ref || ci->i_wrbuffer_ref) in __ceph_caps_used()
979 if (ci->i_fx_ref) in __ceph_caps_used()
989 int __ceph_caps_file_wanted(struct ceph_inode_info *ci) in __ceph_caps_file_wanted() argument
996 ceph_inode_to_client(&ci->vfs_inode)->mount_options; in __ceph_caps_file_wanted()
1000 if (S_ISDIR(ci->vfs_inode.i_mode)) { in __ceph_caps_file_wanted()
1004 if (ci->i_nr_by_mode[RD_SHIFT] > 0 || in __ceph_caps_file_wanted()
1005 time_after(ci->i_last_rd, used_cutoff)) in __ceph_caps_file_wanted()
1008 if (ci->i_nr_by_mode[WR_SHIFT] > 0 || in __ceph_caps_file_wanted()
1009 time_after(ci->i_last_wr, used_cutoff)) { in __ceph_caps_file_wanted()
1015 if (want || ci->i_nr_by_mode[PIN_SHIFT] > 0) in __ceph_caps_file_wanted()
1022 if (ci->i_nr_by_mode[RD_SHIFT] > 0) { in __ceph_caps_file_wanted()
1023 if (ci->i_nr_by_mode[RD_SHIFT] >= FMODE_WAIT_BIAS || in __ceph_caps_file_wanted()
1024 time_after(ci->i_last_rd, used_cutoff)) in __ceph_caps_file_wanted()
1026 } else if (time_after(ci->i_last_rd, idle_cutoff)) { in __ceph_caps_file_wanted()
1030 if (ci->i_nr_by_mode[WR_SHIFT] > 0) { in __ceph_caps_file_wanted()
1031 if (ci->i_nr_by_mode[WR_SHIFT] >= FMODE_WAIT_BIAS || in __ceph_caps_file_wanted()
1032 time_after(ci->i_last_wr, used_cutoff)) in __ceph_caps_file_wanted()
1034 } else if (time_after(ci->i_last_wr, idle_cutoff)) { in __ceph_caps_file_wanted()
1040 ci->i_nr_by_mode[LAZY_SHIFT] > 0) in __ceph_caps_file_wanted()
1050 int __ceph_caps_wanted(struct ceph_inode_info *ci) in __ceph_caps_wanted() argument
1052 int w = __ceph_caps_file_wanted(ci) | __ceph_caps_used(ci); in __ceph_caps_wanted()
1053 if (S_ISDIR(ci->vfs_inode.i_mode)) { in __ceph_caps_wanted()
1068 int __ceph_caps_mds_wanted(struct ceph_inode_info *ci, bool check) in __ceph_caps_mds_wanted() argument
1074 for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) { in __ceph_caps_mds_wanted()
1078 if (cap == ci->i_auth_cap) in __ceph_caps_mds_wanted()
1088 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_is_any_caps() local
1091 spin_lock(&ci->i_ceph_lock); in ceph_is_any_caps()
1092 ret = __ceph_is_any_real_caps(ci); in ceph_is_any_caps()
1093 spin_unlock(&ci->i_ceph_lock); in ceph_is_any_caps()
1107 struct ceph_inode_info *ci = cap->ci; in __ceph_remove_cap() local
1112 if (!ci) { in __ceph_remove_cap()
1117 lockdep_assert_held(&ci->i_ceph_lock); in __ceph_remove_cap()
1119 dout("__ceph_remove_cap %p from %p\n", cap, &ci->vfs_inode); in __ceph_remove_cap()
1121 mdsc = ceph_inode_to_client(&ci->vfs_inode)->mdsc; in __ceph_remove_cap()
1124 rb_erase(&cap->ci_node, &ci->i_caps); in __ceph_remove_cap()
1125 if (ci->i_auth_cap == cap) in __ceph_remove_cap()
1126 ci->i_auth_cap = NULL; in __ceph_remove_cap()
1142 cap->ci = NULL; in __ceph_remove_cap()
1159 cap->cap_ino = ci->i_vino.ino; in __ceph_remove_cap()
1166 if (!__ceph_is_any_real_caps(ci)) { in __ceph_remove_cap()
1171 if (ci->i_wr_ref == 0 && ci->i_snap_realm) in __ceph_remove_cap()
1172 ceph_change_snap_realm(&ci->vfs_inode, NULL); in __ceph_remove_cap()
1174 __cap_delay_cancel(mdsc, ci); in __ceph_remove_cap()
1180 struct ceph_inode_info *ci = cap->ci; in ceph_remove_cap() local
1184 if (!ci) { in ceph_remove_cap()
1189 lockdep_assert_held(&ci->i_ceph_lock); in ceph_remove_cap()
1191 fsc = ceph_sb_to_client(ci->vfs_inode.i_sb); in ceph_remove_cap()
1192 WARN_ON_ONCE(ci->i_auth_cap == cap && in ceph_remove_cap()
1193 !list_empty(&ci->i_dirty_item) && in ceph_remove_cap()
1317 void __ceph_remove_caps(struct ceph_inode_info *ci) in __ceph_remove_caps() argument
1323 spin_lock(&ci->i_ceph_lock); in __ceph_remove_caps()
1324 p = rb_first(&ci->i_caps); in __ceph_remove_caps()
1330 spin_unlock(&ci->i_ceph_lock); in __ceph_remove_caps()
1345 struct ceph_inode_info *ci = cap->ci; in __prep_cap() local
1346 struct inode *inode = &ci->vfs_inode; in __prep_cap()
1349 lockdep_assert_held(&ci->i_ceph_lock); in __prep_cap()
1361 ci->i_ceph_flags &= ~CEPH_I_FLUSH; in __prep_cap()
1376 arg->follows = flushing ? ci->i_head_snapc->seq : 0; in __prep_cap()
1381 ci->i_reported_size = arg->size; in __prep_cap()
1382 arg->max_size = ci->i_wanted_max_size; in __prep_cap()
1383 if (cap == ci->i_auth_cap) { in __prep_cap()
1385 ci->i_requested_max_size = arg->max_size; in __prep_cap()
1387 ci->i_requested_max_size = 0; in __prep_cap()
1391 arg->old_xattr_buf = __ceph_build_xattrs_blob(ci); in __prep_cap()
1392 arg->xattr_version = ci->i_xattrs.version; in __prep_cap()
1393 arg->xattr_buf = ci->i_xattrs.blob; in __prep_cap()
1402 arg->btime = ci->i_btime; in __prep_cap()
1413 arg->time_warp_seq = ci->i_time_warp_seq; in __prep_cap()
1419 arg->inline_data = ci->i_inline_version != CEPH_INLINE_NONE; in __prep_cap()
1421 !list_empty(&ci->i_cap_snaps)) { in __prep_cap()
1423 list_for_each_entry_reverse(capsnap, &ci->i_cap_snaps, ci_item) { in __prep_cap()
1440 static void __send_cap(struct cap_msg_args *arg, struct ceph_inode_info *ci) in __send_cap() argument
1443 struct inode *inode = &ci->vfs_inode; in __send_cap()
1450 spin_lock(&ci->i_ceph_lock); in __send_cap()
1451 __cap_delay_requeue(arg->session->s_mdsc, ci); in __send_cap()
1452 spin_unlock(&ci->i_ceph_lock); in __send_cap()
1460 wake_up_all(&ci->i_cap_wq); in __send_cap()
1526 static void __ceph_flush_snaps(struct ceph_inode_info *ci, in __ceph_flush_snaps() argument
1528 __releases(ci->i_ceph_lock) in __ceph_flush_snaps()
1529 __acquires(ci->i_ceph_lock) in __ceph_flush_snaps()
1531 struct inode *inode = &ci->vfs_inode; in __ceph_flush_snaps()
1539 list_for_each_entry(capsnap, &ci->i_cap_snaps, ci_item) { in __ceph_flush_snaps()
1562 if (list_empty(&ci->i_flushing_item)) { in __ceph_flush_snaps()
1563 list_add_tail(&ci->i_flushing_item, in __ceph_flush_snaps()
1569 &ci->i_cap_flush_list); in __ceph_flush_snaps()
1576 ci->i_ceph_flags &= ~CEPH_I_FLUSH_SNAPS; in __ceph_flush_snaps()
1579 struct ceph_cap *cap = ci->i_auth_cap; in __ceph_flush_snaps()
1590 list_for_each_entry(cf, &ci->i_cap_flush_list, i_list) { in __ceph_flush_snaps()
1603 spin_unlock(&ci->i_ceph_lock); in __ceph_flush_snaps()
1617 spin_lock(&ci->i_ceph_lock); in __ceph_flush_snaps()
1621 void ceph_flush_snaps(struct ceph_inode_info *ci, in ceph_flush_snaps() argument
1624 struct inode *inode = &ci->vfs_inode; in ceph_flush_snaps()
1633 spin_lock(&ci->i_ceph_lock); in ceph_flush_snaps()
1634 if (!(ci->i_ceph_flags & CEPH_I_FLUSH_SNAPS)) { in ceph_flush_snaps()
1638 if (!ci->i_auth_cap) { in ceph_flush_snaps()
1643 mds = ci->i_auth_cap->session->s_mds; in ceph_flush_snaps()
1650 spin_unlock(&ci->i_ceph_lock); in ceph_flush_snaps()
1658 if (ci->i_ceph_flags & CEPH_I_KICK_FLUSH) in ceph_flush_snaps()
1659 __kick_flushing_caps(mdsc, session, ci, 0); in ceph_flush_snaps()
1661 __ceph_flush_snaps(ci, session); in ceph_flush_snaps()
1663 spin_unlock(&ci->i_ceph_lock); in ceph_flush_snaps()
1671 list_del_init(&ci->i_snap_flush_item); in ceph_flush_snaps()
1680 int __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask, in __ceph_mark_dirty_caps() argument
1684 ceph_sb_to_client(ci->vfs_inode.i_sb)->mdsc; in __ceph_mark_dirty_caps()
1685 struct inode *inode = &ci->vfs_inode; in __ceph_mark_dirty_caps()
1686 int was = ci->i_dirty_caps; in __ceph_mark_dirty_caps()
1689 lockdep_assert_held(&ci->i_ceph_lock); in __ceph_mark_dirty_caps()
1691 if (!ci->i_auth_cap) { in __ceph_mark_dirty_caps()
1698 dout("__mark_dirty_caps %p %s dirty %s -> %s\n", &ci->vfs_inode, in __ceph_mark_dirty_caps()
1701 ci->i_dirty_caps |= mask; in __ceph_mark_dirty_caps()
1703 struct ceph_mds_session *session = ci->i_auth_cap->session; in __ceph_mark_dirty_caps()
1705 WARN_ON_ONCE(ci->i_prealloc_cap_flush); in __ceph_mark_dirty_caps()
1706 swap(ci->i_prealloc_cap_flush, *pcf); in __ceph_mark_dirty_caps()
1708 if (!ci->i_head_snapc) { in __ceph_mark_dirty_caps()
1710 ci->i_head_snapc = ceph_get_snap_context( in __ceph_mark_dirty_caps()
1711 ci->i_snap_realm->cached_context); in __ceph_mark_dirty_caps()
1714 &ci->vfs_inode, ci->i_head_snapc, ci->i_auth_cap); in __ceph_mark_dirty_caps()
1715 BUG_ON(!list_empty(&ci->i_dirty_item)); in __ceph_mark_dirty_caps()
1717 list_add(&ci->i_dirty_item, &session->s_cap_dirty); in __ceph_mark_dirty_caps()
1719 if (ci->i_flushing_caps == 0) { in __ceph_mark_dirty_caps()
1724 WARN_ON_ONCE(!ci->i_prealloc_cap_flush); in __ceph_mark_dirty_caps()
1726 BUG_ON(list_empty(&ci->i_dirty_item)); in __ceph_mark_dirty_caps()
1727 if (((was | ci->i_flushing_caps) & CEPH_CAP_FILE_BUFFER) && in __ceph_mark_dirty_caps()
1730 __cap_delay_requeue(mdsc, ci); in __ceph_mark_dirty_caps()
1782 static bool __detach_cap_flush_from_ci(struct ceph_inode_info *ci, in __detach_cap_flush_from_ci() argument
1788 if (wake && cf->i_list.prev != &ci->i_cap_flush_list) { in __detach_cap_flush_from_ci()
1808 struct ceph_inode_info *ci = ceph_inode(inode); in __mark_caps_flushing() local
1812 lockdep_assert_held(&ci->i_ceph_lock); in __mark_caps_flushing()
1813 BUG_ON(ci->i_dirty_caps == 0); in __mark_caps_flushing()
1814 BUG_ON(list_empty(&ci->i_dirty_item)); in __mark_caps_flushing()
1815 BUG_ON(!ci->i_prealloc_cap_flush); in __mark_caps_flushing()
1817 flushing = ci->i_dirty_caps; in __mark_caps_flushing()
1820 ceph_cap_string(ci->i_flushing_caps), in __mark_caps_flushing()
1821 ceph_cap_string(ci->i_flushing_caps | flushing)); in __mark_caps_flushing()
1822 ci->i_flushing_caps |= flushing; in __mark_caps_flushing()
1823 ci->i_dirty_caps = 0; in __mark_caps_flushing()
1826 swap(cf, ci->i_prealloc_cap_flush); in __mark_caps_flushing()
1831 list_del_init(&ci->i_dirty_item); in __mark_caps_flushing()
1837 if (list_empty(&ci->i_flushing_item)) { in __mark_caps_flushing()
1838 list_add_tail(&ci->i_flushing_item, &session->s_cap_flushing); in __mark_caps_flushing()
1843 list_add_tail(&cf->i_list, &ci->i_cap_flush_list); in __mark_caps_flushing()
1852 __releases(ci->i_ceph_lock) in try_nonblocking_invalidate()
1853 __acquires(ci->i_ceph_lock) in try_nonblocking_invalidate()
1855 struct ceph_inode_info *ci = ceph_inode(inode); in try_nonblocking_invalidate() local
1856 u32 invalidating_gen = ci->i_rdcache_gen; in try_nonblocking_invalidate()
1858 spin_unlock(&ci->i_ceph_lock); in try_nonblocking_invalidate()
1861 spin_lock(&ci->i_ceph_lock); in try_nonblocking_invalidate()
1864 invalidating_gen == ci->i_rdcache_gen) { in try_nonblocking_invalidate()
1868 ci->i_rdcache_revoking = ci->i_rdcache_gen - 1; in try_nonblocking_invalidate()
1875 bool __ceph_should_report_size(struct ceph_inode_info *ci) in __ceph_should_report_size() argument
1877 loff_t size = i_size_read(&ci->vfs_inode); in __ceph_should_report_size()
1879 if (ci->i_flushing_caps & CEPH_CAP_FILE_WR) in __ceph_should_report_size()
1881 if (size >= ci->i_max_size) in __ceph_should_report_size()
1884 if (ci->i_max_size > ci->i_reported_size && in __ceph_should_report_size()
1885 (size << 1) >= ci->i_max_size + ci->i_reported_size) in __ceph_should_report_size()
1899 void ceph_check_caps(struct ceph_inode_info *ci, int flags, in ceph_check_caps() argument
1902 struct inode *inode = &ci->vfs_inode; in ceph_check_caps()
1917 spin_lock(&ci->i_ceph_lock); in ceph_check_caps()
1918 if (ci->i_ceph_flags & CEPH_I_FLUSH) in ceph_check_caps()
1922 file_wanted = __ceph_caps_file_wanted(ci); in ceph_check_caps()
1925 used = __ceph_caps_used(ci); in ceph_check_caps()
1933 issued = __ceph_caps_issued(ci, &implemented); in ceph_check_caps()
1945 __ceph_dir_is_complete(ci)) { in ceph_check_caps()
1966 if (ci->i_max_size == 0) in ceph_check_caps()
1974 ceph_cap_string(used), ceph_cap_string(ci->i_dirty_caps), in ceph_check_caps()
1975 ceph_cap_string(ci->i_flushing_caps), in ceph_check_caps()
1988 !(ci->i_wb_ref || ci->i_wrbuffer_ref) && /* no dirty pages... */ in ceph_check_caps()
1997 ci->i_rdcache_revoking = ci->i_rdcache_gen; in ceph_check_caps()
2003 for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) { in ceph_check_caps()
2011 ((flags & CHECK_CAPS_AUTHONLY) && cap != ci->i_auth_cap)) in ceph_check_caps()
2019 if (ci->i_auth_cap && cap != ci->i_auth_cap) in ceph_check_caps()
2020 cap_used &= ~ci->i_auth_cap->issued; in ceph_check_caps()
2029 if (cap == ci->i_auth_cap && in ceph_check_caps()
2032 if (ci->i_wanted_max_size > ci->i_max_size && in ceph_check_caps()
2033 ci->i_wanted_max_size > ci->i_requested_max_size) { in ceph_check_caps()
2039 if (__ceph_should_report_size(ci)) { in ceph_check_caps()
2045 if (cap == ci->i_auth_cap) { in ceph_check_caps()
2046 if ((flags & CHECK_CAPS_FLUSH) && ci->i_dirty_caps) { in ceph_check_caps()
2050 if (ci->i_ceph_flags & CEPH_I_FLUSH_SNAPS) { in ceph_check_caps()
2081 if (cap == ci->i_auth_cap && in ceph_check_caps()
2082 (ci->i_ceph_flags & in ceph_check_caps()
2084 if (ci->i_ceph_flags & CEPH_I_KICK_FLUSH) in ceph_check_caps()
2085 __kick_flushing_caps(mdsc, session, ci, 0); in ceph_check_caps()
2086 if (ci->i_ceph_flags & CEPH_I_FLUSH_SNAPS) in ceph_check_caps()
2087 __ceph_flush_snaps(ci, session); in ceph_check_caps()
2092 if (cap == ci->i_auth_cap && ci->i_dirty_caps) { in ceph_check_caps()
2093 flushing = ci->i_dirty_caps; in ceph_check_caps()
2112 spin_unlock(&ci->i_ceph_lock); in ceph_check_caps()
2113 __send_cap(&arg, ci); in ceph_check_caps()
2114 spin_lock(&ci->i_ceph_lock); in ceph_check_caps()
2120 if (__ceph_is_any_real_caps(ci) && in ceph_check_caps()
2121 list_empty(&ci->i_cap_delay_list) && in ceph_check_caps()
2124 __cap_delay_requeue(mdsc, ci); in ceph_check_caps()
2127 spin_unlock(&ci->i_ceph_lock); in ceph_check_caps()
2140 struct ceph_inode_info *ci = ceph_inode(inode); in try_flush_caps() local
2144 spin_lock(&ci->i_ceph_lock); in try_flush_caps()
2146 if (ci->i_dirty_caps && ci->i_auth_cap) { in try_flush_caps()
2147 struct ceph_cap *cap = ci->i_auth_cap; in try_flush_caps()
2152 spin_unlock(&ci->i_ceph_lock); in try_flush_caps()
2156 if (ci->i_ceph_flags & in try_flush_caps()
2158 if (ci->i_ceph_flags & CEPH_I_KICK_FLUSH) in try_flush_caps()
2159 __kick_flushing_caps(mdsc, session, ci, 0); in try_flush_caps()
2160 if (ci->i_ceph_flags & CEPH_I_FLUSH_SNAPS) in try_flush_caps()
2161 __ceph_flush_snaps(ci, session); in try_flush_caps()
2165 flushing = ci->i_dirty_caps; in try_flush_caps()
2170 __ceph_caps_used(ci), __ceph_caps_wanted(ci), in try_flush_caps()
2173 spin_unlock(&ci->i_ceph_lock); in try_flush_caps()
2175 __send_cap(&arg, ci); in try_flush_caps()
2177 if (!list_empty(&ci->i_cap_flush_list)) { in try_flush_caps()
2179 list_last_entry(&ci->i_cap_flush_list, in try_flush_caps()
2184 flushing = ci->i_flushing_caps; in try_flush_caps()
2185 spin_unlock(&ci->i_ceph_lock); in try_flush_caps()
2197 struct ceph_inode_info *ci = ceph_inode(inode); in caps_are_flushed() local
2200 spin_lock(&ci->i_ceph_lock); in caps_are_flushed()
2201 if (!list_empty(&ci->i_cap_flush_list)) { in caps_are_flushed()
2203 list_first_entry(&ci->i_cap_flush_list, in caps_are_flushed()
2208 spin_unlock(&ci->i_ceph_lock); in caps_are_flushed()
2218 struct ceph_inode_info *ci = ceph_inode(inode); in unsafe_request_wait() local
2222 spin_lock(&ci->i_unsafe_lock); in unsafe_request_wait()
2223 if (S_ISDIR(inode->i_mode) && !list_empty(&ci->i_unsafe_dirops)) { in unsafe_request_wait()
2224 req1 = list_last_entry(&ci->i_unsafe_dirops, in unsafe_request_wait()
2229 if (!list_empty(&ci->i_unsafe_iops)) { in unsafe_request_wait()
2230 req2 = list_last_entry(&ci->i_unsafe_iops, in unsafe_request_wait()
2235 spin_unlock(&ci->i_unsafe_lock); in unsafe_request_wait()
2261 spin_lock(&ci->i_unsafe_lock); in unsafe_request_wait()
2263 list_for_each_entry(req, &ci->i_unsafe_dirops, in unsafe_request_wait()
2267 spin_unlock(&ci->i_unsafe_lock); in unsafe_request_wait()
2277 list_for_each_entry(req, &ci->i_unsafe_iops, in unsafe_request_wait()
2281 spin_unlock(&ci->i_unsafe_lock); in unsafe_request_wait()
2290 spin_unlock(&ci->i_unsafe_lock); in unsafe_request_wait()
2293 spin_lock(&ci->i_ceph_lock); in unsafe_request_wait()
2294 if (ci->i_auth_cap) { in unsafe_request_wait()
2295 s = ci->i_auth_cap->session; in unsafe_request_wait()
2299 spin_unlock(&ci->i_ceph_lock); in unsafe_request_wait()
2334 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_fsync() local
2360 err = wait_event_interruptible(ci->i_cap_wq, in ceph_fsync()
2383 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_write_inode() local
2393 err = wait_event_interruptible(ci->i_cap_wq, in ceph_write_inode()
2399 spin_lock(&ci->i_ceph_lock); in ceph_write_inode()
2400 if (__ceph_caps_dirty(ci)) in ceph_write_inode()
2401 __cap_delay_requeue_front(mdsc, ci); in ceph_write_inode()
2402 spin_unlock(&ci->i_ceph_lock); in ceph_write_inode()
2409 struct ceph_inode_info *ci, in __kick_flushing_caps() argument
2411 __releases(ci->i_ceph_lock) in __kick_flushing_caps()
2412 __acquires(ci->i_ceph_lock) in __kick_flushing_caps()
2414 struct inode *inode = &ci->vfs_inode; in __kick_flushing_caps()
2421 ci->i_ceph_flags &= ~CEPH_I_KICK_FLUSH; in __kick_flushing_caps()
2423 list_for_each_entry_reverse(cf, &ci->i_cap_flush_list, i_list) { in __kick_flushing_caps()
2430 list_for_each_entry(cf, &ci->i_cap_flush_list, i_list) { in __kick_flushing_caps()
2434 cap = ci->i_auth_cap; in __kick_flushing_caps()
2451 __ceph_caps_used(ci), in __kick_flushing_caps()
2452 __ceph_caps_wanted(ci), in __kick_flushing_caps()
2455 spin_unlock(&ci->i_ceph_lock); in __kick_flushing_caps()
2456 __send_cap(&arg, ci); in __kick_flushing_caps()
2466 spin_unlock(&ci->i_ceph_lock); in __kick_flushing_caps()
2481 spin_lock(&ci->i_ceph_lock); in __kick_flushing_caps()
2488 struct ceph_inode_info *ci; in ceph_early_kick_flushing_caps() local
2498 list_for_each_entry(ci, &session->s_cap_flushing, i_flushing_item) { in ceph_early_kick_flushing_caps()
2499 spin_lock(&ci->i_ceph_lock); in ceph_early_kick_flushing_caps()
2500 cap = ci->i_auth_cap; in ceph_early_kick_flushing_caps()
2503 &ci->vfs_inode, cap, session->s_mds); in ceph_early_kick_flushing_caps()
2504 spin_unlock(&ci->i_ceph_lock); in ceph_early_kick_flushing_caps()
2515 if ((cap->issued & ci->i_flushing_caps) != in ceph_early_kick_flushing_caps()
2516 ci->i_flushing_caps) { in ceph_early_kick_flushing_caps()
2523 __kick_flushing_caps(mdsc, session, ci, in ceph_early_kick_flushing_caps()
2526 ci->i_ceph_flags |= CEPH_I_KICK_FLUSH; in ceph_early_kick_flushing_caps()
2529 spin_unlock(&ci->i_ceph_lock); in ceph_early_kick_flushing_caps()
2536 struct ceph_inode_info *ci; in ceph_kick_flushing_caps() local
2548 list_for_each_entry(ci, &session->s_cap_flushing, i_flushing_item) { in ceph_kick_flushing_caps()
2549 spin_lock(&ci->i_ceph_lock); in ceph_kick_flushing_caps()
2550 cap = ci->i_auth_cap; in ceph_kick_flushing_caps()
2553 &ci->vfs_inode, cap, session->s_mds); in ceph_kick_flushing_caps()
2554 spin_unlock(&ci->i_ceph_lock); in ceph_kick_flushing_caps()
2557 if (ci->i_ceph_flags & CEPH_I_KICK_FLUSH) { in ceph_kick_flushing_caps()
2558 __kick_flushing_caps(mdsc, session, ci, in ceph_kick_flushing_caps()
2561 spin_unlock(&ci->i_ceph_lock); in ceph_kick_flushing_caps()
2566 struct ceph_inode_info *ci) in ceph_kick_flushing_inode_caps() argument
2569 struct ceph_cap *cap = ci->i_auth_cap; in ceph_kick_flushing_inode_caps()
2571 lockdep_assert_held(&ci->i_ceph_lock); in ceph_kick_flushing_inode_caps()
2573 dout("%s %p flushing %s\n", __func__, &ci->vfs_inode, in ceph_kick_flushing_inode_caps()
2574 ceph_cap_string(ci->i_flushing_caps)); in ceph_kick_flushing_inode_caps()
2576 if (!list_empty(&ci->i_cap_flush_list)) { in ceph_kick_flushing_inode_caps()
2579 list_move_tail(&ci->i_flushing_item, in ceph_kick_flushing_inode_caps()
2584 __kick_flushing_caps(mdsc, session, ci, oldest_flush_tid); in ceph_kick_flushing_inode_caps()
2593 void ceph_take_cap_refs(struct ceph_inode_info *ci, int got, in ceph_take_cap_refs() argument
2596 lockdep_assert_held(&ci->i_ceph_lock); in ceph_take_cap_refs()
2599 ci->i_pin_ref++; in ceph_take_cap_refs()
2601 ci->i_rd_ref++; in ceph_take_cap_refs()
2603 ci->i_rdcache_ref++; in ceph_take_cap_refs()
2605 ci->i_fx_ref++; in ceph_take_cap_refs()
2607 if (ci->i_wr_ref == 0 && !ci->i_head_snapc) { in ceph_take_cap_refs()
2609 ci->i_head_snapc = ceph_get_snap_context( in ceph_take_cap_refs()
2610 ci->i_snap_realm->cached_context); in ceph_take_cap_refs()
2612 ci->i_wr_ref++; in ceph_take_cap_refs()
2615 if (ci->i_wb_ref == 0) in ceph_take_cap_refs()
2616 ihold(&ci->vfs_inode); in ceph_take_cap_refs()
2617 ci->i_wb_ref++; in ceph_take_cap_refs()
2619 &ci->vfs_inode, ci->i_wb_ref-1, ci->i_wb_ref); in ceph_take_cap_refs()
2645 struct ceph_inode_info *ci = ceph_inode(inode); in try_get_cap_refs() local
2655 spin_lock(&ci->i_ceph_lock); in try_get_cap_refs()
2658 (ci->i_ceph_flags & CEPH_I_ERROR_FILELOCK)) { in try_get_cap_refs()
2665 while (ci->i_truncate_pending) { in try_get_cap_refs()
2666 spin_unlock(&ci->i_ceph_lock); in try_get_cap_refs()
2672 spin_lock(&ci->i_ceph_lock); in try_get_cap_refs()
2675 have = __ceph_caps_issued(ci, &implemented); in try_get_cap_refs()
2678 if (endoff >= 0 && endoff > (loff_t)ci->i_max_size) { in try_get_cap_refs()
2680 inode, endoff, ci->i_max_size); in try_get_cap_refs()
2681 if (endoff > ci->i_requested_max_size) in try_get_cap_refs()
2682 ret = ci->i_auth_cap ? -EFBIG : -ESTALE; in try_get_cap_refs()
2689 if (__ceph_have_pending_cap_snap(ci)) { in try_get_cap_refs()
2709 !ci->i_head_snapc && in try_get_cap_refs()
2721 spin_unlock(&ci->i_ceph_lock); in try_get_cap_refs()
2732 ceph_take_cap_refs(ci, *got, true); in try_get_cap_refs()
2738 if (ci->i_auth_cap && in try_get_cap_refs()
2740 struct ceph_mds_session *s = ci->i_auth_cap->session; in try_get_cap_refs()
2747 inode, ceph_cap_string(need), ci->i_auth_cap->mds); in try_get_cap_refs()
2757 mds_wanted = __ceph_caps_mds_wanted(ci, false); in try_get_cap_refs()
2771 __ceph_touch_fmode(ci, mdsc, flags); in try_get_cap_refs()
2773 spin_unlock(&ci->i_ceph_lock); in try_get_cap_refs()
2794 struct ceph_inode_info *ci = ceph_inode(inode); in check_max_size() local
2798 spin_lock(&ci->i_ceph_lock); in check_max_size()
2799 if (endoff >= ci->i_max_size && endoff > ci->i_wanted_max_size) { in check_max_size()
2802 ci->i_wanted_max_size = endoff; in check_max_size()
2805 if (ci->i_auth_cap && in check_max_size()
2806 (ci->i_auth_cap->issued & CEPH_CAP_FILE_WR) && in check_max_size()
2807 ci->i_wanted_max_size > ci->i_max_size && in check_max_size()
2808 ci->i_wanted_max_size > ci->i_requested_max_size) in check_max_size()
2810 spin_unlock(&ci->i_ceph_lock); in check_max_size()
2812 ceph_check_caps(ci, CHECK_CAPS_AUTHONLY, NULL); in check_max_size()
2860 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_get_caps() local
2897 ceph_get_fmode(ci, flags, FMODE_WAIT_BIAS); in ceph_get_caps()
2898 add_wait_queue(&ci->i_cap_wq, &wait); in ceph_get_caps()
2910 remove_wait_queue(&ci->i_cap_wq, &wait); in ceph_get_caps()
2911 ceph_put_fmode(ci, flags, FMODE_WAIT_BIAS); in ceph_get_caps()
2924 ceph_put_cap_refs(ci, _got); in ceph_get_caps()
2947 if (S_ISREG(ci->vfs_inode.i_mode) && in ceph_get_caps()
2948 ci->i_inline_version != CEPH_INLINE_NONE && in ceph_get_caps()
2964 ceph_put_cap_refs(ci, _got); in ceph_get_caps()
2988 void ceph_get_cap_refs(struct ceph_inode_info *ci, int caps) in ceph_get_cap_refs() argument
2990 spin_lock(&ci->i_ceph_lock); in ceph_get_cap_refs()
2991 ceph_take_cap_refs(ci, caps, false); in ceph_get_cap_refs()
2992 spin_unlock(&ci->i_ceph_lock); in ceph_get_cap_refs()
3000 static int ceph_try_drop_cap_snap(struct ceph_inode_info *ci, in ceph_try_drop_cap_snap() argument
3009 if (!list_is_last(&capsnap->ci_item, &ci->i_cap_snaps)) in ceph_try_drop_cap_snap()
3010 ci->i_ceph_flags |= CEPH_I_FLUSH_SNAPS; in ceph_try_drop_cap_snap()
3034 static void __ceph_put_cap_refs(struct ceph_inode_info *ci, int had, in __ceph_put_cap_refs() argument
3037 struct inode *inode = &ci->vfs_inode; in __ceph_put_cap_refs()
3041 spin_lock(&ci->i_ceph_lock); in __ceph_put_cap_refs()
3043 --ci->i_pin_ref; in __ceph_put_cap_refs()
3045 if (--ci->i_rd_ref == 0) in __ceph_put_cap_refs()
3048 if (--ci->i_rdcache_ref == 0) in __ceph_put_cap_refs()
3051 if (--ci->i_fx_ref == 0) in __ceph_put_cap_refs()
3054 if (--ci->i_wb_ref == 0) { in __ceph_put_cap_refs()
3061 inode, ci->i_wb_ref+1, ci->i_wb_ref); in __ceph_put_cap_refs()
3064 if (--ci->i_wr_ref == 0) { in __ceph_put_cap_refs()
3067 if (ci->i_wrbuffer_ref_head == 0 && in __ceph_put_cap_refs()
3068 ci->i_dirty_caps == 0 && in __ceph_put_cap_refs()
3069 ci->i_flushing_caps == 0) { in __ceph_put_cap_refs()
3070 BUG_ON(!ci->i_head_snapc); in __ceph_put_cap_refs()
3071 ceph_put_snap_context(ci->i_head_snapc); in __ceph_put_cap_refs()
3072 ci->i_head_snapc = NULL; in __ceph_put_cap_refs()
3075 if (!__ceph_is_any_real_caps(ci) && ci->i_snap_realm) in __ceph_put_cap_refs()
3079 if (check_flushsnaps && __ceph_have_pending_cap_snap(ci)) { in __ceph_put_cap_refs()
3081 list_last_entry(&ci->i_cap_snaps, in __ceph_put_cap_refs()
3086 if (ceph_try_drop_cap_snap(ci, capsnap)) in __ceph_put_cap_refs()
3089 else if (__ceph_finish_cap_snap(ci, capsnap)) in __ceph_put_cap_refs()
3093 spin_unlock(&ci->i_ceph_lock); in __ceph_put_cap_refs()
3101 ceph_check_caps(ci, 0, NULL); in __ceph_put_cap_refs()
3103 ceph_flush_snaps(ci, NULL); in __ceph_put_cap_refs()
3115 wake_up_all(&ci->i_cap_wq); in __ceph_put_cap_refs()
3120 void ceph_put_cap_refs(struct ceph_inode_info *ci, int had) in ceph_put_cap_refs() argument
3122 __ceph_put_cap_refs(ci, had, PUT_CAP_REFS_SYNC); in ceph_put_cap_refs()
3125 void ceph_put_cap_refs_async(struct ceph_inode_info *ci, int had) in ceph_put_cap_refs_async() argument
3127 __ceph_put_cap_refs(ci, had, PUT_CAP_REFS_ASYNC); in ceph_put_cap_refs_async()
3130 void ceph_put_cap_refs_no_check_caps(struct ceph_inode_info *ci, int had) in ceph_put_cap_refs_no_check_caps() argument
3132 __ceph_put_cap_refs(ci, had, PUT_CAP_REFS_NO_CHECK); in ceph_put_cap_refs_no_check_caps()
3142 void ceph_put_wrbuffer_cap_refs(struct ceph_inode_info *ci, int nr, in ceph_put_wrbuffer_cap_refs() argument
3145 struct inode *inode = &ci->vfs_inode; in ceph_put_wrbuffer_cap_refs()
3153 spin_lock(&ci->i_ceph_lock); in ceph_put_wrbuffer_cap_refs()
3154 ci->i_wrbuffer_ref -= nr; in ceph_put_wrbuffer_cap_refs()
3155 if (ci->i_wrbuffer_ref == 0) { in ceph_put_wrbuffer_cap_refs()
3160 if (ci->i_head_snapc == snapc) { in ceph_put_wrbuffer_cap_refs()
3161 ci->i_wrbuffer_ref_head -= nr; in ceph_put_wrbuffer_cap_refs()
3162 if (ci->i_wrbuffer_ref_head == 0 && in ceph_put_wrbuffer_cap_refs()
3163 ci->i_wr_ref == 0 && in ceph_put_wrbuffer_cap_refs()
3164 ci->i_dirty_caps == 0 && in ceph_put_wrbuffer_cap_refs()
3165 ci->i_flushing_caps == 0) { in ceph_put_wrbuffer_cap_refs()
3166 BUG_ON(!ci->i_head_snapc); in ceph_put_wrbuffer_cap_refs()
3167 ceph_put_snap_context(ci->i_head_snapc); in ceph_put_wrbuffer_cap_refs()
3168 ci->i_head_snapc = NULL; in ceph_put_wrbuffer_cap_refs()
3172 ci->i_wrbuffer_ref+nr, ci->i_wrbuffer_ref_head+nr, in ceph_put_wrbuffer_cap_refs()
3173 ci->i_wrbuffer_ref, ci->i_wrbuffer_ref_head, in ceph_put_wrbuffer_cap_refs()
3176 list_for_each_entry(capsnap, &ci->i_cap_snaps, ci_item) { in ceph_put_wrbuffer_cap_refs()
3188 WARN_ON_ONCE(ci->i_auth_cap); in ceph_put_wrbuffer_cap_refs()
3196 if (ceph_try_drop_cap_snap(ci, capsnap)) { in ceph_put_wrbuffer_cap_refs()
3199 ci->i_ceph_flags |= CEPH_I_FLUSH_SNAPS; in ceph_put_wrbuffer_cap_refs()
3207 ci->i_wrbuffer_ref+nr, capsnap->dirty_pages + nr, in ceph_put_wrbuffer_cap_refs()
3208 ci->i_wrbuffer_ref, capsnap->dirty_pages, in ceph_put_wrbuffer_cap_refs()
3214 spin_unlock(&ci->i_ceph_lock); in ceph_put_wrbuffer_cap_refs()
3217 ceph_check_caps(ci, 0, NULL); in ceph_put_wrbuffer_cap_refs()
3219 ceph_flush_snaps(ci, NULL); in ceph_put_wrbuffer_cap_refs()
3222 wake_up_all(&ci->i_cap_wq); in ceph_put_wrbuffer_cap_refs()
3288 __releases(ci->i_ceph_lock) in handle_cap_grant()
3291 struct ceph_inode_info *ci = ceph_inode(inode); in handle_cap_grant() local
3320 !(ci->i_wrbuffer_ref || ci->i_wb_ref)) { in handle_cap_grant()
3324 if (ci->i_rdcache_revoking != ci->i_rdcache_gen) { in handle_cap_grant()
3326 ci->i_rdcache_revoking = ci->i_rdcache_gen; in handle_cap_grant()
3343 WARN_ON(cap != ci->i_auth_cap); in handle_cap_grant()
3353 __check_cap_issue(ci, cap, newcaps); in handle_cap_grant()
3368 ci->i_btime = extra_info->btime; in handle_cap_grant()
3387 if (version > ci->i_xattrs.version) { in handle_cap_grant()
3390 if (ci->i_xattrs.blob) in handle_cap_grant()
3391 ceph_buffer_put(ci->i_xattrs.blob); in handle_cap_grant()
3392 ci->i_xattrs.blob = ceph_buffer_get(xattr_buf); in handle_cap_grant()
3393 ci->i_xattrs.version = version; in handle_cap_grant()
3411 ci->i_files = extra_info->nfiles; in handle_cap_grant()
3412 ci->i_subdirs = extra_info->nsubdirs; in handle_cap_grant()
3417 s64 old_pool = ci->i_layout.pool_id; in handle_cap_grant()
3420 ceph_file_layout_from_legacy(&ci->i_layout, &grant->layout); in handle_cap_grant()
3421 old_ns = rcu_dereference_protected(ci->i_layout.pool_ns, in handle_cap_grant()
3422 lockdep_is_held(&ci->i_ceph_lock)); in handle_cap_grant()
3423 rcu_assign_pointer(ci->i_layout.pool_ns, extra_info->pool_ns); in handle_cap_grant()
3425 if (ci->i_layout.pool_id != old_pool || in handle_cap_grant()
3427 ci->i_ceph_flags &= ~CEPH_I_POOL_PERM; in handle_cap_grant()
3438 if (ci->i_auth_cap == cap && (newcaps & CEPH_CAP_ANY_FILE_WR)) { in handle_cap_grant()
3439 if (max_size != ci->i_max_size) { in handle_cap_grant()
3441 ci->i_max_size, max_size); in handle_cap_grant()
3442 ci->i_max_size = max_size; in handle_cap_grant()
3443 if (max_size >= ci->i_wanted_max_size) { in handle_cap_grant()
3444 ci->i_wanted_max_size = 0; /* reset */ in handle_cap_grant()
3445 ci->i_requested_max_size = 0; in handle_cap_grant()
3452 wanted = __ceph_caps_wanted(ci); in handle_cap_grant()
3453 used = __ceph_caps_used(ci); in handle_cap_grant()
3454 dirty = __ceph_caps_dirty(ci); in handle_cap_grant()
3490 else if (cap == ci->i_auth_cap) in handle_cap_grant()
3503 if (cap == ci->i_auth_cap && in handle_cap_grant()
3504 __ceph_caps_revoking_other(ci, cap, newcaps)) in handle_cap_grant()
3516 extra_info->inline_version >= ci->i_inline_version) { in handle_cap_grant()
3517 ci->i_inline_version = extra_info->inline_version; in handle_cap_grant()
3518 if (ci->i_inline_version != CEPH_INLINE_NONE && in handle_cap_grant()
3523 if (ci->i_auth_cap == cap && in handle_cap_grant()
3528 if (ci->i_requested_max_size > max_size || in handle_cap_grant()
3531 ci->i_requested_max_size = 0; in handle_cap_grant()
3535 ceph_kick_flushing_inode_caps(session, ci); in handle_cap_grant()
3536 spin_unlock(&ci->i_ceph_lock); in handle_cap_grant()
3539 spin_unlock(&ci->i_ceph_lock); in handle_cap_grant()
3561 wake_up_all(&ci->i_cap_wq); in handle_cap_grant()
3565 ceph_check_caps(ci, CHECK_CAPS_AUTHONLY | CHECK_CAPS_NOINVAL, in handle_cap_grant()
3568 ceph_check_caps(ci, CHECK_CAPS_NOINVAL, session); in handle_cap_grant()
3579 __releases(ci->i_ceph_lock) in handle_cap_flush_ack()
3581 struct ceph_inode_info *ci = ceph_inode(inode); in handle_cap_flush_ack() local
3592 list_for_each_entry_safe(cf, tmp_cf, &ci->i_cap_flush_list, i_list) { in handle_cap_flush_ack()
3606 wake_ci |= __detach_cap_flush_from_ci(ci, cf); in handle_cap_flush_ack()
3622 ceph_cap_string(cleaned), ceph_cap_string(ci->i_flushing_caps), in handle_cap_flush_ack()
3623 ceph_cap_string(ci->i_flushing_caps & ~cleaned)); in handle_cap_flush_ack()
3628 ci->i_flushing_caps &= ~cleaned; in handle_cap_flush_ack()
3635 if (ci->i_flushing_caps == 0) { in handle_cap_flush_ack()
3636 if (list_empty(&ci->i_cap_flush_list)) { in handle_cap_flush_ack()
3637 list_del_init(&ci->i_flushing_item); in handle_cap_flush_ack()
3649 if (ci->i_dirty_caps == 0) { in handle_cap_flush_ack()
3651 BUG_ON(!list_empty(&ci->i_dirty_item)); in handle_cap_flush_ack()
3653 if (ci->i_wr_ref == 0 && in handle_cap_flush_ack()
3654 ci->i_wrbuffer_ref_head == 0) { in handle_cap_flush_ack()
3655 BUG_ON(!ci->i_head_snapc); in handle_cap_flush_ack()
3656 ceph_put_snap_context(ci->i_head_snapc); in handle_cap_flush_ack()
3657 ci->i_head_snapc = NULL; in handle_cap_flush_ack()
3660 BUG_ON(list_empty(&ci->i_dirty_item)); in handle_cap_flush_ack()
3666 spin_unlock(&ci->i_ceph_lock); in handle_cap_flush_ack()
3677 wake_up_all(&ci->i_cap_wq); in handle_cap_flush_ack()
3687 struct ceph_inode_info *ci = ceph_inode(inode); in __ceph_remove_capsnap() local
3691 lockdep_assert_held(&ci->i_ceph_lock); in __ceph_remove_capsnap()
3693 dout("removing capsnap %p, inode %p ci %p\n", capsnap, inode, ci); in __ceph_remove_capsnap()
3696 ret = __detach_cap_flush_from_ci(ci, &capsnap->cap_flush); in __ceph_remove_capsnap()
3701 if (list_empty(&ci->i_cap_flush_list)) in __ceph_remove_capsnap()
3702 list_del_init(&ci->i_flushing_item); in __ceph_remove_capsnap()
3713 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_remove_capsnap() local
3715 lockdep_assert_held(&ci->i_ceph_lock); in ceph_remove_capsnap()
3731 struct ceph_inode_info *ci = ceph_inode(inode); in handle_cap_flushsnap_ack() local
3740 inode, ci, session->s_mds, follows); in handle_cap_flushsnap_ack()
3742 spin_lock(&ci->i_ceph_lock); in handle_cap_flushsnap_ack()
3743 list_for_each_entry(capsnap, &ci->i_cap_snaps, ci_item) { in handle_cap_flushsnap_ack()
3760 spin_unlock(&ci->i_ceph_lock); in handle_cap_flushsnap_ack()
3766 wake_up_all(&ci->i_cap_wq); in handle_cap_flushsnap_ack()
3782 struct ceph_inode_info *ci = ceph_inode(inode); in handle_cap_trunc() local
3789 int dirty = __ceph_caps_dirty(ci); in handle_cap_trunc()
3793 lockdep_assert_held(&ci->i_ceph_lock); in handle_cap_trunc()
3819 struct ceph_inode_info *ci = ceph_inode(inode); in handle_cap_export() local
3837 inode, ci, mds, mseq, target); in handle_cap_export()
3839 spin_lock(&ci->i_ceph_lock); in handle_cap_export()
3840 cap = __get_cap_for_mds(ci, mds); in handle_cap_export()
3864 tcap = __get_cap_for_mds(ci, target); in handle_cap_export()
3875 if (cap == ci->i_auth_cap) { in handle_cap_export()
3876 ci->i_auth_cap = tcap; in handle_cap_export()
3877 change_auth_cap_ses(ci, tcap->session); in handle_cap_export()
3884 int flag = (cap == ci->i_auth_cap) ? CEPH_CAP_FLAG_AUTH : 0; in handle_cap_export()
3889 if (!list_empty(&ci->i_cap_flush_list) && in handle_cap_export()
3890 ci->i_auth_cap == tcap) { in handle_cap_export()
3892 list_move_tail(&ci->i_flushing_item, in handle_cap_export()
3901 spin_unlock(&ci->i_ceph_lock); in handle_cap_export()
3926 spin_unlock(&ci->i_ceph_lock); in handle_cap_export()
3947 struct ceph_inode_info *ci = ceph_inode(inode); in handle_cap_import() local
3969 inode, ci, mds, mseq, peer); in handle_cap_import()
3971 cap = __get_cap_for_mds(ci, mds); in handle_cap_import()
3974 spin_unlock(&ci->i_ceph_lock); in handle_cap_import()
3976 spin_lock(&ci->i_ceph_lock); in handle_cap_import()
3987 __ceph_caps_issued(ci, &issued); in handle_cap_import()
3988 issued |= __ceph_caps_dirty(ci); in handle_cap_import()
3993 ocap = peer >= 0 ? __get_cap_for_mds(ci, peer) : NULL; in handle_cap_import()
4026 struct ceph_inode_info *ci; in ceph_handle_caps() local
4135 ci = ceph_inode(inode); in ceph_handle_caps()
4184 spin_lock(&ci->i_ceph_lock); in ceph_handle_caps()
4195 spin_lock(&ci->i_ceph_lock); in ceph_handle_caps()
4201 spin_unlock(&ci->i_ceph_lock); in ceph_handle_caps()
4209 __ceph_caps_issued(ci, &extra_info.issued); in ceph_handle_caps()
4210 extra_info.issued |= __ceph_caps_dirty(ci); in ceph_handle_caps()
4222 spin_unlock(&ci->i_ceph_lock); in ceph_handle_caps()
4228 spin_unlock(&ci->i_ceph_lock); in ceph_handle_caps()
4266 struct ceph_inode_info *ci; in ceph_check_delayed_caps() local
4275 ci = list_first_entry(&mdsc->cap_delay_list, in ceph_check_delayed_caps()
4278 if (time_before(loop_start, ci->i_hold_caps_max - delay_max)) { in ceph_check_delayed_caps()
4280 delay = ci->i_hold_caps_max; in ceph_check_delayed_caps()
4283 if ((ci->i_ceph_flags & CEPH_I_FLUSH) == 0 && in ceph_check_delayed_caps()
4284 time_before(jiffies, ci->i_hold_caps_max)) in ceph_check_delayed_caps()
4286 list_del_init(&ci->i_cap_delay_list); in ceph_check_delayed_caps()
4288 inode = igrab(&ci->vfs_inode); in ceph_check_delayed_caps()
4292 ceph_check_caps(ci, 0, NULL); in ceph_check_delayed_caps()
4308 struct ceph_inode_info *ci; in flush_dirty_session_caps() local
4314 ci = list_first_entry(&s->s_cap_dirty, struct ceph_inode_info, in flush_dirty_session_caps()
4316 inode = &ci->vfs_inode; in flush_dirty_session_caps()
4320 ceph_check_caps(ci, CHECK_CAPS_FLUSH, NULL); in flush_dirty_session_caps()
4333 void __ceph_touch_fmode(struct ceph_inode_info *ci, in __ceph_touch_fmode() argument
4338 ci->i_last_rd = now; in __ceph_touch_fmode()
4340 ci->i_last_wr = now; in __ceph_touch_fmode()
4343 __ceph_is_any_real_caps(ci) && in __ceph_touch_fmode()
4344 list_empty(&ci->i_cap_delay_list)) in __ceph_touch_fmode()
4345 __cap_delay_requeue(mdsc, ci); in __ceph_touch_fmode()
4348 void ceph_get_fmode(struct ceph_inode_info *ci, int fmode, int count) in ceph_get_fmode() argument
4350 struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(ci->vfs_inode.i_sb); in ceph_get_fmode()
4358 spin_lock(&ci->i_ceph_lock); in ceph_get_fmode()
4361 ci->i_nr_by_mode[i] += count; in ceph_get_fmode()
4368 if (i && ci->i_nr_by_mode[i] > 1) in ceph_get_fmode()
4374 spin_unlock(&ci->i_ceph_lock); in ceph_get_fmode()
4382 void ceph_put_fmode(struct ceph_inode_info *ci, int fmode, int count) in ceph_put_fmode() argument
4384 struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(ci->vfs_inode.i_sb); in ceph_put_fmode()
4392 spin_lock(&ci->i_ceph_lock); in ceph_put_fmode()
4395 BUG_ON(ci->i_nr_by_mode[i] < count); in ceph_put_fmode()
4396 ci->i_nr_by_mode[i] -= count; in ceph_put_fmode()
4404 if (i && ci->i_nr_by_mode[i]) in ceph_put_fmode()
4410 spin_unlock(&ci->i_ceph_lock); in ceph_put_fmode()
4421 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_drop_caps_for_unlink() local
4424 spin_lock(&ci->i_ceph_lock); in ceph_drop_caps_for_unlink()
4426 drop |= ~(__ceph_caps_wanted(ci) | CEPH_CAP_PIN); in ceph_drop_caps_for_unlink()
4428 if (__ceph_caps_dirty(ci)) { in ceph_drop_caps_for_unlink()
4431 __cap_delay_requeue_front(mdsc, ci); in ceph_drop_caps_for_unlink()
4434 spin_unlock(&ci->i_ceph_lock); in ceph_drop_caps_for_unlink()
4449 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_encode_inode_release() local
4455 spin_lock(&ci->i_ceph_lock); in ceph_encode_inode_release()
4456 used = __ceph_caps_used(ci); in ceph_encode_inode_release()
4457 dirty = __ceph_caps_dirty(ci); in ceph_encode_inode_release()
4466 cap = __get_cap_for_mds(ci, mds); in ceph_encode_inode_release()
4482 int wanted = __ceph_caps_wanted(ci); in ceph_encode_inode_release()
4493 if (cap == ci->i_auth_cap && in ceph_encode_inode_release()
4495 ci->i_requested_max_size = 0; in ceph_encode_inode_release()
4518 spin_unlock(&ci->i_ceph_lock); in ceph_encode_inode_release()