aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorBrian Foster <bfoster@redhat.com>2019-02-07 13:45:45 -0500
committerDarrick J. Wong <darrick.wong@oracle.com>2019-02-11 19:07:01 -0500
commite34d3e74eb8f6eb020312cec747ff55ee1d1ca18 (patch)
tree2f30668dd9c418c55ffe64316c5da7785aa4cbe2 /fs
parent75d0230314997b18946c96dc3d93c8d61cfdb9a5 (diff)
xfs: always check magic values in on-disk byte order
Most verifiers that check on-disk magic values convert the CPU endian magic value constant to disk endian to facilitate compile time optimization of the byte swap and reduce the need for runtime byte swaps in buffer verifiers. Several buffer verifiers do not follow this pattern. Update those verifiers for consistency. Also fix up a random typo in the inode readahead verifier name. Signed-off-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')
-rw-r--r--fs/xfs/libxfs/xfs_alloc.c2
-rw-r--r--fs/xfs/libxfs/xfs_attr_leaf.c4
-rw-r--r--fs/xfs/libxfs/xfs_da_btree.c4
-rw-r--r--fs/xfs/libxfs/xfs_inode_buf.c2
-rw-r--r--fs/xfs/libxfs/xfs_sb.c3
5 files changed, 8 insertions, 7 deletions
diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index b715668886a4..48aab07e7138 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -570,7 +570,7 @@ xfs_agfl_verify(
570 570
571 if (!uuid_equal(&agfl->agfl_uuid, &mp->m_sb.sb_meta_uuid)) 571 if (!uuid_equal(&agfl->agfl_uuid, &mp->m_sb.sb_meta_uuid))
572 return __this_address; 572 return __this_address;
573 if (be32_to_cpu(agfl->agfl_magicnum) != XFS_AGFL_MAGIC) 573 if (agfl->agfl_magicnum != cpu_to_be32(XFS_AGFL_MAGIC))
574 return __this_address; 574 return __this_address;
575 /* 575 /*
576 * during growfs operations, the perag is not fully initialised, 576 * during growfs operations, the perag is not fully initialised,
diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
index 2652d00842d6..e60eba7f129c 100644
--- a/fs/xfs/libxfs/xfs_attr_leaf.c
+++ b/fs/xfs/libxfs/xfs_attr_leaf.c
@@ -251,7 +251,7 @@ xfs_attr3_leaf_verify(
251 if (xfs_sb_version_hascrc(&mp->m_sb)) { 251 if (xfs_sb_version_hascrc(&mp->m_sb)) {
252 struct xfs_da3_node_hdr *hdr3 = bp->b_addr; 252 struct xfs_da3_node_hdr *hdr3 = bp->b_addr;
253 253
254 if (ichdr.magic != XFS_ATTR3_LEAF_MAGIC) 254 if (hdr3->info.hdr.magic != cpu_to_be16(XFS_ATTR3_LEAF_MAGIC))
255 return __this_address; 255 return __this_address;
256 256
257 if (!uuid_equal(&hdr3->info.uuid, &mp->m_sb.sb_meta_uuid)) 257 if (!uuid_equal(&hdr3->info.uuid, &mp->m_sb.sb_meta_uuid))
@@ -261,7 +261,7 @@ xfs_attr3_leaf_verify(
261 if (!xfs_log_check_lsn(mp, be64_to_cpu(hdr3->info.lsn))) 261 if (!xfs_log_check_lsn(mp, be64_to_cpu(hdr3->info.lsn)))
262 return __this_address; 262 return __this_address;
263 } else { 263 } else {
264 if (ichdr.magic != XFS_ATTR_LEAF_MAGIC) 264 if (leaf->hdr.info.magic != cpu_to_be16(XFS_ATTR_LEAF_MAGIC))
265 return __this_address; 265 return __this_address;
266 } 266 }
267 /* 267 /*
diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index 376bee94b5dd..355322688c9f 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -132,7 +132,7 @@ xfs_da3_node_verify(
132 if (xfs_sb_version_hascrc(&mp->m_sb)) { 132 if (xfs_sb_version_hascrc(&mp->m_sb)) {
133 struct xfs_da3_node_hdr *hdr3 = bp->b_addr; 133 struct xfs_da3_node_hdr *hdr3 = bp->b_addr;
134 134
135 if (ichdr.magic != XFS_DA3_NODE_MAGIC) 135 if (hdr3->info.hdr.magic != cpu_to_be16(XFS_DA3_NODE_MAGIC))
136 return __this_address; 136 return __this_address;
137 137
138 if (!uuid_equal(&hdr3->info.uuid, &mp->m_sb.sb_meta_uuid)) 138 if (!uuid_equal(&hdr3->info.uuid, &mp->m_sb.sb_meta_uuid))
@@ -142,7 +142,7 @@ xfs_da3_node_verify(
142 if (!xfs_log_check_lsn(mp, be64_to_cpu(hdr3->info.lsn))) 142 if (!xfs_log_check_lsn(mp, be64_to_cpu(hdr3->info.lsn)))
143 return __this_address; 143 return __this_address;
144 } else { 144 } else {
145 if (ichdr.magic != XFS_DA_NODE_MAGIC) 145 if (hdr->hdr.info.magic != cpu_to_be16(XFS_DA_NODE_MAGIC))
146 return __this_address; 146 return __this_address;
147 } 147 }
148 if (ichdr.level == 0) 148 if (ichdr.level == 0)
diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index 82c4374acb4c..01ebc9557f69 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -151,7 +151,7 @@ const struct xfs_buf_ops xfs_inode_buf_ops = {
151}; 151};
152 152
153const struct xfs_buf_ops xfs_inode_buf_ra_ops = { 153const struct xfs_buf_ops xfs_inode_buf_ra_ops = {
154 .name = "xxfs_inode_ra", 154 .name = "xfs_inode_ra",
155 .verify_read = xfs_inode_buf_readahead_verify, 155 .verify_read = xfs_inode_buf_readahead_verify,
156 .verify_write = xfs_inode_buf_write_verify, 156 .verify_write = xfs_inode_buf_write_verify,
157}; 157};
diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c
index b5a82acd7dfe..a2f52a958091 100644
--- a/fs/xfs/libxfs/xfs_sb.c
+++ b/fs/xfs/libxfs/xfs_sb.c
@@ -225,10 +225,11 @@ xfs_validate_sb_common(
225 struct xfs_buf *bp, 225 struct xfs_buf *bp,
226 struct xfs_sb *sbp) 226 struct xfs_sb *sbp)
227{ 227{
228 struct xfs_dsb *dsb = XFS_BUF_TO_SBP(bp);
228 uint32_t agcount = 0; 229 uint32_t agcount = 0;
229 uint32_t rem; 230 uint32_t rem;
230 231
231 if (sbp->sb_magicnum != XFS_SB_MAGIC) { 232 if (dsb->sb_magicnum != cpu_to_be32(XFS_SB_MAGIC)) {
232 xfs_warn(mp, "bad magic number"); 233 xfs_warn(mp, "bad magic number");
233 return -EWRONGFS; 234 return -EWRONGFS;
234 } 235 }