aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_da_btree.c
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2013-04-03 01:11:29 -0400
committerBen Myers <bpm@sgi.com>2013-04-27 14:01:06 -0400
commitd75afeb3d302019527331520a2632b6614425b40 (patch)
tree181dec415cdae00398086764a6229d115114354d /fs/xfs/xfs_da_btree.c
parentd2e448d5fdebdcda93ed171339a3d864f65c227e (diff)
xfs: add buffer types to directory and attribute buffers
Add buffer types to the buffer log items so that log recovery can validate the buffers and calculate CRCs correctly after the buffers are recovered. 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_da_btree.c')
-rw-r--r--fs/xfs/xfs_da_btree.c46
1 files changed, 43 insertions, 3 deletions
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c
index 779ecdcdbe02..5aebd9bd44d1 100644
--- a/fs/xfs/xfs_da_btree.c
+++ b/fs/xfs/xfs_da_btree.c
@@ -292,7 +292,6 @@ const struct xfs_buf_ops xfs_da3_node_buf_ops = {
292 .verify_write = xfs_da3_node_write_verify, 292 .verify_write = xfs_da3_node_write_verify,
293}; 293};
294 294
295
296int 295int
297xfs_da3_node_read( 296xfs_da3_node_read(
298 struct xfs_trans *tp, 297 struct xfs_trans *tp,
@@ -302,8 +301,35 @@ xfs_da3_node_read(
302 struct xfs_buf **bpp, 301 struct xfs_buf **bpp,
303 int which_fork) 302 int which_fork)
304{ 303{
305 return xfs_da_read_buf(tp, dp, bno, mappedbno, bpp, 304 int err;
305
306 err = xfs_da_read_buf(tp, dp, bno, mappedbno, bpp,
306 which_fork, &xfs_da3_node_buf_ops); 307 which_fork, &xfs_da3_node_buf_ops);
308 if (!err && tp) {
309 struct xfs_da_blkinfo *info = (*bpp)->b_addr;
310 int type;
311
312 switch (be16_to_cpu(info->magic)) {
313 case XFS_DA3_NODE_MAGIC:
314 case XFS_DA_NODE_MAGIC:
315 type = XFS_BLF_DA_NODE_BUF;
316 break;
317 case XFS_ATTR_LEAF_MAGIC:
318 case XFS_ATTR3_LEAF_MAGIC:
319 type = XFS_BLF_ATTR_LEAF_BUF;
320 break;
321 case XFS_DIR2_LEAFN_MAGIC:
322 case XFS_DIR3_LEAFN_MAGIC:
323 type = XFS_BLF_DIR_LEAFN_BUF;
324 break;
325 default:
326 type = 0;
327 ASSERT(0);
328 break;
329 }
330 xfs_trans_buf_set_type(tp, *bpp, type);
331 }
332 return err;
307} 333}
308 334
309/*======================================================================== 335/*========================================================================
@@ -334,6 +360,8 @@ xfs_da3_node_create(
334 error = xfs_da_get_buf(tp, args->dp, blkno, -1, &bp, whichfork); 360 error = xfs_da_get_buf(tp, args->dp, blkno, -1, &bp, whichfork);
335 if (error) 361 if (error)
336 return(error); 362 return(error);
363 bp->b_ops = &xfs_da3_node_buf_ops;
364 xfs_trans_buf_set_type(tp, bp, XFS_BLF_DA_NODE_BUF);
337 node = bp->b_addr; 365 node = bp->b_addr;
338 366
339 if (xfs_sb_version_hascrc(&mp->m_sb)) { 367 if (xfs_sb_version_hascrc(&mp->m_sb)) {
@@ -352,7 +380,6 @@ xfs_da3_node_create(
352 xfs_trans_log_buf(tp, bp, 380 xfs_trans_log_buf(tp, bp,
353 XFS_DA_LOGRANGE(node, &node->hdr, xfs_da3_node_hdr_size(node))); 381 XFS_DA_LOGRANGE(node, &node->hdr, xfs_da3_node_hdr_size(node)));
354 382
355 bp->b_ops = &xfs_da3_node_buf_ops;
356 *bpp = bp; 383 *bpp = bp;
357 return(0); 384 return(0);
358} 385}
@@ -565,6 +592,12 @@ xfs_da3_root_split(
565 btree = xfs_da3_node_tree_p(oldroot); 592 btree = xfs_da3_node_tree_p(oldroot);
566 size = (int)((char *)&btree[nodehdr.count] - (char *)oldroot); 593 size = (int)((char *)&btree[nodehdr.count] - (char *)oldroot);
567 level = nodehdr.level; 594 level = nodehdr.level;
595
596 /*
597 * we are about to copy oldroot to bp, so set up the type
598 * of bp while we know exactly what it will be.
599 */
600 xfs_trans_buf_set_type(tp, bp, XFS_BLF_DA_NODE_BUF);
568 } else { 601 } else {
569 struct xfs_dir3_icleaf_hdr leafhdr; 602 struct xfs_dir3_icleaf_hdr leafhdr;
570 struct xfs_dir2_leaf_entry *ents; 603 struct xfs_dir2_leaf_entry *ents;
@@ -577,6 +610,12 @@ xfs_da3_root_split(
577 leafhdr.magic == XFS_DIR3_LEAFN_MAGIC); 610 leafhdr.magic == XFS_DIR3_LEAFN_MAGIC);
578 size = (int)((char *)&ents[leafhdr.count] - (char *)leaf); 611 size = (int)((char *)&ents[leafhdr.count] - (char *)leaf);
579 level = 0; 612 level = 0;
613
614 /*
615 * we are about to copy oldroot to bp, so set up the type
616 * of bp while we know exactly what it will be.
617 */
618 xfs_trans_buf_set_type(tp, bp, XFS_BLF_DIR_LEAFN_BUF);
580 } 619 }
581 620
582 /* 621 /*
@@ -1092,6 +1131,7 @@ xfs_da3_root_join(
1092 */ 1131 */
1093 memcpy(root_blk->bp->b_addr, bp->b_addr, state->blocksize); 1132 memcpy(root_blk->bp->b_addr, bp->b_addr, state->blocksize);
1094 root_blk->bp->b_ops = bp->b_ops; 1133 root_blk->bp->b_ops = bp->b_ops;
1134 xfs_trans_buf_copy_type(root_blk->bp, bp);
1095 if (oldroothdr.magic == XFS_DA3_NODE_MAGIC) { 1135 if (oldroothdr.magic == XFS_DA3_NODE_MAGIC) {
1096 struct xfs_da3_blkinfo *da3 = root_blk->bp->b_addr; 1136 struct xfs_da3_blkinfo *da3 = root_blk->bp->b_addr;
1097 da3->blkno = cpu_to_be64(root_blk->bp->b_bn); 1137 da3->blkno = cpu_to_be64(root_blk->bp->b_bn);