summaryrefslogtreecommitdiff
path: root/fs/ocfs2/xattr.c
diff options
context:
space:
mode:
authorTao Ma <tao.ma@oracle.com>2009-08-18 07:43:52 +0400
committerJoel Becker <joel.becker@oracle.com>2009-09-23 07:09:44 +0400
commita7fe7a3a1ab5dac8d81e531c060f51e12010133b (patch)
tree9eb5a21cc29e6913d3f591cdab37f59fbfa562d2 /fs/ocfs2/xattr.c
parent8b2c0dba5159570af5721d40490f6c529d721500 (diff)
downloadlinux-a7fe7a3a1ab5dac8d81e531c060f51e12010133b.tar.xz
ocfs2: Create an xattr indexed block if needed.
With reflink, there is a need that we create a new xattr indexed block from the very beginning. So add a new parameter for ocfs2_create_xattr_block. Signed-off-by: Tao Ma <tao.ma@oracle.com>
Diffstat (limited to 'fs/ocfs2/xattr.c')
-rw-r--r--fs/ocfs2/xattr.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 6660f1c6149e..bb92a6d274c0 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -2142,7 +2142,8 @@ static int ocfs2_create_xattr_block(handle_t *handle,
struct inode *inode,
struct buffer_head *inode_bh,
struct ocfs2_alloc_context *meta_ac,
- struct buffer_head **ret_bh)
+ struct buffer_head **ret_bh,
+ int indexed)
{
int ret;
u16 suballoc_bit_start;
@@ -2188,6 +2189,17 @@ static int ocfs2_create_xattr_block(handle_t *handle,
xblk->xb_fs_generation = cpu_to_le32(osb->fs_generation);
xblk->xb_blkno = cpu_to_le64(first_blkno);
+ if (indexed) {
+ struct ocfs2_xattr_tree_root *xr = &xblk->xb_attrs.xb_root;
+ xr->xt_clusters = cpu_to_le32(1);
+ xr->xt_last_eb_blk = 0;
+ xr->xt_list.l_tree_depth = 0;
+ xr->xt_list.l_count = cpu_to_le16(
+ ocfs2_xattr_recs_per_xb(inode->i_sb));
+ xr->xt_list.l_next_free_rec = cpu_to_le16(1);
+ xblk->xb_flags = cpu_to_le16(OCFS2_XATTR_INDEXED);
+ }
+
ret = ocfs2_journal_dirty(handle, new_bh);
if (ret < 0) {
mlog_errno(ret);
@@ -2222,7 +2234,7 @@ static int ocfs2_xattr_block_set(struct inode *inode,
if (!xs->xattr_bh) {
ret = ocfs2_create_xattr_block(handle, inode, xs->inode_bh,
- ctxt->meta_ac, &new_bh);
+ ctxt->meta_ac, &new_bh, 0);
if (ret) {
mlog_errno(ret);
goto end;