aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2
diff options
context:
space:
mode:
authorJoel Becker <joel.becker@oracle.com>2008-11-26 16:18:31 -0500
committerMark Fasheh <mfasheh@suse.com>2009-01-05 11:40:29 -0500
commit54ecb6b6df54bf72befb359b21f3759b2952f9d9 (patch)
tree2b11ad3bbc6f049be5829a72850b3b62d70dbd2c /fs/ocfs2
parent874d65af1c8b8f6456a934701e6828d3017be029 (diff)
ocfs2: ocfs2_mv_xattr_buckets() can handle a partial cluster now.
If you look at ocfs2_mv_xattr_bucket_cross_cluster(), you'll notice that two-thirds of the code is almost identical to ocfs2_mv_xattr_buckets(). The only difference is that ocfs2_mv_xattr_buckets() moves a whole cluster's worth, while ocfs2_mv_xattr_bucket_cross_cluster() moves half the cluster. We change ocfs2_mv_xattr_buckets() to allow moving partial clusters. The original caller of ocfs2_mv_xattr_buckets() still moves the whole cluster's worth - it just passes a start_bucket of 0. Signed-off-by: Joel Becker <joel.becker@oracle.com> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/ocfs2')
-rw-r--r--fs/ocfs2/xattr.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index c1f2e0690747..97340940cee2 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -3995,18 +3995,19 @@ out:
3995/* 3995/*
3996 * src_blk points to the start of an existing extent. last_blk points to 3996 * src_blk points to the start of an existing extent. last_blk points to
3997 * last cluster in that extent. to_blk points to a newly allocated 3997 * last cluster in that extent. to_blk points to a newly allocated
3998 * extent. We copy the buckets from cluster at last_blk to the new extent, 3998 * extent. We copy the buckets from the cluster at last_blk to the new
3999 * initializing its xh_num_buckets. The old extent's xh_num_buckets 3999 * extent. If start_bucket is non-zero, we skip that many buckets before
4000 * shrinks by the same amount. 4000 * we start copying. The new extent's xh_num_buckets gets set to the
4001 * number of buckets we copied. The old extent's xh_num_buckets shrinks
4002 * by the same amount.
4001 */ 4003 */
4002static int ocfs2_mv_xattr_buckets(struct inode *inode, 4004static int ocfs2_mv_xattr_buckets(struct inode *inode, handle_t *handle,
4003 handle_t *handle, 4005 u64 src_blk, u64 last_blk, u64 to_blk,
4004 u64 src_blk, u64 last_blk, 4006 unsigned int start_bucket,
4005 u64 to_blk, u32 *first_hash) 4007 u32 *first_hash)
4006{ 4008{
4007 int i, ret, credits; 4009 int i, ret, credits;
4008 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 4010 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
4009 int bpc = ocfs2_clusters_to_blocks(inode->i_sb, 1);
4010 int blks_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb); 4011 int blks_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
4011 int num_buckets = ocfs2_xattr_buckets_per_cluster(osb); 4012 int num_buckets = ocfs2_xattr_buckets_per_cluster(osb);
4012 struct ocfs2_xattr_bucket *old_first, *new_first; 4013 struct ocfs2_xattr_bucket *old_first, *new_first;
@@ -4014,6 +4015,12 @@ static int ocfs2_mv_xattr_buckets(struct inode *inode,
4014 mlog(0, "mv xattrs from cluster %llu to %llu\n", 4015 mlog(0, "mv xattrs from cluster %llu to %llu\n",
4015 (unsigned long long)last_blk, (unsigned long long)to_blk); 4016 (unsigned long long)last_blk, (unsigned long long)to_blk);
4016 4017
4018 BUG_ON(start_bucket >= num_buckets);
4019 if (start_bucket) {
4020 num_buckets -= start_bucket;
4021 last_blk += (start_bucket * blks_per_bucket);
4022 }
4023
4017 /* The first bucket of the original extent */ 4024 /* The first bucket of the original extent */
4018 old_first = ocfs2_xattr_bucket_new(inode); 4025 old_first = ocfs2_xattr_bucket_new(inode);
4019 /* The first bucket of the new extent */ 4026 /* The first bucket of the new extent */
@@ -4031,10 +4038,11 @@ static int ocfs2_mv_xattr_buckets(struct inode *inode,
4031 } 4038 }
4032 4039
4033 /* 4040 /*
4034 * We need to update the first bucket of the old extent and the 4041 * We need to update the first bucket of the old extent and all
4035 * entire first cluster of the new extent. 4042 * the buckets going to the new extent.
4036 */ 4043 */
4037 credits = blks_per_bucket + bpc + handle->h_buffer_credits; 4044 credits = ((num_buckets + 1) * blks_per_bucket) +
4045 handle->h_buffer_credits;
4038 ret = ocfs2_extend_trans(handle, credits); 4046 ret = ocfs2_extend_trans(handle, credits);
4039 if (ret) { 4047 if (ret) {
4040 mlog_errno(ret); 4048 mlog_errno(ret);
@@ -4177,8 +4185,7 @@ static int ocfs2_adjust_xattr_cross_cluster(struct inode *inode,
4177 if (prev_clusters > 1 && (*header_bh)->b_blocknr != last_blk) 4185 if (prev_clusters > 1 && (*header_bh)->b_blocknr != last_blk)
4178 ret = ocfs2_mv_xattr_buckets(inode, handle, 4186 ret = ocfs2_mv_xattr_buckets(inode, handle,
4179 (*first_bh)->b_blocknr, 4187 (*first_bh)->b_blocknr,
4180 last_blk, 4188 last_blk, new_blk, 0,
4181 new_blk,
4182 v_start); 4189 v_start);
4183 else { 4190 else {
4184 ret = ocfs2_divide_xattr_cluster(inode, handle, 4191 ret = ocfs2_divide_xattr_cluster(inode, handle,