Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 125870
b: refs/heads/master
c: 91f2033
h: refs/heads/master
v: v3
  • Loading branch information
Joel Becker authored and Mark Fasheh committed Jan 5, 2009
1 parent 05f3e8b commit aa1c418
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 28 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: ed29c0ca14871021fc8aced74650648dcb2c6e81
refs/heads/master: 91f2033fa997aa92607470ed1ef90685b9d77a8c
52 changes: 25 additions & 27 deletions trunk/fs/ocfs2/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -4314,43 +4314,42 @@ static int ocfs2_extend_xattr_bucket(struct inode *inode,
}

/*
* Add new xattr bucket in an extent record and adjust the buckets accordingly.
* xb_bh is the ocfs2_xattr_block.
* We will move all the buckets starting from header_bh to the next place. As
* for this one, half num of its xattrs will be moved to the next one.
* Add new xattr bucket in an extent record and adjust the buckets
* accordingly. xb_bh is the ocfs2_xattr_block, and target is the
* bucket we want to insert into.
*
* We will allocate a new cluster if current cluster is full. The
* underlying calls will make sure that there is space at the target
* bucket, shifting buckets around if necessary. 'target' may be updated
* by those calls.
* In the easy case, we will move all the buckets after target down by
* one. Half of target's xattrs will be moved to the next bucket.
*
* If current cluster is full, we'll allocate a new one. This may not
* be contiguous. The underlying calls will make sure that there is
* space for the insert, shifting buckets around if necessary.
* 'target' may be moved by those calls.
*/
static int ocfs2_add_new_xattr_bucket(struct inode *inode,
struct buffer_head *xb_bh,
struct buffer_head *header_bh,
struct ocfs2_xattr_bucket *target,
struct ocfs2_xattr_set_ctxt *ctxt)
{
struct ocfs2_xattr_block *xb =
(struct ocfs2_xattr_block *)xb_bh->b_data;
struct ocfs2_xattr_tree_root *xb_root = &xb->xb_attrs.xb_root;
struct ocfs2_extent_list *el = &xb_root->xt_list;
struct ocfs2_xattr_header *xh =
(struct ocfs2_xattr_header *)header_bh->b_data;
u32 name_hash = le32_to_cpu(xh->xh_entries[0].xe_name_hash);
u32 name_hash =
le32_to_cpu(bucket_xh(target)->xh_entries[0].xe_name_hash);
struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
int ret, num_buckets, extend = 1;
u64 p_blkno;
u32 e_cpos, num_clusters;
/* The bucket at the front of the extent */
struct ocfs2_xattr_bucket *first, *target;
struct ocfs2_xattr_bucket *first;

mlog(0, "Add new xattr bucket starting form %llu\n",
(unsigned long long)header_bh->b_blocknr);
mlog(0, "Add new xattr bucket starting from %llu\n",
(unsigned long long)bucket_blkno(target));

/* 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) {
if (!first) {
ret = -ENOMEM;
mlog_errno(ret);
goto out;
Expand All @@ -4369,12 +4368,6 @@ static int ocfs2_add_new_xattr_bucket(struct inode *inode,
goto out;
}

ret = ocfs2_read_xattr_bucket(target, header_bh->b_blocknr);
if (ret) {
mlog_errno(ret);
goto out;
}

num_buckets = ocfs2_xattr_buckets_per_cluster(osb) * num_clusters;
if (num_buckets == le16_to_cpu(bucket_xh(first)->xh_num_buckets)) {
/*
Expand Down Expand Up @@ -4407,7 +4400,6 @@ static int ocfs2_add_new_xattr_bucket(struct inode *inode,

out:
ocfs2_xattr_bucket_free(first);
ocfs2_xattr_bucket_free(target);

return ret;
}
Expand Down Expand Up @@ -5083,15 +5075,21 @@ static int ocfs2_xattr_set_entry_index_block(struct inode *inode,

ret = ocfs2_add_new_xattr_bucket(inode,
xs->xattr_bh,
xs->bucket->bu_bhs[0],
xs->bucket,
ctxt);
if (ret) {
mlog_errno(ret);
goto out;
}

/*
* ocfs2_add_new_xattr_bucket() will have updated
* xs->bucket if it moved, but it will not have updated
* any of the other search fields. Thus, we drop it and
* re-search. Everything should be cached, so it'll be
* quick.
*/
ocfs2_xattr_bucket_relse(xs->bucket);

ret = ocfs2_xattr_index_block_find(inode, xs->xattr_bh,
xi->name_index,
xi->name, xs);
Expand Down

0 comments on commit aa1c418

Please sign in to comment.