diff options
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | fs/xfs/xfs_ag.h | 6 | ||||
-rw-r--r-- | fs/xfs/xfs_alloc.c | 10 | ||||
-rw-r--r-- | fs/xfs/xfs_dinode.h | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_format.h | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_ialloc.c | 5 | ||||
-rw-r--r-- | fs/xfs/xfs_inode_buf.c | 4 | ||||
-rw-r--r-- | fs/xfs/xfs_sb.c | 5 | ||||
-rw-r--r-- | fs/xfs/xfs_sb.h | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_symlink_remote.c | 5 |
9 files changed, 24 insertions, 17 deletions
diff --git a/fs/xfs/xfs_ag.h b/fs/xfs/xfs_ag.h index 3fc109819c34..0fdd4109c624 100644 --- a/fs/xfs/xfs_ag.h +++ b/fs/xfs/xfs_ag.h | |||
@@ -89,6 +89,8 @@ typedef struct xfs_agf { | |||
89 | /* structure must be padded to 64 bit alignment */ | 89 | /* structure must be padded to 64 bit alignment */ |
90 | } xfs_agf_t; | 90 | } xfs_agf_t; |
91 | 91 | ||
92 | #define XFS_AGF_CRC_OFF offsetof(struct xfs_agf, agf_crc) | ||
93 | |||
92 | #define XFS_AGF_MAGICNUM 0x00000001 | 94 | #define XFS_AGF_MAGICNUM 0x00000001 |
93 | #define XFS_AGF_VERSIONNUM 0x00000002 | 95 | #define XFS_AGF_VERSIONNUM 0x00000002 |
94 | #define XFS_AGF_SEQNO 0x00000004 | 96 | #define XFS_AGF_SEQNO 0x00000004 |
@@ -167,6 +169,8 @@ typedef struct xfs_agi { | |||
167 | /* structure must be padded to 64 bit alignment */ | 169 | /* structure must be padded to 64 bit alignment */ |
168 | } xfs_agi_t; | 170 | } xfs_agi_t; |
169 | 171 | ||
172 | #define XFS_AGI_CRC_OFF offsetof(struct xfs_agi, agi_crc) | ||
173 | |||
170 | #define XFS_AGI_MAGICNUM 0x00000001 | 174 | #define XFS_AGI_MAGICNUM 0x00000001 |
171 | #define XFS_AGI_VERSIONNUM 0x00000002 | 175 | #define XFS_AGI_VERSIONNUM 0x00000002 |
172 | #define XFS_AGI_SEQNO 0x00000004 | 176 | #define XFS_AGI_SEQNO 0x00000004 |
@@ -222,6 +226,8 @@ typedef struct xfs_agfl { | |||
222 | __be32 agfl_bno[]; /* actually XFS_AGFL_SIZE(mp) */ | 226 | __be32 agfl_bno[]; /* actually XFS_AGFL_SIZE(mp) */ |
223 | } xfs_agfl_t; | 227 | } xfs_agfl_t; |
224 | 228 | ||
229 | #define XFS_AGFL_CRC_OFF offsetof(struct xfs_agfl, agfl_crc) | ||
230 | |||
225 | /* | 231 | /* |
226 | * tags for inode radix tree | 232 | * tags for inode radix tree |
227 | */ | 233 | */ |
diff --git a/fs/xfs/xfs_alloc.c b/fs/xfs/xfs_alloc.c index 9eab2dfdcbb5..72ea85512eb6 100644 --- a/fs/xfs/xfs_alloc.c +++ b/fs/xfs/xfs_alloc.c | |||
@@ -486,7 +486,7 @@ xfs_agfl_read_verify( | |||
486 | return; | 486 | return; |
487 | 487 | ||
488 | agfl_ok = xfs_verify_cksum(bp->b_addr, BBTOB(bp->b_length), | 488 | agfl_ok = xfs_verify_cksum(bp->b_addr, BBTOB(bp->b_length), |
489 | offsetof(struct xfs_agfl, agfl_crc)); | 489 | XFS_AGFL_CRC_OFF); |
490 | 490 | ||
491 | agfl_ok = agfl_ok && xfs_agfl_verify(bp); | 491 | agfl_ok = agfl_ok && xfs_agfl_verify(bp); |
492 | 492 | ||
@@ -516,8 +516,7 @@ xfs_agfl_write_verify( | |||
516 | if (bip) | 516 | if (bip) |
517 | XFS_BUF_TO_AGFL(bp)->agfl_lsn = cpu_to_be64(bip->bli_item.li_lsn); | 517 | XFS_BUF_TO_AGFL(bp)->agfl_lsn = cpu_to_be64(bip->bli_item.li_lsn); |
518 | 518 | ||
519 | xfs_update_cksum(bp->b_addr, BBTOB(bp->b_length), | 519 | xfs_update_cksum(bp->b_addr, BBTOB(bp->b_length), XFS_AGFL_CRC_OFF); |
520 | offsetof(struct xfs_agfl, agfl_crc)); | ||
521 | } | 520 | } |
522 | 521 | ||
523 | const struct xfs_buf_ops xfs_agfl_buf_ops = { | 522 | const struct xfs_buf_ops xfs_agfl_buf_ops = { |
@@ -2242,7 +2241,7 @@ xfs_agf_read_verify( | |||
2242 | 2241 | ||
2243 | if (xfs_sb_version_hascrc(&mp->m_sb)) | 2242 | if (xfs_sb_version_hascrc(&mp->m_sb)) |
2244 | agf_ok = xfs_verify_cksum(bp->b_addr, BBTOB(bp->b_length), | 2243 | agf_ok = xfs_verify_cksum(bp->b_addr, BBTOB(bp->b_length), |
2245 | offsetof(struct xfs_agf, agf_crc)); | 2244 | XFS_AGF_CRC_OFF); |
2246 | 2245 | ||
2247 | agf_ok = agf_ok && xfs_agf_verify(mp, bp); | 2246 | agf_ok = agf_ok && xfs_agf_verify(mp, bp); |
2248 | 2247 | ||
@@ -2272,8 +2271,7 @@ xfs_agf_write_verify( | |||
2272 | if (bip) | 2271 | if (bip) |
2273 | XFS_BUF_TO_AGF(bp)->agf_lsn = cpu_to_be64(bip->bli_item.li_lsn); | 2272 | XFS_BUF_TO_AGF(bp)->agf_lsn = cpu_to_be64(bip->bli_item.li_lsn); |
2274 | 2273 | ||
2275 | xfs_update_cksum(bp->b_addr, BBTOB(bp->b_length), | 2274 | xfs_update_cksum(bp->b_addr, BBTOB(bp->b_length), XFS_AGF_CRC_OFF); |
2276 | offsetof(struct xfs_agf, agf_crc)); | ||
2277 | } | 2275 | } |
2278 | 2276 | ||
2279 | const struct xfs_buf_ops xfs_agf_buf_ops = { | 2277 | const struct xfs_buf_ops xfs_agf_buf_ops = { |
diff --git a/fs/xfs/xfs_dinode.h b/fs/xfs/xfs_dinode.h index e5869b50dc41..623bbe8fd921 100644 --- a/fs/xfs/xfs_dinode.h +++ b/fs/xfs/xfs_dinode.h | |||
@@ -89,6 +89,8 @@ typedef struct xfs_dinode { | |||
89 | /* structure must be padded to 64 bit alignment */ | 89 | /* structure must be padded to 64 bit alignment */ |
90 | } xfs_dinode_t; | 90 | } xfs_dinode_t; |
91 | 91 | ||
92 | #define XFS_DINODE_CRC_OFF offsetof(struct xfs_dinode, di_crc) | ||
93 | |||
92 | #define DI_MAX_FLUSH 0xffff | 94 | #define DI_MAX_FLUSH 0xffff |
93 | 95 | ||
94 | /* | 96 | /* |
diff --git a/fs/xfs/xfs_format.h b/fs/xfs/xfs_format.h index b6ab5a3cfa12..9898f31d05d8 100644 --- a/fs/xfs/xfs_format.h +++ b/fs/xfs/xfs_format.h | |||
@@ -145,6 +145,8 @@ struct xfs_dsymlink_hdr { | |||
145 | __be64 sl_lsn; | 145 | __be64 sl_lsn; |
146 | }; | 146 | }; |
147 | 147 | ||
148 | #define XFS_SYMLINK_CRC_OFF offsetof(struct xfs_dsymlink_hdr, sl_crc) | ||
149 | |||
148 | /* | 150 | /* |
149 | * The maximum pathlen is 1024 bytes. Since the minimum file system | 151 | * The maximum pathlen is 1024 bytes. Since the minimum file system |
150 | * blocksize is 512 bytes, we can get a max of 3 extents back from | 152 | * blocksize is 512 bytes, we can get a max of 3 extents back from |
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c index 5d7f105a1c82..d79210b15bc0 100644 --- a/fs/xfs/xfs_ialloc.c +++ b/fs/xfs/xfs_ialloc.c | |||
@@ -1572,7 +1572,7 @@ xfs_agi_read_verify( | |||
1572 | 1572 | ||
1573 | if (xfs_sb_version_hascrc(&mp->m_sb)) | 1573 | if (xfs_sb_version_hascrc(&mp->m_sb)) |
1574 | agi_ok = xfs_verify_cksum(bp->b_addr, BBTOB(bp->b_length), | 1574 | agi_ok = xfs_verify_cksum(bp->b_addr, BBTOB(bp->b_length), |
1575 | offsetof(struct xfs_agi, agi_crc)); | 1575 | XFS_AGI_CRC_OFF); |
1576 | agi_ok = agi_ok && xfs_agi_verify(bp); | 1576 | agi_ok = agi_ok && xfs_agi_verify(bp); |
1577 | 1577 | ||
1578 | if (unlikely(XFS_TEST_ERROR(!agi_ok, mp, XFS_ERRTAG_IALLOC_READ_AGI, | 1578 | if (unlikely(XFS_TEST_ERROR(!agi_ok, mp, XFS_ERRTAG_IALLOC_READ_AGI, |
@@ -1600,8 +1600,7 @@ xfs_agi_write_verify( | |||
1600 | 1600 | ||
1601 | if (bip) | 1601 | if (bip) |
1602 | XFS_BUF_TO_AGI(bp)->agi_lsn = cpu_to_be64(bip->bli_item.li_lsn); | 1602 | XFS_BUF_TO_AGI(bp)->agi_lsn = cpu_to_be64(bip->bli_item.li_lsn); |
1603 | xfs_update_cksum(bp->b_addr, BBTOB(bp->b_length), | 1603 | xfs_update_cksum(bp->b_addr, BBTOB(bp->b_length), XFS_AGI_CRC_OFF); |
1604 | offsetof(struct xfs_agi, agi_crc)); | ||
1605 | } | 1604 | } |
1606 | 1605 | ||
1607 | const struct xfs_buf_ops xfs_agi_buf_ops = { | 1606 | const struct xfs_buf_ops xfs_agi_buf_ops = { |
diff --git a/fs/xfs/xfs_inode_buf.c b/fs/xfs/xfs_inode_buf.c index 4fc9f39dd89e..606b43a48724 100644 --- a/fs/xfs/xfs_inode_buf.c +++ b/fs/xfs/xfs_inode_buf.c | |||
@@ -306,7 +306,7 @@ xfs_dinode_verify( | |||
306 | if (!xfs_sb_version_hascrc(&mp->m_sb)) | 306 | if (!xfs_sb_version_hascrc(&mp->m_sb)) |
307 | return false; | 307 | return false; |
308 | if (!xfs_verify_cksum((char *)dip, mp->m_sb.sb_inodesize, | 308 | if (!xfs_verify_cksum((char *)dip, mp->m_sb.sb_inodesize, |
309 | offsetof(struct xfs_dinode, di_crc))) | 309 | XFS_DINODE_CRC_OFF)) |
310 | return false; | 310 | return false; |
311 | if (be64_to_cpu(dip->di_ino) != ip->i_ino) | 311 | if (be64_to_cpu(dip->di_ino) != ip->i_ino) |
312 | return false; | 312 | return false; |
@@ -327,7 +327,7 @@ xfs_dinode_calc_crc( | |||
327 | 327 | ||
328 | ASSERT(xfs_sb_version_hascrc(&mp->m_sb)); | 328 | ASSERT(xfs_sb_version_hascrc(&mp->m_sb)); |
329 | crc = xfs_start_cksum((char *)dip, mp->m_sb.sb_inodesize, | 329 | crc = xfs_start_cksum((char *)dip, mp->m_sb.sb_inodesize, |
330 | offsetof(struct xfs_dinode, di_crc)); | 330 | XFS_DINODE_CRC_OFF); |
331 | dip->di_crc = xfs_end_cksum(crc); | 331 | dip->di_crc = xfs_end_cksum(crc); |
332 | } | 332 | } |
333 | 333 | ||
diff --git a/fs/xfs/xfs_sb.c b/fs/xfs/xfs_sb.c index 1e116794bb66..1ea7c865b208 100644 --- a/fs/xfs/xfs_sb.c +++ b/fs/xfs/xfs_sb.c | |||
@@ -611,7 +611,7 @@ xfs_sb_read_verify( | |||
611 | dsb->sb_crc != 0)) { | 611 | dsb->sb_crc != 0)) { |
612 | 612 | ||
613 | if (!xfs_verify_cksum(bp->b_addr, BBTOB(bp->b_length), | 613 | if (!xfs_verify_cksum(bp->b_addr, BBTOB(bp->b_length), |
614 | offsetof(struct xfs_sb, sb_crc))) { | 614 | XFS_SB_CRC_OFF)) { |
615 | /* Only fail bad secondaries on a known V5 filesystem */ | 615 | /* Only fail bad secondaries on a known V5 filesystem */ |
616 | if (bp->b_bn == XFS_SB_DADDR || | 616 | if (bp->b_bn == XFS_SB_DADDR || |
617 | xfs_sb_version_hascrc(&mp->m_sb)) { | 617 | xfs_sb_version_hascrc(&mp->m_sb)) { |
@@ -674,8 +674,7 @@ xfs_sb_write_verify( | |||
674 | if (bip) | 674 | if (bip) |
675 | XFS_BUF_TO_SBP(bp)->sb_lsn = cpu_to_be64(bip->bli_item.li_lsn); | 675 | XFS_BUF_TO_SBP(bp)->sb_lsn = cpu_to_be64(bip->bli_item.li_lsn); |
676 | 676 | ||
677 | xfs_update_cksum(bp->b_addr, BBTOB(bp->b_length), | 677 | xfs_update_cksum(bp->b_addr, BBTOB(bp->b_length), XFS_SB_CRC_OFF); |
678 | offsetof(struct xfs_sb, sb_crc)); | ||
679 | } | 678 | } |
680 | 679 | ||
681 | const struct xfs_buf_ops xfs_sb_buf_ops = { | 680 | const struct xfs_buf_ops xfs_sb_buf_ops = { |
diff --git a/fs/xfs/xfs_sb.h b/fs/xfs/xfs_sb.h index 35061d4b614c..f7b2fe77c5a5 100644 --- a/fs/xfs/xfs_sb.h +++ b/fs/xfs/xfs_sb.h | |||
@@ -182,6 +182,8 @@ typedef struct xfs_sb { | |||
182 | /* must be padded to 64 bit alignment */ | 182 | /* must be padded to 64 bit alignment */ |
183 | } xfs_sb_t; | 183 | } xfs_sb_t; |
184 | 184 | ||
185 | #define XFS_SB_CRC_OFF offsetof(struct xfs_sb, sb_crc) | ||
186 | |||
185 | /* | 187 | /* |
186 | * Superblock - on disk version. Must match the in core version above. | 188 | * Superblock - on disk version. Must match the in core version above. |
187 | * Must be padded to 64 bit alignment. | 189 | * Must be padded to 64 bit alignment. |
diff --git a/fs/xfs/xfs_symlink_remote.c b/fs/xfs/xfs_symlink_remote.c index bf59a2b45f8c..7a705a451ebc 100644 --- a/fs/xfs/xfs_symlink_remote.c +++ b/fs/xfs/xfs_symlink_remote.c | |||
@@ -134,7 +134,7 @@ xfs_symlink_read_verify( | |||
134 | return; | 134 | return; |
135 | 135 | ||
136 | if (!xfs_verify_cksum(bp->b_addr, BBTOB(bp->b_length), | 136 | if (!xfs_verify_cksum(bp->b_addr, BBTOB(bp->b_length), |
137 | offsetof(struct xfs_dsymlink_hdr, sl_crc)) || | 137 | XFS_SYMLINK_CRC_OFF) || |
138 | !xfs_symlink_verify(bp)) { | 138 | !xfs_symlink_verify(bp)) { |
139 | XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, bp->b_addr); | 139 | XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, bp->b_addr); |
140 | xfs_buf_ioerror(bp, EFSCORRUPTED); | 140 | xfs_buf_ioerror(bp, EFSCORRUPTED); |
@@ -162,8 +162,7 @@ xfs_symlink_write_verify( | |||
162 | struct xfs_dsymlink_hdr *dsl = bp->b_addr; | 162 | struct xfs_dsymlink_hdr *dsl = bp->b_addr; |
163 | dsl->sl_lsn = cpu_to_be64(bip->bli_item.li_lsn); | 163 | dsl->sl_lsn = cpu_to_be64(bip->bli_item.li_lsn); |
164 | } | 164 | } |
165 | xfs_update_cksum(bp->b_addr, BBTOB(bp->b_length), | 165 | xfs_update_cksum(bp->b_addr, BBTOB(bp->b_length), XFS_SYMLINK_CRC_OFF); |
166 | offsetof(struct xfs_dsymlink_hdr, sl_crc)); | ||
167 | } | 166 | } |
168 | 167 | ||
169 | const struct xfs_buf_ops xfs_symlink_buf_ops = { | 168 | const struct xfs_buf_ops xfs_symlink_buf_ops = { |