Lines Matching defs:inode
13 #include "inode.h"
45 struct inode *inode;
62 struct inode *inode,
396 static int ocfs2_get_refcount_block(struct inode *inode, u64 *ref_blkno)
402 ret = ocfs2_read_inode_block(inode, &di_bh);
408 BUG_ON(!ocfs2_is_refcount_inode(inode));
548 * Create a refcount tree for an inode.
549 * We take for granted that the inode is already locked.
551 static int ocfs2_create_refcount_tree(struct inode *inode,
558 struct ocfs2_inode_info *oi = OCFS2_I(inode);
559 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
567 BUG_ON(ocfs2_is_refcount_inode(inode));
585 ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), di_bh,
607 new_bh = sb_getblk(inode->i_sb, first_blkno);
624 memset(rb, 0, inode->i_sb->s_blocksize);
692 static int ocfs2_set_refcount_tree(struct inode *inode,
699 struct ocfs2_inode_info *oi = OCFS2_I(inode);
700 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
705 BUG_ON(ocfs2_is_refcount_inode(inode));
721 ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), di_bh,
756 int ocfs2_remove_refcount_tree(struct inode *inode, struct buffer_head *di_bh)
761 struct ocfs2_inode_info *oi = OCFS2_I(inode);
762 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
764 struct inode *alloc_inode = NULL;
772 if (!ocfs2_is_refcount_inode(inode))
822 ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), di_bh,
925 int ocfs2_try_remove_refcount_tree(struct inode *inode,
929 struct ocfs2_inode_info *oi = OCFS2_I(inode);
942 ocfs2_has_inline_xattr_value_outside(inode, di))
945 ret = ocfs2_remove_refcount_tree(inode, di_bh);
2288 int ocfs2_decrease_refcount(struct inode *inode,
2299 BUG_ON(!ocfs2_is_refcount_inode(inode));
2301 ret = ocfs2_get_refcount_block(inode, &ref_blkno);
2307 ret = ocfs2_get_refcount_tree(OCFS2_SB(inode->i_sb), ref_blkno, &tree);
2338 static int ocfs2_mark_extent_refcounted(struct inode *inode,
2347 trace_ocfs2_mark_extent_refcounted(OCFS2_I(inode)->ip_blkno,
2350 if (!ocfs2_refcount_tree(OCFS2_SB(inode->i_sb))) {
2351 ret = ocfs2_error(inode->i_sb, "Inode %lu want to use refcount tree, but the feature bit is not set in the super block\n",
2352 inode->i_ino);
2521 int ocfs2_prepare_refcount_change_for_del(struct inode *inode,
2531 u64 start_cpos = ocfs2_blocks_to_clusters(inode->i_sb, phys_blkno);
2533 if (!ocfs2_refcount_tree(OCFS2_SB(inode->i_sb))) {
2534 ret = ocfs2_error(inode->i_sb, "Inode %lu want to use refcount tree, but the feature bit is not set in the super block\n",
2535 inode->i_ino);
2539 BUG_ON(!ocfs2_is_refcount_inode(inode));
2541 ret = ocfs2_get_refcount_tree(OCFS2_SB(inode->i_sb),
2555 ret = ocfs2_calc_refcount_meta_credits(inode->i_sb,
2629 static int ocfs2_refcount_cal_cow_clusters(struct inode *inode,
2643 int contig_clusters = ocfs2_cow_contig_clusters(inode->i_sb);
2649 ret = ocfs2_find_leaf(INODE_CACHE(inode), el, cpos, &eb_bh);
2659 ret = ocfs2_error(inode->i_sb,
2661 inode->i_ino,
2673 "index %d\n", inode->i_ino, i);
2738 want_clusters = ocfs2_cow_align_length(inode->i_sb,
2771 *cow_start = ocfs2_cow_align_start(inode->i_sb,
2783 *cow_start = ocfs2_cow_align_start(inode->i_sb,
2787 want_clusters = ocfs2_cow_align_length(inode->i_sb,
2808 ret = ocfs2_read_extent_block(INODE_CACHE(inode),
2906 struct inode *inode,
2911 struct super_block *sb = inode->i_sb;
2917 struct address_space *mapping = inode->i_mapping;
2928 if (end > i_size_read(inode))
2929 end = i_size_read(inode);
2984 ocfs2_map_and_dirty_page(inode,
3001 struct inode *inode,
3006 struct super_block *sb = inode->i_sb;
3007 struct ocfs2_caching_info *ci = INODE_CACHE(inode);
3128 ret = context->cow_duplicate_clusters(handle, context->inode,
3146 struct inode *inode,
3154 if (ocfs2_should_order_data(inode))
3160 ret = filemap_fdatawrite_range(inode->i_mapping,
3173 page = find_or_create_page(inode->i_mapping,
3200 return ocfs2_get_clusters(context->inode, v_cluster, p_cluster,
3319 ret = context->post_refcount->func(context->inode, handle,
3332 ret = ocfs2_cow_sync_writeback(sb, context->inode, cpos,
3358 struct inode *inode = context->inode;
3362 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
3365 return ocfs2_error(inode->i_sb, "Inode %lu want to use refcount tree, but the feature bit is not set in the super block\n",
3366 inode->i_ino);
3384 ret = ocfs2_make_clusters_writable(inode->i_sb, context,
3409 static int ocfs2_refcount_cow_hunk(struct inode *inode,
3415 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
3421 BUG_ON(!ocfs2_is_refcount_inode(inode));
3423 ret = ocfs2_refcount_cal_cow_clusters(inode, &di->id2.i_list,
3431 trace_ocfs2_refcount_cow_hunk(OCFS2_I(inode)->ip_blkno,
3451 context->inode = inode;
3460 INODE_CACHE(inode), di_bh);
3471 ocfs2_extent_map_trunc(inode, cow_start);
3485 int ocfs2_refcount_cow(struct inode *inode,
3494 ret = ocfs2_get_clusters(inode, cpos, &p_cluster,
3505 ret = ocfs2_refcount_cow_hunk(inode, di_bh, cpos,
3525 struct inode *inode = context->inode;
3528 return ocfs2_xattr_get_clusters(inode, v_cluster, p_cluster,
3537 int ocfs2_refcounted_xattr_delete_need(struct inode *inode,
3551 ret = ocfs2_xattr_get_clusters(inode, cpos, &p_cluster,
3609 *credits += ocfs2_calc_extend_credits(inode->i_sb,
3621 int ocfs2_refcount_cow_xattr(struct inode *inode,
3634 BUG_ON(!ocfs2_is_refcount_inode(inode));
3636 ret = ocfs2_refcount_cal_cow_clusters(inode, &xv->xr_list,
3653 context->inode = inode;
3663 ocfs2_clusters_to_blocks(inode->i_sb, 1) * cow_len;
3668 INODE_CACHE(inode), vb);
3683 int ocfs2_add_refcount_flag(struct inode *inode,
3694 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
3700 ret = ocfs2_calc_refcount_meta_credits(inode->i_sb,
3730 ret = ocfs2_mark_extent_refcounted(inode, data_et, handle,
3747 ret = post->func(inode, handle, post->para);
3760 static int ocfs2_change_ctime(struct inode *inode,
3767 handle = ocfs2_start_trans(OCFS2_SB(inode->i_sb),
3775 ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), di_bh,
3782 inode->i_ctime = current_time(inode);
3783 di->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
3784 di->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
3789 ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle);
3794 static int ocfs2_attach_refcount_tree(struct inode *inode,
3799 struct ocfs2_inode_info *oi = OCFS2_I(inode);
3801 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
3811 if (!ocfs2_is_refcount_inode(inode)) {
3812 ret = ocfs2_create_refcount_tree(inode, di_bh);
3831 ocfs2_init_dinode_extent_tree(&di_et, INODE_CACHE(inode), di_bh);
3833 size = i_size_read(inode);
3834 clusters = ocfs2_clusters_for_bytes(inode->i_sb, size);
3838 ret = ocfs2_get_clusters(inode, cpos, &p_cluster,
3845 ret = ocfs2_add_refcount_flag(inode, &di_et,
3862 ret = ocfs2_xattr_attach_refcount_tree(inode, di_bh,
3873 ret = ocfs2_change_ctime(inode, di_bh);
3891 ocfs2_extent_map_trunc(inode, 0);
3896 static int ocfs2_add_refcounted_extent(struct inode *inode,
3907 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
3910 ret = ocfs2_lock_refcount_allocators(inode->i_sb,
3928 ocfs2_clusters_to_blocks(inode->i_sb, p_cluster),
3943 ret = dquot_alloc_space_nodirty(inode,
3956 static int ocfs2_duplicate_inline_data(struct inode *s_inode,
3958 struct inode *t_inode,
3999 static int ocfs2_duplicate_extent_list(struct inode *s_inode,
4000 struct inode *t_inode,
4051 static int ocfs2_complete_reflink(struct inode *s_inode,
4053 struct inode *t_inode,
4122 static int ocfs2_create_reflink_node(struct inode *s_inode,
4124 struct inode *t_inode,
4181 struct inode *new_inode,
4185 struct inode *inode = d_inode(old_dentry);
4188 if (OCFS2_I(inode)->ip_flags & OCFS2_INODE_SYSTEM_FILE) {
4194 ret = filemap_fdatawrite(inode->i_mapping);
4200 ret = ocfs2_attach_refcount_tree(inode, old_bh);
4214 ret = ocfs2_create_reflink_node(inode, old_bh,
4221 if (OCFS2_I(inode)->ip_dyn_features & OCFS2_HAS_XATTR_FL) {
4222 ret = ocfs2_reflink_xattrs(inode, old_bh,
4231 ret = ocfs2_complete_reflink(inode, old_bh,
4243 ret = filemap_fdatawait(inode->i_mapping);
4250 static int ocfs2_reflink(struct dentry *old_dentry, struct inode *dir,
4254 struct inode *inode = d_inode(old_dentry);
4256 struct inode *new_orphan_inode = NULL;
4259 if (!ocfs2_refcount_tree(OCFS2_SB(inode->i_sb)))
4263 error = ocfs2_create_inode_in_orphan(dir, inode->i_mode,
4270 error = ocfs2_rw_lock(inode, 1);
4276 error = ocfs2_inode_lock(inode, &old_bh, 1);
4279 ocfs2_rw_unlock(inode, 1);
4283 down_write(&OCFS2_I(inode)->ip_xattr_sem);
4284 down_write(&OCFS2_I(inode)->ip_alloc_sem);
4287 up_write(&OCFS2_I(inode)->ip_alloc_sem);
4288 up_write(&OCFS2_I(inode)->ip_xattr_sem);
4290 ocfs2_inode_unlock(inode, 1);
4291 ocfs2_rw_unlock(inode, 1);
4325 * We need to open_unlock the inode no matter whether we
4343 static inline int ocfs2_may_create(struct inode *dir, struct dentry *child)
4355 * @old_dentry: source dentry + inode
4360 static int ocfs2_vfs_reflink(struct dentry *old_dentry, struct inode *dir,
4363 struct inode *inode = d_inode(old_dentry);
4366 if (!inode)
4373 if (dir->i_sb != inode->i_sb)
4379 if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4383 if (!S_ISREG(inode->i_mode))
4391 if (!uid_eq(current_fsuid(), inode->i_uid) && !capable(CAP_CHOWN))
4393 if (!in_group_p(inode->i_gid) && !capable(CAP_CHOWN))
4403 error = inode_permission(inode, MAY_READ);
4408 inode_lock(inode);
4412 inode_unlock(inode);
4420 int ocfs2_reflink_ioctl(struct inode *inode,
4429 if (!ocfs2_refcount_tree(OCFS2_SB(inode->i_sb)))
4462 /* Update destination inode size, if necessary. */
4463 int ocfs2_reflink_update_dest(struct inode *dest,
4502 static loff_t ocfs2_reflink_remap_extent(struct inode *s_inode,
4505 struct inode *t_inode,
4616 loff_t ocfs2_reflink_remap_blocks(struct inode *s_inode,
4619 struct inode *t_inode,
4660 /* Neither inode has a refcount tree. Add one to s_inode. */
4714 /* Lock an inode and grab a bh pointing to the inode. */
4715 int ocfs2_reflink_inodes_lock(struct inode *s_inode,
4717 struct inode *t_inode,
4720 struct inode *inode1 = s_inode;
4721 struct inode *inode2 = t_inode;
4782 * If we swapped inode order above, we have to swap the buffer heads
4809 void ocfs2_reflink_inodes_unlock(struct inode *s_inode,
4811 struct inode *t_inode,