Lines Matching refs:ci

76 	struct ceph_inode_info *ci = ceph_inode(inode);  in ceph_get_snapdir()  local
86 ci->i_snap_caps = CEPH_CAP_PIN; /* so we can open */ in ceph_get_snapdir()
87 ci->i_rbytes = 0; in ceph_get_snapdir()
115 static struct ceph_inode_frag *__get_or_create_frag(struct ceph_inode_info *ci, in __get_or_create_frag() argument
123 p = &ci->i_fragtree.rb_node; in __get_or_create_frag()
139 "frag %x\n", &ci->vfs_inode, in __get_or_create_frag()
140 ceph_vinop(&ci->vfs_inode), f); in __get_or_create_frag()
149 rb_insert_color(&frag->node, &ci->i_fragtree); in __get_or_create_frag()
152 ceph_vinop(&ci->vfs_inode), f); in __get_or_create_frag()
159 struct ceph_inode_frag *__ceph_find_frag(struct ceph_inode_info *ci, u32 f) in __ceph_find_frag() argument
161 struct rb_node *n = ci->i_fragtree.rb_node; in __ceph_find_frag()
182 static u32 __ceph_choose_frag(struct ceph_inode_info *ci, u32 v, in __ceph_choose_frag() argument
195 frag = __ceph_find_frag(ci, t); in __ceph_choose_frag()
224 u32 ceph_choose_frag(struct ceph_inode_info *ci, u32 v, in ceph_choose_frag() argument
228 mutex_lock(&ci->i_fragtree_mutex); in ceph_choose_frag()
229 ret = __ceph_choose_frag(ci, v, pfrag, found); in ceph_choose_frag()
230 mutex_unlock(&ci->i_fragtree_mutex); in ceph_choose_frag()
242 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_fill_dirfrag() local
251 spin_lock(&ci->i_ceph_lock); in ceph_fill_dirfrag()
252 if (ci->i_auth_cap) in ceph_fill_dirfrag()
253 diri_auth = ci->i_auth_cap->mds; in ceph_fill_dirfrag()
254 spin_unlock(&ci->i_ceph_lock); in ceph_fill_dirfrag()
256 mutex_lock(&ci->i_fragtree_mutex); in ceph_fill_dirfrag()
259 frag = __ceph_find_frag(ci, id); in ceph_fill_dirfrag()
266 rb_erase(&frag->node, &ci->i_fragtree); in ceph_fill_dirfrag()
280 frag = __get_or_create_frag(ci, id); in ceph_fill_dirfrag()
298 mutex_unlock(&ci->i_fragtree_mutex); in ceph_fill_dirfrag()
306 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_fill_fragtree() local
313 mutex_lock(&ci->i_fragtree_mutex); in ceph_fill_fragtree()
318 if (!__ceph_find_frag(ci, id)) in ceph_fill_fragtree()
320 } else if (!RB_EMPTY_ROOT(&ci->i_fragtree)) { in ceph_fill_fragtree()
321 rb_node = rb_first(&ci->i_fragtree); in ceph_fill_fragtree()
328 if (id != __ceph_choose_frag(ci, id, NULL, NULL)) in ceph_fill_fragtree()
335 rb_node = rb_first(&ci->i_fragtree); in ceph_fill_fragtree()
349 rb_erase(&frag->node, &ci->i_fragtree); in ceph_fill_fragtree()
354 frag = __get_or_create_frag(ci, id); in ceph_fill_fragtree()
364 rb_erase(&frag->node, &ci->i_fragtree); in ceph_fill_fragtree()
368 mutex_unlock(&ci->i_fragtree_mutex); in ceph_fill_fragtree()
377 struct ceph_inode_info *ci; in ceph_alloc_inode() local
380 ci = kmem_cache_alloc(ceph_inode_cachep, GFP_NOFS); in ceph_alloc_inode()
381 if (!ci) in ceph_alloc_inode()
384 dout("alloc_inode %p\n", &ci->vfs_inode); in ceph_alloc_inode()
386 spin_lock_init(&ci->i_ceph_lock); in ceph_alloc_inode()
388 ci->i_version = 0; in ceph_alloc_inode()
389 ci->i_inline_version = 0; in ceph_alloc_inode()
390 ci->i_time_warp_seq = 0; in ceph_alloc_inode()
391 ci->i_ceph_flags = 0; in ceph_alloc_inode()
392 atomic64_set(&ci->i_ordered_count, 1); in ceph_alloc_inode()
393 atomic64_set(&ci->i_release_count, 1); in ceph_alloc_inode()
394 atomic64_set(&ci->i_complete_seq[0], 0); in ceph_alloc_inode()
395 atomic64_set(&ci->i_complete_seq[1], 0); in ceph_alloc_inode()
396 ci->i_symlink = NULL; in ceph_alloc_inode()
398 memset(&ci->i_dir_layout, 0, sizeof(ci->i_dir_layout)); in ceph_alloc_inode()
400 ci->i_fragtree = RB_ROOT; in ceph_alloc_inode()
401 mutex_init(&ci->i_fragtree_mutex); in ceph_alloc_inode()
403 ci->i_xattrs.blob = NULL; in ceph_alloc_inode()
404 ci->i_xattrs.prealloc_blob = NULL; in ceph_alloc_inode()
405 ci->i_xattrs.dirty = false; in ceph_alloc_inode()
406 ci->i_xattrs.index = RB_ROOT; in ceph_alloc_inode()
407 ci->i_xattrs.count = 0; in ceph_alloc_inode()
408 ci->i_xattrs.names_size = 0; in ceph_alloc_inode()
409 ci->i_xattrs.vals_size = 0; in ceph_alloc_inode()
410 ci->i_xattrs.version = 0; in ceph_alloc_inode()
411 ci->i_xattrs.index_version = 0; in ceph_alloc_inode()
413 ci->i_caps = RB_ROOT; in ceph_alloc_inode()
414 ci->i_auth_cap = NULL; in ceph_alloc_inode()
415 ci->i_dirty_caps = 0; in ceph_alloc_inode()
416 ci->i_flushing_caps = 0; in ceph_alloc_inode()
417 INIT_LIST_HEAD(&ci->i_dirty_item); in ceph_alloc_inode()
418 INIT_LIST_HEAD(&ci->i_flushing_item); in ceph_alloc_inode()
419 ci->i_prealloc_cap_flush = NULL; in ceph_alloc_inode()
420 ci->i_cap_flush_tree = RB_ROOT; in ceph_alloc_inode()
421 init_waitqueue_head(&ci->i_cap_wq); in ceph_alloc_inode()
422 ci->i_hold_caps_min = 0; in ceph_alloc_inode()
423 ci->i_hold_caps_max = 0; in ceph_alloc_inode()
424 INIT_LIST_HEAD(&ci->i_cap_delay_list); in ceph_alloc_inode()
425 INIT_LIST_HEAD(&ci->i_cap_snaps); in ceph_alloc_inode()
426 ci->i_head_snapc = NULL; in ceph_alloc_inode()
427 ci->i_snap_caps = 0; in ceph_alloc_inode()
430 ci->i_nr_by_mode[i] = 0; in ceph_alloc_inode()
432 mutex_init(&ci->i_truncate_mutex); in ceph_alloc_inode()
433 ci->i_truncate_seq = 0; in ceph_alloc_inode()
434 ci->i_truncate_size = 0; in ceph_alloc_inode()
435 ci->i_truncate_pending = 0; in ceph_alloc_inode()
437 ci->i_max_size = 0; in ceph_alloc_inode()
438 ci->i_reported_size = 0; in ceph_alloc_inode()
439 ci->i_wanted_max_size = 0; in ceph_alloc_inode()
440 ci->i_requested_max_size = 0; in ceph_alloc_inode()
442 ci->i_pin_ref = 0; in ceph_alloc_inode()
443 ci->i_rd_ref = 0; in ceph_alloc_inode()
444 ci->i_rdcache_ref = 0; in ceph_alloc_inode()
445 ci->i_wr_ref = 0; in ceph_alloc_inode()
446 ci->i_wb_ref = 0; in ceph_alloc_inode()
447 ci->i_wrbuffer_ref = 0; in ceph_alloc_inode()
448 ci->i_wrbuffer_ref_head = 0; in ceph_alloc_inode()
449 ci->i_shared_gen = 0; in ceph_alloc_inode()
450 ci->i_rdcache_gen = 0; in ceph_alloc_inode()
451 ci->i_rdcache_revoking = 0; in ceph_alloc_inode()
453 INIT_LIST_HEAD(&ci->i_unsafe_writes); in ceph_alloc_inode()
454 INIT_LIST_HEAD(&ci->i_unsafe_dirops); in ceph_alloc_inode()
455 INIT_LIST_HEAD(&ci->i_unsafe_iops); in ceph_alloc_inode()
456 spin_lock_init(&ci->i_unsafe_lock); in ceph_alloc_inode()
458 ci->i_snap_realm = NULL; in ceph_alloc_inode()
459 INIT_LIST_HEAD(&ci->i_snap_realm_item); in ceph_alloc_inode()
460 INIT_LIST_HEAD(&ci->i_snap_flush_item); in ceph_alloc_inode()
462 INIT_WORK(&ci->i_wb_work, ceph_writeback_work); in ceph_alloc_inode()
463 INIT_WORK(&ci->i_pg_inv_work, ceph_invalidate_work); in ceph_alloc_inode()
465 INIT_WORK(&ci->i_vmtruncate_work, ceph_vmtruncate_work); in ceph_alloc_inode()
467 ceph_fscache_inode_init(ci); in ceph_alloc_inode()
469 return &ci->vfs_inode; in ceph_alloc_inode()
475 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_i_callback() local
477 kmem_cache_free(ceph_inode_cachep, ci); in ceph_i_callback()
482 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_destroy_inode() local
488 ceph_fscache_unregister_inode_cookie(ci); in ceph_destroy_inode()
496 if (ci->i_snap_realm) { in ceph_destroy_inode()
498 ceph_sb_to_client(ci->vfs_inode.i_sb)->mdsc; in ceph_destroy_inode()
499 struct ceph_snap_realm *realm = ci->i_snap_realm; in ceph_destroy_inode()
503 list_del_init(&ci->i_snap_realm_item); in ceph_destroy_inode()
508 kfree(ci->i_symlink); in ceph_destroy_inode()
509 while ((n = rb_first(&ci->i_fragtree)) != NULL) { in ceph_destroy_inode()
511 rb_erase(n, &ci->i_fragtree); in ceph_destroy_inode()
515 __ceph_destroy_xattrs(ci); in ceph_destroy_inode()
516 if (ci->i_xattrs.blob) in ceph_destroy_inode()
517 ceph_buffer_put(ci->i_xattrs.blob); in ceph_destroy_inode()
518 if (ci->i_xattrs.prealloc_blob) in ceph_destroy_inode()
519 ceph_buffer_put(ci->i_xattrs.prealloc_blob); in ceph_destroy_inode()
545 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_fill_file_size() local
548 if (ceph_seq_cmp(truncate_seq, ci->i_truncate_seq) > 0 || in ceph_fill_file_size()
549 (truncate_seq == ci->i_truncate_seq && size > inode->i_size)) { in ceph_fill_file_size()
553 ci->i_reported_size = size; in ceph_fill_file_size()
554 if (truncate_seq != ci->i_truncate_seq) { in ceph_fill_file_size()
556 ci->i_truncate_seq, truncate_seq); in ceph_fill_file_size()
557 ci->i_truncate_seq = truncate_seq; in ceph_fill_file_size()
573 __ceph_caps_file_wanted(ci)) { in ceph_fill_file_size()
574 ci->i_truncate_pending++; in ceph_fill_file_size()
579 if (ceph_seq_cmp(truncate_seq, ci->i_truncate_seq) >= 0 && in ceph_fill_file_size()
580 ci->i_truncate_size != truncate_size) { in ceph_fill_file_size()
581 dout("truncate_size %lld -> %llu\n", ci->i_truncate_size, in ceph_fill_file_size()
583 ci->i_truncate_size = truncate_size; in ceph_fill_file_size()
596 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_fill_file_time() local
610 if (ceph_seq_cmp(time_warp_seq, ci->i_time_warp_seq) > 0) { in ceph_fill_file_time()
616 ci->i_time_warp_seq, (int)time_warp_seq); in ceph_fill_file_time()
620 ci->i_time_warp_seq = time_warp_seq; in ceph_fill_file_time()
621 } else if (time_warp_seq == ci->i_time_warp_seq) { in ceph_fill_file_time()
644 if (ceph_seq_cmp(time_warp_seq, ci->i_time_warp_seq) >= 0) { in ceph_fill_file_time()
648 ci->i_time_warp_seq = time_warp_seq; in ceph_fill_file_time()
655 inode, time_warp_seq, ci->i_time_warp_seq); in ceph_fill_file_time()
671 struct ceph_inode_info *ci = ceph_inode(inode); in fill_inode() local
684 ci->i_version); in fill_inode()
702 spin_lock(&ci->i_ceph_lock); in fill_inode()
715 if (ci->i_version == 0 || in fill_inode()
717 le64_to_cpu(info->version) > (ci->i_version & ~1))) in fill_inode()
720 issued = __ceph_caps_issued(ci, &implemented); in fill_inode()
721 issued |= implemented | __ceph_caps_dirty(ci); in fill_inode()
725 ci->i_version = le64_to_cpu(info->version); in fill_inode()
756 if (ci->i_layout.fl_pg_pool != info->layout.fl_pg_pool) in fill_inode()
757 ci->i_ceph_flags &= ~CEPH_I_POOL_PERM; in fill_inode()
758 ci->i_layout = info->layout; in fill_inode()
766 ci->i_max_size != le64_to_cpu(info->max_size)) { in fill_inode()
767 dout("max_size %lld -> %llu\n", ci->i_max_size, in fill_inode()
769 ci->i_max_size = le64_to_cpu(info->max_size); in fill_inode()
775 if ((ci->i_xattrs.version == 0 || !(issued & CEPH_CAP_XATTR_EXCL)) && in fill_inode()
776 le64_to_cpu(info->xattr_version) > ci->i_xattrs.version) { in fill_inode()
777 if (ci->i_xattrs.blob) in fill_inode()
778 ceph_buffer_put(ci->i_xattrs.blob); in fill_inode()
779 ci->i_xattrs.blob = xattr_blob; in fill_inode()
781 memcpy(ci->i_xattrs.blob->vec.iov_base, in fill_inode()
783 ci->i_xattrs.version = le64_to_cpu(info->xattr_version); in fill_inode()
804 if (!ci->i_symlink) { in fill_inode()
808 spin_unlock(&ci->i_ceph_lock); in fill_inode()
819 spin_lock(&ci->i_ceph_lock); in fill_inode()
820 if (!ci->i_symlink) in fill_inode()
821 ci->i_symlink = sym; in fill_inode()
825 inode->i_link = ci->i_symlink; in fill_inode()
831 ci->i_dir_layout = iinfo->dir_layout; in fill_inode()
833 ci->i_files = le64_to_cpu(info->files); in fill_inode()
834 ci->i_subdirs = le64_to_cpu(info->subdirs); in fill_inode()
835 ci->i_rbytes = le64_to_cpu(info->rbytes); in fill_inode()
836 ci->i_rfiles = le64_to_cpu(info->rfiles); in fill_inode()
837 ci->i_rsubdirs = le64_to_cpu(info->rsubdirs); in fill_inode()
838 ceph_decode_timespec(&ci->i_rctime, &info->rctime); in fill_inode()
860 ci->i_files == 0 && ci->i_subdirs == 0 && in fill_inode()
863 !__ceph_dir_is_complete(ci)) { in fill_inode()
866 __ceph_dir_set_complete(ci, in fill_inode()
867 atomic64_read(&ci->i_release_count), in fill_inode()
868 atomic64_read(&ci->i_ordered_count)); in fill_inode()
875 ci->i_snap_caps |= le32_to_cpu(info->cap.caps); in fill_inode()
877 __ceph_get_fmode(ci, cap_fmode); in fill_inode()
882 __ceph_get_fmode(ci, cap_fmode); in fill_inode()
886 iinfo->inline_version >= ci->i_inline_version) { in fill_inode()
888 ci->i_inline_version = iinfo->inline_version; in fill_inode()
889 if (ci->i_inline_version != CEPH_INLINE_NONE && in fill_inode()
895 spin_unlock(&ci->i_ceph_lock); in fill_inode()
902 wake_up_all(&ci->i_cap_wq); in fill_inode()
1354 struct ceph_inode_info *ci = ceph_inode(dir); in fill_readdir_cache() local
1372 if (req->r_dir_release_cnt == atomic64_read(&ci->i_release_count) && in fill_readdir_cache()
1373 req->r_dir_ordered_cnt == atomic64_read(&ci->i_ordered_count)) { in fill_readdir_cache()
1428 struct ceph_inode_info *ci = ceph_inode(d_inode(parent)); in ceph_readdir_prepopulate() local
1429 req->r_dir_release_cnt = atomic64_read(&ci->i_release_count); in ceph_readdir_prepopulate()
1430 req->r_dir_ordered_cnt = atomic64_read(&ci->i_ordered_count); in ceph_readdir_prepopulate()
1547 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_inode_set_size() local
1550 spin_lock(&ci->i_ceph_lock); in ceph_inode_set_size()
1556 if ((size << 1) >= ci->i_max_size && in ceph_inode_set_size()
1557 (ci->i_reported_size << 1) < ci->i_max_size) in ceph_inode_set_size()
1560 spin_unlock(&ci->i_ceph_lock); in ceph_inode_set_size()
1582 struct ceph_inode_info *ci = container_of(work, struct ceph_inode_info, in ceph_writeback_work() local
1584 struct inode *inode = &ci->vfs_inode; in ceph_writeback_work()
1612 struct ceph_inode_info *ci = container_of(work, struct ceph_inode_info, in ceph_invalidate_work() local
1614 struct inode *inode = &ci->vfs_inode; in ceph_invalidate_work()
1618 mutex_lock(&ci->i_truncate_mutex); in ceph_invalidate_work()
1619 spin_lock(&ci->i_ceph_lock); in ceph_invalidate_work()
1621 ci->i_rdcache_gen, ci->i_rdcache_revoking); in ceph_invalidate_work()
1622 if (ci->i_rdcache_revoking != ci->i_rdcache_gen) { in ceph_invalidate_work()
1623 if (__ceph_caps_revoking_other(ci, NULL, CEPH_CAP_FILE_CACHE)) in ceph_invalidate_work()
1625 spin_unlock(&ci->i_ceph_lock); in ceph_invalidate_work()
1626 mutex_unlock(&ci->i_truncate_mutex); in ceph_invalidate_work()
1629 orig_gen = ci->i_rdcache_gen; in ceph_invalidate_work()
1630 spin_unlock(&ci->i_ceph_lock); in ceph_invalidate_work()
1634 spin_lock(&ci->i_ceph_lock); in ceph_invalidate_work()
1635 if (orig_gen == ci->i_rdcache_gen && in ceph_invalidate_work()
1636 orig_gen == ci->i_rdcache_revoking) { in ceph_invalidate_work()
1638 ci->i_rdcache_gen); in ceph_invalidate_work()
1639 ci->i_rdcache_revoking--; in ceph_invalidate_work()
1643 inode, orig_gen, ci->i_rdcache_gen, in ceph_invalidate_work()
1644 ci->i_rdcache_revoking); in ceph_invalidate_work()
1645 if (__ceph_caps_revoking_other(ci, NULL, CEPH_CAP_FILE_CACHE)) in ceph_invalidate_work()
1648 spin_unlock(&ci->i_ceph_lock); in ceph_invalidate_work()
1649 mutex_unlock(&ci->i_truncate_mutex); in ceph_invalidate_work()
1652 ceph_check_caps(ci, 0, NULL); in ceph_invalidate_work()
1664 struct ceph_inode_info *ci = container_of(work, struct ceph_inode_info, in ceph_vmtruncate_work() local
1666 struct inode *inode = &ci->vfs_inode; in ceph_vmtruncate_work()
1679 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_queue_vmtruncate() local
1684 &ci->i_vmtruncate_work)) { in ceph_queue_vmtruncate()
1688 inode, ci->i_truncate_pending); in ceph_queue_vmtruncate()
1699 struct ceph_inode_info *ci = ceph_inode(inode); in __ceph_do_pending_vmtruncate() local
1703 mutex_lock(&ci->i_truncate_mutex); in __ceph_do_pending_vmtruncate()
1705 spin_lock(&ci->i_ceph_lock); in __ceph_do_pending_vmtruncate()
1706 if (ci->i_truncate_pending == 0) { in __ceph_do_pending_vmtruncate()
1708 spin_unlock(&ci->i_ceph_lock); in __ceph_do_pending_vmtruncate()
1709 mutex_unlock(&ci->i_truncate_mutex); in __ceph_do_pending_vmtruncate()
1717 if (ci->i_wrbuffer_ref_head < ci->i_wrbuffer_ref) { in __ceph_do_pending_vmtruncate()
1720 spin_unlock(&ci->i_ceph_lock); in __ceph_do_pending_vmtruncate()
1727 WARN_ON_ONCE(ci->i_rd_ref || ci->i_wr_ref); in __ceph_do_pending_vmtruncate()
1729 to = ci->i_truncate_size; in __ceph_do_pending_vmtruncate()
1730 wrbuffer_refs = ci->i_wrbuffer_ref; in __ceph_do_pending_vmtruncate()
1732 ci->i_truncate_pending, to); in __ceph_do_pending_vmtruncate()
1733 spin_unlock(&ci->i_ceph_lock); in __ceph_do_pending_vmtruncate()
1737 spin_lock(&ci->i_ceph_lock); in __ceph_do_pending_vmtruncate()
1738 if (to == ci->i_truncate_size) { in __ceph_do_pending_vmtruncate()
1739 ci->i_truncate_pending = 0; in __ceph_do_pending_vmtruncate()
1742 spin_unlock(&ci->i_ceph_lock); in __ceph_do_pending_vmtruncate()
1746 mutex_unlock(&ci->i_truncate_mutex); in __ceph_do_pending_vmtruncate()
1749 ceph_check_caps(ci, CHECK_CAPS_AUTHONLY, NULL); in __ceph_do_pending_vmtruncate()
1751 wake_up_all(&ci->i_cap_wq); in __ceph_do_pending_vmtruncate()
1774 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_setattr() local
1804 spin_lock(&ci->i_ceph_lock); in ceph_setattr()
1805 issued = __ceph_caps_issued(ci, NULL); in ceph_setattr()
1807 if (!ci->i_head_snapc && in ceph_setattr()
1811 spin_unlock(&ci->i_ceph_lock); in ceph_setattr()
1813 spin_lock(&ci->i_ceph_lock); in ceph_setattr()
1814 issued = __ceph_caps_issued(ci, NULL); in ceph_setattr()
1870 ci->i_time_warp_seq++; in ceph_setattr()
1892 ci->i_time_warp_seq++; in ceph_setattr()
1918 ci->i_reported_size = attr->ia_size; in ceph_setattr()
1960 inode_dirty_flags = __ceph_mark_dirty_caps(ci, dirtied, in ceph_setattr()
1966 spin_unlock(&ci->i_ceph_lock); in ceph_setattr()
2075 struct ceph_inode_info *ci = ceph_inode(inode); in ceph_getattr() local
2089 stat->size = ci->i_rbytes; in ceph_getattr()
2091 stat->size = ci->i_files + ci->i_subdirs; in ceph_getattr()