Lines Matching defs:inode

41 #include "inode.h"
59 /* The inode these xattrs are associated with */
60 struct inode *bu_inode;
123 * when extended attribute in inode, xattr_bh is equal to inode_bh.
189 /* This xattr belongs to this inode */
190 struct inode *xl_inode;
249 static int ocfs2_xattr_block_find(struct inode *inode,
253 static int ocfs2_xattr_index_block_find(struct inode *inode,
259 static int ocfs2_xattr_tree_list_index_block(struct inode *inode,
264 static int ocfs2_xattr_create_index_block(struct inode *inode,
268 static int ocfs2_xattr_set_entry_index_block(struct inode *inode,
273 typedef int (xattr_tree_rec_func)(struct inode *inode,
276 static int ocfs2_iterate_xattr_index_block(struct inode *inode,
280 static int ocfs2_delete_xattr_in_bucket(struct inode *inode,
283 static int ocfs2_rm_xattr_cluster(struct inode *inode,
290 static int ocfs2_mv_xattr_buckets(struct inode *inode, handle_t *handle,
294 static int ocfs2_prepare_refcount_xattr(struct inode *inode,
322 static struct ocfs2_xattr_bucket *ocfs2_xattr_bucket_new(struct inode *inode)
325 int blks = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
331 bucket->bu_inode = inode;
517 static int ocfs2_read_xattr_block(struct inode *inode, u64 xb_blkno,
523 rc = ocfs2_read_block(INODE_CACHE(inode), xb_blkno, &tmp,
542 static u32 ocfs2_xattr_name_hash(struct inode *inode,
547 u32 hash = OCFS2_SB(inode->i_sb)->uuid_hash;
578 int ocfs2_calc_security_init(struct inode *dir,
616 int ocfs2_calc_xattr_init(struct inode *dir,
701 static int ocfs2_xattr_extend_allocation(struct inode *inode,
712 ocfs2_init_xattr_value_extent_tree(&et, INODE_CACHE(inode), vb);
717 status = vb->vb_access(handle, INODE_CACHE(inode), vb->vb_bh,
751 credits = ocfs2_calc_extend_credits(inode->i_sb,
765 static int __ocfs2_remove_xattr_range(struct inode *inode,
772 u64 phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos);
776 ocfs2_init_xattr_value_extent_tree(&et, INODE_CACHE(inode), vb);
778 ret = vb->vb_access(handle, INODE_CACHE(inode), vb->vb_bh,
796 ret = ocfs2_decrease_refcount(inode, handle,
797 ocfs2_blocks_to_clusters(inode->i_sb,
810 static int ocfs2_xattr_shrink_size(struct inode *inode,
827 ret = ocfs2_xattr_get_clusters(inode, cpos, &phys_cpos,
838 ret = __ocfs2_remove_xattr_range(inode, vb, cpos,
846 block = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos);
847 ocfs2_remove_xattr_clusters_from_cache(INODE_CACHE(inode),
857 static int ocfs2_xattr_value_truncate(struct inode *inode,
863 u32 new_clusters = ocfs2_clusters_for_bytes(inode->i_sb, len);
870 ret = ocfs2_xattr_extend_allocation(inode,
874 ret = ocfs2_xattr_shrink_size(inode,
930 static int ocfs2_xattr_list_entries(struct inode *inode,
944 ret = ocfs2_xattr_list_entry(inode->i_sb,
955 int ocfs2_has_inline_xattr_value_outside(struct inode *inode,
962 ((void *)di + inode->i_sb->s_blocksize -
972 static int ocfs2_xattr_ibody_list(struct inode *inode,
978 struct ocfs2_inode_info *oi = OCFS2_I(inode);
985 ((void *)di + inode->i_sb->s_blocksize -
988 ret = ocfs2_xattr_list_entries(inode, header, buffer, buffer_size);
993 static int ocfs2_xattr_block_list(struct inode *inode,
1005 ret = ocfs2_read_xattr_block(inode, le64_to_cpu(di->i_xattr_loc),
1015 ret = ocfs2_xattr_list_entries(inode, header,
1018 ret = ocfs2_xattr_tree_list_index_block(inode, blk_bh,
1101 static int ocfs2_xattr_get_value_outside(struct inode *inode,
1115 bpc = ocfs2_clusters_to_blocks(inode->i_sb, 1);
1116 blocksize = inode->i_sb->s_blocksize;
1120 ret = ocfs2_xattr_get_clusters(inode, cpos, &p_cluster,
1127 blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cluster);
1130 ret = ocfs2_read_block(INODE_CACHE(inode), blkno,
1153 static int ocfs2_xattr_ibody_get(struct inode *inode,
1160 struct ocfs2_inode_info *oi = OCFS2_I(inode);
1169 xs->end = (void *)di + inode->i_sb->s_blocksize;
1191 ret = ocfs2_xattr_get_value_outside(inode, xv,
1203 static int ocfs2_xattr_block_get(struct inode *inode,
1216 xs->bucket = ocfs2_xattr_bucket_new(inode);
1223 ret = ocfs2_xattr_block_find(inode, name_index, name, xs);
1246 ret = ocfs2_xattr_bucket_get_name_value(inode->i_sb,
1263 ret = ocfs2_xattr_get_value_outside(inode, xv,
1280 int ocfs2_xattr_get_nolock(struct inode *inode,
1289 struct ocfs2_inode_info *oi = OCFS2_I(inode);
1297 if (!ocfs2_supports_xattr(OCFS2_SB(inode->i_sb)))
1306 ret = ocfs2_xattr_ibody_get(inode, name_index, name, buffer,
1309 ret = ocfs2_xattr_block_get(inode, name_index, name, buffer,
1320 static int ocfs2_xattr_get(struct inode *inode,
1330 had_lock = ocfs2_inode_lock_tracker(inode, &di_bh, 0, &oh);
1335 down_read(&OCFS2_I(inode)->ip_xattr_sem);
1336 ret = ocfs2_xattr_get_nolock(inode, di_bh, name_index,
1338 up_read(&OCFS2_I(inode)->ip_xattr_sem);
1340 ocfs2_inode_unlock_tracker(inode, 0, &oh, had_lock);
1347 static int __ocfs2_xattr_set_value_outside(struct inode *inode,
1354 u16 blocksize = inode->i_sb->s_blocksize;
1356 u32 cpos = 0, bpc = ocfs2_clusters_to_blocks(inode->i_sb, 1);
1357 u32 clusters = ocfs2_clusters_for_bytes(inode->i_sb, value_len);
1366 ret = ocfs2_xattr_get_clusters(inode, cpos, &p_cluster,
1376 blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cluster);
1379 ret = ocfs2_read_block(INODE_CACHE(inode), blkno,
1387 INODE_CACHE(inode),
1688 * Operations for xattrs stored in blocks. This includes inline inode
2268 struct inode *inode,
2274 BUG_ON(!(OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_XATTR_FL));
2276 loc->xl_inode = inode;
2287 struct inode *inode,
2296 loc->xl_inode = inode;
2321 static int ocfs2_lock_xattr_remove_allocators(struct inode *inode,
2333 ret = ocfs2_xattr_get_clusters(inode, 0, &p_cluster,
2345 ret = ocfs2_refcounted_xattr_delete_need(inode, ref_ci,
2353 ret = ocfs2_reserve_new_metadata_blocks(OCFS2_SB(inode->i_sb),
2362 static int ocfs2_remove_value_outside(struct inode*inode,
2369 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
2386 ret = ocfs2_lock_xattr_remove_allocators(inode, vb->vb_xv,
2399 ret = ocfs2_xattr_value_truncate(inode, vb, 0, &ctxt);
2421 static int ocfs2_xattr_ibody_remove(struct inode *inode,
2436 ((void *)di + inode->i_sb->s_blocksize -
2439 ret = ocfs2_remove_value_outside(inode, &vb, header,
2450 static int ocfs2_xattr_block_remove(struct inode *inode,
2469 ret = ocfs2_remove_value_outside(inode, &vb, header,
2472 ret = ocfs2_iterate_xattr_index_block(inode,
2480 static int ocfs2_xattr_free_block(struct inode *inode,
2485 struct inode *xb_alloc_inode;
2489 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
2495 ret = ocfs2_read_xattr_block(inode, block, &blk_bh);
2501 ret = ocfs2_xattr_block_remove(inode, blk_bh, ref_ci, ref_root_bh);
2558 * Free extended attribute resources associated with this inode.
2560 int ocfs2_xattr_remove(struct inode *inode, struct buffer_head *di_bh)
2562 struct ocfs2_inode_info *oi = OCFS2_I(inode);
2570 if (!ocfs2_supports_xattr(OCFS2_SB(inode->i_sb)))
2576 if (ocfs2_is_refcount_inode(inode)) {
2577 ret = ocfs2_lock_refcount_tree(OCFS2_SB(inode->i_sb),
2589 ret = ocfs2_xattr_ibody_remove(inode, di_bh,
2598 ret = ocfs2_xattr_free_block(inode,
2607 handle = ocfs2_start_trans((OCFS2_SB(inode->i_sb)),
2614 ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), di_bh,
2627 ocfs2_update_inode_fsync_trans(handle, inode, 0);
2631 ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle);
2634 ocfs2_unlock_refcount_tree(OCFS2_SB(inode->i_sb), ref_tree, 1);
2639 static int ocfs2_xattr_has_space_inline(struct inode *inode,
2642 struct ocfs2_inode_info *oi = OCFS2_I(inode);
2643 unsigned int xattrsize = OCFS2_SB(inode->i_sb)->s_xattr_inline_size;
2652 } else if (ocfs2_inode_is_fast_symlink(inode)) {
2653 free = ocfs2_fast_symlink_chars(inode->i_sb) -
2670 * Find extended attribute in inode block and
2673 static int ocfs2_xattr_ibody_find(struct inode *inode,
2678 struct ocfs2_inode_info *oi = OCFS2_I(inode);
2683 if (inode->i_sb->s_blocksize == OCFS2_MIN_BLOCKSIZE)
2688 has_space = ocfs2_xattr_has_space_inline(inode, di);
2695 xs->end = (void *)di + inode->i_sb->s_blocksize;
2701 (xs->end - OCFS2_SB(inode->i_sb)->s_xattr_inline_size);
2716 static int ocfs2_xattr_ibody_init(struct inode *inode,
2721 struct ocfs2_inode_info *oi = OCFS2_I(inode);
2723 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
2726 if (!ocfs2_xattr_has_space_inline(inode, di)) {
2731 ret = ocfs2_journal_access_di(ctxt->handle, INODE_CACHE(inode), di_bh,
2745 } else if (!(ocfs2_inode_is_fast_symlink(inode))) {
2766 * Set, replace or remove an extended attribute into inode block.
2769 static int ocfs2_xattr_ibody_set(struct inode *inode,
2775 struct ocfs2_inode_info *oi = OCFS2_I(inode);
2778 if (inode->i_sb->s_blocksize == OCFS2_MIN_BLOCKSIZE)
2783 ret = ocfs2_xattr_ibody_init(inode, xs->inode_bh, ctxt);
2791 ocfs2_init_dinode_xa_loc(&loc, inode, xs->inode_bh,
2813 static int ocfs2_xattr_block_find(struct inode *inode,
2826 ret = ocfs2_read_xattr_block(inode, le64_to_cpu(di->i_xattr_loc),
2844 ret = ocfs2_xattr_index_block_find(inode, blk_bh,
2860 static int ocfs2_create_xattr_block(struct inode *inode,
2874 ret = ocfs2_journal_access_di(ctxt->handle, INODE_CACHE(inode),
2889 new_bh = sb_getblk(inode->i_sb, first_blkno);
2896 ocfs2_set_new_buffer_uptodate(INODE_CACHE(inode), new_bh);
2898 ret = ocfs2_journal_access_xb(ctxt->handle, INODE_CACHE(inode),
2908 memset(xblk, 0, inode->i_sb->s_blocksize);
2914 cpu_to_le32(OCFS2_SB(inode->i_sb)->fs_generation);
2922 ocfs2_xattr_recs_per_xb(inode->i_sb));
2928 /* Add it to the inode */
2931 spin_lock(&OCFS2_I(inode)->ip_lock);
2932 OCFS2_I(inode)->ip_dyn_features |= OCFS2_HAS_XATTR_FL;
2933 di->i_dyn_features = cpu_to_le16(OCFS2_I(inode)->ip_dyn_features);
2934 spin_unlock(&OCFS2_I(inode)->ip_lock);
2952 static int ocfs2_xattr_block_set(struct inode *inode,
2963 ret = ocfs2_create_xattr_block(inode, xs->inode_bh, ctxt,
2974 xs->end = (void *)xblk + inode->i_sb->s_blocksize;
2980 ocfs2_init_xattr_block_xa_loc(&loc, inode, xs->xattr_bh,
2989 ret = ocfs2_xattr_create_index_block(inode, xs, ctxt);
2996 ret = ocfs2_xattr_set_entry_index_block(inode, xi, xs, ctxt);
3002 /* Check whether the new xattr can be inserted into the inode. */
3003 static int ocfs2_xattr_can_be_in_inode(struct inode *inode,
3035 static int ocfs2_calc_xattr_set_need(struct inode *inode,
3052 u32 new_clusters = ocfs2_clusters_for_bytes(inode->i_sb,
3063 ocfs2_clusters_to_blocks(inode->i_sb, 1);
3066 credits += ocfs2_blocks_per_xattr_bucket(inode->i_sb);
3070 credits += ocfs2_calc_extend_credits(inode->i_sb,
3093 ret = ocfs2_xattr_bucket_get_name_value(inode->i_sb,
3098 credits += ocfs2_blocks_per_xattr_bucket(inode->i_sb);
3114 credits += ocfs2_remove_extent_credits(inode->i_sb);
3124 * In xattr set, we always try to set the xe in inode first,
3125 * so if it can be inserted into inode successfully, the old
3127 * will be inserted into inode as a new xattr in inode.
3129 if (ocfs2_xattr_can_be_in_inode(inode, xi, xis)) {
3131 credits += ocfs2_remove_extent_credits(inode->i_sb) +
3135 inode->i_sb,
3146 old_clusters = ocfs2_clusters_for_bytes(inode->i_sb,
3155 credits += ocfs2_remove_extent_credits(inode->i_sb);
3160 credits += ocfs2_calc_extend_credits(inode->i_sb,
3183 ret = ocfs2_read_xattr_block(inode,
3206 credits += ocfs2_calc_extend_credits(inode->i_sb,
3219 credits += ocfs2_blocks_per_xattr_bucket(inode->i_sb);
3221 OCFS2_SB(inode->i_sb)->s_clustersize) {
3222 credits += ocfs2_blocks_per_xattr_bucket(inode->i_sb);
3230 credits += ocfs2_calc_extend_credits(inode->i_sb,
3247 static int ocfs2_init_xattr_set_ctxt(struct inode *inode,
3257 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
3263 ret = ocfs2_calc_xattr_set_need(inode, di, xi, xis, xbs,
3303 static int __ocfs2_xattr_set_handle(struct inode *inode,
3315 ret = ocfs2_xattr_ibody_set(inode, xi, xis, ctxt);
3317 ret = ocfs2_xattr_block_set(inode, xi, xbs, ctxt);
3319 /* We always try to set extended attribute into inode first*/
3320 ret = ocfs2_xattr_ibody_set(inode, xi, xis, ctxt);
3331 ret = ocfs2_calc_xattr_set_need(inode,
3350 ret = ocfs2_xattr_block_set(inode, xi, xbs, ctxt);
3353 ret = ocfs2_xattr_block_find(inode,
3361 ret = ocfs2_calc_xattr_set_need(inode,
3382 * If no space in inode, we will set extended attribute
3385 ret = ocfs2_xattr_block_set(inode, xi, xbs, ctxt);
3391 * existing in inode, we will remove it.
3396 ret = ocfs2_calc_xattr_set_need(inode,
3414 ret = ocfs2_xattr_ibody_set(inode, xi,
3421 /* Update inode ctime. */
3422 ret = ocfs2_journal_access_di(ctxt->handle, INODE_CACHE(inode),
3430 inode->i_ctime = current_time(inode);
3431 di->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
3432 di->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
3440 * This function only called duing creating inode
3441 * for init security/acl xattrs of the new inode.
3445 struct inode *inode,
3480 if (!ocfs2_supports_xattr(OCFS2_SB(inode->i_sb)))
3488 if (inode->i_sb->s_blocksize == OCFS2_MIN_BLOCKSIZE) {
3489 xbs.bucket = ocfs2_xattr_bucket_new(inode);
3499 down_write(&OCFS2_I(inode)->ip_xattr_sem);
3501 ret = ocfs2_xattr_ibody_find(inode, name_index, name, &xis);
3505 ret = ocfs2_xattr_block_find(inode, name_index, name, &xbs);
3510 ret = __ocfs2_xattr_set_handle(inode, di, &xi, &xis, &xbs, &ctxt);
3513 up_write(&OCFS2_I(inode)->ip_xattr_sem);
3523 * Set, replace or remove an extended attribute for this inode.
3527 int ocfs2_xattr_set(struct inode *inode,
3537 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
3538 struct inode *tl_inode = osb->osb_tl_inode;
3566 xbs.bucket = ocfs2_xattr_bucket_new(inode);
3572 had_lock = ocfs2_inode_lock_tracker(inode, &di_bh, 1, &oh);
3581 down_write(&OCFS2_I(inode)->ip_xattr_sem);
3583 * Scan inode and external block to find the same name
3586 ret = ocfs2_xattr_ibody_find(inode, name_index, name, &xis);
3590 ret = ocfs2_xattr_block_find(inode, name_index, name, &xbs);
3609 if (ocfs2_is_refcount_inode(inode) &&
3611 ret = ocfs2_prepare_refcount_xattr(inode, di, &xi,
3632 ret = ocfs2_init_xattr_set_ctxt(inode, di, &xi, &xis,
3639 /* we need to update inode's ctime field, so add credit for it. */
3648 ret = __ocfs2_xattr_set_handle(inode, di, &xi, &xis, &xbs, &ctxt);
3649 ocfs2_update_inode_fsync_trans(ctxt.handle, inode, 0);
3665 up_write(&OCFS2_I(inode)->ip_xattr_sem);
3667 ret = ocfs2_try_remove_refcount_tree(inode, di_bh);
3671 ocfs2_inode_unlock_tracker(inode, 1, &oh, had_lock);
3685 static int ocfs2_xattr_get_rec(struct inode *inode,
3699 ret = ocfs2_find_leaf(INODE_CACHE(inode), el, name_hash,
3710 ret = ocfs2_error(inode->i_sb,
3712 inode->i_ino,
3728 ret = ocfs2_error(inode->i_sb, "Inode %lu has bad extent record (%u, %u, 0) in xattr\n",
3729 inode->i_ino,
3744 typedef int (xattr_bucket_func)(struct inode *inode,
3748 static int ocfs2_find_xe_in_bucket(struct inode *inode,
3780 ret = ocfs2_xattr_bucket_get_name_value(inode->i_sb,
3812 static int ocfs2_xattr_bucket_find(struct inode *inode,
3825 u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
3830 search = ocfs2_xattr_bucket_new(inode);
3880 ret = ocfs2_find_xe_in_bucket(inode, search,
3907 xs->end = xs->base + inode->i_sb->s_blocksize;
3911 trace_ocfs2_xattr_bucket_find(OCFS2_I(inode)->ip_blkno,
3923 static int ocfs2_xattr_index_block_find(struct inode *inode,
3936 u32 name_hash = ocfs2_xattr_name_hash(inode, name, strlen(name));
3941 trace_ocfs2_xattr_index_block_find(OCFS2_I(inode)->ip_blkno,
3946 ret = ocfs2_xattr_get_rec(inode, name_hash, &p_blkno, &first_hash,
3955 trace_ocfs2_xattr_index_block_find_rec(OCFS2_I(inode)->ip_blkno,
3960 ret = ocfs2_xattr_bucket_find(inode, name_index, name, name_hash,
3967 static int ocfs2_iterate_xattr_buckets(struct inode *inode,
3974 u32 bpc = ocfs2_xattr_buckets_per_cluster(OCFS2_SB(inode->i_sb));
3978 bucket = ocfs2_xattr_bucket_new(inode);
3985 (unsigned long long)OCFS2_I(inode)->ip_blkno,
4005 ret = func(inode, bucket, para);
4045 static int ocfs2_list_xattr_bucket(struct inode *inode,
4058 ret = ocfs2_xattr_bucket_get_name_value(inode->i_sb,
4068 ret = ocfs2_xattr_list_entry(inode->i_sb,
4081 static int ocfs2_iterate_xattr_index_block(struct inode *inode,
4097 ret = ocfs2_xattr_get_rec(inode, name_hash, &p_blkno,
4104 ret = rec_func(inode, blk_bh, p_blkno, e_cpos,
4122 static int ocfs2_list_xattr_tree_rec(struct inode *inode,
4126 return ocfs2_iterate_xattr_buckets(inode, blkno, len,
4130 static int ocfs2_xattr_tree_list_index_block(struct inode *inode,
4142 ret = ocfs2_iterate_xattr_index_block(inode, blk_bh,
4184 static void ocfs2_cp_xattr_block_to_bucket(struct inode *inode,
4188 int i, blocksize = inode->i_sb->s_blocksize;
4189 int blks = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
4252 static void ocfs2_xattr_update_xattr_search(struct inode *inode,
4263 xs->end = xs->base + inode->i_sb->s_blocksize;
4272 static int ocfs2_xattr_create_index_block(struct inode *inode,
4280 struct ocfs2_inode_info *oi = OCFS2_I(inode);
4300 ret = ocfs2_journal_access_xb(handle, INODE_CACHE(inode), xb_bh,
4319 blkno = ocfs2_clusters_to_blocks(inode->i_sb, bit_off);
4336 ocfs2_cp_xattr_block_to_bucket(inode, xb_bh, xs->bucket);
4339 ocfs2_xattr_update_xattr_search(inode, xs, xb_bh);
4342 memset(&xb->xb_attrs, 0, inode->i_sb->s_blocksize -
4349 xr->xt_list.l_count = cpu_to_le16(ocfs2_xattr_recs_per_xb(inode->i_sb));
4385 static int ocfs2_defrag_xattr_bucket(struct inode *inode,
4395 size_t blocksize = inode->i_sb->s_blocksize;
4507 static int ocfs2_mv_xattr_bucket_cross_cluster(struct inode *inode,
4516 struct super_block *sb = inode->i_sb;
4531 ret = ocfs2_mv_xattr_buckets(inode, handle, bucket_blkno(first),
4625 static int ocfs2_divide_xattr_bucket(struct inode *inode,
4637 int blocksize = inode->i_sb->s_blocksize;
4642 s_bucket = ocfs2_xattr_bucket_new(inode);
4643 t_bucket = ocfs2_xattr_bucket_new(inode);
4802 static int ocfs2_cp_xattr_bucket(struct inode *inode,
4817 s_bucket = ocfs2_xattr_bucket_new(inode);
4818 t_bucket = ocfs2_xattr_bucket_new(inode);
4876 static int ocfs2_mv_xattr_buckets(struct inode *inode, handle_t *handle,
4882 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
4883 int blks_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
4897 old_first = ocfs2_xattr_bucket_new(inode);
4899 new_first = ocfs2_xattr_bucket_new(inode);
4931 ret = ocfs2_cp_xattr_bucket(inode, handle,
4979 static int ocfs2_divide_xattr_cluster(struct inode *inode,
4985 u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
4988 BUG_ON(OCFS2_XATTR_BUCKET_SIZE < OCFS2_SB(inode->i_sb)->s_clustersize);
4997 return ocfs2_divide_xattr_bucket(inode, handle, prev_blk,
5027 static int ocfs2_adjust_xattr_cross_cluster(struct inode *inode,
5042 if (ocfs2_xattr_buckets_per_cluster(OCFS2_SB(inode->i_sb)) > 1) {
5043 ret = ocfs2_mv_xattr_bucket_cross_cluster(inode,
5055 ocfs2_clusters_to_blocks(inode->i_sb, 1));
5058 ret = ocfs2_mv_xattr_buckets(inode, handle,
5065 ret = ocfs2_divide_xattr_cluster(inode, handle,
5095 static int ocfs2_add_new_xattr_cluster(struct inode *inode,
5105 u16 bpc = ocfs2_clusters_to_blocks(inode->i_sb, 1);
5110 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
5114 (unsigned long long)OCFS2_I(inode)->ip_blkno,
5118 ocfs2_init_xattr_tree_extent_tree(&et, INODE_CACHE(inode), root_bh);
5120 ret = ocfs2_journal_access_xb(handle, INODE_CACHE(inode), root_bh,
5155 ret = ocfs2_adjust_xattr_cross_cluster(inode,
5193 static int ocfs2_extend_xattr_bucket(struct inode *inode,
5200 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
5201 u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
5238 ret = ocfs2_cp_xattr_bucket(inode, handle, end_blk,
5246 ret = ocfs2_divide_xattr_bucket(inode, handle, target_blk,
5269 static int ocfs2_add_new_xattr_bucket(struct inode *inode,
5280 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
5291 first = ocfs2_xattr_bucket_new(inode);
5298 ret = ocfs2_xattr_get_rec(inode, name_hash, &p_blkno, &e_cpos,
5317 ret = ocfs2_add_new_xattr_cluster(inode,
5332 ret = ocfs2_extend_xattr_bucket(inode,
5354 static int ocfs2_xattr_bucket_value_truncate(struct inode *inode,
5364 size_t blocksize = inode->i_sb->s_blocksize;
5396 ret = ocfs2_xattr_value_truncate(inode, &vb, len, ctxt);
5417 static int ocfs2_rm_xattr_cluster(struct inode *inode,
5425 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
5426 struct inode *tl_inode = osb->osb_tl_inode;
5434 ret = ocfs2_iterate_xattr_buckets(inode, blkno, len,
5441 ocfs2_init_xattr_tree_extent_tree(&et, INODE_CACHE(inode), root_bh);
5446 (unsigned long long)OCFS2_I(inode)->ip_blkno,
5449 ocfs2_remove_xattr_clusters_from_cache(INODE_CACHE(inode), blkno,
5452 ret = ocfs2_lock_allocators(inode, &et, 0, 1, NULL, &meta_ac);
5475 ret = ocfs2_journal_access_xb(handle, INODE_CACHE(inode), root_bh,
5495 ocfs2_update_inode_fsync_trans(handle, inode, 0);
5518 static int ocfs2_check_xattr_bucket_collision(struct inode *inode,
5523 u32 name_hash = ocfs2_xattr_name_hash(inode, name, strlen(name));
5544 static int ocfs2_xattr_set_entry_bucket(struct inode *inode,
5567 ret = ocfs2_defrag_xattr_bucket(inode, ctxt->handle,
5587 static int ocfs2_xattr_set_entry_index_block(struct inode *inode,
5596 ret = ocfs2_xattr_set_entry_bucket(inode, xi, xs, ctxt);
5612 ret = ocfs2_check_xattr_bucket_collision(inode,
5620 ret = ocfs2_add_new_xattr_bucket(inode,
5637 ret = ocfs2_xattr_index_block_find(inode, xs->xattr_bh,
5645 ret = ocfs2_xattr_set_entry_bucket(inode, xi, xs, ctxt);
5653 static int ocfs2_delete_xattr_in_bucket(struct inode *inode,
5661 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
5664 ocfs2_blocks_per_xattr_bucket(inode->i_sb);
5676 ret = ocfs2_get_xattr_tree_value_root(inode->i_sb, bucket,
5683 ret = ocfs2_lock_xattr_remove_allocators(inode, xv,
5696 ret = ocfs2_xattr_bucket_value_truncate(inode, bucket,
5725 static int ocfs2_xattr_bucket_post_refcount(struct inode *inode,
5759 static int ocfs2_prepare_refcount_xattr(struct inode *inode,
5777 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
5798 ret = ocfs2_xattr_bucket_get_name_value(inode->i_sb,
5832 ret = ocfs2_xattr_get_clusters(inode, 0, &p_cluster,
5865 ret = ocfs2_refcounted_xattr_delete_need(inode,
5874 ret = ocfs2_refcount_cow_xattr(inode, di, &vb,
5889 static int ocfs2_xattr_value_attach_refcount(struct inode *inode,
5905 ret = ocfs2_xattr_get_clusters(inode, cpos, &p_cluster,
5918 ret = ocfs2_add_refcount_flag(inode, value_et,
5935 * Used for xattrs stored in inode and ocfs2_xattr_block.
5937 static int ocfs2_xattr_attach_refcount_normal(struct inode *inode,
5961 ocfs2_init_xattr_value_extent_tree(&et, INODE_CACHE(inode), vb);
5963 ret = ocfs2_xattr_value_attach_refcount(inode, xv, &et,
5975 static int ocfs2_xattr_inline_attach_refcount(struct inode *inode,
5983 (fe_bh->b_data + inode->i_sb->s_blocksize -
5990 return ocfs2_xattr_attach_refcount_normal(inode, &vb, header,
6036 static int ocfs2_xattr_bucket_value_refcount(struct inode *inode,
6058 if (ocfs2_meta_ecc(OCFS2_SB(inode->i_sb)))
6070 ret = ocfs2_get_xattr_tree_value_root(inode->i_sb, bucket, i,
6078 INODE_CACHE(inode), &vb);
6080 ret = ocfs2_xattr_value_attach_refcount(inode, vb.vb_xv,
6094 static int ocfs2_refcount_xattr_tree_rec(struct inode *inode,
6098 return ocfs2_iterate_xattr_buckets(inode, blkno, len,
6103 static int ocfs2_xattr_block_attach_refcount(struct inode *inode,
6120 ret = ocfs2_xattr_attach_refcount_normal(inode, &vb, header,
6130 ret = ocfs2_iterate_xattr_index_block(inode, blk_bh,
6138 int ocfs2_xattr_attach_refcount_tree(struct inode *inode,
6145 struct ocfs2_inode_info *oi = OCFS2_I(inode);
6150 ret = ocfs2_xattr_inline_attach_refcount(inode, fe_bh,
6162 ret = ocfs2_read_xattr_block(inode, le64_to_cpu(di->i_xattr_loc),
6169 ret = ocfs2_xattr_block_attach_refcount(inode, blk_bh, ref_ci,
6183 * old_bh and new_bh are inode bh for the old and new inode.
6186 struct inode *old_inode;
6187 struct inode *new_inode;
6199 * xattr in inode, block and xattr tree have different implementaions.
6257 /* Used by xattr inode and block to return the right xv and buffer_head. */
6329 * It can be used for inode, block and bucket.
6546 static int ocfs2_create_empty_xattr_block(struct inode *inode,
6552 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
6571 ret = ocfs2_create_xattr_block(inode, fe_bh, &ctxt, indexed,
6611 /* One more credits in case we need to add xattr flags in new inode. */
6724 static int ocfs2_calc_value_tree_metas(struct inode *inode,
6735 return ocfs2_value_metas_in_xattr_header(inode->i_sb, bucket->bu_bhs[0],
6925 struct inode *inode,
6937 ocfs2_xattr_buckets_per_cluster(OCFS2_SB(inode->i_sb));
6955 new_blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cluster);
6985 blkno += ocfs2_clusters_to_blocks(inode->i_sb, num_clusters);
6993 * Create the same xattr extent record in the new inode's xattr tree.
6995 static int ocfs2_reflink_xattr_rec(struct inode *inode,
7006 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
7032 ret = ocfs2_reflink_xattr_buckets(handle, inode, args, &et,
7130 int ocfs2_reflink_xattrs(struct inode *old_inode,
7132 struct inode *new_inode,
7206 * Initialize security and acl for a already created inode.
7212 int ocfs2_init_security_and_acl(struct inode *dir,
7213 struct inode *inode,
7219 ret = ocfs2_init_security_get(inode, dir, qstr, NULL);
7230 ret = ocfs2_init_acl(NULL, inode, dir, NULL, dir_bh, NULL, NULL);
7244 struct dentry *unused, struct inode *inode,
7247 return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_SECURITY,
7252 struct dentry *unused, struct inode *inode,
7256 return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_SECURITY,
7260 static int ocfs2_initxattrs(struct inode *inode, const struct xattr *xattr_array,
7279 err = ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_SECURITY,
7288 int ocfs2_init_security_get(struct inode *inode,
7289 struct inode *dir,
7299 ret = security_inode_init_security(inode, dir, qstr,
7311 return security_inode_init_security(inode, dir, qstr,
7316 struct inode *inode,
7322 return ocfs2_xattr_set_handle(handle, inode, di_bh,
7338 struct dentry *unused, struct inode *inode,
7341 return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_TRUSTED,
7346 struct dentry *unused, struct inode *inode,
7350 return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_TRUSTED,
7364 struct dentry *unused, struct inode *inode,
7367 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
7371 return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_USER, name,
7376 struct dentry *unused, struct inode *inode,
7380 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
7385 return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_USER,