[PATCH v2 15/20] xfsprogs/repair: pass btree block magic as param to build_ino_tree()

Brian Foster
2013-11-13T15:56:30Z

A minor cleanup to build_ino_tree() to provide the appropriate
magic value for btree block initialization from the caller. This
facilitates use of separate magic values for finobt blocks when
building the free inode btree.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
repair/phase5.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/repair/phase5.c b/repair/phase5.c
index 77eb125..10ed1eb 100644
--- a/repair/phase5.c
+++ b/repair/phase5.c
@@ -1097,7 +1097,7 @@ build_agi(xfs_mount_t *mp, xfs_agnumber_t agno,
*/
static void
build_ino_tree(xfs_mount_t *mp, xfs_agnumber_t agno,
- bt_status_t *btree_curs)
+ bt_status_t *btree_curs, __uint32_t magic)
{
xfs_agnumber_t i;
xfs_agblock_t j;
@@ -1135,11 +1135,11 @@ build_ino_tree(xfs_mount_t *mp, xfs_agnumber_t agno,
bt_hdr = XFS_BUF_TO_BLOCK(lptr->buf_p);
memset(bt_hdr, 0, mp->m_sb.sb_blocksize);
if (xfs_sb_version_hascrc(&mp->m_sb))
- xfs_btree_init_block(mp, lptr->buf_p, XFS_IBT_CRC_MAGIC,
+ xfs_btree_init_block(mp, lptr->buf_p, magic,
i, 0, agno,
XFS_BTREE_CRC_BLOCKS);
else
- xfs_btree_init_block(mp, lptr->buf_p, XFS_IBT_MAGIC,
+ xfs_btree_init_block(mp, lptr->buf_p, magic,
i, 0, agno, 0);
}

@@ -1166,11 +1166,11 @@ build_ino_tree(xfs_mount_t *mp, xfs_agnumber_t agno,
bt_hdr = XFS_BUF_TO_BLOCK(lptr->buf_p);
memset(bt_hdr, 0, mp->m_sb.sb_blocksize);
if (xfs_sb_version_hascrc(&mp->m_sb))
- xfs_btree_init_block(mp, lptr->buf_p, XFS_IBT_CRC_MAGIC,
+ xfs_btree_init_block(mp, lptr->buf_p, magic,
0, 0, agno,
XFS_BTREE_CRC_BLOCKS);
else
- xfs_btree_init_block(mp, lptr->buf_p, XFS_IBT_MAGIC,
+ xfs_btree_init_block(mp, lptr->buf_p, magic,
0, 0, agno, 0);

bt_hdr->bb_u.s.bb_leftsib = cpu_to_be32(lptr->prev_agbno);
@@ -1483,6 +1483,7 @@ phase5_func(
xfs_extlen_t freeblks2;
#endif
xfs_agblock_t num_extents;
+ __uint32_t magic;

if (verbose)
do_log(_(" - agno = %d\n"), agno);
@@ -1616,7 +1617,9 @@ phase5_func(
/*
* build inode allocation tree. this also build the agi
*/
- build_ino_tree(mp, agno, &ino_btree_curs);
+ magic = xfs_sb_version_hascrc(&mp->m_sb) ?
+ XFS_IBT_CRC_MAGIC : XFS_IBT_MAGIC;
+ build_ino_tree(mp, agno, &ino_btree_curs, magic);
write_cursor(&ino_btree_curs);
/*
* tear down cursors