diff options
author | Dave Chinner <dchinner@redhat.com> | 2013-05-21 04:02:05 -0400 |
---|---|---|
committer | Ben Myers <bpm@sgi.com> | 2013-05-23 18:52:07 -0400 |
commit | 8517de2a81da830f5d90da66b4799f4040c76dc9 (patch) | |
tree | 7d21555f5c33cfc942443eed9e6459ddd7bbdfb3 /fs/xfs/xfs_attr_leaf.c | |
parent | 6863ef8449f1908c19f43db572e4474f24a1e9da (diff) |
xfs: fully initialise temp leaf in xfs_attr3_leaf_unbalance
xfs_attr3_leaf_unbalance() uses a temporary buffer for recombining
the entries in two leaves when the destination leaf requires
compaction. The temporary buffer ends up being copied back over the
original destination buffer, so the header in the temporary buffer
needs to contain all the information that is in the destination
buffer.
To make sure the temporary buffer is fully initialised, once we've
set up the temporary incore header appropriately, write is back to
the temporary buffer before starting to move entries around.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Ben Myers <bpm@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_attr_leaf.c')
-rw-r--r-- | fs/xfs/xfs_attr_leaf.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c index 0bce1b348580..79ece72976ae 100644 --- a/fs/xfs/xfs_attr_leaf.c +++ b/fs/xfs/xfs_attr_leaf.c | |||
@@ -2181,14 +2181,24 @@ xfs_attr3_leaf_unbalance( | |||
2181 | struct xfs_attr_leafblock *tmp_leaf; | 2181 | struct xfs_attr_leafblock *tmp_leaf; |
2182 | struct xfs_attr3_icleaf_hdr tmphdr; | 2182 | struct xfs_attr3_icleaf_hdr tmphdr; |
2183 | 2183 | ||
2184 | tmp_leaf = kmem_alloc(state->blocksize, KM_SLEEP); | 2184 | tmp_leaf = kmem_zalloc(state->blocksize, KM_SLEEP); |
2185 | memset(tmp_leaf, 0, state->blocksize); | 2185 | |
2186 | memset(&tmphdr, 0, sizeof(tmphdr)); | 2186 | /* |
2187 | * Copy the header into the temp leaf so that all the stuff | ||
2188 | * not in the incore header is present and gets copied back in | ||
2189 | * once we've moved all the entries. | ||
2190 | */ | ||
2191 | memcpy(tmp_leaf, save_leaf, xfs_attr3_leaf_hdr_size(save_leaf)); | ||
2187 | 2192 | ||
2193 | memset(&tmphdr, 0, sizeof(tmphdr)); | ||
2188 | tmphdr.magic = savehdr.magic; | 2194 | tmphdr.magic = savehdr.magic; |
2189 | tmphdr.forw = savehdr.forw; | 2195 | tmphdr.forw = savehdr.forw; |
2190 | tmphdr.back = savehdr.back; | 2196 | tmphdr.back = savehdr.back; |
2191 | tmphdr.firstused = state->blocksize; | 2197 | tmphdr.firstused = state->blocksize; |
2198 | |||
2199 | /* write the header to the temp buffer to initialise it */ | ||
2200 | xfs_attr3_leaf_hdr_to_disk(tmp_leaf, &tmphdr); | ||
2201 | |||
2192 | if (xfs_attr3_leaf_order(save_blk->bp, &savehdr, | 2202 | if (xfs_attr3_leaf_order(save_blk->bp, &savehdr, |
2193 | drop_blk->bp, &drophdr)) { | 2203 | drop_blk->bp, &drophdr)) { |
2194 | xfs_attr3_leaf_moveents(drop_leaf, &drophdr, 0, | 2204 | xfs_attr3_leaf_moveents(drop_leaf, &drophdr, 0, |