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->netfs.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->netfs.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->netfs.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->netfs.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->netfs.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->netfs.inode.i_mode)) { in __check_cap_issue()
587 dout(" marking %p NOT complete\n", &ci->netfs.inode); in __check_cap_issue()
588 __ceph_dir_clear_complete(ci); in __check_cap_issue()
593 if (S_ISDIR(ci->netfs.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 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()
757 wake_up_all(&ci->i_cap_wq); in ceph_add_cap()
775 "but STALE (gen %u vs %u)\n", &cap->ci->netfs.inode, in __cap_is_valid()
788 int __ceph_caps_issued(struct ceph_inode_info *ci, int *implemented) in __ceph_caps_issued() argument
790 int have = ci->i_snap_caps; in __ceph_caps_issued()
796 for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) { in __ceph_caps_issued()
801 &ci->netfs.inode, cap, ceph_cap_string(cap->issued)); in __ceph_caps_issued()
811 if (ci->i_auth_cap) { in __ceph_caps_issued()
812 cap = ci->i_auth_cap; in __ceph_caps_issued()
821 int __ceph_caps_issued_other(struct ceph_inode_info *ci, struct ceph_cap *ocap) in __ceph_caps_issued_other() argument
823 int have = ci->i_snap_caps; in __ceph_caps_issued_other()
827 for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) { in __ceph_caps_issued_other()
848 dout("__touch_cap %p cap %p mds%d\n", &cap->ci->netfs.inode, cap, in __touch_cap()
853 &cap->ci->netfs.inode, cap, s->s_mds); in __touch_cap()
863 int __ceph_caps_issued_mask(struct ceph_inode_info *ci, int mask, int touch) in __ceph_caps_issued_mask() argument
867 int have = ci->i_snap_caps; in __ceph_caps_issued_mask()
871 " (mask %s)\n", ceph_ino(&ci->netfs.inode), in __ceph_caps_issued_mask()
877 for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) { in __ceph_caps_issued_mask()
883 " (mask %s)\n", ceph_ino(&ci->netfs.inode), cap, in __ceph_caps_issued_mask()
895 " (mask %s)\n", ceph_ino(&ci->netfs.inode), in __ceph_caps_issued_mask()
903 for (q = rb_first(&ci->i_caps); q != p; in __ceph_caps_issued_mask()
920 int __ceph_caps_issued_mask_metric(struct ceph_inode_info *ci, int mask, in __ceph_caps_issued_mask_metric() argument
923 struct ceph_fs_client *fsc = ceph_sb_to_client(ci->netfs.inode.i_sb); in __ceph_caps_issued_mask_metric()
926 r = __ceph_caps_issued_mask(ci, mask, touch); in __ceph_caps_issued_mask_metric()
937 int __ceph_caps_revoking_other(struct ceph_inode_info *ci, in __ceph_caps_revoking_other() argument
943 for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) { in __ceph_caps_revoking_other()
952 int ceph_caps_revoking(struct ceph_inode_info *ci, int mask) in ceph_caps_revoking() argument
954 struct inode *inode = &ci->netfs.inode; in ceph_caps_revoking()
957 spin_lock(&ci->i_ceph_lock); in ceph_caps_revoking()
958 ret = __ceph_caps_revoking_other(ci, NULL, mask); in ceph_caps_revoking()
959 spin_unlock(&ci->i_ceph_lock); in ceph_caps_revoking()
965 int __ceph_caps_used(struct ceph_inode_info *ci) in __ceph_caps_used() argument
968 if (ci->i_pin_ref) in __ceph_caps_used()
970 if (ci->i_rd_ref) in __ceph_caps_used()
972 if (ci->i_rdcache_ref || in __ceph_caps_used()
973 (S_ISREG(ci->netfs.inode.i_mode) && in __ceph_caps_used()
974 ci->netfs.inode.i_data.nrpages)) in __ceph_caps_used()
976 if (ci->i_wr_ref) in __ceph_caps_used()
978 if (ci->i_wb_ref || ci->i_wrbuffer_ref) in __ceph_caps_used()
980 if (ci->i_fx_ref) in __ceph_caps_used()
990 int __ceph_caps_file_wanted(struct ceph_inode_info *ci) in __ceph_caps_file_wanted() argument
997 ceph_inode_to_client(&ci->netfs.inode)->mount_options; in __ceph_caps_file_wanted()
1001 if (S_ISDIR(ci->netfs.inode.i_mode)) { in __ceph_caps_file_wanted()
1005 if (ci->i_nr_by_mode[RD_SHIFT] > 0 || in __ceph_caps_file_wanted()
1006 time_after(ci->i_last_rd, used_cutoff)) in __ceph_caps_file_wanted()
1009 if (ci->i_nr_by_mode[WR_SHIFT] > 0 || in __ceph_caps_file_wanted()
1010 time_after(ci->i_last_wr, used_cutoff)) { in __ceph_caps_file_wanted()
1016 if (want || ci->i_nr_by_mode[PIN_SHIFT] > 0) in __ceph_caps_file_wanted()
1023 if (ci->i_nr_by_mode[RD_SHIFT] > 0) { in __ceph_caps_file_wanted()
1024 if (ci->i_nr_by_mode[RD_SHIFT] >= FMODE_WAIT_BIAS || in __ceph_caps_file_wanted()
1025 time_after(ci->i_last_rd, used_cutoff)) in __ceph_caps_file_wanted()
1027 } else if (time_after(ci->i_last_rd, idle_cutoff)) { in __ceph_caps_file_wanted()
1031 if (ci->i_nr_by_mode[WR_SHIFT] > 0) { in __ceph_caps_file_wanted()
1032 if (ci->i_nr_by_mode[WR_SHIFT] >= FMODE_WAIT_BIAS || in __ceph_caps_file_wanted()
1033 time_after(ci->i_last_wr, used_cutoff)) in __ceph_caps_file_wanted()
1035 } else if (time_after(ci->i_last_wr, idle_cutoff)) { in __ceph_caps_file_wanted()
1041 ci->i_nr_by_mode[LAZY_SHIFT] > 0) in __ceph_caps_file_wanted()
1051 int __ceph_caps_wanted(struct ceph_inode_info *ci) in __ceph_caps_wanted() argument
1053 int w = __ceph_caps_file_wanted(ci) | __ceph_caps_used(ci); in __ceph_caps_wanted()
1054 if (S_ISDIR(ci->netfs.inode.i_mode)) { in __ceph_caps_wanted()
1069 int __ceph_caps_mds_wanted(struct ceph_inode_info *ci, bool check) in __ceph_caps_mds_wanted() argument
1075 for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) { in __ceph_caps_mds_wanted()
1079 if (cap == ci->i_auth_cap) in __ceph_caps_mds_wanted()
1089 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_is_any_caps() local
1092 spin_lock(&ci->i_ceph_lock); in ceph_is_any_caps()
1093 ret = __ceph_is_any_real_caps(ci); in ceph_is_any_caps()
1094 spin_unlock(&ci->i_ceph_lock); in ceph_is_any_caps()
1108 struct ceph_inode_info *ci = cap->ci; in __ceph_remove_cap() local
1113 if (!ci) { in __ceph_remove_cap()
1118 lockdep_assert_held(&ci->i_ceph_lock); in __ceph_remove_cap()
1120 dout("__ceph_remove_cap %p from %p\n", cap, &ci->netfs.inode); in __ceph_remove_cap()
1122 mdsc = ceph_inode_to_client(&ci->netfs.inode)->mdsc; in __ceph_remove_cap()
1125 rb_erase(&cap->ci_node, &ci->i_caps); in __ceph_remove_cap()
1126 if (ci->i_auth_cap == cap) in __ceph_remove_cap()
1127 ci->i_auth_cap = NULL; in __ceph_remove_cap()
1143 cap->ci = NULL; in __ceph_remove_cap()
1160 cap->cap_ino = ci->i_vino.ino; in __ceph_remove_cap()
1167 if (!__ceph_is_any_real_caps(ci)) { in __ceph_remove_cap()
1172 if (ci->i_wr_ref == 0 && ci->i_snap_realm) in __ceph_remove_cap()
1173 ceph_change_snap_realm(&ci->netfs.inode, NULL); in __ceph_remove_cap()
1175 __cap_delay_cancel(mdsc, ci); in __ceph_remove_cap()
1181 struct ceph_inode_info *ci = cap->ci; in ceph_remove_cap() local
1185 if (!ci) { in ceph_remove_cap()
1190 lockdep_assert_held(&ci->i_ceph_lock); in ceph_remove_cap()
1192 fsc = ceph_inode_to_client(&ci->netfs.inode); in ceph_remove_cap()
1193 WARN_ON_ONCE(ci->i_auth_cap == cap && in ceph_remove_cap()
1194 !list_empty(&ci->i_dirty_item) && in ceph_remove_cap()
1196 !ceph_inode_is_shutdown(&ci->netfs.inode)); in ceph_remove_cap()
1318 void __ceph_remove_caps(struct ceph_inode_info *ci) in __ceph_remove_caps() argument
1324 spin_lock(&ci->i_ceph_lock); in __ceph_remove_caps()
1325 p = rb_first(&ci->i_caps); in __ceph_remove_caps()
1331 spin_unlock(&ci->i_ceph_lock); in __ceph_remove_caps()
1346 struct ceph_inode_info *ci = cap->ci; in __prep_cap() local
1347 struct inode *inode = &ci->netfs.inode; in __prep_cap()
1350 lockdep_assert_held(&ci->i_ceph_lock); in __prep_cap()
1362 ci->i_ceph_flags &= ~CEPH_I_FLUSH; in __prep_cap()
1377 arg->follows = flushing ? ci->i_head_snapc->seq : 0; in __prep_cap()
1382 ci->i_reported_size = arg->size; in __prep_cap()
1383 arg->max_size = ci->i_wanted_max_size; in __prep_cap()
1384 if (cap == ci->i_auth_cap) { in __prep_cap()
1386 ci->i_requested_max_size = arg->max_size; in __prep_cap()
1388 ci->i_requested_max_size = 0; in __prep_cap()
1392 arg->old_xattr_buf = __ceph_build_xattrs_blob(ci); in __prep_cap()
1393 arg->xattr_version = ci->i_xattrs.version; in __prep_cap()
1394 arg->xattr_buf = ci->i_xattrs.blob; in __prep_cap()
1403 arg->btime = ci->i_btime; in __prep_cap()
1414 arg->time_warp_seq = ci->i_time_warp_seq; in __prep_cap()
1420 arg->inline_data = ci->i_inline_version != CEPH_INLINE_NONE; in __prep_cap()
1422 !list_empty(&ci->i_cap_snaps)) { in __prep_cap()
1424 list_for_each_entry_reverse(capsnap, &ci->i_cap_snaps, ci_item) { in __prep_cap()
1441 static void __send_cap(struct cap_msg_args *arg, struct ceph_inode_info *ci) in __send_cap() argument
1444 struct inode *inode = &ci->netfs.inode; in __send_cap()
1451 spin_lock(&ci->i_ceph_lock); in __send_cap()
1452 __cap_delay_requeue(arg->session->s_mdsc, ci); in __send_cap()
1453 spin_unlock(&ci->i_ceph_lock); in __send_cap()
1461 wake_up_all(&ci->i_cap_wq); in __send_cap()
1527 static void __ceph_flush_snaps(struct ceph_inode_info *ci, in __ceph_flush_snaps() argument
1529 __releases(ci->i_ceph_lock) in __ceph_flush_snaps()
1530 __acquires(ci->i_ceph_lock) in __ceph_flush_snaps()
1532 struct inode *inode = &ci->netfs.inode; in __ceph_flush_snaps()
1540 list_for_each_entry(capsnap, &ci->i_cap_snaps, ci_item) { in __ceph_flush_snaps()
1563 if (list_empty(&ci->i_flushing_item)) { in __ceph_flush_snaps()
1564 list_add_tail(&ci->i_flushing_item, in __ceph_flush_snaps()
1570 &ci->i_cap_flush_list); in __ceph_flush_snaps()
1577 ci->i_ceph_flags &= ~CEPH_I_FLUSH_SNAPS; in __ceph_flush_snaps()
1580 struct ceph_cap *cap = ci->i_auth_cap; in __ceph_flush_snaps()
1591 list_for_each_entry(iter, &ci->i_cap_flush_list, i_list) { in __ceph_flush_snaps()
1605 spin_unlock(&ci->i_ceph_lock); in __ceph_flush_snaps()
1619 spin_lock(&ci->i_ceph_lock); in __ceph_flush_snaps()
1623 void ceph_flush_snaps(struct ceph_inode_info *ci, in ceph_flush_snaps() argument
1626 struct inode *inode = &ci->netfs.inode; in ceph_flush_snaps()
1635 spin_lock(&ci->i_ceph_lock); in ceph_flush_snaps()
1636 if (!(ci->i_ceph_flags & CEPH_I_FLUSH_SNAPS)) { in ceph_flush_snaps()
1640 if (!ci->i_auth_cap) { in ceph_flush_snaps()
1645 mds = ci->i_auth_cap->session->s_mds; in ceph_flush_snaps()
1652 spin_unlock(&ci->i_ceph_lock); in ceph_flush_snaps()
1660 if (ci->i_ceph_flags & CEPH_I_KICK_FLUSH) in ceph_flush_snaps()
1661 __kick_flushing_caps(mdsc, session, ci, 0); in ceph_flush_snaps()
1663 __ceph_flush_snaps(ci, session); in ceph_flush_snaps()
1665 spin_unlock(&ci->i_ceph_lock); in ceph_flush_snaps()
1673 list_del_init(&ci->i_snap_flush_item); in ceph_flush_snaps()
1682 int __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask, in __ceph_mark_dirty_caps() argument
1686 ceph_sb_to_client(ci->netfs.inode.i_sb)->mdsc; in __ceph_mark_dirty_caps()
1687 struct inode *inode = &ci->netfs.inode; in __ceph_mark_dirty_caps()
1688 int was = ci->i_dirty_caps; in __ceph_mark_dirty_caps()
1691 lockdep_assert_held(&ci->i_ceph_lock); in __ceph_mark_dirty_caps()
1693 if (!ci->i_auth_cap) { in __ceph_mark_dirty_caps()
1700 dout("__mark_dirty_caps %p %s dirty %s -> %s\n", &ci->netfs.inode, in __ceph_mark_dirty_caps()
1703 ci->i_dirty_caps |= mask; in __ceph_mark_dirty_caps()
1705 struct ceph_mds_session *session = ci->i_auth_cap->session; in __ceph_mark_dirty_caps()
1707 WARN_ON_ONCE(ci->i_prealloc_cap_flush); in __ceph_mark_dirty_caps()
1708 swap(ci->i_prealloc_cap_flush, *pcf); in __ceph_mark_dirty_caps()
1710 if (!ci->i_head_snapc) { in __ceph_mark_dirty_caps()
1712 ci->i_head_snapc = ceph_get_snap_context( in __ceph_mark_dirty_caps()
1713 ci->i_snap_realm->cached_context); in __ceph_mark_dirty_caps()
1716 &ci->netfs.inode, ci->i_head_snapc, ci->i_auth_cap); in __ceph_mark_dirty_caps()
1717 BUG_ON(!list_empty(&ci->i_dirty_item)); in __ceph_mark_dirty_caps()
1719 list_add(&ci->i_dirty_item, &session->s_cap_dirty); in __ceph_mark_dirty_caps()
1721 if (ci->i_flushing_caps == 0) { in __ceph_mark_dirty_caps()
1726 WARN_ON_ONCE(!ci->i_prealloc_cap_flush); in __ceph_mark_dirty_caps()
1728 BUG_ON(list_empty(&ci->i_dirty_item)); in __ceph_mark_dirty_caps()
1729 if (((was | ci->i_flushing_caps) & CEPH_CAP_FILE_BUFFER) && in __ceph_mark_dirty_caps()
1732 __cap_delay_requeue(mdsc, ci); in __ceph_mark_dirty_caps()
1784 static bool __detach_cap_flush_from_ci(struct ceph_inode_info *ci, in __detach_cap_flush_from_ci() argument
1790 if (wake && cf->i_list.prev != &ci->i_cap_flush_list) { in __detach_cap_flush_from_ci()
1810 struct ceph_inode_info *ci = ceph_inode(inode); in __mark_caps_flushing() local
1814 lockdep_assert_held(&ci->i_ceph_lock); in __mark_caps_flushing()
1815 BUG_ON(ci->i_dirty_caps == 0); in __mark_caps_flushing()
1816 BUG_ON(list_empty(&ci->i_dirty_item)); in __mark_caps_flushing()
1817 BUG_ON(!ci->i_prealloc_cap_flush); in __mark_caps_flushing()
1819 flushing = ci->i_dirty_caps; in __mark_caps_flushing()
1822 ceph_cap_string(ci->i_flushing_caps), in __mark_caps_flushing()
1823 ceph_cap_string(ci->i_flushing_caps | flushing)); in __mark_caps_flushing()
1824 ci->i_flushing_caps |= flushing; in __mark_caps_flushing()
1825 ci->i_dirty_caps = 0; in __mark_caps_flushing()
1828 swap(cf, ci->i_prealloc_cap_flush); in __mark_caps_flushing()
1833 list_del_init(&ci->i_dirty_item); in __mark_caps_flushing()
1839 if (list_empty(&ci->i_flushing_item)) { in __mark_caps_flushing()
1840 list_add_tail(&ci->i_flushing_item, &session->s_cap_flushing); in __mark_caps_flushing()
1845 list_add_tail(&cf->i_list, &ci->i_cap_flush_list); in __mark_caps_flushing()
1854 __releases(ci->i_ceph_lock) in try_nonblocking_invalidate()
1855 __acquires(ci->i_ceph_lock) in try_nonblocking_invalidate()
1857 struct ceph_inode_info *ci = ceph_inode(inode); in try_nonblocking_invalidate() local
1858 u32 invalidating_gen = ci->i_rdcache_gen; in try_nonblocking_invalidate()
1860 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 = i_size_read(&ci->netfs.inode); 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->netfs.inode; in ceph_check_caps()
1920 spin_lock(&ci->i_ceph_lock); in ceph_check_caps()
1921 if (ci->i_ceph_flags & CEPH_I_ASYNC_CREATE) { in ceph_check_caps()
1923 spin_unlock(&ci->i_ceph_lock); in ceph_check_caps()
1928 if (ci->i_ceph_flags & CEPH_I_FLUSH) in ceph_check_caps()
1932 file_wanted = __ceph_caps_file_wanted(ci); in ceph_check_caps()
1935 used = __ceph_caps_used(ci); in ceph_check_caps()
1943 issued = __ceph_caps_issued(ci, &implemented); in ceph_check_caps()
1955 __ceph_dir_is_complete(ci)) { in ceph_check_caps()
1976 if (ci->i_max_size == 0) in ceph_check_caps()
1984 ceph_cap_string(used), ceph_cap_string(ci->i_dirty_caps), in ceph_check_caps()
1985 ceph_cap_string(ci->i_flushing_caps), in ceph_check_caps()
1999 !(ci->i_wb_ref || ci->i_wrbuffer_ref) && /* no dirty pages... */ in ceph_check_caps()
2009 ci->i_rdcache_revoking = ci->i_rdcache_gen; in ceph_check_caps()
2015 for (p = rb_first(&ci->i_caps); p; p = rb_next(p)) { in ceph_check_caps()
2023 ((flags & CHECK_CAPS_AUTHONLY) && cap != ci->i_auth_cap)) in ceph_check_caps()
2031 if (ci->i_auth_cap && cap != ci->i_auth_cap) in ceph_check_caps()
2032 cap_used &= ~ci->i_auth_cap->issued; in ceph_check_caps()
2041 if (cap == ci->i_auth_cap && in ceph_check_caps()
2044 if (ci->i_wanted_max_size > ci->i_max_size && in ceph_check_caps()
2045 ci->i_wanted_max_size > ci->i_requested_max_size) { in ceph_check_caps()
2051 if (__ceph_should_report_size(ci)) { in ceph_check_caps()
2057 if (cap == ci->i_auth_cap) { in ceph_check_caps()
2058 if ((flags & CHECK_CAPS_FLUSH) && ci->i_dirty_caps) { in ceph_check_caps()
2062 if (ci->i_ceph_flags & CEPH_I_FLUSH_SNAPS) { in ceph_check_caps()
2087 if (S_ISREG(inode->i_mode) && ci->i_wrbuffer_ref && in ceph_check_caps()
2110 if (cap == ci->i_auth_cap && in ceph_check_caps()
2111 (ci->i_ceph_flags & in ceph_check_caps()
2113 if (ci->i_ceph_flags & CEPH_I_KICK_FLUSH) in ceph_check_caps()
2114 __kick_flushing_caps(mdsc, session, ci, 0); in ceph_check_caps()
2115 if (ci->i_ceph_flags & CEPH_I_FLUSH_SNAPS) in ceph_check_caps()
2116 __ceph_flush_snaps(ci, session); in ceph_check_caps()
2121 if (cap == ci->i_auth_cap && ci->i_dirty_caps) { in ceph_check_caps()
2122 flushing = ci->i_dirty_caps; in ceph_check_caps()
2141 spin_unlock(&ci->i_ceph_lock); in ceph_check_caps()
2142 __send_cap(&arg, ci); in ceph_check_caps()
2143 spin_lock(&ci->i_ceph_lock); in ceph_check_caps()
2149 if (__ceph_is_any_real_caps(ci) && in ceph_check_caps()
2150 list_empty(&ci->i_cap_delay_list) && in ceph_check_caps()
2153 __cap_delay_requeue(mdsc, ci); in ceph_check_caps()
2156 spin_unlock(&ci->i_ceph_lock); in ceph_check_caps()
2171 struct ceph_inode_info *ci = ceph_inode(inode); in try_flush_caps() local
2175 spin_lock(&ci->i_ceph_lock); in try_flush_caps()
2177 if (ci->i_dirty_caps && ci->i_auth_cap) { in try_flush_caps()
2178 struct ceph_cap *cap = ci->i_auth_cap; in try_flush_caps()
2183 spin_unlock(&ci->i_ceph_lock); in try_flush_caps()
2187 if (ci->i_ceph_flags & in try_flush_caps()
2189 if (ci->i_ceph_flags & CEPH_I_KICK_FLUSH) in try_flush_caps()
2190 __kick_flushing_caps(mdsc, session, ci, 0); in try_flush_caps()
2191 if (ci->i_ceph_flags & CEPH_I_FLUSH_SNAPS) in try_flush_caps()
2192 __ceph_flush_snaps(ci, session); in try_flush_caps()
2196 flushing = ci->i_dirty_caps; in try_flush_caps()
2201 __ceph_caps_used(ci), __ceph_caps_wanted(ci), in try_flush_caps()
2204 spin_unlock(&ci->i_ceph_lock); in try_flush_caps()
2206 __send_cap(&arg, ci); in try_flush_caps()
2208 if (!list_empty(&ci->i_cap_flush_list)) { in try_flush_caps()
2210 list_last_entry(&ci->i_cap_flush_list, in try_flush_caps()
2215 flushing = ci->i_flushing_caps; in try_flush_caps()
2216 spin_unlock(&ci->i_ceph_lock); in try_flush_caps()
2228 struct ceph_inode_info *ci = ceph_inode(inode); in caps_are_flushed() local
2231 spin_lock(&ci->i_ceph_lock); in caps_are_flushed()
2232 if (!list_empty(&ci->i_cap_flush_list)) { in caps_are_flushed()
2234 list_first_entry(&ci->i_cap_flush_list, in caps_are_flushed()
2239 spin_unlock(&ci->i_ceph_lock); in caps_are_flushed()
2249 struct ceph_inode_info *ci = ceph_inode(inode); in flush_mdlog_and_wait_inode_unsafe_requests() local
2253 spin_lock(&ci->i_unsafe_lock); in flush_mdlog_and_wait_inode_unsafe_requests()
2254 if (S_ISDIR(inode->i_mode) && !list_empty(&ci->i_unsafe_dirops)) { in flush_mdlog_and_wait_inode_unsafe_requests()
2255 req1 = list_last_entry(&ci->i_unsafe_dirops, in flush_mdlog_and_wait_inode_unsafe_requests()
2260 if (!list_empty(&ci->i_unsafe_iops)) { in flush_mdlog_and_wait_inode_unsafe_requests()
2261 req2 = list_last_entry(&ci->i_unsafe_iops, in flush_mdlog_and_wait_inode_unsafe_requests()
2266 spin_unlock(&ci->i_unsafe_lock); in flush_mdlog_and_wait_inode_unsafe_requests()
2290 spin_lock(&ci->i_unsafe_lock); in flush_mdlog_and_wait_inode_unsafe_requests()
2292 list_for_each_entry(req, &ci->i_unsafe_dirops, in flush_mdlog_and_wait_inode_unsafe_requests()
2304 list_for_each_entry(req, &ci->i_unsafe_iops, in flush_mdlog_and_wait_inode_unsafe_requests()
2315 spin_unlock(&ci->i_unsafe_lock); in flush_mdlog_and_wait_inode_unsafe_requests()
2318 spin_lock(&ci->i_ceph_lock); in flush_mdlog_and_wait_inode_unsafe_requests()
2319 if (ci->i_auth_cap) { in flush_mdlog_and_wait_inode_unsafe_requests()
2320 s = ci->i_auth_cap->session; in flush_mdlog_and_wait_inode_unsafe_requests()
2324 spin_unlock(&ci->i_ceph_lock); in flush_mdlog_and_wait_inode_unsafe_requests()
2364 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_fsync() local
2390 err = wait_event_interruptible(ci->i_cap_wq, in ceph_fsync()
2413 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_write_inode() local
2427 err = wait_event_interruptible(ci->i_cap_wq, in ceph_write_inode()
2433 spin_lock(&ci->i_ceph_lock); in ceph_write_inode()
2434 if (__ceph_caps_dirty(ci)) in ceph_write_inode()
2435 __cap_delay_requeue_front(mdsc, ci); in ceph_write_inode()
2436 spin_unlock(&ci->i_ceph_lock); in ceph_write_inode()
2443 struct ceph_inode_info *ci, in __kick_flushing_caps() argument
2445 __releases(ci->i_ceph_lock) in __kick_flushing_caps()
2446 __acquires(ci->i_ceph_lock) in __kick_flushing_caps()
2448 struct inode *inode = &ci->netfs.inode; in __kick_flushing_caps()
2456 if (ci->i_ceph_flags & CEPH_I_ASYNC_CREATE) in __kick_flushing_caps()
2459 ci->i_ceph_flags &= ~CEPH_I_KICK_FLUSH; in __kick_flushing_caps()
2461 list_for_each_entry_reverse(cf, &ci->i_cap_flush_list, i_list) { in __kick_flushing_caps()
2468 list_for_each_entry(cf, &ci->i_cap_flush_list, i_list) { in __kick_flushing_caps()
2472 cap = ci->i_auth_cap; in __kick_flushing_caps()
2489 __ceph_caps_used(ci), in __kick_flushing_caps()
2490 __ceph_caps_wanted(ci), in __kick_flushing_caps()
2493 spin_unlock(&ci->i_ceph_lock); in __kick_flushing_caps()
2494 __send_cap(&arg, ci); in __kick_flushing_caps()
2504 spin_unlock(&ci->i_ceph_lock); in __kick_flushing_caps()
2519 spin_lock(&ci->i_ceph_lock); in __kick_flushing_caps()
2526 struct ceph_inode_info *ci; in ceph_early_kick_flushing_caps() local
2536 list_for_each_entry(ci, &session->s_cap_flushing, i_flushing_item) { in ceph_early_kick_flushing_caps()
2537 spin_lock(&ci->i_ceph_lock); in ceph_early_kick_flushing_caps()
2538 cap = ci->i_auth_cap; in ceph_early_kick_flushing_caps()
2541 &ci->netfs.inode, cap, session->s_mds); in ceph_early_kick_flushing_caps()
2542 spin_unlock(&ci->i_ceph_lock); in ceph_early_kick_flushing_caps()
2553 if ((cap->issued & ci->i_flushing_caps) != in ceph_early_kick_flushing_caps()
2554 ci->i_flushing_caps) { in ceph_early_kick_flushing_caps()
2561 __kick_flushing_caps(mdsc, session, ci, in ceph_early_kick_flushing_caps()
2564 ci->i_ceph_flags |= CEPH_I_KICK_FLUSH; in ceph_early_kick_flushing_caps()
2567 spin_unlock(&ci->i_ceph_lock); in ceph_early_kick_flushing_caps()
2574 struct ceph_inode_info *ci; in ceph_kick_flushing_caps() local
2586 list_for_each_entry(ci, &session->s_cap_flushing, i_flushing_item) { in ceph_kick_flushing_caps()
2587 spin_lock(&ci->i_ceph_lock); in ceph_kick_flushing_caps()
2588 cap = ci->i_auth_cap; in ceph_kick_flushing_caps()
2591 &ci->netfs.inode, cap, session->s_mds); in ceph_kick_flushing_caps()
2592 spin_unlock(&ci->i_ceph_lock); in ceph_kick_flushing_caps()
2595 if (ci->i_ceph_flags & CEPH_I_KICK_FLUSH) { in ceph_kick_flushing_caps()
2596 __kick_flushing_caps(mdsc, session, ci, in ceph_kick_flushing_caps()
2599 spin_unlock(&ci->i_ceph_lock); in ceph_kick_flushing_caps()
2604 struct ceph_inode_info *ci) in ceph_kick_flushing_inode_caps() argument
2607 struct ceph_cap *cap = ci->i_auth_cap; in ceph_kick_flushing_inode_caps()
2609 lockdep_assert_held(&ci->i_ceph_lock); in ceph_kick_flushing_inode_caps()
2611 dout("%s %p flushing %s\n", __func__, &ci->netfs.inode, in ceph_kick_flushing_inode_caps()
2612 ceph_cap_string(ci->i_flushing_caps)); in ceph_kick_flushing_inode_caps()
2614 if (!list_empty(&ci->i_cap_flush_list)) { in ceph_kick_flushing_inode_caps()
2617 list_move_tail(&ci->i_flushing_item, in ceph_kick_flushing_inode_caps()
2622 __kick_flushing_caps(mdsc, session, ci, oldest_flush_tid); in ceph_kick_flushing_inode_caps()
2631 void ceph_take_cap_refs(struct ceph_inode_info *ci, int got, in ceph_take_cap_refs() argument
2634 lockdep_assert_held(&ci->i_ceph_lock); in ceph_take_cap_refs()
2637 ci->i_pin_ref++; in ceph_take_cap_refs()
2639 ci->i_rd_ref++; in ceph_take_cap_refs()
2641 ci->i_rdcache_ref++; in ceph_take_cap_refs()
2643 ci->i_fx_ref++; in ceph_take_cap_refs()
2645 if (ci->i_wr_ref == 0 && !ci->i_head_snapc) { in ceph_take_cap_refs()
2647 ci->i_head_snapc = ceph_get_snap_context( in ceph_take_cap_refs()
2648 ci->i_snap_realm->cached_context); in ceph_take_cap_refs()
2650 ci->i_wr_ref++; in ceph_take_cap_refs()
2653 if (ci->i_wb_ref == 0) in ceph_take_cap_refs()
2654 ihold(&ci->netfs.inode); in ceph_take_cap_refs()
2655 ci->i_wb_ref++; in ceph_take_cap_refs()
2657 &ci->netfs.inode, ci->i_wb_ref-1, ci->i_wb_ref); in ceph_take_cap_refs()
2683 struct ceph_inode_info *ci = ceph_inode(inode); in try_get_cap_refs() local
2693 spin_lock(&ci->i_ceph_lock); in try_get_cap_refs()
2696 (ci->i_ceph_flags & CEPH_I_ERROR_FILELOCK)) { in try_get_cap_refs()
2703 while (ci->i_truncate_pending) { in try_get_cap_refs()
2704 spin_unlock(&ci->i_ceph_lock); in try_get_cap_refs()
2710 spin_lock(&ci->i_ceph_lock); in try_get_cap_refs()
2713 have = __ceph_caps_issued(ci, &implemented); in try_get_cap_refs()
2716 if (endoff >= 0 && endoff > (loff_t)ci->i_max_size) { in try_get_cap_refs()
2718 inode, endoff, ci->i_max_size); in try_get_cap_refs()
2719 if (endoff > ci->i_requested_max_size) in try_get_cap_refs()
2720 ret = ci->i_auth_cap ? -EFBIG : -EUCLEAN; in try_get_cap_refs()
2727 if (__ceph_have_pending_cap_snap(ci)) { in try_get_cap_refs()
2751 !ci->i_head_snapc && in try_get_cap_refs()
2763 spin_unlock(&ci->i_ceph_lock); in try_get_cap_refs()
2774 ceph_take_cap_refs(ci, *got, true); in try_get_cap_refs()
2780 if (ci->i_auth_cap && in try_get_cap_refs()
2782 struct ceph_mds_session *s = ci->i_auth_cap->session; in try_get_cap_refs()
2789 inode, ceph_cap_string(need), ci->i_auth_cap->mds); in try_get_cap_refs()
2799 mds_wanted = __ceph_caps_mds_wanted(ci, false); in try_get_cap_refs()
2813 __ceph_touch_fmode(ci, mdsc, flags); in try_get_cap_refs()
2815 spin_unlock(&ci->i_ceph_lock); in try_get_cap_refs()
2836 struct ceph_inode_info *ci = ceph_inode(inode); in check_max_size() local
2840 spin_lock(&ci->i_ceph_lock); in check_max_size()
2841 if (endoff >= ci->i_max_size && endoff > ci->i_wanted_max_size) { in check_max_size()
2844 ci->i_wanted_max_size = endoff; in check_max_size()
2847 if (ci->i_auth_cap && in check_max_size()
2848 (ci->i_auth_cap->issued & CEPH_CAP_FILE_WR) && in check_max_size()
2849 ci->i_wanted_max_size > ci->i_max_size && in check_max_size()
2850 ci->i_wanted_max_size > ci->i_requested_max_size) in check_max_size()
2852 spin_unlock(&ci->i_ceph_lock); in check_max_size()
2854 ceph_check_caps(ci, CHECK_CAPS_AUTHONLY, NULL); in check_max_size()
2902 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_get_caps() local
2939 ceph_get_fmode(ci, flags, FMODE_WAIT_BIAS); in ceph_get_caps()
2940 add_wait_queue(&ci->i_cap_wq, &wait); in ceph_get_caps()
2952 remove_wait_queue(&ci->i_cap_wq, &wait); in ceph_get_caps()
2953 ceph_put_fmode(ci, flags, FMODE_WAIT_BIAS); in ceph_get_caps()
2966 ceph_put_cap_refs(ci, _got); in ceph_get_caps()
2989 if (S_ISREG(ci->netfs.inode.i_mode) && in ceph_get_caps()
2990 ceph_has_inline_data(ci) && in ceph_get_caps()
3006 ceph_put_cap_refs(ci, _got); in ceph_get_caps()
3030 void ceph_get_cap_refs(struct ceph_inode_info *ci, int caps) in ceph_get_cap_refs() argument
3032 spin_lock(&ci->i_ceph_lock); in ceph_get_cap_refs()
3033 ceph_take_cap_refs(ci, caps, false); in ceph_get_cap_refs()
3034 spin_unlock(&ci->i_ceph_lock); in ceph_get_cap_refs()
3042 static int ceph_try_drop_cap_snap(struct ceph_inode_info *ci, in ceph_try_drop_cap_snap() argument
3051 if (!list_is_last(&capsnap->ci_item, &ci->i_cap_snaps)) in ceph_try_drop_cap_snap()
3052 ci->i_ceph_flags |= CEPH_I_FLUSH_SNAPS; in ceph_try_drop_cap_snap()
3076 static void __ceph_put_cap_refs(struct ceph_inode_info *ci, int had, in __ceph_put_cap_refs() argument
3079 struct inode *inode = &ci->netfs.inode; in __ceph_put_cap_refs()
3083 spin_lock(&ci->i_ceph_lock); in __ceph_put_cap_refs()
3085 --ci->i_pin_ref; in __ceph_put_cap_refs()
3087 if (--ci->i_rd_ref == 0) in __ceph_put_cap_refs()
3090 if (--ci->i_rdcache_ref == 0) in __ceph_put_cap_refs()
3093 if (--ci->i_fx_ref == 0) in __ceph_put_cap_refs()
3096 if (--ci->i_wb_ref == 0) { in __ceph_put_cap_refs()
3103 inode, ci->i_wb_ref+1, ci->i_wb_ref); in __ceph_put_cap_refs()
3106 if (--ci->i_wr_ref == 0) { in __ceph_put_cap_refs()
3109 if (ci->i_wrbuffer_ref_head == 0 && in __ceph_put_cap_refs()
3110 ci->i_dirty_caps == 0 && in __ceph_put_cap_refs()
3111 ci->i_flushing_caps == 0) { in __ceph_put_cap_refs()
3112 BUG_ON(!ci->i_head_snapc); in __ceph_put_cap_refs()
3113 ceph_put_snap_context(ci->i_head_snapc); in __ceph_put_cap_refs()
3114 ci->i_head_snapc = NULL; in __ceph_put_cap_refs()
3117 if (!__ceph_is_any_real_caps(ci) && ci->i_snap_realm) in __ceph_put_cap_refs()
3121 if (check_flushsnaps && __ceph_have_pending_cap_snap(ci)) { in __ceph_put_cap_refs()
3123 list_last_entry(&ci->i_cap_snaps, in __ceph_put_cap_refs()
3128 if (ceph_try_drop_cap_snap(ci, capsnap)) in __ceph_put_cap_refs()
3131 else if (__ceph_finish_cap_snap(ci, capsnap)) in __ceph_put_cap_refs()
3135 spin_unlock(&ci->i_ceph_lock); in __ceph_put_cap_refs()
3143 ceph_check_caps(ci, 0, NULL); in __ceph_put_cap_refs()
3145 ceph_flush_snaps(ci, NULL); in __ceph_put_cap_refs()
3157 wake_up_all(&ci->i_cap_wq); in __ceph_put_cap_refs()
3162 void ceph_put_cap_refs(struct ceph_inode_info *ci, int had) in ceph_put_cap_refs() argument
3164 __ceph_put_cap_refs(ci, had, PUT_CAP_REFS_SYNC); in ceph_put_cap_refs()
3167 void ceph_put_cap_refs_async(struct ceph_inode_info *ci, int had) in ceph_put_cap_refs_async() argument
3169 __ceph_put_cap_refs(ci, had, PUT_CAP_REFS_ASYNC); in ceph_put_cap_refs_async()
3172 void ceph_put_cap_refs_no_check_caps(struct ceph_inode_info *ci, int had) in ceph_put_cap_refs_no_check_caps() argument
3174 __ceph_put_cap_refs(ci, had, PUT_CAP_REFS_NO_CHECK); in ceph_put_cap_refs_no_check_caps()
3184 void ceph_put_wrbuffer_cap_refs(struct ceph_inode_info *ci, int nr, in ceph_put_wrbuffer_cap_refs() argument
3187 struct inode *inode = &ci->netfs.inode; in ceph_put_wrbuffer_cap_refs()
3194 spin_lock(&ci->i_ceph_lock); in ceph_put_wrbuffer_cap_refs()
3195 ci->i_wrbuffer_ref -= nr; in ceph_put_wrbuffer_cap_refs()
3196 if (ci->i_wrbuffer_ref == 0) { in ceph_put_wrbuffer_cap_refs()
3201 if (ci->i_head_snapc == snapc) { in ceph_put_wrbuffer_cap_refs()
3202 ci->i_wrbuffer_ref_head -= nr; in ceph_put_wrbuffer_cap_refs()
3203 if (ci->i_wrbuffer_ref_head == 0 && in ceph_put_wrbuffer_cap_refs()
3204 ci->i_wr_ref == 0 && in ceph_put_wrbuffer_cap_refs()
3205 ci->i_dirty_caps == 0 && in ceph_put_wrbuffer_cap_refs()
3206 ci->i_flushing_caps == 0) { in ceph_put_wrbuffer_cap_refs()
3207 BUG_ON(!ci->i_head_snapc); in ceph_put_wrbuffer_cap_refs()
3208 ceph_put_snap_context(ci->i_head_snapc); in ceph_put_wrbuffer_cap_refs()
3209 ci->i_head_snapc = NULL; in ceph_put_wrbuffer_cap_refs()
3213 ci->i_wrbuffer_ref+nr, ci->i_wrbuffer_ref_head+nr, in ceph_put_wrbuffer_cap_refs()
3214 ci->i_wrbuffer_ref, ci->i_wrbuffer_ref_head, in ceph_put_wrbuffer_cap_refs()
3217 list_for_each_entry(iter, &ci->i_cap_snaps, ci_item) { in ceph_put_wrbuffer_cap_refs()
3229 WARN_ON_ONCE(ci->i_auth_cap); in ceph_put_wrbuffer_cap_refs()
3237 if (ceph_try_drop_cap_snap(ci, capsnap)) { in ceph_put_wrbuffer_cap_refs()
3240 ci->i_ceph_flags |= CEPH_I_FLUSH_SNAPS; in ceph_put_wrbuffer_cap_refs()
3248 ci->i_wrbuffer_ref+nr, capsnap->dirty_pages + nr, in ceph_put_wrbuffer_cap_refs()
3249 ci->i_wrbuffer_ref, capsnap->dirty_pages, in ceph_put_wrbuffer_cap_refs()
3255 spin_unlock(&ci->i_ceph_lock); in ceph_put_wrbuffer_cap_refs()
3258 ceph_check_caps(ci, 0, NULL); in ceph_put_wrbuffer_cap_refs()
3260 ceph_flush_snaps(ci, NULL); in ceph_put_wrbuffer_cap_refs()
3263 wake_up_all(&ci->i_cap_wq); in ceph_put_wrbuffer_cap_refs()
3329 __releases(ci->i_ceph_lock) in handle_cap_grant()
3332 struct ceph_inode_info *ci = ceph_inode(inode); in handle_cap_grant() local
3361 !(ci->i_wrbuffer_ref || ci->i_wb_ref)) { in handle_cap_grant()
3365 if (ci->i_rdcache_revoking != ci->i_rdcache_gen) { in handle_cap_grant()
3367 ci->i_rdcache_revoking = ci->i_rdcache_gen; in handle_cap_grant()
3384 WARN_ON(cap != ci->i_auth_cap); in handle_cap_grant()
3394 __check_cap_issue(ci, cap, newcaps); in handle_cap_grant()
3409 ci->i_btime = extra_info->btime; in handle_cap_grant()
3427 if (version > ci->i_xattrs.version) { in handle_cap_grant()
3430 if (ci->i_xattrs.blob) in handle_cap_grant()
3431 ceph_buffer_put(ci->i_xattrs.blob); in handle_cap_grant()
3432 ci->i_xattrs.blob = ceph_buffer_get(xattr_buf); in handle_cap_grant()
3433 ci->i_xattrs.version = version; in handle_cap_grant()
3451 ci->i_files = extra_info->nfiles; in handle_cap_grant()
3452 ci->i_subdirs = extra_info->nsubdirs; in handle_cap_grant()
3457 s64 old_pool = ci->i_layout.pool_id; in handle_cap_grant()
3460 ceph_file_layout_from_legacy(&ci->i_layout, &grant->layout); in handle_cap_grant()
3461 old_ns = rcu_dereference_protected(ci->i_layout.pool_ns, in handle_cap_grant()
3462 lockdep_is_held(&ci->i_ceph_lock)); in handle_cap_grant()
3463 rcu_assign_pointer(ci->i_layout.pool_ns, extra_info->pool_ns); in handle_cap_grant()
3465 if (ci->i_layout.pool_id != old_pool || in handle_cap_grant()
3467 ci->i_ceph_flags &= ~CEPH_I_POOL_PERM; in handle_cap_grant()
3478 if (ci->i_auth_cap == cap && (newcaps & CEPH_CAP_ANY_FILE_WR)) { in handle_cap_grant()
3479 if (max_size != ci->i_max_size) { in handle_cap_grant()
3481 ci->i_max_size, max_size); in handle_cap_grant()
3482 ci->i_max_size = max_size; in handle_cap_grant()
3483 if (max_size >= ci->i_wanted_max_size) { in handle_cap_grant()
3484 ci->i_wanted_max_size = 0; /* reset */ in handle_cap_grant()
3485 ci->i_requested_max_size = 0; in handle_cap_grant()
3492 wanted = __ceph_caps_wanted(ci); in handle_cap_grant()
3493 used = __ceph_caps_used(ci); in handle_cap_grant()
3494 dirty = __ceph_caps_dirty(ci); in handle_cap_grant()
3530 else if (cap == ci->i_auth_cap) in handle_cap_grant()
3546 if (cap == ci->i_auth_cap && in handle_cap_grant()
3547 __ceph_caps_revoking_other(ci, cap, newcaps)) in handle_cap_grant()
3559 extra_info->inline_version >= ci->i_inline_version) { in handle_cap_grant()
3560 ci->i_inline_version = extra_info->inline_version; in handle_cap_grant()
3561 if (ci->i_inline_version != CEPH_INLINE_NONE && in handle_cap_grant()
3567 if (ci->i_auth_cap == cap) { in handle_cap_grant()
3571 if (ci->i_requested_max_size > max_size || in handle_cap_grant()
3574 ci->i_requested_max_size = 0; in handle_cap_grant()
3578 ceph_kick_flushing_inode_caps(session, ci); in handle_cap_grant()
3582 spin_unlock(&ci->i_ceph_lock); in handle_cap_grant()
3603 wake_up_all(&ci->i_cap_wq); in handle_cap_grant()
3607 ceph_check_caps(ci, CHECK_CAPS_AUTHONLY | CHECK_CAPS_NOINVAL, in handle_cap_grant()
3610 ceph_check_caps(ci, CHECK_CAPS_NOINVAL, session); in handle_cap_grant()
3621 __releases(ci->i_ceph_lock) in handle_cap_flush_ack()
3623 struct ceph_inode_info *ci = ceph_inode(inode); in handle_cap_flush_ack() local
3634 list_for_each_entry_safe(cf, tmp_cf, &ci->i_cap_flush_list, i_list) { in handle_cap_flush_ack()
3648 wake_ci |= __detach_cap_flush_from_ci(ci, cf); in handle_cap_flush_ack()
3664 ceph_cap_string(cleaned), ceph_cap_string(ci->i_flushing_caps), in handle_cap_flush_ack()
3665 ceph_cap_string(ci->i_flushing_caps & ~cleaned)); in handle_cap_flush_ack()
3670 ci->i_flushing_caps &= ~cleaned; in handle_cap_flush_ack()
3677 if (ci->i_flushing_caps == 0) { in handle_cap_flush_ack()
3678 if (list_empty(&ci->i_cap_flush_list)) { in handle_cap_flush_ack()
3679 list_del_init(&ci->i_flushing_item); in handle_cap_flush_ack()
3691 if (ci->i_dirty_caps == 0) { in handle_cap_flush_ack()
3693 BUG_ON(!list_empty(&ci->i_dirty_item)); in handle_cap_flush_ack()
3695 if (ci->i_wr_ref == 0 && in handle_cap_flush_ack()
3696 ci->i_wrbuffer_ref_head == 0) { in handle_cap_flush_ack()
3697 BUG_ON(!ci->i_head_snapc); in handle_cap_flush_ack()
3698 ceph_put_snap_context(ci->i_head_snapc); in handle_cap_flush_ack()
3699 ci->i_head_snapc = NULL; in handle_cap_flush_ack()
3702 BUG_ON(list_empty(&ci->i_dirty_item)); in handle_cap_flush_ack()
3708 spin_unlock(&ci->i_ceph_lock); in handle_cap_flush_ack()
3719 wake_up_all(&ci->i_cap_wq); in handle_cap_flush_ack()
3729 struct ceph_inode_info *ci = ceph_inode(inode); in __ceph_remove_capsnap() local
3733 lockdep_assert_held(&ci->i_ceph_lock); in __ceph_remove_capsnap()
3735 dout("removing capsnap %p, inode %p ci %p\n", capsnap, inode, ci); in __ceph_remove_capsnap()
3738 ret = __detach_cap_flush_from_ci(ci, &capsnap->cap_flush); in __ceph_remove_capsnap()
3743 if (list_empty(&ci->i_cap_flush_list)) in __ceph_remove_capsnap()
3744 list_del_init(&ci->i_flushing_item); in __ceph_remove_capsnap()
3755 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_remove_capsnap() local
3757 lockdep_assert_held(&ci->i_ceph_lock); in ceph_remove_capsnap()
3773 struct ceph_inode_info *ci = ceph_inode(inode); in handle_cap_flushsnap_ack() local
3781 inode, ci, session->s_mds, follows); in handle_cap_flushsnap_ack()
3783 spin_lock(&ci->i_ceph_lock); in handle_cap_flushsnap_ack()
3784 list_for_each_entry(iter, &ci->i_cap_snaps, ci_item) { in handle_cap_flushsnap_ack()
3801 spin_unlock(&ci->i_ceph_lock); in handle_cap_flushsnap_ack()
3807 wake_up_all(&ci->i_cap_wq); in handle_cap_flushsnap_ack()
3823 struct ceph_inode_info *ci = ceph_inode(inode); in handle_cap_trunc() local
3830 int dirty = __ceph_caps_dirty(ci); in handle_cap_trunc()
3834 lockdep_assert_held(&ci->i_ceph_lock); in handle_cap_trunc()
3860 struct ceph_inode_info *ci = ceph_inode(inode); in handle_cap_export() local
3878 inode, ci, mds, mseq, target); in handle_cap_export()
3881 spin_lock(&ci->i_ceph_lock); in handle_cap_export()
3882 cap = __get_cap_for_mds(ci, mds); in handle_cap_export()
3906 tcap = __get_cap_for_mds(ci, target); in handle_cap_export()
3917 if (cap == ci->i_auth_cap) { in handle_cap_export()
3918 ci->i_auth_cap = tcap; in handle_cap_export()
3919 change_auth_cap_ses(ci, tcap->session); in handle_cap_export()
3926 int flag = (cap == ci->i_auth_cap) ? CEPH_CAP_FLAG_AUTH : 0; in handle_cap_export()
3931 if (!list_empty(&ci->i_cap_flush_list) && in handle_cap_export()
3932 ci->i_auth_cap == tcap) { in handle_cap_export()
3934 list_move_tail(&ci->i_flushing_item, in handle_cap_export()
3943 spin_unlock(&ci->i_ceph_lock); in handle_cap_export()
3969 spin_unlock(&ci->i_ceph_lock); in handle_cap_export()
3991 struct ceph_inode_info *ci = ceph_inode(inode); in handle_cap_import() local
4013 inode, ci, mds, mseq, peer); in handle_cap_import()
4015 cap = __get_cap_for_mds(ci, mds); in handle_cap_import()
4018 spin_unlock(&ci->i_ceph_lock); in handle_cap_import()
4020 spin_lock(&ci->i_ceph_lock); in handle_cap_import()
4031 __ceph_caps_issued(ci, &issued); in handle_cap_import()
4032 issued |= __ceph_caps_dirty(ci); in handle_cap_import()
4037 ocap = peer >= 0 ? __get_cap_for_mds(ci, peer) : NULL; in handle_cap_import()
4070 struct ceph_inode_info *ci; in ceph_handle_caps() local
4204 ci = ceph_inode(inode); in ceph_handle_caps()
4228 spin_lock(&ci->i_ceph_lock); in ceph_handle_caps()
4239 spin_lock(&ci->i_ceph_lock); in ceph_handle_caps()
4245 spin_unlock(&ci->i_ceph_lock); in ceph_handle_caps()
4253 __ceph_caps_issued(ci, &extra_info.issued); in ceph_handle_caps()
4254 extra_info.issued |= __ceph_caps_dirty(ci); in ceph_handle_caps()
4266 spin_unlock(&ci->i_ceph_lock); in ceph_handle_caps()
4272 spin_unlock(&ci->i_ceph_lock); in ceph_handle_caps()
4310 struct ceph_inode_info *ci; in ceph_check_delayed_caps() local
4319 ci = list_first_entry(&mdsc->cap_delay_list, in ceph_check_delayed_caps()
4322 if (time_before(loop_start, ci->i_hold_caps_max - delay_max)) { in ceph_check_delayed_caps()
4324 delay = ci->i_hold_caps_max; in ceph_check_delayed_caps()
4327 if ((ci->i_ceph_flags & CEPH_I_FLUSH) == 0 && in ceph_check_delayed_caps()
4328 time_before(jiffies, ci->i_hold_caps_max)) in ceph_check_delayed_caps()
4330 list_del_init(&ci->i_cap_delay_list); in ceph_check_delayed_caps()
4332 inode = igrab(&ci->netfs.inode); in ceph_check_delayed_caps()
4336 ceph_check_caps(ci, 0, NULL); in ceph_check_delayed_caps()
4352 struct ceph_inode_info *ci; in flush_dirty_session_caps() local
4358 ci = list_first_entry(&s->s_cap_dirty, struct ceph_inode_info, in flush_dirty_session_caps()
4360 inode = &ci->netfs.inode; in flush_dirty_session_caps()
4365 ceph_check_caps(ci, CHECK_CAPS_FLUSH, NULL); in flush_dirty_session_caps()
4378 void __ceph_touch_fmode(struct ceph_inode_info *ci, in __ceph_touch_fmode() argument
4383 ci->i_last_rd = now; in __ceph_touch_fmode()
4385 ci->i_last_wr = now; in __ceph_touch_fmode()
4388 __ceph_is_any_real_caps(ci) && in __ceph_touch_fmode()
4389 list_empty(&ci->i_cap_delay_list)) in __ceph_touch_fmode()
4390 __cap_delay_requeue(mdsc, ci); in __ceph_touch_fmode()
4393 void ceph_get_fmode(struct ceph_inode_info *ci, int fmode, int count) in ceph_get_fmode() argument
4395 struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(ci->netfs.inode.i_sb); in ceph_get_fmode()
4403 spin_lock(&ci->i_ceph_lock); in ceph_get_fmode()
4410 if (i && ci->i_nr_by_mode[i]) in ceph_get_fmode()
4414 ci->i_nr_by_mode[i] += count; in ceph_get_fmode()
4419 spin_unlock(&ci->i_ceph_lock); in ceph_get_fmode()
4427 void ceph_put_fmode(struct ceph_inode_info *ci, int fmode, int count) in ceph_put_fmode() argument
4429 struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(ci->netfs.inode.i_sb); in ceph_put_fmode()
4437 spin_lock(&ci->i_ceph_lock); in ceph_put_fmode()
4440 BUG_ON(ci->i_nr_by_mode[i] < count); in ceph_put_fmode()
4441 ci->i_nr_by_mode[i] -= count; in ceph_put_fmode()
4449 if (i && ci->i_nr_by_mode[i]) in ceph_put_fmode()
4455 spin_unlock(&ci->i_ceph_lock); in ceph_put_fmode()
4466 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_drop_caps_for_unlink() local
4469 spin_lock(&ci->i_ceph_lock); in ceph_drop_caps_for_unlink()
4471 drop |= ~(__ceph_caps_wanted(ci) | CEPH_CAP_PIN); in ceph_drop_caps_for_unlink()
4473 if (__ceph_caps_dirty(ci)) { in ceph_drop_caps_for_unlink()
4476 __cap_delay_requeue_front(mdsc, ci); in ceph_drop_caps_for_unlink()
4479 spin_unlock(&ci->i_ceph_lock); in ceph_drop_caps_for_unlink()
4494 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_encode_inode_release() local
4500 spin_lock(&ci->i_ceph_lock); in ceph_encode_inode_release()
4501 used = __ceph_caps_used(ci); in ceph_encode_inode_release()
4502 dirty = __ceph_caps_dirty(ci); in ceph_encode_inode_release()
4511 cap = __get_cap_for_mds(ci, mds); in ceph_encode_inode_release()
4527 int wanted = __ceph_caps_wanted(ci); in ceph_encode_inode_release()
4538 if (cap == ci->i_auth_cap && in ceph_encode_inode_release()
4540 ci->i_requested_max_size = 0; in ceph_encode_inode_release()
4563 spin_unlock(&ci->i_ceph_lock); in ceph_encode_inode_release()
4611 struct ceph_inode_info *ci = ceph_inode(inode); in remove_capsnaps() local
4615 lockdep_assert_held(&ci->i_ceph_lock); in remove_capsnaps()
4617 dout("removing capsnaps, ci is %p, inode is %p\n", ci, inode); in remove_capsnaps()
4619 while (!list_empty(&ci->i_cap_snaps)) { in remove_capsnaps()
4620 capsnap = list_first_entry(&ci->i_cap_snaps, in remove_capsnaps()
4627 wake_up_all(&ci->i_cap_wq); in remove_capsnaps()
4636 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_purge_inode_cap() local
4641 lockdep_assert_held(&ci->i_ceph_lock); in ceph_purge_inode_cap()
4644 cap, ci, &ci->netfs.inode); in ceph_purge_inode_cap()
4646 is_auth = (cap == ci->i_auth_cap); in ceph_purge_inode_cap()
4654 if (ci->i_wrbuffer_ref > 0) in ceph_purge_inode_cap()
4661 while (!list_empty(&ci->i_cap_flush_list)) { in ceph_purge_inode_cap()
4662 cf = list_first_entry(&ci->i_cap_flush_list, in ceph_purge_inode_cap()
4670 if (!list_empty(&ci->i_dirty_item)) { in ceph_purge_inode_cap()
4673 ceph_cap_string(ci->i_dirty_caps), in ceph_purge_inode_cap()
4675 ci->i_dirty_caps = 0; in ceph_purge_inode_cap()
4676 list_del_init(&ci->i_dirty_item); in ceph_purge_inode_cap()
4679 if (!list_empty(&ci->i_flushing_item)) { in ceph_purge_inode_cap()
4682 ceph_cap_string(ci->i_flushing_caps), in ceph_purge_inode_cap()
4684 ci->i_flushing_caps = 0; in ceph_purge_inode_cap()
4685 list_del_init(&ci->i_flushing_item); in ceph_purge_inode_cap()
4694 if (ci->i_wrbuffer_ref_head == 0 && in ceph_purge_inode_cap()
4695 ci->i_wr_ref == 0 && in ceph_purge_inode_cap()
4696 ci->i_dirty_caps == 0 && in ceph_purge_inode_cap()
4697 ci->i_flushing_caps == 0) { in ceph_purge_inode_cap()
4698 ceph_put_snap_context(ci->i_head_snapc); in ceph_purge_inode_cap()
4699 ci->i_head_snapc = NULL; in ceph_purge_inode_cap()
4703 if (atomic_read(&ci->i_filelock_ref) > 0) { in ceph_purge_inode_cap()
4705 ci->i_ceph_flags |= CEPH_I_ERROR_FILELOCK; in ceph_purge_inode_cap()
4710 if (!ci->i_dirty_caps && ci->i_prealloc_cap_flush) { in ceph_purge_inode_cap()
4711 cf = ci->i_prealloc_cap_flush; in ceph_purge_inode_cap()
4712 ci->i_prealloc_cap_flush = NULL; in ceph_purge_inode_cap()
4717 if (!list_empty(&ci->i_cap_snaps)) in ceph_purge_inode_cap()