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()
652 cap = __get_cap_for_mds(ci, mds); in ceph_add_cap()
663 cap->ci = ci; in ceph_add_cap()
664 __insert_cap_node(ci, cap); in ceph_add_cap()
691 WARN_ON(cap != ci->i_auth_cap); in ceph_add_cap()
700 if (!ci->i_snap_realm || in ceph_add_cap()
702 realmino != (u64)-1 && ci->i_snap_realm->ino != realmino)) { in ceph_add_cap()
709 struct ceph_snap_realm *oldrealm = ci->i_snap_realm; in ceph_add_cap()
712 list_del_init(&ci->i_snap_realm_item); in ceph_add_cap()
717 list_add(&ci->i_snap_realm_item, in ceph_add_cap()
719 ci->i_snap_realm = realm; in ceph_add_cap()
720 if (realm->ino == ci->i_vino.ino) in ceph_add_cap()
733 __check_cap_issue(ci, cap, issued); in ceph_add_cap()
740 actual_wanted = __ceph_caps_wanted(ci); in ceph_add_cap()
746 __cap_delay_requeue(mdsc, ci); in ceph_add_cap()
750 if (!ci->i_auth_cap || in ceph_add_cap()
751 ceph_seq_cmp(ci->i_auth_cap->mseq, mseq) < 0) { in ceph_add_cap()
752 if (ci->i_auth_cap && in ceph_add_cap()
753 ci->i_auth_cap->session != cap->session) in ceph_add_cap()
754 change_auth_cap_ses(ci, cap->session); in ceph_add_cap()
755 ci->i_auth_cap = cap; in ceph_add_cap()
759 WARN_ON(ci->i_auth_cap == cap); in ceph_add_cap()
795 "but STALE (gen %u vs %u)\n", &cap->ci->vfs_inode, in __cap_is_valid()
808 int __ceph_caps_issued(struct ceph_inode_info *ci, int *implemented) in __ceph_caps_issued() argument
810 int have = ci->i_snap_caps; in __ceph_caps_issued()
816 for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) { in __ceph_caps_issued()
821 &ci->vfs_inode, cap, ceph_cap_string(cap->issued)); in __ceph_caps_issued()
831 if (ci->i_auth_cap) { in __ceph_caps_issued()
832 cap = ci->i_auth_cap; in __ceph_caps_issued()
841 int __ceph_caps_issued_other(struct ceph_inode_info *ci, struct ceph_cap *ocap) in __ceph_caps_issued_other() argument
843 int have = ci->i_snap_caps; in __ceph_caps_issued_other()
847 for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) { in __ceph_caps_issued_other()
868 dout("__touch_cap %p cap %p mds%d\n", &cap->ci->vfs_inode, cap, in __touch_cap()
873 &cap->ci->vfs_inode, cap, s->s_mds); in __touch_cap()
883 int __ceph_caps_issued_mask(struct ceph_inode_info *ci, int mask, int touch) in __ceph_caps_issued_mask() argument
887 int have = ci->i_snap_caps; in __ceph_caps_issued_mask()
891 " (mask %s)\n", ceph_ino(&ci->vfs_inode), in __ceph_caps_issued_mask()
897 for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) { in __ceph_caps_issued_mask()
903 " (mask %s)\n", ceph_ino(&ci->vfs_inode), cap, in __ceph_caps_issued_mask()
915 " (mask %s)\n", ceph_ino(&ci->vfs_inode), in __ceph_caps_issued_mask()
923 for (q = rb_first(&ci->i_caps); q != p; in __ceph_caps_issued_mask()
940 int __ceph_caps_issued_mask_metric(struct ceph_inode_info *ci, int mask, in __ceph_caps_issued_mask_metric() argument
943 struct ceph_fs_client *fsc = ceph_sb_to_client(ci->vfs_inode.i_sb); in __ceph_caps_issued_mask_metric()
946 r = __ceph_caps_issued_mask(ci, mask, touch); in __ceph_caps_issued_mask_metric()
957 int __ceph_caps_revoking_other(struct ceph_inode_info *ci, in __ceph_caps_revoking_other() argument
963 for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) { in __ceph_caps_revoking_other()
972 int ceph_caps_revoking(struct ceph_inode_info *ci, int mask) in ceph_caps_revoking() argument
974 struct inode *inode = &ci->vfs_inode; in ceph_caps_revoking()
977 spin_lock(&ci->i_ceph_lock); in ceph_caps_revoking()
978 ret = __ceph_caps_revoking_other(ci, NULL, mask); in ceph_caps_revoking()
979 spin_unlock(&ci->i_ceph_lock); in ceph_caps_revoking()
985 int __ceph_caps_used(struct ceph_inode_info *ci) in __ceph_caps_used() argument
988 if (ci->i_pin_ref) in __ceph_caps_used()
990 if (ci->i_rd_ref) in __ceph_caps_used()
992 if (ci->i_rdcache_ref || in __ceph_caps_used()
993 (S_ISREG(ci->vfs_inode.i_mode) && in __ceph_caps_used()
994 ci->vfs_inode.i_data.nrpages)) in __ceph_caps_used()
996 if (ci->i_wr_ref) in __ceph_caps_used()
998 if (ci->i_wb_ref || ci->i_wrbuffer_ref) in __ceph_caps_used()
1000 if (ci->i_fx_ref) in __ceph_caps_used()
1010 int __ceph_caps_file_wanted(struct ceph_inode_info *ci) in __ceph_caps_file_wanted() argument
1017 ceph_inode_to_client(&ci->vfs_inode)->mount_options; in __ceph_caps_file_wanted()
1021 if (S_ISDIR(ci->vfs_inode.i_mode)) { in __ceph_caps_file_wanted()
1025 if (ci->i_nr_by_mode[RD_SHIFT] > 0 || in __ceph_caps_file_wanted()
1026 time_after(ci->i_last_rd, used_cutoff)) in __ceph_caps_file_wanted()
1029 if (ci->i_nr_by_mode[WR_SHIFT] > 0 || in __ceph_caps_file_wanted()
1030 time_after(ci->i_last_wr, used_cutoff)) { in __ceph_caps_file_wanted()
1036 if (want || ci->i_nr_by_mode[PIN_SHIFT] > 0) in __ceph_caps_file_wanted()
1043 if (ci->i_nr_by_mode[RD_SHIFT] > 0) { in __ceph_caps_file_wanted()
1044 if (ci->i_nr_by_mode[RD_SHIFT] >= FMODE_WAIT_BIAS || in __ceph_caps_file_wanted()
1045 time_after(ci->i_last_rd, used_cutoff)) in __ceph_caps_file_wanted()
1047 } else if (time_after(ci->i_last_rd, idle_cutoff)) { in __ceph_caps_file_wanted()
1051 if (ci->i_nr_by_mode[WR_SHIFT] > 0) { in __ceph_caps_file_wanted()
1052 if (ci->i_nr_by_mode[WR_SHIFT] >= FMODE_WAIT_BIAS || in __ceph_caps_file_wanted()
1053 time_after(ci->i_last_wr, used_cutoff)) in __ceph_caps_file_wanted()
1055 } else if (time_after(ci->i_last_wr, idle_cutoff)) { in __ceph_caps_file_wanted()
1061 ci->i_nr_by_mode[LAZY_SHIFT] > 0) in __ceph_caps_file_wanted()
1071 int __ceph_caps_wanted(struct ceph_inode_info *ci) in __ceph_caps_wanted() argument
1073 int w = __ceph_caps_file_wanted(ci) | __ceph_caps_used(ci); in __ceph_caps_wanted()
1074 if (S_ISDIR(ci->vfs_inode.i_mode)) { in __ceph_caps_wanted()
1089 int __ceph_caps_mds_wanted(struct ceph_inode_info *ci, bool check) in __ceph_caps_mds_wanted() argument
1095 for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) { in __ceph_caps_mds_wanted()
1099 if (cap == ci->i_auth_cap) in __ceph_caps_mds_wanted()
1109 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_is_any_caps() local
1112 spin_lock(&ci->i_ceph_lock); in ceph_is_any_caps()
1113 ret = __ceph_is_any_real_caps(ci); in ceph_is_any_caps()
1114 spin_unlock(&ci->i_ceph_lock); in ceph_is_any_caps()
1119 static void drop_inode_snap_realm(struct ceph_inode_info *ci) in drop_inode_snap_realm() argument
1121 struct ceph_snap_realm *realm = ci->i_snap_realm; in drop_inode_snap_realm()
1123 list_del_init(&ci->i_snap_realm_item); in drop_inode_snap_realm()
1124 ci->i_snap_realm_counter++; in drop_inode_snap_realm()
1125 ci->i_snap_realm = NULL; in drop_inode_snap_realm()
1126 if (realm->ino == ci->i_vino.ino) in drop_inode_snap_realm()
1129 ceph_put_snap_realm(ceph_sb_to_client(ci->vfs_inode.i_sb)->mdsc, in drop_inode_snap_realm()
1142 struct ceph_inode_info *ci = cap->ci; in __ceph_remove_cap() local
1144 ceph_sb_to_client(ci->vfs_inode.i_sb)->mdsc; in __ceph_remove_cap()
1147 dout("__ceph_remove_cap %p from %p\n", cap, &ci->vfs_inode); in __ceph_remove_cap()
1150 rb_erase(&cap->ci_node, &ci->i_caps); in __ceph_remove_cap()
1151 if (ci->i_auth_cap == cap) { in __ceph_remove_cap()
1152 WARN_ON_ONCE(!list_empty(&ci->i_dirty_item)); in __ceph_remove_cap()
1153 ci->i_auth_cap = NULL; in __ceph_remove_cap()
1170 cap->ci = NULL; in __ceph_remove_cap()
1186 cap->cap_ino = ci->i_vino.ino; in __ceph_remove_cap()
1193 if (!__ceph_is_any_real_caps(ci)) { in __ceph_remove_cap()
1198 if (ci->i_wr_ref == 0 && ci->i_snap_realm) in __ceph_remove_cap()
1199 drop_inode_snap_realm(ci); in __ceph_remove_cap()
1201 __cap_delay_cancel(mdsc, ci); in __ceph_remove_cap()
1322 void __ceph_remove_caps(struct ceph_inode_info *ci) in __ceph_remove_caps() argument
1328 spin_lock(&ci->i_ceph_lock); in __ceph_remove_caps()
1329 p = rb_first(&ci->i_caps); in __ceph_remove_caps()
1335 spin_unlock(&ci->i_ceph_lock); in __ceph_remove_caps()
1350 struct ceph_inode_info *ci = cap->ci; in __prep_cap() local
1351 struct inode *inode = &ci->vfs_inode; in __prep_cap()
1354 lockdep_assert_held(&ci->i_ceph_lock); in __prep_cap()
1366 ci->i_ceph_flags &= ~CEPH_I_FLUSH; in __prep_cap()
1381 arg->follows = flushing ? ci->i_head_snapc->seq : 0; in __prep_cap()
1386 ci->i_reported_size = arg->size; in __prep_cap()
1387 arg->max_size = ci->i_wanted_max_size; in __prep_cap()
1388 if (cap == ci->i_auth_cap) { in __prep_cap()
1390 ci->i_requested_max_size = arg->max_size; in __prep_cap()
1392 ci->i_requested_max_size = 0; in __prep_cap()
1396 arg->old_xattr_buf = __ceph_build_xattrs_blob(ci); in __prep_cap()
1397 arg->xattr_version = ci->i_xattrs.version; in __prep_cap()
1398 arg->xattr_buf = ci->i_xattrs.blob; in __prep_cap()
1407 arg->btime = ci->i_btime; in __prep_cap()
1418 arg->time_warp_seq = ci->i_time_warp_seq; in __prep_cap()
1424 arg->inline_data = ci->i_inline_version != CEPH_INLINE_NONE; in __prep_cap()
1426 !list_empty(&ci->i_cap_snaps)) { in __prep_cap()
1428 list_for_each_entry_reverse(capsnap, &ci->i_cap_snaps, ci_item) { in __prep_cap()
1445 static void __send_cap(struct cap_msg_args *arg, struct ceph_inode_info *ci) in __send_cap() argument
1448 struct inode *inode = &ci->vfs_inode; in __send_cap()
1455 spin_lock(&ci->i_ceph_lock); in __send_cap()
1456 __cap_delay_requeue(arg->session->s_mdsc, ci); in __send_cap()
1457 spin_unlock(&ci->i_ceph_lock); in __send_cap()
1465 wake_up_all(&ci->i_cap_wq); in __send_cap()
1531 static void __ceph_flush_snaps(struct ceph_inode_info *ci, in __ceph_flush_snaps() argument
1533 __releases(ci->i_ceph_lock) in __ceph_flush_snaps()
1534 __acquires(ci->i_ceph_lock) in __ceph_flush_snaps()
1536 struct inode *inode = &ci->vfs_inode; in __ceph_flush_snaps()
1544 list_for_each_entry(capsnap, &ci->i_cap_snaps, ci_item) { in __ceph_flush_snaps()
1567 if (list_empty(&ci->i_flushing_item)) { in __ceph_flush_snaps()
1568 list_add_tail(&ci->i_flushing_item, in __ceph_flush_snaps()
1574 &ci->i_cap_flush_list); in __ceph_flush_snaps()
1581 ci->i_ceph_flags &= ~CEPH_I_FLUSH_SNAPS; in __ceph_flush_snaps()
1584 struct ceph_cap *cap = ci->i_auth_cap; in __ceph_flush_snaps()
1595 list_for_each_entry(cf, &ci->i_cap_flush_list, i_list) { in __ceph_flush_snaps()
1608 spin_unlock(&ci->i_ceph_lock); in __ceph_flush_snaps()
1622 spin_lock(&ci->i_ceph_lock); in __ceph_flush_snaps()
1626 void ceph_flush_snaps(struct ceph_inode_info *ci, in ceph_flush_snaps() argument
1629 struct inode *inode = &ci->vfs_inode; in ceph_flush_snaps()
1638 spin_lock(&ci->i_ceph_lock); in ceph_flush_snaps()
1639 if (!(ci->i_ceph_flags & CEPH_I_FLUSH_SNAPS)) { in ceph_flush_snaps()
1643 if (!ci->i_auth_cap) { in ceph_flush_snaps()
1648 mds = ci->i_auth_cap->session->s_mds; in ceph_flush_snaps()
1656 spin_unlock(&ci->i_ceph_lock); in ceph_flush_snaps()
1668 if (ci->i_ceph_flags & CEPH_I_KICK_FLUSH) in ceph_flush_snaps()
1669 __kick_flushing_caps(mdsc, session, ci, 0); in ceph_flush_snaps()
1671 __ceph_flush_snaps(ci, session); in ceph_flush_snaps()
1673 spin_unlock(&ci->i_ceph_lock); in ceph_flush_snaps()
1683 list_del_init(&ci->i_snap_flush_item); in ceph_flush_snaps()
1692 int __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask, in __ceph_mark_dirty_caps() argument
1696 ceph_sb_to_client(ci->vfs_inode.i_sb)->mdsc; in __ceph_mark_dirty_caps()
1697 struct inode *inode = &ci->vfs_inode; in __ceph_mark_dirty_caps()
1698 int was = ci->i_dirty_caps; in __ceph_mark_dirty_caps()
1701 lockdep_assert_held(&ci->i_ceph_lock); in __ceph_mark_dirty_caps()
1703 if (!ci->i_auth_cap) { in __ceph_mark_dirty_caps()
1710 dout("__mark_dirty_caps %p %s dirty %s -> %s\n", &ci->vfs_inode, in __ceph_mark_dirty_caps()
1713 ci->i_dirty_caps |= mask; in __ceph_mark_dirty_caps()
1715 struct ceph_mds_session *session = ci->i_auth_cap->session; in __ceph_mark_dirty_caps()
1717 WARN_ON_ONCE(ci->i_prealloc_cap_flush); in __ceph_mark_dirty_caps()
1718 swap(ci->i_prealloc_cap_flush, *pcf); in __ceph_mark_dirty_caps()
1720 if (!ci->i_head_snapc) { in __ceph_mark_dirty_caps()
1722 ci->i_head_snapc = ceph_get_snap_context( in __ceph_mark_dirty_caps()
1723 ci->i_snap_realm->cached_context); in __ceph_mark_dirty_caps()
1726 &ci->vfs_inode, ci->i_head_snapc, ci->i_auth_cap); in __ceph_mark_dirty_caps()
1727 BUG_ON(!list_empty(&ci->i_dirty_item)); in __ceph_mark_dirty_caps()
1729 list_add(&ci->i_dirty_item, &session->s_cap_dirty); in __ceph_mark_dirty_caps()
1731 if (ci->i_flushing_caps == 0) { in __ceph_mark_dirty_caps()
1736 WARN_ON_ONCE(!ci->i_prealloc_cap_flush); in __ceph_mark_dirty_caps()
1738 BUG_ON(list_empty(&ci->i_dirty_item)); in __ceph_mark_dirty_caps()
1739 if (((was | ci->i_flushing_caps) & CEPH_CAP_FILE_BUFFER) && in __ceph_mark_dirty_caps()
1742 __cap_delay_requeue(mdsc, ci); in __ceph_mark_dirty_caps()
1787 static bool __detach_cap_flush_from_ci(struct ceph_inode_info *ci, in __detach_cap_flush_from_ci() argument
1793 if (wake && cf->i_list.prev != &ci->i_cap_flush_list) { in __detach_cap_flush_from_ci()
1813 struct ceph_inode_info *ci = ceph_inode(inode); in __mark_caps_flushing() local
1817 lockdep_assert_held(&ci->i_ceph_lock); in __mark_caps_flushing()
1818 BUG_ON(ci->i_dirty_caps == 0); in __mark_caps_flushing()
1819 BUG_ON(list_empty(&ci->i_dirty_item)); in __mark_caps_flushing()
1820 BUG_ON(!ci->i_prealloc_cap_flush); in __mark_caps_flushing()
1822 flushing = ci->i_dirty_caps; in __mark_caps_flushing()
1825 ceph_cap_string(ci->i_flushing_caps), in __mark_caps_flushing()
1826 ceph_cap_string(ci->i_flushing_caps | flushing)); in __mark_caps_flushing()
1827 ci->i_flushing_caps |= flushing; in __mark_caps_flushing()
1828 ci->i_dirty_caps = 0; in __mark_caps_flushing()
1831 swap(cf, ci->i_prealloc_cap_flush); in __mark_caps_flushing()
1836 list_del_init(&ci->i_dirty_item); in __mark_caps_flushing()
1842 if (list_empty(&ci->i_flushing_item)) { in __mark_caps_flushing()
1843 list_add_tail(&ci->i_flushing_item, &session->s_cap_flushing); in __mark_caps_flushing()
1848 list_add_tail(&cf->i_list, &ci->i_cap_flush_list); in __mark_caps_flushing()
1858 struct ceph_inode_info *ci = ceph_inode(inode); in try_nonblocking_invalidate() local
1859 u32 invalidating_gen = ci->i_rdcache_gen; in try_nonblocking_invalidate()
1861 spin_unlock(&ci->i_ceph_lock); in try_nonblocking_invalidate()
1863 spin_lock(&ci->i_ceph_lock); in try_nonblocking_invalidate()
1866 invalidating_gen == ci->i_rdcache_gen) { in try_nonblocking_invalidate()
1870 ci->i_rdcache_revoking = ci->i_rdcache_gen - 1; in try_nonblocking_invalidate()
1877 bool __ceph_should_report_size(struct ceph_inode_info *ci) in __ceph_should_report_size() argument
1879 loff_t size = ci->vfs_inode.i_size; in __ceph_should_report_size()
1881 if (ci->i_flushing_caps & CEPH_CAP_FILE_WR) in __ceph_should_report_size()
1883 if (size >= ci->i_max_size) in __ceph_should_report_size()
1886 if (ci->i_max_size > ci->i_reported_size && in __ceph_should_report_size()
1887 (size << 1) >= ci->i_max_size + ci->i_reported_size) in __ceph_should_report_size()
1901 void ceph_check_caps(struct ceph_inode_info *ci, int flags, in ceph_check_caps() argument
1904 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()
1923 spin_lock(&ci->i_ceph_lock); in ceph_check_caps()
1926 file_wanted = __ceph_caps_file_wanted(ci); in ceph_check_caps()
1929 used = __ceph_caps_used(ci); in ceph_check_caps()
1937 issued = __ceph_caps_issued(ci, &implemented); in ceph_check_caps()
1949 __ceph_dir_is_complete(ci)) { in ceph_check_caps()
1970 if (ci->i_max_size == 0) in ceph_check_caps()
1978 ceph_cap_string(used), ceph_cap_string(ci->i_dirty_caps), in ceph_check_caps()
1979 ceph_cap_string(ci->i_flushing_caps), in ceph_check_caps()
1992 !(ci->i_wb_ref || ci->i_wrbuffer_ref) && /* no dirty pages... */ in ceph_check_caps()
2001 ci->i_rdcache_revoking = ci->i_rdcache_gen; in ceph_check_caps()
2007 for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) { in ceph_check_caps()
2015 ((flags & CHECK_CAPS_AUTHONLY) && cap != ci->i_auth_cap)) in ceph_check_caps()
2025 if (ci->i_auth_cap && cap != ci->i_auth_cap) in ceph_check_caps()
2026 cap_used &= ~ci->i_auth_cap->issued; in ceph_check_caps()
2035 if (cap == ci->i_auth_cap && in ceph_check_caps()
2038 if (ci->i_wanted_max_size > ci->i_max_size && in ceph_check_caps()
2039 ci->i_wanted_max_size > ci->i_requested_max_size) { in ceph_check_caps()
2045 if (__ceph_should_report_size(ci)) { in ceph_check_caps()
2051 if (cap == ci->i_auth_cap) { in ceph_check_caps()
2052 if ((flags & CHECK_CAPS_FLUSH) && ci->i_dirty_caps) { in ceph_check_caps()
2056 if (ci->i_ceph_flags & CEPH_I_FLUSH_SNAPS) { in ceph_check_caps()
2093 spin_unlock(&ci->i_ceph_lock); in ceph_check_caps()
2116 if (cap == ci->i_auth_cap && in ceph_check_caps()
2117 (ci->i_ceph_flags & in ceph_check_caps()
2119 if (ci->i_ceph_flags & CEPH_I_KICK_FLUSH) in ceph_check_caps()
2120 __kick_flushing_caps(mdsc, session, ci, 0); in ceph_check_caps()
2121 if (ci->i_ceph_flags & CEPH_I_FLUSH_SNAPS) in ceph_check_caps()
2122 __ceph_flush_snaps(ci, session); in ceph_check_caps()
2132 spin_unlock(&ci->i_ceph_lock); in ceph_check_caps()
2140 if (cap == ci->i_auth_cap && ci->i_dirty_caps) { in ceph_check_caps()
2141 flushing = ci->i_dirty_caps; in ceph_check_caps()
2159 spin_unlock(&ci->i_ceph_lock); in ceph_check_caps()
2161 __send_cap(&arg, ci); in ceph_check_caps()
2167 if (__ceph_is_any_real_caps(ci) && in ceph_check_caps()
2168 list_empty(&ci->i_cap_delay_list) && in ceph_check_caps()
2171 __cap_delay_requeue(mdsc, ci); in ceph_check_caps()
2174 spin_unlock(&ci->i_ceph_lock); in ceph_check_caps()
2191 struct ceph_inode_info *ci = ceph_inode(inode); in try_flush_caps() local
2197 spin_lock(&ci->i_ceph_lock); in try_flush_caps()
2199 if (ci->i_dirty_caps && ci->i_auth_cap) { in try_flush_caps()
2200 struct ceph_cap *cap = ci->i_auth_cap; in try_flush_caps()
2204 spin_unlock(&ci->i_ceph_lock); in try_flush_caps()
2212 spin_unlock(&ci->i_ceph_lock); in try_flush_caps()
2216 if (ci->i_ceph_flags & in try_flush_caps()
2218 if (ci->i_ceph_flags & CEPH_I_KICK_FLUSH) in try_flush_caps()
2219 __kick_flushing_caps(mdsc, session, ci, 0); in try_flush_caps()
2220 if (ci->i_ceph_flags & CEPH_I_FLUSH_SNAPS) in try_flush_caps()
2221 __ceph_flush_snaps(ci, session); in try_flush_caps()
2225 flushing = ci->i_dirty_caps; in try_flush_caps()
2230 __ceph_caps_used(ci), __ceph_caps_wanted(ci), in try_flush_caps()
2233 spin_unlock(&ci->i_ceph_lock); in try_flush_caps()
2235 __send_cap(&arg, ci); in try_flush_caps()
2237 if (!list_empty(&ci->i_cap_flush_list)) { in try_flush_caps()
2239 list_last_entry(&ci->i_cap_flush_list, in try_flush_caps()
2244 flushing = ci->i_flushing_caps; in try_flush_caps()
2245 spin_unlock(&ci->i_ceph_lock); in try_flush_caps()
2260 struct ceph_inode_info *ci = ceph_inode(inode); in caps_are_flushed() local
2263 spin_lock(&ci->i_ceph_lock); in caps_are_flushed()
2264 if (!list_empty(&ci->i_cap_flush_list)) { in caps_are_flushed()
2266 list_first_entry(&ci->i_cap_flush_list, in caps_are_flushed()
2271 spin_unlock(&ci->i_ceph_lock); in caps_are_flushed()
2280 struct ceph_inode_info *ci = ceph_inode(inode); in unsafe_request_wait() local
2284 spin_lock(&ci->i_unsafe_lock); in unsafe_request_wait()
2285 if (S_ISDIR(inode->i_mode) && !list_empty(&ci->i_unsafe_dirops)) { in unsafe_request_wait()
2286 req1 = list_last_entry(&ci->i_unsafe_dirops, in unsafe_request_wait()
2291 if (!list_empty(&ci->i_unsafe_iops)) { in unsafe_request_wait()
2292 req2 = list_last_entry(&ci->i_unsafe_iops, in unsafe_request_wait()
2297 spin_unlock(&ci->i_unsafe_lock); in unsafe_request_wait()
2322 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_fsync() local
2348 err = wait_event_interruptible(ci->i_cap_wq, in ceph_fsync()
2355 if (errseq_check(&ci->i_meta_err, READ_ONCE(fi->meta_err))) { in ceph_fsync()
2357 err = errseq_check_and_advance(&ci->i_meta_err, in ceph_fsync()
2376 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_write_inode() local
2386 err = wait_event_interruptible(ci->i_cap_wq, in ceph_write_inode()
2392 spin_lock(&ci->i_ceph_lock); in ceph_write_inode()
2393 if (__ceph_caps_dirty(ci)) in ceph_write_inode()
2394 __cap_delay_requeue_front(mdsc, ci); in ceph_write_inode()
2395 spin_unlock(&ci->i_ceph_lock); in ceph_write_inode()
2402 struct ceph_inode_info *ci, in __kick_flushing_caps() argument
2404 __releases(ci->i_ceph_lock) in __kick_flushing_caps()
2405 __acquires(ci->i_ceph_lock) in __kick_flushing_caps()
2407 struct inode *inode = &ci->vfs_inode; in __kick_flushing_caps()
2414 ci->i_ceph_flags &= ~CEPH_I_KICK_FLUSH; in __kick_flushing_caps()
2416 list_for_each_entry_reverse(cf, &ci->i_cap_flush_list, i_list) { in __kick_flushing_caps()
2423 list_for_each_entry(cf, &ci->i_cap_flush_list, i_list) { in __kick_flushing_caps()
2427 cap = ci->i_auth_cap; in __kick_flushing_caps()
2444 __ceph_caps_used(ci), in __kick_flushing_caps()
2445 __ceph_caps_wanted(ci), in __kick_flushing_caps()
2448 spin_unlock(&ci->i_ceph_lock); in __kick_flushing_caps()
2449 __send_cap(&arg, ci); in __kick_flushing_caps()
2459 spin_unlock(&ci->i_ceph_lock); in __kick_flushing_caps()
2474 spin_lock(&ci->i_ceph_lock); in __kick_flushing_caps()
2481 struct ceph_inode_info *ci; in ceph_early_kick_flushing_caps() local
2491 list_for_each_entry(ci, &session->s_cap_flushing, i_flushing_item) { in ceph_early_kick_flushing_caps()
2492 spin_lock(&ci->i_ceph_lock); in ceph_early_kick_flushing_caps()
2493 cap = ci->i_auth_cap; in ceph_early_kick_flushing_caps()
2496 &ci->vfs_inode, cap, session->s_mds); in ceph_early_kick_flushing_caps()
2497 spin_unlock(&ci->i_ceph_lock); in ceph_early_kick_flushing_caps()
2508 if ((cap->issued & ci->i_flushing_caps) != in ceph_early_kick_flushing_caps()
2509 ci->i_flushing_caps) { in ceph_early_kick_flushing_caps()
2516 __kick_flushing_caps(mdsc, session, ci, in ceph_early_kick_flushing_caps()
2519 ci->i_ceph_flags |= CEPH_I_KICK_FLUSH; in ceph_early_kick_flushing_caps()
2522 spin_unlock(&ci->i_ceph_lock); in ceph_early_kick_flushing_caps()
2529 struct ceph_inode_info *ci; in ceph_kick_flushing_caps() local
2541 list_for_each_entry(ci, &session->s_cap_flushing, i_flushing_item) { in ceph_kick_flushing_caps()
2542 spin_lock(&ci->i_ceph_lock); in ceph_kick_flushing_caps()
2543 cap = ci->i_auth_cap; in ceph_kick_flushing_caps()
2546 &ci->vfs_inode, cap, session->s_mds); in ceph_kick_flushing_caps()
2547 spin_unlock(&ci->i_ceph_lock); in ceph_kick_flushing_caps()
2550 if (ci->i_ceph_flags & CEPH_I_KICK_FLUSH) { in ceph_kick_flushing_caps()
2551 __kick_flushing_caps(mdsc, session, ci, in ceph_kick_flushing_caps()
2554 spin_unlock(&ci->i_ceph_lock); in ceph_kick_flushing_caps()
2559 struct ceph_inode_info *ci) in ceph_kick_flushing_inode_caps() argument
2562 struct ceph_cap *cap = ci->i_auth_cap; in ceph_kick_flushing_inode_caps()
2564 lockdep_assert_held(&ci->i_ceph_lock); in ceph_kick_flushing_inode_caps()
2566 dout("%s %p flushing %s\n", __func__, &ci->vfs_inode, in ceph_kick_flushing_inode_caps()
2567 ceph_cap_string(ci->i_flushing_caps)); in ceph_kick_flushing_inode_caps()
2569 if (!list_empty(&ci->i_cap_flush_list)) { in ceph_kick_flushing_inode_caps()
2572 list_move_tail(&ci->i_flushing_item, in ceph_kick_flushing_inode_caps()
2577 __kick_flushing_caps(mdsc, session, ci, oldest_flush_tid); in ceph_kick_flushing_inode_caps()
2586 void ceph_take_cap_refs(struct ceph_inode_info *ci, int got, in ceph_take_cap_refs() argument
2589 lockdep_assert_held(&ci->i_ceph_lock); in ceph_take_cap_refs()
2592 ci->i_pin_ref++; in ceph_take_cap_refs()
2594 ci->i_rd_ref++; in ceph_take_cap_refs()
2596 ci->i_rdcache_ref++; in ceph_take_cap_refs()
2598 ci->i_fx_ref++; in ceph_take_cap_refs()
2600 if (ci->i_wr_ref == 0 && !ci->i_head_snapc) { in ceph_take_cap_refs()
2602 ci->i_head_snapc = ceph_get_snap_context( in ceph_take_cap_refs()
2603 ci->i_snap_realm->cached_context); in ceph_take_cap_refs()
2605 ci->i_wr_ref++; in ceph_take_cap_refs()
2608 if (ci->i_wb_ref == 0) in ceph_take_cap_refs()
2609 ihold(&ci->vfs_inode); in ceph_take_cap_refs()
2610 ci->i_wb_ref++; in ceph_take_cap_refs()
2612 &ci->vfs_inode, ci->i_wb_ref-1, ci->i_wb_ref); in ceph_take_cap_refs()
2638 struct ceph_inode_info *ci = ceph_inode(inode); in try_get_cap_refs() local
2648 spin_lock(&ci->i_ceph_lock); in try_get_cap_refs()
2651 (ci->i_ceph_flags & CEPH_I_ERROR_FILELOCK)) { in try_get_cap_refs()
2658 while (ci->i_truncate_pending) { in try_get_cap_refs()
2659 spin_unlock(&ci->i_ceph_lock); in try_get_cap_refs()
2665 spin_lock(&ci->i_ceph_lock); in try_get_cap_refs()
2668 have = __ceph_caps_issued(ci, &implemented); in try_get_cap_refs()
2671 if (endoff >= 0 && endoff > (loff_t)ci->i_max_size) { in try_get_cap_refs()
2673 inode, endoff, ci->i_max_size); in try_get_cap_refs()
2674 if (endoff > ci->i_requested_max_size) in try_get_cap_refs()
2675 ret = ci->i_auth_cap ? -EFBIG : -ESTALE; in try_get_cap_refs()
2682 if (__ceph_have_pending_cap_snap(ci)) { in try_get_cap_refs()
2702 !ci->i_head_snapc && in try_get_cap_refs()
2714 spin_unlock(&ci->i_ceph_lock); in try_get_cap_refs()
2728 ceph_disable_fscache_readpage(ci); in try_get_cap_refs()
2729 ceph_take_cap_refs(ci, *got, true); in try_get_cap_refs()
2735 if (ci->i_auth_cap && in try_get_cap_refs()
2737 struct ceph_mds_session *s = ci->i_auth_cap->session; in try_get_cap_refs()
2744 inode, ceph_cap_string(need), ci->i_auth_cap->mds); in try_get_cap_refs()
2754 mds_wanted = __ceph_caps_mds_wanted(ci, false); in try_get_cap_refs()
2768 __ceph_touch_fmode(ci, mdsc, flags); in try_get_cap_refs()
2770 spin_unlock(&ci->i_ceph_lock); in try_get_cap_refs()
2791 struct ceph_inode_info *ci = ceph_inode(inode); in check_max_size() local
2795 spin_lock(&ci->i_ceph_lock); in check_max_size()
2796 if (endoff >= ci->i_max_size && endoff > ci->i_wanted_max_size) { in check_max_size()
2799 ci->i_wanted_max_size = endoff; in check_max_size()
2802 if (ci->i_auth_cap && in check_max_size()
2803 (ci->i_auth_cap->issued & CEPH_CAP_FILE_WR) && in check_max_size()
2804 ci->i_wanted_max_size > ci->i_max_size && in check_max_size()
2805 ci->i_wanted_max_size > ci->i_requested_max_size) in check_max_size()
2807 spin_unlock(&ci->i_ceph_lock); in check_max_size()
2809 ceph_check_caps(ci, CHECK_CAPS_AUTHONLY, NULL); in check_max_size()
2858 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_get_caps() local
2895 ceph_get_fmode(ci, flags, FMODE_WAIT_BIAS); in ceph_get_caps()
2896 add_wait_queue(&ci->i_cap_wq, &wait); in ceph_get_caps()
2908 remove_wait_queue(&ci->i_cap_wq, &wait); in ceph_get_caps()
2909 ceph_put_fmode(ci, flags, FMODE_WAIT_BIAS); in ceph_get_caps()
2922 ceph_put_cap_refs(ci, _got); in ceph_get_caps()
2945 if (S_ISREG(ci->vfs_inode.i_mode) && in ceph_get_caps()
2946 ci->i_inline_version != CEPH_INLINE_NONE && in ceph_get_caps()
2962 ceph_put_cap_refs(ci, _got); in ceph_get_caps()
2979 if (S_ISREG(ci->vfs_inode.i_mode) && in ceph_get_caps()
2981 ceph_fscache_revalidate_cookie(ci); in ceph_get_caps()
2991 void ceph_get_cap_refs(struct ceph_inode_info *ci, int caps) in ceph_get_cap_refs() argument
2993 spin_lock(&ci->i_ceph_lock); in ceph_get_cap_refs()
2994 ceph_take_cap_refs(ci, caps, false); in ceph_get_cap_refs()
2995 spin_unlock(&ci->i_ceph_lock); in ceph_get_cap_refs()
3003 static int ceph_try_drop_cap_snap(struct ceph_inode_info *ci, in ceph_try_drop_cap_snap() argument
3012 if (!list_is_last(&capsnap->ci_item, &ci->i_cap_snaps)) in ceph_try_drop_cap_snap()
3013 ci->i_ceph_flags |= CEPH_I_FLUSH_SNAPS; in ceph_try_drop_cap_snap()
3031 static void __ceph_put_cap_refs(struct ceph_inode_info *ci, int had, in __ceph_put_cap_refs() argument
3034 struct inode *inode = &ci->vfs_inode; in __ceph_put_cap_refs()
3037 spin_lock(&ci->i_ceph_lock); in __ceph_put_cap_refs()
3039 --ci->i_pin_ref; in __ceph_put_cap_refs()
3041 if (--ci->i_rd_ref == 0) in __ceph_put_cap_refs()
3044 if (--ci->i_rdcache_ref == 0) in __ceph_put_cap_refs()
3047 if (--ci->i_fx_ref == 0) in __ceph_put_cap_refs()
3050 if (--ci->i_wb_ref == 0) { in __ceph_put_cap_refs()
3055 inode, ci->i_wb_ref+1, ci->i_wb_ref); in __ceph_put_cap_refs()
3058 if (--ci->i_wr_ref == 0) { in __ceph_put_cap_refs()
3060 if (__ceph_have_pending_cap_snap(ci)) { in __ceph_put_cap_refs()
3062 list_last_entry(&ci->i_cap_snaps, in __ceph_put_cap_refs()
3066 if (ceph_try_drop_cap_snap(ci, capsnap)) in __ceph_put_cap_refs()
3068 else if (__ceph_finish_cap_snap(ci, capsnap)) in __ceph_put_cap_refs()
3072 if (ci->i_wrbuffer_ref_head == 0 && in __ceph_put_cap_refs()
3073 ci->i_dirty_caps == 0 && in __ceph_put_cap_refs()
3074 ci->i_flushing_caps == 0) { in __ceph_put_cap_refs()
3075 BUG_ON(!ci->i_head_snapc); in __ceph_put_cap_refs()
3076 ceph_put_snap_context(ci->i_head_snapc); in __ceph_put_cap_refs()
3077 ci->i_head_snapc = NULL; in __ceph_put_cap_refs()
3080 if (!__ceph_is_any_real_caps(ci) && ci->i_snap_realm) in __ceph_put_cap_refs()
3081 drop_inode_snap_realm(ci); in __ceph_put_cap_refs()
3083 spin_unlock(&ci->i_ceph_lock); in __ceph_put_cap_refs()
3089 ceph_check_caps(ci, 0, NULL); in __ceph_put_cap_refs()
3091 ceph_flush_snaps(ci, NULL); in __ceph_put_cap_refs()
3093 wake_up_all(&ci->i_cap_wq); in __ceph_put_cap_refs()
3098 void ceph_put_cap_refs(struct ceph_inode_info *ci, int had) in ceph_put_cap_refs() argument
3100 __ceph_put_cap_refs(ci, had, false); in ceph_put_cap_refs()
3103 void ceph_put_cap_refs_no_check_caps(struct ceph_inode_info *ci, int had) in ceph_put_cap_refs_no_check_caps() argument
3105 __ceph_put_cap_refs(ci, had, true); in ceph_put_cap_refs_no_check_caps()
3115 void ceph_put_wrbuffer_cap_refs(struct ceph_inode_info *ci, int nr, in ceph_put_wrbuffer_cap_refs() argument
3118 struct inode *inode = &ci->vfs_inode; in ceph_put_wrbuffer_cap_refs()
3126 spin_lock(&ci->i_ceph_lock); in ceph_put_wrbuffer_cap_refs()
3127 ci->i_wrbuffer_ref -= nr; in ceph_put_wrbuffer_cap_refs()
3128 if (ci->i_wrbuffer_ref == 0) { in ceph_put_wrbuffer_cap_refs()
3133 if (ci->i_head_snapc == snapc) { in ceph_put_wrbuffer_cap_refs()
3134 ci->i_wrbuffer_ref_head -= nr; in ceph_put_wrbuffer_cap_refs()
3135 if (ci->i_wrbuffer_ref_head == 0 && in ceph_put_wrbuffer_cap_refs()
3136 ci->i_wr_ref == 0 && in ceph_put_wrbuffer_cap_refs()
3137 ci->i_dirty_caps == 0 && in ceph_put_wrbuffer_cap_refs()
3138 ci->i_flushing_caps == 0) { in ceph_put_wrbuffer_cap_refs()
3139 BUG_ON(!ci->i_head_snapc); in ceph_put_wrbuffer_cap_refs()
3140 ceph_put_snap_context(ci->i_head_snapc); in ceph_put_wrbuffer_cap_refs()
3141 ci->i_head_snapc = NULL; in ceph_put_wrbuffer_cap_refs()
3145 ci->i_wrbuffer_ref+nr, ci->i_wrbuffer_ref_head+nr, in ceph_put_wrbuffer_cap_refs()
3146 ci->i_wrbuffer_ref, ci->i_wrbuffer_ref_head, in ceph_put_wrbuffer_cap_refs()
3149 list_for_each_entry(capsnap, &ci->i_cap_snaps, ci_item) { in ceph_put_wrbuffer_cap_refs()
3160 if (ceph_try_drop_cap_snap(ci, capsnap)) { in ceph_put_wrbuffer_cap_refs()
3163 ci->i_ceph_flags |= CEPH_I_FLUSH_SNAPS; in ceph_put_wrbuffer_cap_refs()
3171 ci->i_wrbuffer_ref+nr, capsnap->dirty_pages + nr, in ceph_put_wrbuffer_cap_refs()
3172 ci->i_wrbuffer_ref, capsnap->dirty_pages, in ceph_put_wrbuffer_cap_refs()
3177 spin_unlock(&ci->i_ceph_lock); in ceph_put_wrbuffer_cap_refs()
3180 ceph_check_caps(ci, 0, NULL); in ceph_put_wrbuffer_cap_refs()
3182 ceph_flush_snaps(ci, NULL); in ceph_put_wrbuffer_cap_refs()
3185 wake_up_all(&ci->i_cap_wq); in ceph_put_wrbuffer_cap_refs()
3252 __releases(ci->i_ceph_lock) in handle_cap_grant()
3255 struct ceph_inode_info *ci = ceph_inode(inode); in handle_cap_grant() local
3284 !(ci->i_wrbuffer_ref || ci->i_wb_ref)) { in handle_cap_grant()
3288 if (ci->i_rdcache_revoking != ci->i_rdcache_gen) { in handle_cap_grant()
3290 ci->i_rdcache_revoking = ci->i_rdcache_gen; in handle_cap_grant()
3307 WARN_ON(cap != ci->i_auth_cap); in handle_cap_grant()
3317 __check_cap_issue(ci, cap, newcaps); in handle_cap_grant()
3326 ci->i_btime = extra_info->btime; in handle_cap_grant()
3345 if (version > ci->i_xattrs.version) { in handle_cap_grant()
3348 if (ci->i_xattrs.blob) in handle_cap_grant()
3349 ceph_buffer_put(ci->i_xattrs.blob); in handle_cap_grant()
3350 ci->i_xattrs.blob = ceph_buffer_get(xattr_buf); in handle_cap_grant()
3351 ci->i_xattrs.version = version; in handle_cap_grant()
3369 ci->i_files = extra_info->nfiles; in handle_cap_grant()
3370 ci->i_subdirs = extra_info->nsubdirs; in handle_cap_grant()
3375 s64 old_pool = ci->i_layout.pool_id; in handle_cap_grant()
3378 ceph_file_layout_from_legacy(&ci->i_layout, &grant->layout); in handle_cap_grant()
3379 old_ns = rcu_dereference_protected(ci->i_layout.pool_ns, in handle_cap_grant()
3380 lockdep_is_held(&ci->i_ceph_lock)); in handle_cap_grant()
3381 rcu_assign_pointer(ci->i_layout.pool_ns, extra_info->pool_ns); in handle_cap_grant()
3383 if (ci->i_layout.pool_id != old_pool || in handle_cap_grant()
3385 ci->i_ceph_flags &= ~CEPH_I_POOL_PERM; in handle_cap_grant()
3396 if (ci->i_auth_cap == cap && (newcaps & CEPH_CAP_ANY_FILE_WR)) { in handle_cap_grant()
3397 if (max_size != ci->i_max_size) { in handle_cap_grant()
3399 ci->i_max_size, max_size); in handle_cap_grant()
3400 ci->i_max_size = max_size; in handle_cap_grant()
3401 if (max_size >= ci->i_wanted_max_size) { in handle_cap_grant()
3402 ci->i_wanted_max_size = 0; /* reset */ in handle_cap_grant()
3403 ci->i_requested_max_size = 0; in handle_cap_grant()
3410 wanted = __ceph_caps_wanted(ci); in handle_cap_grant()
3411 used = __ceph_caps_used(ci); in handle_cap_grant()
3412 dirty = __ceph_caps_dirty(ci); in handle_cap_grant()
3448 else if (cap == ci->i_auth_cap) in handle_cap_grant()
3461 if (cap == ci->i_auth_cap && in handle_cap_grant()
3462 __ceph_caps_revoking_other(ci, cap, newcaps)) in handle_cap_grant()
3474 extra_info->inline_version >= ci->i_inline_version) { in handle_cap_grant()
3475 ci->i_inline_version = extra_info->inline_version; in handle_cap_grant()
3476 if (ci->i_inline_version != CEPH_INLINE_NONE && in handle_cap_grant()
3481 if (ci->i_auth_cap == cap && in handle_cap_grant()
3486 if (ci->i_requested_max_size > max_size || in handle_cap_grant()
3489 ci->i_requested_max_size = 0; in handle_cap_grant()
3493 ceph_kick_flushing_inode_caps(session, ci); in handle_cap_grant()
3494 spin_unlock(&ci->i_ceph_lock); in handle_cap_grant()
3497 spin_unlock(&ci->i_ceph_lock); in handle_cap_grant()
3519 wake_up_all(&ci->i_cap_wq); in handle_cap_grant()
3522 ceph_check_caps(ci, CHECK_CAPS_AUTHONLY | CHECK_CAPS_NOINVAL, in handle_cap_grant()
3525 ceph_check_caps(ci, CHECK_CAPS_NOINVAL, session); in handle_cap_grant()
3538 __releases(ci->i_ceph_lock) in handle_cap_flush_ack()
3540 struct ceph_inode_info *ci = ceph_inode(inode); in handle_cap_flush_ack() local
3551 list_for_each_entry_safe(cf, tmp_cf, &ci->i_cap_flush_list, i_list) { in handle_cap_flush_ack()
3565 wake_ci |= __detach_cap_flush_from_ci(ci, cf); in handle_cap_flush_ack()
3581 ceph_cap_string(cleaned), ceph_cap_string(ci->i_flushing_caps), in handle_cap_flush_ack()
3582 ceph_cap_string(ci->i_flushing_caps & ~cleaned)); in handle_cap_flush_ack()
3587 ci->i_flushing_caps &= ~cleaned; in handle_cap_flush_ack()
3594 if (ci->i_flushing_caps == 0) { in handle_cap_flush_ack()
3595 if (list_empty(&ci->i_cap_flush_list)) { in handle_cap_flush_ack()
3596 list_del_init(&ci->i_flushing_item); in handle_cap_flush_ack()
3608 if (ci->i_dirty_caps == 0) { in handle_cap_flush_ack()
3610 BUG_ON(!list_empty(&ci->i_dirty_item)); in handle_cap_flush_ack()
3612 if (ci->i_wr_ref == 0 && in handle_cap_flush_ack()
3613 ci->i_wrbuffer_ref_head == 0) { in handle_cap_flush_ack()
3614 BUG_ON(!ci->i_head_snapc); in handle_cap_flush_ack()
3615 ceph_put_snap_context(ci->i_head_snapc); in handle_cap_flush_ack()
3616 ci->i_head_snapc = NULL; in handle_cap_flush_ack()
3619 BUG_ON(list_empty(&ci->i_dirty_item)); in handle_cap_flush_ack()
3625 spin_unlock(&ci->i_ceph_lock); in handle_cap_flush_ack()
3635 wake_up_all(&ci->i_cap_wq); in handle_cap_flush_ack()
3652 struct ceph_inode_info *ci = ceph_inode(inode); in handle_cap_flushsnap_ack() local
3661 inode, ci, session->s_mds, follows); in handle_cap_flushsnap_ack()
3663 spin_lock(&ci->i_ceph_lock); in handle_cap_flushsnap_ack()
3664 list_for_each_entry(capsnap, &ci->i_cap_snaps, ci_item) { in handle_cap_flushsnap_ack()
3684 wake_ci |= __detach_cap_flush_from_ci(ci, &capsnap->cap_flush); in handle_cap_flushsnap_ack()
3688 if (list_empty(&ci->i_cap_flush_list)) in handle_cap_flushsnap_ack()
3689 list_del_init(&ci->i_flushing_item); in handle_cap_flushsnap_ack()
3695 spin_unlock(&ci->i_ceph_lock); in handle_cap_flushsnap_ack()
3700 wake_up_all(&ci->i_cap_wq); in handle_cap_flushsnap_ack()
3716 struct ceph_inode_info *ci = ceph_inode(inode); in handle_cap_trunc() local
3723 int dirty = __ceph_caps_dirty(ci); in handle_cap_trunc()
3727 lockdep_assert_held(&ci->i_ceph_lock); in handle_cap_trunc()
3753 struct ceph_inode_info *ci = ceph_inode(inode); in handle_cap_export() local
3771 inode, ci, mds, mseq, target); in handle_cap_export()
3773 spin_lock(&ci->i_ceph_lock); in handle_cap_export()
3774 cap = __get_cap_for_mds(ci, mds); in handle_cap_export()
3798 tcap = __get_cap_for_mds(ci, target); in handle_cap_export()
3809 if (cap == ci->i_auth_cap) { in handle_cap_export()
3810 ci->i_auth_cap = tcap; in handle_cap_export()
3811 change_auth_cap_ses(ci, tcap->session); in handle_cap_export()
3818 int flag = (cap == ci->i_auth_cap) ? CEPH_CAP_FLAG_AUTH : 0; in handle_cap_export()
3823 if (!list_empty(&ci->i_cap_flush_list) && in handle_cap_export()
3824 ci->i_auth_cap == tcap) { in handle_cap_export()
3826 list_move_tail(&ci->i_flushing_item, in handle_cap_export()
3835 spin_unlock(&ci->i_ceph_lock); in handle_cap_export()
3860 spin_unlock(&ci->i_ceph_lock); in handle_cap_export()
3881 struct ceph_inode_info *ci = ceph_inode(inode); in handle_cap_import() local
3903 inode, ci, mds, mseq, peer); in handle_cap_import()
3905 cap = __get_cap_for_mds(ci, mds); in handle_cap_import()
3908 spin_unlock(&ci->i_ceph_lock); in handle_cap_import()
3910 spin_lock(&ci->i_ceph_lock); in handle_cap_import()
3921 __ceph_caps_issued(ci, &issued); in handle_cap_import()
3922 issued |= __ceph_caps_dirty(ci); in handle_cap_import()
3927 ocap = peer >= 0 ? __get_cap_for_mds(ci, peer) : NULL; in handle_cap_import()
3960 struct ceph_inode_info *ci; in ceph_handle_caps() local
4072 ci = ceph_inode(inode); in ceph_handle_caps()
4121 spin_lock(&ci->i_ceph_lock); in ceph_handle_caps()
4132 spin_lock(&ci->i_ceph_lock); in ceph_handle_caps()
4138 spin_unlock(&ci->i_ceph_lock); in ceph_handle_caps()
4146 __ceph_caps_issued(ci, &extra_info.issued); in ceph_handle_caps()
4147 extra_info.issued |= __ceph_caps_dirty(ci); in ceph_handle_caps()
4159 spin_unlock(&ci->i_ceph_lock); in ceph_handle_caps()
4165 spin_unlock(&ci->i_ceph_lock); in ceph_handle_caps()
4199 struct ceph_inode_info *ci; in ceph_check_delayed_caps() local
4204 ci = list_first_entry(&mdsc->cap_delay_list, in ceph_check_delayed_caps()
4207 if ((ci->i_ceph_flags & CEPH_I_FLUSH) == 0 && in ceph_check_delayed_caps()
4208 time_before(jiffies, ci->i_hold_caps_max)) in ceph_check_delayed_caps()
4210 list_del_init(&ci->i_cap_delay_list); in ceph_check_delayed_caps()
4212 inode = igrab(&ci->vfs_inode); in ceph_check_delayed_caps()
4216 ceph_check_caps(ci, 0, NULL); in ceph_check_delayed_caps()
4231 struct ceph_inode_info *ci; in flush_dirty_session_caps() local
4237 ci = list_first_entry(&s->s_cap_dirty, struct ceph_inode_info, in flush_dirty_session_caps()
4239 inode = &ci->vfs_inode; in flush_dirty_session_caps()
4243 ceph_check_caps(ci, CHECK_CAPS_FLUSH, NULL); in flush_dirty_session_caps()
4280 void __ceph_touch_fmode(struct ceph_inode_info *ci, in __ceph_touch_fmode() argument
4285 ci->i_last_rd = now; in __ceph_touch_fmode()
4287 ci->i_last_wr = now; in __ceph_touch_fmode()
4290 __ceph_is_any_real_caps(ci) && in __ceph_touch_fmode()
4291 list_empty(&ci->i_cap_delay_list)) in __ceph_touch_fmode()
4292 __cap_delay_requeue(mdsc, ci); in __ceph_touch_fmode()
4295 void ceph_get_fmode(struct ceph_inode_info *ci, int fmode, int count) in ceph_get_fmode() argument
4297 struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(ci->vfs_inode.i_sb); in ceph_get_fmode()
4305 spin_lock(&ci->i_ceph_lock); in ceph_get_fmode()
4308 ci->i_nr_by_mode[i] += count; in ceph_get_fmode()
4315 if (i && ci->i_nr_by_mode[i] > 1) in ceph_get_fmode()
4321 spin_unlock(&ci->i_ceph_lock); in ceph_get_fmode()
4329 void ceph_put_fmode(struct ceph_inode_info *ci, int fmode, int count) in ceph_put_fmode() argument
4331 struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(ci->vfs_inode.i_sb); in ceph_put_fmode()
4339 spin_lock(&ci->i_ceph_lock); in ceph_put_fmode()
4342 BUG_ON(ci->i_nr_by_mode[i] < count); in ceph_put_fmode()
4343 ci->i_nr_by_mode[i] -= count; in ceph_put_fmode()
4351 if (i && ci->i_nr_by_mode[i]) in ceph_put_fmode()
4357 spin_unlock(&ci->i_ceph_lock); in ceph_put_fmode()
4368 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_drop_caps_for_unlink() local
4371 spin_lock(&ci->i_ceph_lock); in ceph_drop_caps_for_unlink()
4373 drop |= ~(__ceph_caps_wanted(ci) | CEPH_CAP_PIN); in ceph_drop_caps_for_unlink()
4375 if (__ceph_caps_dirty(ci)) { in ceph_drop_caps_for_unlink()
4378 __cap_delay_requeue_front(mdsc, ci); in ceph_drop_caps_for_unlink()
4381 spin_unlock(&ci->i_ceph_lock); in ceph_drop_caps_for_unlink()
4396 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_encode_inode_release() local
4402 spin_lock(&ci->i_ceph_lock); in ceph_encode_inode_release()
4403 used = __ceph_caps_used(ci); in ceph_encode_inode_release()
4404 dirty = __ceph_caps_dirty(ci); in ceph_encode_inode_release()
4413 cap = __get_cap_for_mds(ci, mds); in ceph_encode_inode_release()
4429 int wanted = __ceph_caps_wanted(ci); in ceph_encode_inode_release()
4440 if (cap == ci->i_auth_cap && in ceph_encode_inode_release()
4442 ci->i_requested_max_size = 0; in ceph_encode_inode_release()
4465 spin_unlock(&ci->i_ceph_lock); in ceph_encode_inode_release()