aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Becker <joel.becker@oracle.com>2008-11-26 15:25:41 -0800
committerMark Fasheh <mfasheh@suse.com>2009-01-05 08:40:30 -0800
commit91f2033fa997aa92607470ed1ef90685b9d77a8c (patch)
tree7082fbdd368eff8e82e09f26b24a9f19d17a8278
parented29c0ca14871021fc8aced74650648dcb2c6e81 (diff)
ocfs2: Pass xs->bucket into ocfs2_add_new_xattr_bucket().
Pass the actual target bucket for insert through to ocfs2_add_new_xattr_bucket(). Now growing a bucket has no buffer_head knowledge. ocfs2_add_new_xattr_bucket() leavs xs->bucket in the proper state for insert. However, it doesn't update the rest of the search fields in xs, so we still have to relse() and re-find. That's OK, because everything is cached. Signed-off-by: Joel Becker <joel.becker@oracle.com> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
-rw-r--r--fs/ocfs2/xattr.c52
1 files changed, 25 insertions, 27 deletions
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 5a5a1bd7eed..dfc51c305bb 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -4314,43 +4314,42 @@ out:
}
/*
- * 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;
@@ -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)) {
/*
@@ -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;
}
@@ -5083,15 +5075,21 @@ try_again:
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);