Lines Matching refs:inode

39 #include "inode.h"
57 /* The inode these xattrs are associated with */
58 struct inode *bu_inode;
117 * when extended attribute in inode, xattr_bh is equal to inode_bh.
183 /* This xattr belongs to this inode */
184 struct inode *xl_inode;
243 static int ocfs2_xattr_block_find(struct inode *inode,
247 static int ocfs2_xattr_index_block_find(struct inode *inode,
253 static int ocfs2_xattr_tree_list_index_block(struct inode *inode,
258 static int ocfs2_xattr_create_index_block(struct inode *inode,
262 static int ocfs2_xattr_set_entry_index_block(struct inode *inode,
267 typedef int (xattr_tree_rec_func)(struct inode *inode,
270 static int ocfs2_iterate_xattr_index_block(struct inode *inode,
274 static int ocfs2_delete_xattr_in_bucket(struct inode *inode,
277 static int ocfs2_rm_xattr_cluster(struct inode *inode,
284 static int ocfs2_mv_xattr_buckets(struct inode *inode, handle_t *handle,
288 static int ocfs2_prepare_refcount_xattr(struct inode *inode,
316 static struct ocfs2_xattr_bucket *ocfs2_xattr_bucket_new(struct inode *inode)
319 int blks = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
325 bucket->bu_inode = inode;
511 static int ocfs2_read_xattr_block(struct inode *inode, u64 xb_blkno,
517 rc = ocfs2_read_block(INODE_CACHE(inode), xb_blkno, &tmp,
536 static u32 ocfs2_xattr_name_hash(struct inode *inode,
541 u32 hash = OCFS2_SB(inode->i_sb)->uuid_hash;
572 int ocfs2_calc_security_init(struct inode *dir,
610 int ocfs2_calc_xattr_init(struct inode *dir,
695 static int ocfs2_xattr_extend_allocation(struct inode *inode,
706 ocfs2_init_xattr_value_extent_tree(&et, INODE_CACHE(inode), vb);
711 status = vb->vb_access(handle, INODE_CACHE(inode), vb->vb_bh,
745 credits = ocfs2_calc_extend_credits(inode->i_sb,
759 static int __ocfs2_remove_xattr_range(struct inode *inode,
766 u64 phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos);
770 ocfs2_init_xattr_value_extent_tree(&et, INODE_CACHE(inode), vb);
772 ret = vb->vb_access(handle, INODE_CACHE(inode), vb->vb_bh,
790 ret = ocfs2_decrease_refcount(inode, handle,
791 ocfs2_blocks_to_clusters(inode->i_sb,
804 static int ocfs2_xattr_shrink_size(struct inode *inode,
821 ret = ocfs2_xattr_get_clusters(inode, cpos, &phys_cpos,
832 ret = __ocfs2_remove_xattr_range(inode, vb, cpos,
840 block = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos);
841 ocfs2_remove_xattr_clusters_from_cache(INODE_CACHE(inode),
851 static int ocfs2_xattr_value_truncate(struct inode *inode,
857 u32 new_clusters = ocfs2_clusters_for_bytes(inode->i_sb, len);
864 ret = ocfs2_xattr_extend_allocation(inode,
868 ret = ocfs2_xattr_shrink_size(inode,
924 static int ocfs2_xattr_list_entries(struct inode *inode,
938 ret = ocfs2_xattr_list_entry(inode->i_sb,
949 int ocfs2_has_inline_xattr_value_outside(struct inode *inode,
956 ((void *)di + inode->i_sb->s_blocksize -
966 static int ocfs2_xattr_ibody_list(struct inode *inode,
972 struct ocfs2_inode_info *oi = OCFS2_I(inode);
979 ((void *)di + inode->i_sb->s_blocksize -
982 ret = ocfs2_xattr_list_entries(inode, header, buffer, buffer_size);
987 static int ocfs2_xattr_block_list(struct inode *inode,
999 ret = ocfs2_read_xattr_block(inode, le64_to_cpu(di->i_xattr_loc),
1009 ret = ocfs2_xattr_list_entries(inode, header,
1012 ret = ocfs2_xattr_tree_list_index_block(inode, blk_bh,
1095 static int ocfs2_xattr_get_value_outside(struct inode *inode,
1109 bpc = ocfs2_clusters_to_blocks(inode->i_sb, 1);
1110 blocksize = inode->i_sb->s_blocksize;
1114 ret = ocfs2_xattr_get_clusters(inode, cpos, &p_cluster,
1121 blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cluster);
1124 ret = ocfs2_read_block(INODE_CACHE(inode), blkno,
1147 static int ocfs2_xattr_ibody_get(struct inode *inode,
1154 struct ocfs2_inode_info *oi = OCFS2_I(inode);
1163 xs->end = (void *)di + inode->i_sb->s_blocksize;
1185 ret = ocfs2_xattr_get_value_outside(inode, xv,
1197 static int ocfs2_xattr_block_get(struct inode *inode,
1210 xs->bucket = ocfs2_xattr_bucket_new(inode);
1217 ret = ocfs2_xattr_block_find(inode, name_index, name, xs);
1240 ret = ocfs2_xattr_bucket_get_name_value(inode->i_sb,
1257 ret = ocfs2_xattr_get_value_outside(inode, xv,
1274 int ocfs2_xattr_get_nolock(struct inode *inode,
1283 struct ocfs2_inode_info *oi = OCFS2_I(inode);
1291 if (!ocfs2_supports_xattr(OCFS2_SB(inode->i_sb)))
1300 ret = ocfs2_xattr_ibody_get(inode, name_index, name, buffer,
1303 ret = ocfs2_xattr_block_get(inode, name_index, name, buffer,
1314 static int ocfs2_xattr_get(struct inode *inode,
1324 had_lock = ocfs2_inode_lock_tracker(inode, &di_bh, 0, &oh);
1329 down_read(&OCFS2_I(inode)->ip_xattr_sem);
1330 ret = ocfs2_xattr_get_nolock(inode, di_bh, name_index,
1332 up_read(&OCFS2_I(inode)->ip_xattr_sem);
1334 ocfs2_inode_unlock_tracker(inode, 0, &oh, had_lock);
1341 static int __ocfs2_xattr_set_value_outside(struct inode *inode,
1348 u16 blocksize = inode->i_sb->s_blocksize;
1350 u32 cpos = 0, bpc = ocfs2_clusters_to_blocks(inode->i_sb, 1);
1351 u32 clusters = ocfs2_clusters_for_bytes(inode->i_sb, value_len);
1360 ret = ocfs2_xattr_get_clusters(inode, cpos, &p_cluster,
1370 blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cluster);
1373 ret = ocfs2_read_block(INODE_CACHE(inode), blkno,
1381 INODE_CACHE(inode),
1682 * Operations for xattrs stored in blocks. This includes inline inode
2262 struct inode *inode,
2268 BUG_ON(!(OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_XATTR_FL));
2270 loc->xl_inode = inode;
2281 struct inode *inode,
2290 loc->xl_inode = inode;
2315 static int ocfs2_lock_xattr_remove_allocators(struct inode *inode,
2327 ret = ocfs2_xattr_get_clusters(inode, 0, &p_cluster,
2339 ret = ocfs2_refcounted_xattr_delete_need(inode, ref_ci,
2347 ret = ocfs2_reserve_new_metadata_blocks(OCFS2_SB(inode->i_sb),
2356 static int ocfs2_remove_value_outside(struct inode*inode,
2363 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
2380 ret = ocfs2_lock_xattr_remove_allocators(inode, vb->vb_xv,
2393 ret = ocfs2_xattr_value_truncate(inode, vb, 0, &ctxt);
2415 static int ocfs2_xattr_ibody_remove(struct inode *inode,
2430 ((void *)di + inode->i_sb->s_blocksize -
2433 ret = ocfs2_remove_value_outside(inode, &vb, header,
2444 static int ocfs2_xattr_block_remove(struct inode *inode,
2463 ret = ocfs2_remove_value_outside(inode, &vb, header,
2466 ret = ocfs2_iterate_xattr_index_block(inode,
2474 static int ocfs2_xattr_free_block(struct inode *inode,
2479 struct inode *xb_alloc_inode;
2483 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
2489 ret = ocfs2_read_xattr_block(inode, block, &blk_bh);
2495 ret = ocfs2_xattr_block_remove(inode, blk_bh, ref_ci, ref_root_bh);
2552 * Free extended attribute resources associated with this inode.
2554 int ocfs2_xattr_remove(struct inode *inode, struct buffer_head *di_bh)
2556 struct ocfs2_inode_info *oi = OCFS2_I(inode);
2564 if (!ocfs2_supports_xattr(OCFS2_SB(inode->i_sb)))
2570 if (ocfs2_is_refcount_inode(inode)) {
2571 ret = ocfs2_lock_refcount_tree(OCFS2_SB(inode->i_sb),
2583 ret = ocfs2_xattr_ibody_remove(inode, di_bh,
2592 ret = ocfs2_xattr_free_block(inode,
2601 handle = ocfs2_start_trans((OCFS2_SB(inode->i_sb)),
2608 ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), di_bh,
2621 ocfs2_update_inode_fsync_trans(handle, inode, 0);
2625 ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle);
2628 ocfs2_unlock_refcount_tree(OCFS2_SB(inode->i_sb), ref_tree, 1);
2633 static int ocfs2_xattr_has_space_inline(struct inode *inode,
2636 struct ocfs2_inode_info *oi = OCFS2_I(inode);
2637 unsigned int xattrsize = OCFS2_SB(inode->i_sb)->s_xattr_inline_size;
2646 } else if (ocfs2_inode_is_fast_symlink(inode)) {
2647 free = ocfs2_fast_symlink_chars(inode->i_sb) -
2664 * Find extended attribute in inode block and
2667 static int ocfs2_xattr_ibody_find(struct inode *inode,
2672 struct ocfs2_inode_info *oi = OCFS2_I(inode);
2677 if (inode->i_sb->s_blocksize == OCFS2_MIN_BLOCKSIZE)
2682 has_space = ocfs2_xattr_has_space_inline(inode, di);
2689 xs->end = (void *)di + inode->i_sb->s_blocksize;
2695 (xs->end - OCFS2_SB(inode->i_sb)->s_xattr_inline_size);
2710 static int ocfs2_xattr_ibody_init(struct inode *inode,
2715 struct ocfs2_inode_info *oi = OCFS2_I(inode);
2717 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
2720 if (!ocfs2_xattr_has_space_inline(inode, di)) {
2725 ret = ocfs2_journal_access_di(ctxt->handle, INODE_CACHE(inode), di_bh,
2739 } else if (!(ocfs2_inode_is_fast_symlink(inode))) {
2760 * Set, replace or remove an extended attribute into inode block.
2763 static int ocfs2_xattr_ibody_set(struct inode *inode,
2769 struct ocfs2_inode_info *oi = OCFS2_I(inode);
2772 if (inode->i_sb->s_blocksize == OCFS2_MIN_BLOCKSIZE)
2777 ret = ocfs2_xattr_ibody_init(inode, xs->inode_bh, ctxt);
2785 ocfs2_init_dinode_xa_loc(&loc, inode, xs->inode_bh,
2807 static int ocfs2_xattr_block_find(struct inode *inode,
2820 ret = ocfs2_read_xattr_block(inode, le64_to_cpu(di->i_xattr_loc),
2838 ret = ocfs2_xattr_index_block_find(inode, blk_bh,
2854 static int ocfs2_create_xattr_block(struct inode *inode,
2868 ret = ocfs2_journal_access_di(ctxt->handle, INODE_CACHE(inode),
2883 new_bh = sb_getblk(inode->i_sb, first_blkno);
2890 ocfs2_set_new_buffer_uptodate(INODE_CACHE(inode), new_bh);
2892 ret = ocfs2_journal_access_xb(ctxt->handle, INODE_CACHE(inode),
2902 memset(xblk, 0, inode->i_sb->s_blocksize);
2908 cpu_to_le32(OCFS2_SB(inode->i_sb)->fs_generation);
2916 ocfs2_xattr_recs_per_xb(inode->i_sb));
2922 /* Add it to the inode */
2925 spin_lock(&OCFS2_I(inode)->ip_lock);
2926 OCFS2_I(inode)->ip_dyn_features |= OCFS2_HAS_XATTR_FL;
2927 di->i_dyn_features = cpu_to_le16(OCFS2_I(inode)->ip_dyn_features);
2928 spin_unlock(&OCFS2_I(inode)->ip_lock);
2946 static int ocfs2_xattr_block_set(struct inode *inode,
2957 ret = ocfs2_create_xattr_block(inode, xs->inode_bh, ctxt,
2968 xs->end = (void *)xblk + inode->i_sb->s_blocksize;
2974 ocfs2_init_xattr_block_xa_loc(&loc, inode, xs->xattr_bh,
2983 ret = ocfs2_xattr_create_index_block(inode, xs, ctxt);
2990 ret = ocfs2_xattr_set_entry_index_block(inode, xi, xs, ctxt);
2996 /* Check whether the new xattr can be inserted into the inode. */
2997 static int ocfs2_xattr_can_be_in_inode(struct inode *inode,
3029 static int ocfs2_calc_xattr_set_need(struct inode *inode,
3046 u32 new_clusters = ocfs2_clusters_for_bytes(inode->i_sb,
3057 ocfs2_clusters_to_blocks(inode->i_sb, 1);
3060 credits += ocfs2_blocks_per_xattr_bucket(inode->i_sb);
3064 credits += ocfs2_calc_extend_credits(inode->i_sb,
3087 ret = ocfs2_xattr_bucket_get_name_value(inode->i_sb,
3092 credits += ocfs2_blocks_per_xattr_bucket(inode->i_sb);
3108 credits += ocfs2_remove_extent_credits(inode->i_sb);
3118 * In xattr set, we always try to set the xe in inode first,
3119 * so if it can be inserted into inode successfully, the old
3121 * will be inserted into inode as a new xattr in inode.
3123 if (ocfs2_xattr_can_be_in_inode(inode, xi, xis)) {
3125 credits += ocfs2_remove_extent_credits(inode->i_sb) +
3129 inode->i_sb,
3140 old_clusters = ocfs2_clusters_for_bytes(inode->i_sb,
3149 credits += ocfs2_remove_extent_credits(inode->i_sb);
3154 credits += ocfs2_calc_extend_credits(inode->i_sb,
3177 ret = ocfs2_read_xattr_block(inode,
3200 credits += ocfs2_calc_extend_credits(inode->i_sb,
3213 credits += ocfs2_blocks_per_xattr_bucket(inode->i_sb);
3215 OCFS2_SB(inode->i_sb)->s_clustersize) {
3216 credits += ocfs2_blocks_per_xattr_bucket(inode->i_sb);
3224 credits += ocfs2_calc_extend_credits(inode->i_sb,
3241 static int ocfs2_init_xattr_set_ctxt(struct inode *inode,
3251 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
3257 ret = ocfs2_calc_xattr_set_need(inode, di, xi, xis, xbs,
3297 static int __ocfs2_xattr_set_handle(struct inode *inode,
3309 ret = ocfs2_xattr_ibody_set(inode, xi, xis, ctxt);
3311 ret = ocfs2_xattr_block_set(inode, xi, xbs, ctxt);
3313 /* We always try to set extended attribute into inode first*/
3314 ret = ocfs2_xattr_ibody_set(inode, xi, xis, ctxt);
3325 ret = ocfs2_calc_xattr_set_need(inode,
3344 ret = ocfs2_xattr_block_set(inode, xi, xbs, ctxt);
3347 ret = ocfs2_xattr_block_find(inode,
3355 ret = ocfs2_calc_xattr_set_need(inode,
3376 * If no space in inode, we will set extended attribute
3379 ret = ocfs2_xattr_block_set(inode, xi, xbs, ctxt);
3385 * existing in inode, we will remove it.
3390 ret = ocfs2_calc_xattr_set_need(inode,
3408 ret = ocfs2_xattr_ibody_set(inode, xi,
3415 /* Update inode ctime. */
3416 ret = ocfs2_journal_access_di(ctxt->handle, INODE_CACHE(inode),
3424 inode_set_ctime_current(inode);
3425 di->i_ctime = cpu_to_le64(inode_get_ctime_sec(inode));
3426 di->i_ctime_nsec = cpu_to_le32(inode_get_ctime_nsec(inode));
3434 * This function only called duing creating inode
3435 * for init security/acl xattrs of the new inode.
3439 struct inode *inode,
3474 if (!ocfs2_supports_xattr(OCFS2_SB(inode->i_sb)))
3482 if (inode->i_sb->s_blocksize == OCFS2_MIN_BLOCKSIZE) {
3483 xbs.bucket = ocfs2_xattr_bucket_new(inode);
3493 down_write(&OCFS2_I(inode)->ip_xattr_sem);
3495 ret = ocfs2_xattr_ibody_find(inode, name_index, name, &xis);
3499 ret = ocfs2_xattr_block_find(inode, name_index, name, &xbs);
3504 ret = __ocfs2_xattr_set_handle(inode, di, &xi, &xis, &xbs, &ctxt);
3507 up_write(&OCFS2_I(inode)->ip_xattr_sem);
3517 * Set, replace or remove an extended attribute for this inode.
3521 int ocfs2_xattr_set(struct inode *inode,
3531 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
3532 struct inode *tl_inode = osb->osb_tl_inode;
3560 xbs.bucket = ocfs2_xattr_bucket_new(inode);
3566 had_lock = ocfs2_inode_lock_tracker(inode, &di_bh, 1, &oh);
3575 down_write(&OCFS2_I(inode)->ip_xattr_sem);
3577 * Scan inode and external block to find the same name
3580 ret = ocfs2_xattr_ibody_find(inode, name_index, name, &xis);
3584 ret = ocfs2_xattr_block_find(inode, name_index, name, &xbs);
3603 if (ocfs2_is_refcount_inode(inode) &&
3605 ret = ocfs2_prepare_refcount_xattr(inode, di, &xi,
3626 ret = ocfs2_init_xattr_set_ctxt(inode, di, &xi, &xis,
3633 /* we need to update inode's ctime field, so add credit for it. */
3642 ret = __ocfs2_xattr_set_handle(inode, di, &xi, &xis, &xbs, &ctxt);
3643 ocfs2_update_inode_fsync_trans(ctxt.handle, inode, 0);
3659 up_write(&OCFS2_I(inode)->ip_xattr_sem);
3661 ret = ocfs2_try_remove_refcount_tree(inode, di_bh);
3665 ocfs2_inode_unlock_tracker(inode, 1, &oh, had_lock);
3679 static int ocfs2_xattr_get_rec(struct inode *inode,
3693 ret = ocfs2_find_leaf(INODE_CACHE(inode), el, name_hash,
3704 ret = ocfs2_error(inode->i_sb,
3706 inode->i_ino,
3722 ret = ocfs2_error(inode->i_sb, "Inode %lu has bad extent record (%u, %u, 0) in xattr\n",
3723 inode->i_ino,
3738 typedef int (xattr_bucket_func)(struct inode *inode,
3742 static int ocfs2_find_xe_in_bucket(struct inode *inode,
3774 ret = ocfs2_xattr_bucket_get_name_value(inode->i_sb,
3806 static int ocfs2_xattr_bucket_find(struct inode *inode,
3819 u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
3824 search = ocfs2_xattr_bucket_new(inode);
3874 ret = ocfs2_find_xe_in_bucket(inode, search,
3901 xs->end = xs->base + inode->i_sb->s_blocksize;
3905 trace_ocfs2_xattr_bucket_find(OCFS2_I(inode)->ip_blkno,
3917 static int ocfs2_xattr_index_block_find(struct inode *inode,
3930 u32 name_hash = ocfs2_xattr_name_hash(inode, name, strlen(name));
3935 trace_ocfs2_xattr_index_block_find(OCFS2_I(inode)->ip_blkno,
3940 ret = ocfs2_xattr_get_rec(inode, name_hash, &p_blkno, &first_hash,
3949 trace_ocfs2_xattr_index_block_find_rec(OCFS2_I(inode)->ip_blkno,
3954 ret = ocfs2_xattr_bucket_find(inode, name_index, name, name_hash,
3961 static int ocfs2_iterate_xattr_buckets(struct inode *inode,
3968 u32 bpc = ocfs2_xattr_buckets_per_cluster(OCFS2_SB(inode->i_sb));
3972 bucket = ocfs2_xattr_bucket_new(inode);
3979 (unsigned long long)OCFS2_I(inode)->ip_blkno,
3999 ret = func(inode, bucket, para);
4039 static int ocfs2_list_xattr_bucket(struct inode *inode,
4052 ret = ocfs2_xattr_bucket_get_name_value(inode->i_sb,
4062 ret = ocfs2_xattr_list_entry(inode->i_sb,
4075 static int ocfs2_iterate_xattr_index_block(struct inode *inode,
4091 ret = ocfs2_xattr_get_rec(inode, name_hash, &p_blkno,
4098 ret = rec_func(inode, blk_bh, p_blkno, e_cpos,
4116 static int ocfs2_list_xattr_tree_rec(struct inode *inode,
4120 return ocfs2_iterate_xattr_buckets(inode, blkno, len,
4124 static int ocfs2_xattr_tree_list_index_block(struct inode *inode,
4136 ret = ocfs2_iterate_xattr_index_block(inode, blk_bh,
4178 static void ocfs2_cp_xattr_block_to_bucket(struct inode *inode,
4182 int i, blocksize = inode->i_sb->s_blocksize;
4183 int blks = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
4246 static void ocfs2_xattr_update_xattr_search(struct inode *inode,
4257 xs->end = xs->base + inode->i_sb->s_blocksize;
4266 static int ocfs2_xattr_create_index_block(struct inode *inode,
4274 struct ocfs2_inode_info *oi = OCFS2_I(inode);
4294 ret = ocfs2_journal_access_xb(handle, INODE_CACHE(inode), xb_bh,
4313 blkno = ocfs2_clusters_to_blocks(inode->i_sb, bit_off);
4330 ocfs2_cp_xattr_block_to_bucket(inode, xb_bh, xs->bucket);
4333 ocfs2_xattr_update_xattr_search(inode, xs, xb_bh);
4336 memset(&xb->xb_attrs, 0, inode->i_sb->s_blocksize -
4343 xr->xt_list.l_count = cpu_to_le16(ocfs2_xattr_recs_per_xb(inode->i_sb));
4379 static int ocfs2_defrag_xattr_bucket(struct inode *inode,
4389 size_t blocksize = inode->i_sb->s_blocksize;
4501 static int ocfs2_mv_xattr_bucket_cross_cluster(struct inode *inode,
4510 struct super_block *sb = inode->i_sb;
4525 ret = ocfs2_mv_xattr_buckets(inode, handle, bucket_blkno(first),
4619 static int ocfs2_divide_xattr_bucket(struct inode *inode,
4631 int blocksize = inode->i_sb->s_blocksize;
4636 s_bucket = ocfs2_xattr_bucket_new(inode);
4637 t_bucket = ocfs2_xattr_bucket_new(inode);
4796 static int ocfs2_cp_xattr_bucket(struct inode *inode,
4811 s_bucket = ocfs2_xattr_bucket_new(inode);
4812 t_bucket = ocfs2_xattr_bucket_new(inode);
4870 static int ocfs2_mv_xattr_buckets(struct inode *inode, handle_t *handle,
4876 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
4877 int blks_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
4891 old_first = ocfs2_xattr_bucket_new(inode);
4893 new_first = ocfs2_xattr_bucket_new(inode);
4925 ret = ocfs2_cp_xattr_bucket(inode, handle,
4973 static int ocfs2_divide_xattr_cluster(struct inode *inode,
4979 u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
4982 BUG_ON(OCFS2_XATTR_BUCKET_SIZE < OCFS2_SB(inode->i_sb)->s_clustersize);
4991 return ocfs2_divide_xattr_bucket(inode, handle, prev_blk,
5021 static int ocfs2_adjust_xattr_cross_cluster(struct inode *inode,
5036 if (ocfs2_xattr_buckets_per_cluster(OCFS2_SB(inode->i_sb)) > 1) {
5037 ret = ocfs2_mv_xattr_bucket_cross_cluster(inode,
5049 ocfs2_clusters_to_blocks(inode->i_sb, 1));
5052 ret = ocfs2_mv_xattr_buckets(inode, handle,
5059 ret = ocfs2_divide_xattr_cluster(inode, handle,
5089 static int ocfs2_add_new_xattr_cluster(struct inode *inode,
5099 u16 bpc = ocfs2_clusters_to_blocks(inode->i_sb, 1);
5104 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
5108 (unsigned long long)OCFS2_I(inode)->ip_blkno,
5112 ocfs2_init_xattr_tree_extent_tree(&et, INODE_CACHE(inode), root_bh);
5114 ret = ocfs2_journal_access_xb(handle, INODE_CACHE(inode), root_bh,
5149 ret = ocfs2_adjust_xattr_cross_cluster(inode,
5187 static int ocfs2_extend_xattr_bucket(struct inode *inode,
5194 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
5195 u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
5232 ret = ocfs2_cp_xattr_bucket(inode, handle, end_blk,
5240 ret = ocfs2_divide_xattr_bucket(inode, handle, target_blk,
5263 static int ocfs2_add_new_xattr_bucket(struct inode *inode,
5274 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
5285 first = ocfs2_xattr_bucket_new(inode);
5292 ret = ocfs2_xattr_get_rec(inode, name_hash, &p_blkno, &e_cpos,
5311 ret = ocfs2_add_new_xattr_cluster(inode,
5326 ret = ocfs2_extend_xattr_bucket(inode,
5348 static int ocfs2_xattr_bucket_value_truncate(struct inode *inode,
5358 size_t blocksize = inode->i_sb->s_blocksize;
5390 ret = ocfs2_xattr_value_truncate(inode, &vb, len, ctxt);
5411 static int ocfs2_rm_xattr_cluster(struct inode *inode,
5419 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
5420 struct inode *tl_inode = osb->osb_tl_inode;
5428 ret = ocfs2_iterate_xattr_buckets(inode, blkno, len,
5435 ocfs2_init_xattr_tree_extent_tree(&et, INODE_CACHE(inode), root_bh);
5440 (unsigned long long)OCFS2_I(inode)->ip_blkno,
5443 ocfs2_remove_xattr_clusters_from_cache(INODE_CACHE(inode), blkno,
5446 ret = ocfs2_lock_allocators(inode, &et, 0, 1, NULL, &meta_ac);
5469 ret = ocfs2_journal_access_xb(handle, INODE_CACHE(inode), root_bh,
5489 ocfs2_update_inode_fsync_trans(handle, inode, 0);
5512 static int ocfs2_check_xattr_bucket_collision(struct inode *inode,
5517 u32 name_hash = ocfs2_xattr_name_hash(inode, name, strlen(name));
5538 static int ocfs2_xattr_set_entry_bucket(struct inode *inode,
5561 ret = ocfs2_defrag_xattr_bucket(inode, ctxt->handle,
5581 static int ocfs2_xattr_set_entry_index_block(struct inode *inode,
5590 ret = ocfs2_xattr_set_entry_bucket(inode, xi, xs, ctxt);
5606 ret = ocfs2_check_xattr_bucket_collision(inode,
5614 ret = ocfs2_add_new_xattr_bucket(inode,
5631 ret = ocfs2_xattr_index_block_find(inode, xs->xattr_bh,
5639 ret = ocfs2_xattr_set_entry_bucket(inode, xi, xs, ctxt);
5647 static int ocfs2_delete_xattr_in_bucket(struct inode *inode,
5655 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
5658 ocfs2_blocks_per_xattr_bucket(inode->i_sb);
5670 ret = ocfs2_get_xattr_tree_value_root(inode->i_sb, bucket,
5677 ret = ocfs2_lock_xattr_remove_allocators(inode, xv,
5690 ret = ocfs2_xattr_bucket_value_truncate(inode, bucket,
5719 static int ocfs2_xattr_bucket_post_refcount(struct inode *inode,
5753 static int ocfs2_prepare_refcount_xattr(struct inode *inode,
5771 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
5792 ret = ocfs2_xattr_bucket_get_name_value(inode->i_sb,
5826 ret = ocfs2_xattr_get_clusters(inode, 0, &p_cluster,
5859 ret = ocfs2_refcounted_xattr_delete_need(inode,
5868 ret = ocfs2_refcount_cow_xattr(inode, di, &vb,
5883 static int ocfs2_xattr_value_attach_refcount(struct inode *inode,
5899 ret = ocfs2_xattr_get_clusters(inode, cpos, &p_cluster,
5912 ret = ocfs2_add_refcount_flag(inode, value_et,
5929 * Used for xattrs stored in inode and ocfs2_xattr_block.
5931 static int ocfs2_xattr_attach_refcount_normal(struct inode *inode,
5955 ocfs2_init_xattr_value_extent_tree(&et, INODE_CACHE(inode), vb);
5957 ret = ocfs2_xattr_value_attach_refcount(inode, xv, &et,
5969 static int ocfs2_xattr_inline_attach_refcount(struct inode *inode,
5977 (fe_bh->b_data + inode->i_sb->s_blocksize -
5984 return ocfs2_xattr_attach_refcount_normal(inode, &vb, header,
6030 static int ocfs2_xattr_bucket_value_refcount(struct inode *inode,
6052 if (ocfs2_meta_ecc(OCFS2_SB(inode->i_sb)))
6064 ret = ocfs2_get_xattr_tree_value_root(inode->i_sb, bucket, i,
6072 INODE_CACHE(inode), &vb);
6074 ret = ocfs2_xattr_value_attach_refcount(inode, vb.vb_xv,
6088 static int ocfs2_refcount_xattr_tree_rec(struct inode *inode,
6092 return ocfs2_iterate_xattr_buckets(inode, blkno, len,
6097 static int ocfs2_xattr_block_attach_refcount(struct inode *inode,
6114 ret = ocfs2_xattr_attach_refcount_normal(inode, &vb, header,
6124 ret = ocfs2_iterate_xattr_index_block(inode, blk_bh,
6132 int ocfs2_xattr_attach_refcount_tree(struct inode *inode,
6139 struct ocfs2_inode_info *oi = OCFS2_I(inode);
6144 ret = ocfs2_xattr_inline_attach_refcount(inode, fe_bh,
6156 ret = ocfs2_read_xattr_block(inode, le64_to_cpu(di->i_xattr_loc),
6163 ret = ocfs2_xattr_block_attach_refcount(inode, blk_bh, ref_ci,
6177 * old_bh and new_bh are inode bh for the old and new inode.
6180 struct inode *old_inode;
6181 struct inode *new_inode;
6193 * xattr in inode, block and xattr tree have different implementaions.
6251 /* Used by xattr inode and block to return the right xv and buffer_head. */
6323 * It can be used for inode, block and bucket.
6540 static int ocfs2_create_empty_xattr_block(struct inode *inode,
6546 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
6565 ret = ocfs2_create_xattr_block(inode, fe_bh, &ctxt, indexed,
6605 /* One more credits in case we need to add xattr flags in new inode. */
6718 static int ocfs2_calc_value_tree_metas(struct inode *inode,
6729 return ocfs2_value_metas_in_xattr_header(inode->i_sb, bucket->bu_bhs[0],
6919 struct inode *inode,
6931 ocfs2_xattr_buckets_per_cluster(OCFS2_SB(inode->i_sb));
6949 new_blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cluster);
6979 blkno += ocfs2_clusters_to_blocks(inode->i_sb, num_clusters);
6987 * Create the same xattr extent record in the new inode's xattr tree.
6989 static int ocfs2_reflink_xattr_rec(struct inode *inode,
7000 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
7026 ret = ocfs2_reflink_xattr_buckets(handle, inode, args, &et,
7124 int ocfs2_reflink_xattrs(struct inode *old_inode,
7126 struct inode *new_inode,
7200 * Initialize security and acl for a already created inode.
7206 int ocfs2_init_security_and_acl(struct inode *dir,
7207 struct inode *inode,
7213 ret = ocfs2_init_security_get(inode, dir, qstr, NULL);
7224 ret = ocfs2_init_acl(NULL, inode, dir, NULL, dir_bh, NULL, NULL);
7238 struct dentry *unused, struct inode *inode,
7241 return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_SECURITY,
7247 struct dentry *unused, struct inode *inode,
7251 return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_SECURITY,
7255 static int ocfs2_initxattrs(struct inode *inode, const struct xattr *xattr_array,
7274 err = ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_SECURITY,
7283 int ocfs2_init_security_get(struct inode *inode,
7284 struct inode *dir,
7294 ret = security_inode_init_security(inode, dir, qstr,
7306 return security_inode_init_security(inode, dir, qstr,
7311 struct inode *inode,
7317 return ocfs2_xattr_set_handle(handle, inode, di_bh,
7333 struct dentry *unused, struct inode *inode,
7336 return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_TRUSTED,
7342 struct dentry *unused, struct inode *inode,
7346 return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_TRUSTED,
7360 struct dentry *unused, struct inode *inode,
7363 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
7367 return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_USER, name,
7373 struct dentry *unused, struct inode *inode,
7377 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
7382 return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_USER,