summaryrefslogtreecommitdiffstats
path: root/fs/xfs/libxfs
diff options
context:
space:
mode:
authorEric Sandeen <sandeen@sandeen.net>2017-01-28 02:16:39 -0500
committerDarrick J. Wong <darrick.wong@oracle.com>2017-01-30 19:32:24 -0500
commitb6f41e448277ff080fea734b93121e6cd7513f0c (patch)
tree836dd90f7b2d3d412eb5782e1b1fc463e9d9fd4c /fs/xfs/libxfs
parentaf7d20fd83d9e2b3111a847e4220bf943e2d531c (diff)
xfs: remove boilerplate around xfs_btree_init_block
Now that xfs_btree_init_block_int is able to determine crc status from the passed-in mp, we can determine the proper magic as well if we are given a btree number, rather than an explicit magic value. Change xfs_btree_init_block[_int] callers to pass in the btree number, and let xfs_btree_init_block_int use the xfs_magics array via the xfs_btree_magic macro to determine which magic value is needed. This makes all of the if (crc) / else stanzas identical, and the if/else can be removed, leading to a single, common init_block call. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Diffstat (limited to 'fs/xfs/libxfs')
-rw-r--r--fs/xfs/libxfs/xfs_bmap.c19
-rw-r--r--fs/xfs/libxfs/xfs_bmap_btree.c10
-rw-r--r--fs/xfs/libxfs/xfs_btree.c11
-rw-r--r--fs/xfs/libxfs/xfs_btree.h4
4 files changed, 13 insertions, 31 deletions
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 1d4b8d5edaaf..d3da53e6a927 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -740,15 +740,9 @@ xfs_bmap_extents_to_btree(
740 * Fill in the root. 740 * Fill in the root.
741 */ 741 */
742 block = ifp->if_broot; 742 block = ifp->if_broot;
743 if (xfs_sb_version_hascrc(&mp->m_sb)) 743 xfs_btree_init_block_int(mp, block, XFS_BUF_DADDR_NULL,
744 xfs_btree_init_block_int(mp, block, XFS_BUF_DADDR_NULL, 744 XFS_BTNUM_BMAP, 1, 1, ip->i_ino,
745 XFS_BMAP_CRC_MAGIC, 1, 1, ip->i_ino,
746 XFS_BTREE_LONG_PTRS); 745 XFS_BTREE_LONG_PTRS);
747 else
748 xfs_btree_init_block_int(mp, block, XFS_BUF_DADDR_NULL,
749 XFS_BMAP_MAGIC, 1, 1, ip->i_ino,
750 XFS_BTREE_LONG_PTRS);
751
752 /* 746 /*
753 * Need a cursor. Can't allocate until bb_level is filled in. 747 * Need a cursor. Can't allocate until bb_level is filled in.
754 */ 748 */
@@ -817,13 +811,8 @@ try_another_ag:
817 */ 811 */
818 abp->b_ops = &xfs_bmbt_buf_ops; 812 abp->b_ops = &xfs_bmbt_buf_ops;
819 ablock = XFS_BUF_TO_BLOCK(abp); 813 ablock = XFS_BUF_TO_BLOCK(abp);
820 if (xfs_sb_version_hascrc(&mp->m_sb)) 814 xfs_btree_init_block_int(mp, ablock, abp->b_bn,
821 xfs_btree_init_block_int(mp, ablock, abp->b_bn, 815 XFS_BTNUM_BMAP, 0, 0, ip->i_ino,
822 XFS_BMAP_CRC_MAGIC, 0, 0, ip->i_ino,
823 XFS_BTREE_LONG_PTRS);
824 else
825 xfs_btree_init_block_int(mp, ablock, abp->b_bn,
826 XFS_BMAP_MAGIC, 0, 0, ip->i_ino,
827 XFS_BTREE_LONG_PTRS); 816 XFS_BTREE_LONG_PTRS);
828 817
829 arp = XFS_BMBT_REC_ADDR(mp, ablock, 1); 818 arp = XFS_BMBT_REC_ADDR(mp, ablock, 1);
diff --git a/fs/xfs/libxfs/xfs_bmap_btree.c b/fs/xfs/libxfs/xfs_bmap_btree.c
index a80bf8080b1c..f93072b58a58 100644
--- a/fs/xfs/libxfs/xfs_bmap_btree.c
+++ b/fs/xfs/libxfs/xfs_bmap_btree.c
@@ -71,15 +71,9 @@ xfs_bmdr_to_bmbt(
71 xfs_bmbt_key_t *tkp; 71 xfs_bmbt_key_t *tkp;
72 __be64 *tpp; 72 __be64 *tpp;
73 73
74 if (xfs_sb_version_hascrc(&mp->m_sb)) 74 xfs_btree_init_block_int(mp, rblock, XFS_BUF_DADDR_NULL,
75 xfs_btree_init_block_int(mp, rblock, XFS_BUF_DADDR_NULL, 75 XFS_BTNUM_BMAP, 0, 0, ip->i_ino,
76 XFS_BMAP_CRC_MAGIC, 0, 0, ip->i_ino,
77 XFS_BTREE_LONG_PTRS);
78 else
79 xfs_btree_init_block_int(mp, rblock, XFS_BUF_DADDR_NULL,
80 XFS_BMAP_MAGIC, 0, 0, ip->i_ino,
81 XFS_BTREE_LONG_PTRS); 76 XFS_BTREE_LONG_PTRS);
82
83 rblock->bb_level = dblock->bb_level; 77 rblock->bb_level = dblock->bb_level;
84 ASSERT(be16_to_cpu(rblock->bb_level) > 0); 78 ASSERT(be16_to_cpu(rblock->bb_level) > 0);
85 rblock->bb_numrecs = dblock->bb_numrecs; 79 rblock->bb_numrecs = dblock->bb_numrecs;
diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
index 18afab315445..421efa0ef778 100644
--- a/fs/xfs/libxfs/xfs_btree.c
+++ b/fs/xfs/libxfs/xfs_btree.c
@@ -1100,13 +1100,14 @@ xfs_btree_init_block_int(
1100 struct xfs_mount *mp, 1100 struct xfs_mount *mp,
1101 struct xfs_btree_block *buf, 1101 struct xfs_btree_block *buf,
1102 xfs_daddr_t blkno, 1102 xfs_daddr_t blkno,
1103 __u32 magic, 1103 xfs_btnum_t btnum,
1104 __u16 level, 1104 __u16 level,
1105 __u16 numrecs, 1105 __u16 numrecs,
1106 __u64 owner, 1106 __u64 owner,
1107 unsigned int flags) 1107 unsigned int flags)
1108{ 1108{
1109 int crc = xfs_sb_version_hascrc(&mp->m_sb); 1109 int crc = xfs_sb_version_hascrc(&mp->m_sb);
1110 __u32 magic = xfs_btree_magic(crc, btnum);
1110 1111
1111 buf->bb_magic = cpu_to_be32(magic); 1112 buf->bb_magic = cpu_to_be32(magic);
1112 buf->bb_level = cpu_to_be16(level); 1113 buf->bb_level = cpu_to_be16(level);
@@ -1141,14 +1142,14 @@ void
1141xfs_btree_init_block( 1142xfs_btree_init_block(
1142 struct xfs_mount *mp, 1143 struct xfs_mount *mp,
1143 struct xfs_buf *bp, 1144 struct xfs_buf *bp,
1144 __u32 magic, 1145 xfs_btnum_t btnum,
1145 __u16 level, 1146 __u16 level,
1146 __u16 numrecs, 1147 __u16 numrecs,
1147 __u64 owner, 1148 __u64 owner,
1148 unsigned int flags) 1149 unsigned int flags)
1149{ 1150{
1150 xfs_btree_init_block_int(mp, XFS_BUF_TO_BLOCK(bp), bp->b_bn, 1151 xfs_btree_init_block_int(mp, XFS_BUF_TO_BLOCK(bp), bp->b_bn,
1151 magic, level, numrecs, owner, flags); 1152 btnum, level, numrecs, owner, flags);
1152} 1153}
1153 1154
1154STATIC void 1155STATIC void
@@ -1159,8 +1160,6 @@ xfs_btree_init_block_cur(
1159 int numrecs) 1160 int numrecs)
1160{ 1161{
1161 __u64 owner; 1162 __u64 owner;
1162 int crc = xfs_sb_version_hascrc(&cur->bc_mp->m_sb);
1163 xfs_btnum_t btnum = cur->bc_btnum;
1164 1163
1165 /* 1164 /*
1166 * we can pull the owner from the cursor right now as the different 1165 * we can pull the owner from the cursor right now as the different
@@ -1174,7 +1173,7 @@ xfs_btree_init_block_cur(
1174 owner = cur->bc_private.a.agno; 1173 owner = cur->bc_private.a.agno;
1175 1174
1176 xfs_btree_init_block_int(cur->bc_mp, XFS_BUF_TO_BLOCK(bp), bp->b_bn, 1175 xfs_btree_init_block_int(cur->bc_mp, XFS_BUF_TO_BLOCK(bp), bp->b_bn,
1177 xfs_btree_magic(crc, btnum), level, numrecs, 1176 cur->bc_btnum, level, numrecs,
1178 owner, cur->bc_flags); 1177 owner, cur->bc_flags);
1179} 1178}
1180 1179
diff --git a/fs/xfs/libxfs/xfs_btree.h b/fs/xfs/libxfs/xfs_btree.h
index 95ea6ed0c14b..cdd4f05a5976 100644
--- a/fs/xfs/libxfs/xfs_btree.h
+++ b/fs/xfs/libxfs/xfs_btree.h
@@ -380,7 +380,7 @@ void
380xfs_btree_init_block( 380xfs_btree_init_block(
381 struct xfs_mount *mp, 381 struct xfs_mount *mp,
382 struct xfs_buf *bp, 382 struct xfs_buf *bp,
383 __u32 magic, 383 xfs_btnum_t btnum,
384 __u16 level, 384 __u16 level,
385 __u16 numrecs, 385 __u16 numrecs,
386 __u64 owner, 386 __u64 owner,
@@ -391,7 +391,7 @@ xfs_btree_init_block_int(
391 struct xfs_mount *mp, 391 struct xfs_mount *mp,
392 struct xfs_btree_block *buf, 392 struct xfs_btree_block *buf,
393 xfs_daddr_t blkno, 393 xfs_daddr_t blkno,
394 __u32 magic, 394 xfs_btnum_t btnum,
395 __u16 level, 395 __u16 level,
396 __u16 numrecs, 396 __u16 numrecs,
397 __u64 owner, 397 __u64 owner,