Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 125783
b: refs/heads/master
c: 161d6f3
h: refs/heads/master
i:
  125781: 4b7d008
  125779: 31aaad2
  125775: 8aa31ef
v: v3
  • Loading branch information
Joel Becker authored and Mark Fasheh committed Jan 5, 2009
1 parent 5553ae2 commit df20cc4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 33 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 178eeac354ea28828d5e94a3a7b51368c171d6a5
refs/heads/master: 161d6f30f18c4a7e2b24705b6690cce3ff276eb9
55 changes: 23 additions & 32 deletions trunk/fs/ocfs2/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -2894,21 +2894,11 @@ static int ocfs2_defrag_xattr_bucket(struct inode *inode,
struct ocfs2_xattr_header *xh;
char *entries, *buf, *bucket_buf = NULL;
u64 blkno = bucket_blkno(bucket);
u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
u16 xh_free_start;
size_t blocksize = inode->i_sb->s_blocksize;
handle_t *handle;
struct buffer_head **bhs;
struct ocfs2_xattr_entry *xe;

bhs = kzalloc(sizeof(struct buffer_head *) * blk_per_bucket,
GFP_NOFS);
if (!bhs)
return -ENOMEM;

ret = ocfs2_read_blocks(inode, blkno, blk_per_bucket, bhs, 0);
if (ret)
goto out;
struct ocfs2_xattr_bucket *wb = NULL;

/*
* In order to make the operation more efficient and generic,
Expand All @@ -2922,25 +2912,33 @@ static int ocfs2_defrag_xattr_bucket(struct inode *inode,
goto out;
}

wb = ocfs2_xattr_bucket_new(inode);
if (!wb) {
ret = -ENOMEM;
goto out;
}

ret = ocfs2_read_xattr_bucket(wb, blkno);
if (ret)
goto out;

buf = bucket_buf;
for (i = 0; i < blk_per_bucket; i++, buf += blocksize)
memcpy(buf, bhs[i]->b_data, blocksize);
for (i = 0; i < wb->bu_blocks; i++, buf += blocksize)
memcpy(buf, bucket_block(wb, i), blocksize);

handle = ocfs2_start_trans((OCFS2_SB(inode->i_sb)), blk_per_bucket);
handle = ocfs2_start_trans((OCFS2_SB(inode->i_sb)), wb->bu_blocks);
if (IS_ERR(handle)) {
ret = PTR_ERR(handle);
handle = NULL;
mlog_errno(ret);
goto out;
}

for (i = 0; i < blk_per_bucket; i++) {
ret = ocfs2_journal_access(handle, inode, bhs[i],
OCFS2_JOURNAL_ACCESS_WRITE);
if (ret < 0) {
mlog_errno(ret);
goto commit;
}
ret = ocfs2_xattr_bucket_journal_access(handle, wb,
OCFS2_JOURNAL_ACCESS_WRITE);
if (ret < 0) {
mlog_errno(ret);
goto commit;
}

xh = (struct ocfs2_xattr_header *)bucket_buf;
Expand Down Expand Up @@ -3009,21 +3007,14 @@ static int ocfs2_defrag_xattr_bucket(struct inode *inode,
cmp_xe, swap_xe);

buf = bucket_buf;
for (i = 0; i < blk_per_bucket; i++, buf += blocksize) {
memcpy(bhs[i]->b_data, buf, blocksize);
ocfs2_journal_dirty(handle, bhs[i]);
}
for (i = 0; i < wb->bu_blocks; i++, buf += blocksize)
memcpy(bucket_block(wb, i), buf, blocksize);
ocfs2_xattr_bucket_journal_dirty(handle, wb);

commit:
ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle);
out:

if (bhs) {
for (i = 0; i < blk_per_bucket; i++)
brelse(bhs[i]);
}
kfree(bhs);

ocfs2_xattr_bucket_free(wb);
kfree(bucket_buf);
return ret;
}
Expand Down

0 comments on commit df20cc4

Please sign in to comment.