*/
static int ocfs2_adjust_xattr_cross_cluster(struct inode *inode,
handle_t *handle,
- struct buffer_head **first_bh,
- struct buffer_head **header_bh,
+ struct ocfs2_xattr_bucket *first,
+ struct ocfs2_xattr_bucket *target,
u64 new_blk,
- u64 prev_blk,
u32 prev_clusters,
u32 *v_start,
int *extend)
{
int ret;
- struct ocfs2_xattr_bucket *first, *target;
mlog(0, "adjust xattrs from cluster %llu len %u to %llu\n",
- (unsigned long long)prev_blk, prev_clusters,
+ (unsigned long long)bucket_blkno(first), prev_clusters,
(unsigned long long)new_blk);
- /* The first bucket of the original extent */
- first = ocfs2_xattr_bucket_new(inode);
- /* The target bucket for insert */
- target = ocfs2_xattr_bucket_new(inode);
- if (!first || !target) {
- ret = -ENOMEM;
- mlog_errno(ret);
- goto out;
- }
-
- BUG_ON(prev_blk != (*first_bh)->b_blocknr);
- ret = ocfs2_read_xattr_bucket(first, prev_blk);
- if (ret) {
- mlog_errno(ret);
- goto out;
- }
-
- ret = ocfs2_read_xattr_bucket(target, (*header_bh)->b_blocknr);
- if (ret) {
- mlog_errno(ret);
- goto out;
- }
-
if (ocfs2_xattr_buckets_per_cluster(OCFS2_SB(inode->i_sb)) > 1) {
ret = ocfs2_mv_xattr_bucket_cross_cluster(inode,
handle,
new_blk,
prev_clusters,
v_start);
- if (ret) {
+ if (ret)
mlog_errno(ret);
- goto out;
- }
-
- /* Did first+target get moved? */
- if (prev_blk != bucket_blkno(first)) {
- brelse(*first_bh);
- *first_bh = first->bu_bhs[0];
- get_bh(*first_bh);
-
- brelse(*header_bh);
- *header_bh = target->bu_bhs[0];
- get_bh(*header_bh);
- }
} else {
/* The start of the last cluster in the first extent */
u64 last_blk = bucket_blkno(first) +
((prev_clusters - 1) *
ocfs2_clusters_to_blocks(inode->i_sb, 1));
- if (prev_clusters > 1 && bucket_blkno(target) != last_blk)
+ if (prev_clusters > 1 && bucket_blkno(target) != last_blk) {
ret = ocfs2_mv_xattr_buckets(inode, handle,
bucket_blkno(first),
last_blk, new_blk, 0,
v_start);
- else {
+ if (ret)
+ mlog_errno(ret);
+ } else {
ret = ocfs2_divide_xattr_cluster(inode, handle,
last_blk, new_blk,
v_start);
+ if (ret)
+ mlog_errno(ret);
if ((bucket_blkno(target) == last_blk) && extend)
*extend = 0;
}
}
-out:
- ocfs2_xattr_bucket_free(first);
- ocfs2_xattr_bucket_free(target);
-
return ret;
}
handle_t *handle = ctxt->handle;
struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
struct ocfs2_extent_tree et;
+ struct ocfs2_xattr_bucket *first, *target;
mlog(0, "Add new xattr cluster for %llu, previous xattr hash = %u, "
"previous xattr blkno = %llu\n",
ocfs2_init_xattr_tree_extent_tree(&et, inode, root_bh);
+ /* The first bucket of the original extent */
+ first = ocfs2_xattr_bucket_new(inode);
+ /* The target bucket for insert */
+ target = ocfs2_xattr_bucket_new(inode);
+ if (!first || !target) {
+ ret = -ENOMEM;
+ mlog_errno(ret);
+ goto leave;
+ }
+
+ BUG_ON(prev_blkno != (*first_bh)->b_blocknr);
+ ret = ocfs2_read_xattr_bucket(first, prev_blkno);
+ if (ret) {
+ mlog_errno(ret);
+ goto leave;
+ }
+
+ ret = ocfs2_read_xattr_bucket(target, (*header_bh)->b_blocknr);
+ if (ret) {
+ mlog_errno(ret);
+ goto leave;
+ }
+
ret = ocfs2_journal_access(handle, inode, root_bh,
OCFS2_JOURNAL_ACCESS_WRITE);
if (ret < 0) {
} else {
ret = ocfs2_adjust_xattr_cross_cluster(inode,
handle,
- first_bh,
- header_bh,
+ first,
+ target,
block,
- prev_blkno,
prev_clusters,
&v_start,
extend);
mlog_errno(ret);
goto leave;
}
+
+ /* Did first+target get moved? */
+ if (prev_blkno != bucket_blkno(first)) {
+ brelse(*first_bh);
+ *first_bh = first->bu_bhs[0];
+ get_bh(*first_bh);
+
+ brelse(*header_bh);
+ *header_bh = target->bu_bhs[0];
+ get_bh(*header_bh);
+ }
}
mlog(0, "Insert %u clusters at block %llu for xattr at %u\n",
mlog_errno(ret);
leave:
+ ocfs2_xattr_bucket_free(first);
+ ocfs2_xattr_bucket_free(target);
return ret;
}