aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorDave Chinner <david@fromorbit.com>2016-01-04 16:08:35 -0500
committerDave Chinner <david@fromorbit.com>2016-01-04 16:08:35 -0500
commit7eeabbd4b6b69f3f6cb75730f17804b714bd853b (patch)
tree9acbd170426728ea53f1d12ebae6c22b100f78de /fs/xfs
parent609adfc2ed5ba16700f125da0b656248bd9d4316 (diff)
parenta841b64df29b4c7e68ce564d752dfb2042db5404 (diff)
Merge branch 'xfs-misc-fixes-for-4.5' into for-next
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/libxfs/xfs_alloc.c4
-rw-r--r--fs/xfs/libxfs/xfs_alloc.h1
-rw-r--r--fs/xfs/libxfs/xfs_alloc_btree.c35
-rw-r--r--fs/xfs/libxfs/xfs_attr_leaf.c1
-rw-r--r--fs/xfs/libxfs/xfs_attr_remote.c1
-rw-r--r--fs/xfs/libxfs/xfs_bit.c6
-rw-r--r--fs/xfs/libxfs/xfs_bmap.c27
-rw-r--r--fs/xfs/libxfs/xfs_bmap_btree.c1
-rw-r--r--fs/xfs/libxfs/xfs_btree.c58
-rw-r--r--fs/xfs/libxfs/xfs_btree.h3
-rw-r--r--fs/xfs/libxfs/xfs_da_btree.c1
-rw-r--r--fs/xfs/libxfs/xfs_dir2_block.c1
-rw-r--r--fs/xfs/libxfs/xfs_dir2_data.c2
-rw-r--r--fs/xfs/libxfs/xfs_dir2_leaf.c2
-rw-r--r--fs/xfs/libxfs/xfs_dir2_node.c1
-rw-r--r--fs/xfs/libxfs/xfs_dquot_buf.c1
-rw-r--r--fs/xfs/libxfs/xfs_format.h2
-rw-r--r--fs/xfs/libxfs/xfs_ialloc.c1
-rw-r--r--fs/xfs/libxfs/xfs_ialloc_btree.c27
-rw-r--r--fs/xfs/libxfs/xfs_inode_buf.c2
-rw-r--r--fs/xfs/libxfs/xfs_sb.c2
-rw-r--r--fs/xfs/libxfs/xfs_symlink_remote.c1
-rw-r--r--fs/xfs/xfs_buf.c2
-rw-r--r--fs/xfs/xfs_buf.h1
-rw-r--r--fs/xfs/xfs_error.c4
-rw-r--r--fs/xfs/xfs_log.c6
-rw-r--r--fs/xfs/xfs_super.c2
-rw-r--r--fs/xfs/xfs_trans_dquot.c14
28 files changed, 126 insertions, 83 deletions
diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index 3479294c1d58..a708e38b494c 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -535,6 +535,7 @@ xfs_agfl_write_verify(
535} 535}
536 536
537const struct xfs_buf_ops xfs_agfl_buf_ops = { 537const struct xfs_buf_ops xfs_agfl_buf_ops = {
538 .name = "xfs_agfl",
538 .verify_read = xfs_agfl_read_verify, 539 .verify_read = xfs_agfl_read_verify,
539 .verify_write = xfs_agfl_write_verify, 540 .verify_write = xfs_agfl_write_verify,
540}; 541};
@@ -1926,7 +1927,7 @@ xfs_alloc_space_available(
1926 * Decide whether to use this allocation group for this allocation. 1927 * Decide whether to use this allocation group for this allocation.
1927 * If so, fix up the btree freelist's size. 1928 * If so, fix up the btree freelist's size.
1928 */ 1929 */
1929STATIC int /* error */ 1930int /* error */
1930xfs_alloc_fix_freelist( 1931xfs_alloc_fix_freelist(
1931 struct xfs_alloc_arg *args, /* allocation argument structure */ 1932 struct xfs_alloc_arg *args, /* allocation argument structure */
1932 int flags) /* XFS_ALLOC_FLAG_... */ 1933 int flags) /* XFS_ALLOC_FLAG_... */
@@ -2339,6 +2340,7 @@ xfs_agf_write_verify(
2339} 2340}
2340 2341
2341const struct xfs_buf_ops xfs_agf_buf_ops = { 2342const struct xfs_buf_ops xfs_agf_buf_ops = {
2343 .name = "xfs_agf",
2342 .verify_read = xfs_agf_read_verify, 2344 .verify_read = xfs_agf_read_verify,
2343 .verify_write = xfs_agf_write_verify, 2345 .verify_write = xfs_agf_write_verify,
2344}; 2346};
diff --git a/fs/xfs/libxfs/xfs_alloc.h b/fs/xfs/libxfs/xfs_alloc.h
index 0ecde4d5cac8..135eb3d24db7 100644
--- a/fs/xfs/libxfs/xfs_alloc.h
+++ b/fs/xfs/libxfs/xfs_alloc.h
@@ -235,5 +235,6 @@ xfs_alloc_get_rec(
235 235
236int xfs_read_agf(struct xfs_mount *mp, struct xfs_trans *tp, 236int xfs_read_agf(struct xfs_mount *mp, struct xfs_trans *tp,
237 xfs_agnumber_t agno, int flags, struct xfs_buf **bpp); 237 xfs_agnumber_t agno, int flags, struct xfs_buf **bpp);
238int xfs_alloc_fix_freelist(struct xfs_alloc_arg *args, int flags);
238 239
239#endif /* __XFS_ALLOC_H__ */ 240#endif /* __XFS_ALLOC_H__ */
diff --git a/fs/xfs/libxfs/xfs_alloc_btree.c b/fs/xfs/libxfs/xfs_alloc_btree.c
index 90de071dd4c2..444626ddbd1b 100644
--- a/fs/xfs/libxfs/xfs_alloc_btree.c
+++ b/fs/xfs/libxfs/xfs_alloc_btree.c
@@ -293,14 +293,7 @@ xfs_allocbt_verify(
293 level = be16_to_cpu(block->bb_level); 293 level = be16_to_cpu(block->bb_level);
294 switch (block->bb_magic) { 294 switch (block->bb_magic) {
295 case cpu_to_be32(XFS_ABTB_CRC_MAGIC): 295 case cpu_to_be32(XFS_ABTB_CRC_MAGIC):
296 if (!xfs_sb_version_hascrc(&mp->m_sb)) 296 if (!xfs_btree_sblock_v5hdr_verify(bp))
297 return false;
298 if (!uuid_equal(&block->bb_u.s.bb_uuid, &mp->m_sb.sb_meta_uuid))
299 return false;
300 if (block->bb_u.s.bb_blkno != cpu_to_be64(bp->b_bn))
301 return false;
302 if (pag &&
303 be32_to_cpu(block->bb_u.s.bb_owner) != pag->pag_agno)
304 return false; 297 return false;
305 /* fall through */ 298 /* fall through */
306 case cpu_to_be32(XFS_ABTB_MAGIC): 299 case cpu_to_be32(XFS_ABTB_MAGIC):
@@ -311,14 +304,7 @@ xfs_allocbt_verify(
311 return false; 304 return false;
312 break; 305 break;
313 case cpu_to_be32(XFS_ABTC_CRC_MAGIC): 306 case cpu_to_be32(XFS_ABTC_CRC_MAGIC):
314 if (!xfs_sb_version_hascrc(&mp->m_sb)) 307 if (!xfs_btree_sblock_v5hdr_verify(bp))
315 return false;
316 if (!uuid_equal(&block->bb_u.s.bb_uuid, &mp->m_sb.sb_meta_uuid))
317 return false;
318 if (block->bb_u.s.bb_blkno != cpu_to_be64(bp->b_bn))
319 return false;
320 if (pag &&
321 be32_to_cpu(block->bb_u.s.bb_owner) != pag->pag_agno)
322 return false; 308 return false;
323 /* fall through */ 309 /* fall through */
324 case cpu_to_be32(XFS_ABTC_MAGIC): 310 case cpu_to_be32(XFS_ABTC_MAGIC):
@@ -332,21 +318,7 @@ xfs_allocbt_verify(
332 return false; 318 return false;
333 } 319 }
334 320
335 /* numrecs verification */ 321 return xfs_btree_sblock_verify(bp, mp->m_alloc_mxr[level != 0]);
336 if (be16_to_cpu(block->bb_numrecs) > mp->m_alloc_mxr[level != 0])
337 return false;
338
339 /* sibling pointer verification */
340 if (!block->bb_u.s.bb_leftsib ||
341 (be32_to_cpu(block->bb_u.s.bb_leftsib) >= mp->m_sb.sb_agblocks &&
342 block->bb_u.s.bb_leftsib != cpu_to_be32(NULLAGBLOCK)))
343 return false;
344 if (!block->bb_u.s.bb_rightsib ||
345 (be32_to_cpu(block->bb_u.s.bb_rightsib) >= mp->m_sb.sb_agblocks &&
346 block->bb_u.s.bb_rightsib != cpu_to_be32(NULLAGBLOCK)))
347 return false;
348
349 return true;
350} 322}
351 323
352static void 324static void
@@ -379,6 +351,7 @@ xfs_allocbt_write_verify(
379} 351}
380 352
381const struct xfs_buf_ops xfs_allocbt_buf_ops = { 353const struct xfs_buf_ops xfs_allocbt_buf_ops = {
354 .name = "xfs_allocbt",
382 .verify_read = xfs_allocbt_read_verify, 355 .verify_read = xfs_allocbt_read_verify,
383 .verify_write = xfs_allocbt_write_verify, 356 .verify_write = xfs_allocbt_write_verify,
384}; 357};
diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
index aa187f7ba2dd..01a5ecfedfcf 100644
--- a/fs/xfs/libxfs/xfs_attr_leaf.c
+++ b/fs/xfs/libxfs/xfs_attr_leaf.c
@@ -328,6 +328,7 @@ xfs_attr3_leaf_read_verify(
328} 328}
329 329
330const struct xfs_buf_ops xfs_attr3_leaf_buf_ops = { 330const struct xfs_buf_ops xfs_attr3_leaf_buf_ops = {
331 .name = "xfs_attr3_leaf",
331 .verify_read = xfs_attr3_leaf_read_verify, 332 .verify_read = xfs_attr3_leaf_read_verify,
332 .verify_write = xfs_attr3_leaf_write_verify, 333 .verify_write = xfs_attr3_leaf_write_verify,
333}; 334};
diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c
index 5ab95ffa4ae9..f3ed9bf0b065 100644
--- a/fs/xfs/libxfs/xfs_attr_remote.c
+++ b/fs/xfs/libxfs/xfs_attr_remote.c
@@ -201,6 +201,7 @@ xfs_attr3_rmt_write_verify(
201} 201}
202 202
203const struct xfs_buf_ops xfs_attr3_rmt_buf_ops = { 203const struct xfs_buf_ops xfs_attr3_rmt_buf_ops = {
204 .name = "xfs_attr3_rmt",
204 .verify_read = xfs_attr3_rmt_read_verify, 205 .verify_read = xfs_attr3_rmt_read_verify,
205 .verify_write = xfs_attr3_rmt_write_verify, 206 .verify_write = xfs_attr3_rmt_write_verify,
206}; 207};
diff --git a/fs/xfs/libxfs/xfs_bit.c b/fs/xfs/libxfs/xfs_bit.c
index 0e8885a59646..0a94cce5ea35 100644
--- a/fs/xfs/libxfs/xfs_bit.c
+++ b/fs/xfs/libxfs/xfs_bit.c
@@ -32,13 +32,13 @@ int
32xfs_bitmap_empty(uint *map, uint size) 32xfs_bitmap_empty(uint *map, uint size)
33{ 33{
34 uint i; 34 uint i;
35 uint ret = 0;
36 35
37 for (i = 0; i < size; i++) { 36 for (i = 0; i < size; i++) {
38 ret |= map[i]; 37 if (map[i] != 0)
38 return 0;
39 } 39 }
40 40
41 return (ret == 0); 41 return 1;
42} 42}
43 43
44/* 44/*
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 119c2422aac7..73884953b21c 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -1723,10 +1723,11 @@ xfs_bmap_add_extent_delay_real(
1723 xfs_filblks_t temp=0; /* value for da_new calculations */ 1723 xfs_filblks_t temp=0; /* value for da_new calculations */
1724 xfs_filblks_t temp2=0;/* value for da_new calculations */ 1724 xfs_filblks_t temp2=0;/* value for da_new calculations */
1725 int tmp_rval; /* partial logging flags */ 1725 int tmp_rval; /* partial logging flags */
1726 int whichfork = XFS_DATA_FORK;
1726 struct xfs_mount *mp; 1727 struct xfs_mount *mp;
1727 1728
1728 mp = bma->tp ? bma->tp->t_mountp : NULL; 1729 mp = bma->ip->i_mount;
1729 ifp = XFS_IFORK_PTR(bma->ip, XFS_DATA_FORK); 1730 ifp = XFS_IFORK_PTR(bma->ip, whichfork);
1730 1731
1731 ASSERT(bma->idx >= 0); 1732 ASSERT(bma->idx >= 0);
1732 ASSERT(bma->idx <= ifp->if_bytes / sizeof(struct xfs_bmbt_rec)); 1733 ASSERT(bma->idx <= ifp->if_bytes / sizeof(struct xfs_bmbt_rec));
@@ -1785,7 +1786,7 @@ xfs_bmap_add_extent_delay_real(
1785 * Don't set contiguous if the combined extent would be too large. 1786 * Don't set contiguous if the combined extent would be too large.
1786 * Also check for all-three-contiguous being too large. 1787 * Also check for all-three-contiguous being too large.
1787 */ 1788 */
1788 if (bma->idx < bma->ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t) - 1) { 1789 if (bma->idx < ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t) - 1) {
1789 state |= BMAP_RIGHT_VALID; 1790 state |= BMAP_RIGHT_VALID;
1790 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, bma->idx + 1), &RIGHT); 1791 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, bma->idx + 1), &RIGHT);
1791 1792
@@ -2016,10 +2017,10 @@ xfs_bmap_add_extent_delay_real(
2016 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); 2017 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
2017 } 2018 }
2018 2019
2019 if (xfs_bmap_needs_btree(bma->ip, XFS_DATA_FORK)) { 2020 if (xfs_bmap_needs_btree(bma->ip, whichfork)) {
2020 error = xfs_bmap_extents_to_btree(bma->tp, bma->ip, 2021 error = xfs_bmap_extents_to_btree(bma->tp, bma->ip,
2021 bma->firstblock, bma->flist, 2022 bma->firstblock, bma->flist,
2022 &bma->cur, 1, &tmp_rval, XFS_DATA_FORK); 2023 &bma->cur, 1, &tmp_rval, whichfork);
2023 rval |= tmp_rval; 2024 rval |= tmp_rval;
2024 if (error) 2025 if (error)
2025 goto done; 2026 goto done;
@@ -2100,10 +2101,10 @@ xfs_bmap_add_extent_delay_real(
2100 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); 2101 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
2101 } 2102 }
2102 2103
2103 if (xfs_bmap_needs_btree(bma->ip, XFS_DATA_FORK)) { 2104 if (xfs_bmap_needs_btree(bma->ip, whichfork)) {
2104 error = xfs_bmap_extents_to_btree(bma->tp, bma->ip, 2105 error = xfs_bmap_extents_to_btree(bma->tp, bma->ip,
2105 bma->firstblock, bma->flist, &bma->cur, 1, 2106 bma->firstblock, bma->flist, &bma->cur, 1,
2106 &tmp_rval, XFS_DATA_FORK); 2107 &tmp_rval, whichfork);
2107 rval |= tmp_rval; 2108 rval |= tmp_rval;
2108 if (error) 2109 if (error)
2109 goto done; 2110 goto done;
@@ -2169,10 +2170,10 @@ xfs_bmap_add_extent_delay_real(
2169 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); 2170 XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
2170 } 2171 }
2171 2172
2172 if (xfs_bmap_needs_btree(bma->ip, XFS_DATA_FORK)) { 2173 if (xfs_bmap_needs_btree(bma->ip, whichfork)) {
2173 error = xfs_bmap_extents_to_btree(bma->tp, bma->ip, 2174 error = xfs_bmap_extents_to_btree(bma->tp, bma->ip,
2174 bma->firstblock, bma->flist, &bma->cur, 2175 bma->firstblock, bma->flist, &bma->cur,
2175 1, &tmp_rval, XFS_DATA_FORK); 2176 1, &tmp_rval, whichfork);
2176 rval |= tmp_rval; 2177 rval |= tmp_rval;
2177 if (error) 2178 if (error)
2178 goto done; 2179 goto done;
@@ -2215,13 +2216,13 @@ xfs_bmap_add_extent_delay_real(
2215 } 2216 }
2216 2217
2217 /* convert to a btree if necessary */ 2218 /* convert to a btree if necessary */
2218 if (xfs_bmap_needs_btree(bma->ip, XFS_DATA_FORK)) { 2219 if (xfs_bmap_needs_btree(bma->ip, whichfork)) {
2219 int tmp_logflags; /* partial log flag return val */ 2220 int tmp_logflags; /* partial log flag return val */
2220 2221
2221 ASSERT(bma->cur == NULL); 2222 ASSERT(bma->cur == NULL);
2222 error = xfs_bmap_extents_to_btree(bma->tp, bma->ip, 2223 error = xfs_bmap_extents_to_btree(bma->tp, bma->ip,
2223 bma->firstblock, bma->flist, &bma->cur, 2224 bma->firstblock, bma->flist, &bma->cur,
2224 da_old > 0, &tmp_logflags, XFS_DATA_FORK); 2225 da_old > 0, &tmp_logflags, whichfork);
2225 bma->logflags |= tmp_logflags; 2226 bma->logflags |= tmp_logflags;
2226 if (error) 2227 if (error)
2227 goto done; 2228 goto done;
@@ -2242,7 +2243,7 @@ xfs_bmap_add_extent_delay_real(
2242 if (bma->cur) 2243 if (bma->cur)
2243 bma->cur->bc_private.b.allocated = 0; 2244 bma->cur->bc_private.b.allocated = 0;
2244 2245
2245 xfs_bmap_check_leaf_extents(bma->cur, bma->ip, XFS_DATA_FORK); 2246 xfs_bmap_check_leaf_extents(bma->cur, bma->ip, whichfork);
2246done: 2247done:
2247 bma->logflags |= rval; 2248 bma->logflags |= rval;
2248 return error; 2249 return error;
@@ -2939,7 +2940,7 @@ xfs_bmap_add_extent_hole_real(
2939 int state; /* state bits, accessed thru macros */ 2940 int state; /* state bits, accessed thru macros */
2940 struct xfs_mount *mp; 2941 struct xfs_mount *mp;
2941 2942
2942 mp = bma->tp ? bma->tp->t_mountp : NULL; 2943 mp = bma->ip->i_mount;
2943 ifp = XFS_IFORK_PTR(bma->ip, whichfork); 2944 ifp = XFS_IFORK_PTR(bma->ip, whichfork);
2944 2945
2945 ASSERT(bma->idx >= 0); 2946 ASSERT(bma->idx >= 0);
diff --git a/fs/xfs/libxfs/xfs_bmap_btree.c b/fs/xfs/libxfs/xfs_bmap_btree.c
index 6b0cf6546a82..1637c37bfbaa 100644
--- a/fs/xfs/libxfs/xfs_bmap_btree.c
+++ b/fs/xfs/libxfs/xfs_bmap_btree.c
@@ -720,6 +720,7 @@ xfs_bmbt_write_verify(
720} 720}
721 721
722const struct xfs_buf_ops xfs_bmbt_buf_ops = { 722const struct xfs_buf_ops xfs_bmbt_buf_ops = {
723 .name = "xfs_bmbt",
723 .verify_read = xfs_bmbt_read_verify, 724 .verify_read = xfs_bmbt_read_verify,
724 .verify_write = xfs_bmbt_write_verify, 725 .verify_write = xfs_bmbt_write_verify,
725}; 726};
diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
index af1bbee5586e..a0eb18ce3ad3 100644
--- a/fs/xfs/libxfs/xfs_btree.c
+++ b/fs/xfs/libxfs/xfs_btree.c
@@ -4080,3 +4080,61 @@ xfs_btree_change_owner(
4080 4080
4081 return 0; 4081 return 0;
4082} 4082}
4083
4084/**
4085 * xfs_btree_sblock_v5hdr_verify() -- verify the v5 fields of a short-format
4086 * btree block
4087 *
4088 * @bp: buffer containing the btree block
4089 * @max_recs: pointer to the m_*_mxr max records field in the xfs mount
4090 * @pag_max_level: pointer to the per-ag max level field
4091 */
4092bool
4093xfs_btree_sblock_v5hdr_verify(
4094 struct xfs_buf *bp)
4095{
4096 struct xfs_mount *mp = bp->b_target->bt_mount;
4097 struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp);
4098 struct xfs_perag *pag = bp->b_pag;
4099
4100 if (!xfs_sb_version_hascrc(&mp->m_sb))
4101 return false;
4102 if (!uuid_equal(&block->bb_u.s.bb_uuid, &mp->m_sb.sb_meta_uuid))
4103 return false;
4104 if (block->bb_u.s.bb_blkno != cpu_to_be64(bp->b_bn))
4105 return false;
4106 if (pag && be32_to_cpu(block->bb_u.s.bb_owner) != pag->pag_agno)
4107 return false;
4108 return true;
4109}
4110
4111/**
4112 * xfs_btree_sblock_verify() -- verify a short-format btree block
4113 *
4114 * @bp: buffer containing the btree block
4115 * @max_recs: maximum records allowed in this btree node
4116 */
4117bool
4118xfs_btree_sblock_verify(
4119 struct xfs_buf *bp,
4120 unsigned int max_recs)
4121{
4122 struct xfs_mount *mp = bp->b_target->bt_mount;
4123 struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp);
4124
4125 /* numrecs verification */
4126 if (be16_to_cpu(block->bb_numrecs) > max_recs)
4127 return false;
4128
4129 /* sibling pointer verification */
4130 if (!block->bb_u.s.bb_leftsib ||
4131 (be32_to_cpu(block->bb_u.s.bb_leftsib) >= mp->m_sb.sb_agblocks &&
4132 block->bb_u.s.bb_leftsib != cpu_to_be32(NULLAGBLOCK)))
4133 return false;
4134 if (!block->bb_u.s.bb_rightsib ||
4135 (be32_to_cpu(block->bb_u.s.bb_rightsib) >= mp->m_sb.sb_agblocks &&
4136 block->bb_u.s.bb_rightsib != cpu_to_be32(NULLAGBLOCK)))
4137 return false;
4138
4139 return true;
4140}
diff --git a/fs/xfs/libxfs/xfs_btree.h b/fs/xfs/libxfs/xfs_btree.h
index 992dec0638f3..2e874be70209 100644
--- a/fs/xfs/libxfs/xfs_btree.h
+++ b/fs/xfs/libxfs/xfs_btree.h
@@ -472,4 +472,7 @@ static inline int xfs_btree_get_level(struct xfs_btree_block *block)
472#define XFS_BTREE_TRACE_ARGR(c, r) 472#define XFS_BTREE_TRACE_ARGR(c, r)
473#define XFS_BTREE_TRACE_CURSOR(c, t) 473#define XFS_BTREE_TRACE_CURSOR(c, t)
474 474
475bool xfs_btree_sblock_v5hdr_verify(struct xfs_buf *bp);
476bool xfs_btree_sblock_verify(struct xfs_buf *bp, unsigned int max_recs);
477
475#endif /* __XFS_BTREE_H__ */ 478#endif /* __XFS_BTREE_H__ */
diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index e89a0f8f827c..097bf7717d80 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -245,6 +245,7 @@ xfs_da3_node_read_verify(
245} 245}
246 246
247const struct xfs_buf_ops xfs_da3_node_buf_ops = { 247const struct xfs_buf_ops xfs_da3_node_buf_ops = {
248 .name = "xfs_da3_node",
248 .verify_read = xfs_da3_node_read_verify, 249 .verify_read = xfs_da3_node_read_verify,
249 .verify_write = xfs_da3_node_write_verify, 250 .verify_write = xfs_da3_node_write_verify,
250}; 251};
diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c
index 9c10e2b8cfcb..aa17cb788946 100644
--- a/fs/xfs/libxfs/xfs_dir2_block.c
+++ b/fs/xfs/libxfs/xfs_dir2_block.c
@@ -123,6 +123,7 @@ xfs_dir3_block_write_verify(
123} 123}
124 124
125const struct xfs_buf_ops xfs_dir3_block_buf_ops = { 125const struct xfs_buf_ops xfs_dir3_block_buf_ops = {
126 .name = "xfs_dir3_block",
126 .verify_read = xfs_dir3_block_read_verify, 127 .verify_read = xfs_dir3_block_read_verify,
127 .verify_write = xfs_dir3_block_write_verify, 128 .verify_write = xfs_dir3_block_write_verify,
128}; 129};
diff --git a/fs/xfs/libxfs/xfs_dir2_data.c b/fs/xfs/libxfs/xfs_dir2_data.c
index af71a84f343c..725fc7841fde 100644
--- a/fs/xfs/libxfs/xfs_dir2_data.c
+++ b/fs/xfs/libxfs/xfs_dir2_data.c
@@ -305,11 +305,13 @@ xfs_dir3_data_write_verify(
305} 305}
306 306
307const struct xfs_buf_ops xfs_dir3_data_buf_ops = { 307const struct xfs_buf_ops xfs_dir3_data_buf_ops = {
308 .name = "xfs_dir3_data",
308 .verify_read = xfs_dir3_data_read_verify, 309 .verify_read = xfs_dir3_data_read_verify,
309 .verify_write = xfs_dir3_data_write_verify, 310 .verify_write = xfs_dir3_data_write_verify,
310}; 311};
311 312
312static const struct xfs_buf_ops xfs_dir3_data_reada_buf_ops = { 313static const struct xfs_buf_ops xfs_dir3_data_reada_buf_ops = {
314 .name = "xfs_dir3_data_reada",
313 .verify_read = xfs_dir3_data_reada_verify, 315 .verify_read = xfs_dir3_data_reada_verify,
314 .verify_write = xfs_dir3_data_write_verify, 316 .verify_write = xfs_dir3_data_write_verify,
315}; 317};
diff --git a/fs/xfs/libxfs/xfs_dir2_leaf.c b/fs/xfs/libxfs/xfs_dir2_leaf.c
index 3923e1f94697..b887fb2a2bcf 100644
--- a/fs/xfs/libxfs/xfs_dir2_leaf.c
+++ b/fs/xfs/libxfs/xfs_dir2_leaf.c
@@ -245,11 +245,13 @@ xfs_dir3_leafn_write_verify(
245} 245}
246 246
247const struct xfs_buf_ops xfs_dir3_leaf1_buf_ops = { 247const struct xfs_buf_ops xfs_dir3_leaf1_buf_ops = {
248 .name = "xfs_dir3_leaf1",
248 .verify_read = xfs_dir3_leaf1_read_verify, 249 .verify_read = xfs_dir3_leaf1_read_verify,
249 .verify_write = xfs_dir3_leaf1_write_verify, 250 .verify_write = xfs_dir3_leaf1_write_verify,
250}; 251};
251 252
252const struct xfs_buf_ops xfs_dir3_leafn_buf_ops = { 253const struct xfs_buf_ops xfs_dir3_leafn_buf_ops = {
254 .name = "xfs_dir3_leafn",
253 .verify_read = xfs_dir3_leafn_read_verify, 255 .verify_read = xfs_dir3_leafn_read_verify,
254 .verify_write = xfs_dir3_leafn_write_verify, 256 .verify_write = xfs_dir3_leafn_write_verify,
255}; 257};
diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c
index 70b0cb2fd556..63ee03db796c 100644
--- a/fs/xfs/libxfs/xfs_dir2_node.c
+++ b/fs/xfs/libxfs/xfs_dir2_node.c
@@ -150,6 +150,7 @@ xfs_dir3_free_write_verify(
150} 150}
151 151
152const struct xfs_buf_ops xfs_dir3_free_buf_ops = { 152const struct xfs_buf_ops xfs_dir3_free_buf_ops = {
153 .name = "xfs_dir3_free",
153 .verify_read = xfs_dir3_free_read_verify, 154 .verify_read = xfs_dir3_free_read_verify,
154 .verify_write = xfs_dir3_free_write_verify, 155 .verify_write = xfs_dir3_free_write_verify,
155}; 156};
diff --git a/fs/xfs/libxfs/xfs_dquot_buf.c b/fs/xfs/libxfs/xfs_dquot_buf.c
index 5331b7f0460c..11cefb2a372a 100644
--- a/fs/xfs/libxfs/xfs_dquot_buf.c
+++ b/fs/xfs/libxfs/xfs_dquot_buf.c
@@ -282,6 +282,7 @@ xfs_dquot_buf_write_verify(
282} 282}
283 283
284const struct xfs_buf_ops xfs_dquot_buf_ops = { 284const struct xfs_buf_ops xfs_dquot_buf_ops = {
285 .name = "xfs_dquot",
285 .verify_read = xfs_dquot_buf_read_verify, 286 .verify_read = xfs_dquot_buf_read_verify,
286 .verify_write = xfs_dquot_buf_write_verify, 287 .verify_write = xfs_dquot_buf_write_verify,
287}; 288};
diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h
index 8774498ce0ff..e2536bb1c760 100644
--- a/fs/xfs/libxfs/xfs_format.h
+++ b/fs/xfs/libxfs/xfs_format.h
@@ -786,7 +786,7 @@ typedef struct xfs_agfl {
786 __be64 agfl_lsn; 786 __be64 agfl_lsn;
787 __be32 agfl_crc; 787 __be32 agfl_crc;
788 __be32 agfl_bno[]; /* actually XFS_AGFL_SIZE(mp) */ 788 __be32 agfl_bno[]; /* actually XFS_AGFL_SIZE(mp) */
789} xfs_agfl_t; 789} __attribute__((packed)) xfs_agfl_t;
790 790
791#define XFS_AGFL_CRC_OFF offsetof(struct xfs_agfl, agfl_crc) 791#define XFS_AGFL_CRC_OFF offsetof(struct xfs_agfl, agfl_crc)
792 792
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index 70c1db99f6a7..66d702e6b9ff 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -2572,6 +2572,7 @@ xfs_agi_write_verify(
2572} 2572}
2573 2573
2574const struct xfs_buf_ops xfs_agi_buf_ops = { 2574const struct xfs_buf_ops xfs_agi_buf_ops = {
2575 .name = "xfs_agi",
2575 .verify_read = xfs_agi_read_verify, 2576 .verify_read = xfs_agi_read_verify,
2576 .verify_write = xfs_agi_write_verify, 2577 .verify_write = xfs_agi_write_verify,
2577}; 2578};
diff --git a/fs/xfs/libxfs/xfs_ialloc_btree.c b/fs/xfs/libxfs/xfs_ialloc_btree.c
index f39b285beb19..c679f3c05b63 100644
--- a/fs/xfs/libxfs/xfs_ialloc_btree.c
+++ b/fs/xfs/libxfs/xfs_ialloc_btree.c
@@ -221,7 +221,6 @@ xfs_inobt_verify(
221{ 221{
222 struct xfs_mount *mp = bp->b_target->bt_mount; 222 struct xfs_mount *mp = bp->b_target->bt_mount;
223 struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); 223 struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp);
224 struct xfs_perag *pag = bp->b_pag;
225 unsigned int level; 224 unsigned int level;
226 225
227 /* 226 /*
@@ -237,14 +236,7 @@ xfs_inobt_verify(
237 switch (block->bb_magic) { 236 switch (block->bb_magic) {
238 case cpu_to_be32(XFS_IBT_CRC_MAGIC): 237 case cpu_to_be32(XFS_IBT_CRC_MAGIC):
239 case cpu_to_be32(XFS_FIBT_CRC_MAGIC): 238 case cpu_to_be32(XFS_FIBT_CRC_MAGIC):
240 if (!xfs_sb_version_hascrc(&mp->m_sb)) 239 if (!xfs_btree_sblock_v5hdr_verify(bp))
241 return false;
242 if (!uuid_equal(&block->bb_u.s.bb_uuid, &mp->m_sb.sb_meta_uuid))
243 return false;
244 if (block->bb_u.s.bb_blkno != cpu_to_be64(bp->b_bn))
245 return false;
246 if (pag &&
247 be32_to_cpu(block->bb_u.s.bb_owner) != pag->pag_agno)
248 return false; 240 return false;
249 /* fall through */ 241 /* fall through */
250 case cpu_to_be32(XFS_IBT_MAGIC): 242 case cpu_to_be32(XFS_IBT_MAGIC):
@@ -254,24 +246,12 @@ xfs_inobt_verify(
254 return 0; 246 return 0;
255 } 247 }
256 248
257 /* numrecs and level verification */ 249 /* level verification */
258 level = be16_to_cpu(block->bb_level); 250 level = be16_to_cpu(block->bb_level);
259 if (level >= mp->m_in_maxlevels) 251 if (level >= mp->m_in_maxlevels)
260 return false; 252 return false;
261 if (be16_to_cpu(block->bb_numrecs) > mp->m_inobt_mxr[level != 0])
262 return false;
263
264 /* sibling pointer verification */
265 if (!block->bb_u.s.bb_leftsib ||
266 (be32_to_cpu(block->bb_u.s.bb_leftsib) >= mp->m_sb.sb_agblocks &&
267 block->bb_u.s.bb_leftsib != cpu_to_be32(NULLAGBLOCK)))
268 return false;
269 if (!block->bb_u.s.bb_rightsib ||
270 (be32_to_cpu(block->bb_u.s.bb_rightsib) >= mp->m_sb.sb_agblocks &&
271 block->bb_u.s.bb_rightsib != cpu_to_be32(NULLAGBLOCK)))
272 return false;
273 253
274 return true; 254 return xfs_btree_sblock_verify(bp, mp->m_inobt_mxr[level != 0]);
275} 255}
276 256
277static void 257static void
@@ -304,6 +284,7 @@ xfs_inobt_write_verify(
304} 284}
305 285
306const struct xfs_buf_ops xfs_inobt_buf_ops = { 286const struct xfs_buf_ops xfs_inobt_buf_ops = {
287 .name = "xfs_inobt",
307 .verify_read = xfs_inobt_read_verify, 288 .verify_read = xfs_inobt_read_verify,
308 .verify_write = xfs_inobt_write_verify, 289 .verify_write = xfs_inobt_write_verify,
309}; 290};
diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index 268c00f4f83a..1b8d98a915c4 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -132,11 +132,13 @@ xfs_inode_buf_write_verify(
132} 132}
133 133
134const struct xfs_buf_ops xfs_inode_buf_ops = { 134const struct xfs_buf_ops xfs_inode_buf_ops = {
135 .name = "xfs_inode",
135 .verify_read = xfs_inode_buf_read_verify, 136 .verify_read = xfs_inode_buf_read_verify,
136 .verify_write = xfs_inode_buf_write_verify, 137 .verify_write = xfs_inode_buf_write_verify,
137}; 138};
138 139
139const struct xfs_buf_ops xfs_inode_buf_ra_ops = { 140const struct xfs_buf_ops xfs_inode_buf_ra_ops = {
141 .name = "xxfs_inode_ra",
140 .verify_read = xfs_inode_buf_readahead_verify, 142 .verify_read = xfs_inode_buf_readahead_verify,
141 .verify_write = xfs_inode_buf_write_verify, 143 .verify_write = xfs_inode_buf_write_verify,
142}; 144};
diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c
index a0b071d881a0..8a53eaa349f4 100644
--- a/fs/xfs/libxfs/xfs_sb.c
+++ b/fs/xfs/libxfs/xfs_sb.c
@@ -679,11 +679,13 @@ xfs_sb_write_verify(
679} 679}
680 680
681const struct xfs_buf_ops xfs_sb_buf_ops = { 681const struct xfs_buf_ops xfs_sb_buf_ops = {
682 .name = "xfs_sb",
682 .verify_read = xfs_sb_read_verify, 683 .verify_read = xfs_sb_read_verify,
683 .verify_write = xfs_sb_write_verify, 684 .verify_write = xfs_sb_write_verify,
684}; 685};
685 686
686const struct xfs_buf_ops xfs_sb_quiet_buf_ops = { 687const struct xfs_buf_ops xfs_sb_quiet_buf_ops = {
688 .name = "xfs_sb_quiet",
687 .verify_read = xfs_sb_quiet_read_verify, 689 .verify_read = xfs_sb_quiet_read_verify,
688 .verify_write = xfs_sb_write_verify, 690 .verify_write = xfs_sb_write_verify,
689}; 691};
diff --git a/fs/xfs/libxfs/xfs_symlink_remote.c b/fs/xfs/libxfs/xfs_symlink_remote.c
index cb6fd20a4d3d..2e2c6716b623 100644
--- a/fs/xfs/libxfs/xfs_symlink_remote.c
+++ b/fs/xfs/libxfs/xfs_symlink_remote.c
@@ -168,6 +168,7 @@ xfs_symlink_write_verify(
168} 168}
169 169
170const struct xfs_buf_ops xfs_symlink_buf_ops = { 170const struct xfs_buf_ops xfs_symlink_buf_ops = {
171 .name = "xfs_symlink",
171 .verify_read = xfs_symlink_read_verify, 172 .verify_read = xfs_symlink_read_verify,
172 .verify_write = xfs_symlink_write_verify, 173 .verify_write = xfs_symlink_write_verify,
173}; 174};
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 3243cdf97f33..45a8ea7cfdb2 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -1045,7 +1045,7 @@ xfs_buf_ioend_work(
1045 xfs_buf_ioend(bp); 1045 xfs_buf_ioend(bp);
1046} 1046}
1047 1047
1048void 1048static void
1049xfs_buf_ioend_async( 1049xfs_buf_ioend_async(
1050 struct xfs_buf *bp) 1050 struct xfs_buf *bp)
1051{ 1051{
diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
index c79b717d9b88..c75721acd867 100644
--- a/fs/xfs/xfs_buf.h
+++ b/fs/xfs/xfs_buf.h
@@ -132,6 +132,7 @@ struct xfs_buf_map {
132 struct xfs_buf_map (map) = { .bm_bn = (blkno), .bm_len = (numblk) }; 132 struct xfs_buf_map (map) = { .bm_bn = (blkno), .bm_len = (numblk) };
133 133
134struct xfs_buf_ops { 134struct xfs_buf_ops {
135 char *name;
135 void (*verify_read)(struct xfs_buf *); 136 void (*verify_read)(struct xfs_buf *);
136 void (*verify_write)(struct xfs_buf *); 137 void (*verify_write)(struct xfs_buf *);
137}; 138};
diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
index 74d0e5966ebc..88693a98fac5 100644
--- a/fs/xfs/xfs_error.c
+++ b/fs/xfs/xfs_error.c
@@ -164,9 +164,9 @@ xfs_verifier_error(
164{ 164{
165 struct xfs_mount *mp = bp->b_target->bt_mount; 165 struct xfs_mount *mp = bp->b_target->bt_mount;
166 166
167 xfs_alert(mp, "Metadata %s detected at %pF, block 0x%llx", 167 xfs_alert(mp, "Metadata %s detected at %pF, %s block 0x%llx",
168 bp->b_error == -EFSBADCRC ? "CRC error" : "corruption", 168 bp->b_error == -EFSBADCRC ? "CRC error" : "corruption",
169 __return_address, bp->b_bn); 169 __return_address, bp->b_ops->name, bp->b_bn);
170 170
171 xfs_alert(mp, "Unmount and run xfs_repair"); 171 xfs_alert(mp, "Unmount and run xfs_repair");
172 172
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 887c44320909..9c9a1c9bcc7f 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -2068,12 +2068,14 @@ xlog_print_tic_res(
2068 "QM_DQCLUSTER", 2068 "QM_DQCLUSTER",
2069 "QM_QINOCREATE", 2069 "QM_QINOCREATE",
2070 "QM_QUOTAOFF_END", 2070 "QM_QUOTAOFF_END",
2071 "SB_UNIT",
2072 "FSYNC_TS", 2071 "FSYNC_TS",
2073 "GROWFSRT_ALLOC", 2072 "GROWFSRT_ALLOC",
2074 "GROWFSRT_ZERO", 2073 "GROWFSRT_ZERO",
2075 "GROWFSRT_FREE", 2074 "GROWFSRT_FREE",
2076 "SWAPEXT" 2075 "SWAPEXT",
2076 "CHECKPOINT",
2077 "ICREATE",
2078 "CREATE_TMPFILE"
2077 }; 2079 };
2078 2080
2079 xfs_warn(mp, "xlog_write: reservation summary:"); 2081 xfs_warn(mp, "xlog_write: reservation summary:");
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 36bd8825bfb0..b35775752b74 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -137,7 +137,7 @@ static const match_table_t tokens = {
137}; 137};
138 138
139 139
140STATIC unsigned long 140STATIC int
141suffix_kstrtoint(char *s, unsigned int base, int *res) 141suffix_kstrtoint(char *s, unsigned int base, int *res)
142{ 142{
143 int last, shift_left_factor = 0, _res; 143 int last, shift_left_factor = 0, _res;
diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c
index ce78534a047e..995170194df0 100644
--- a/fs/xfs/xfs_trans_dquot.c
+++ b/fs/xfs/xfs_trans_dquot.c
@@ -572,12 +572,16 @@ xfs_quota_warn(
572 struct xfs_dquot *dqp, 572 struct xfs_dquot *dqp,
573 int type) 573 int type)
574{ 574{
575 /* no warnings for project quotas - we just return ENOSPC later */ 575 enum quota_type qtype;
576
576 if (dqp->dq_flags & XFS_DQ_PROJ) 577 if (dqp->dq_flags & XFS_DQ_PROJ)
577 return; 578 qtype = PRJQUOTA;
578 quota_send_warning(make_kqid(&init_user_ns, 579 else if (dqp->dq_flags & XFS_DQ_USER)
579 (dqp->dq_flags & XFS_DQ_USER) ? 580 qtype = USRQUOTA;
580 USRQUOTA : GRPQUOTA, 581 else
582 qtype = GRPQUOTA;
583
584 quota_send_warning(make_kqid(&init_user_ns, qtype,
581 be32_to_cpu(dqp->q_core.d_id)), 585 be32_to_cpu(dqp->q_core.d_id)),
582 mp->m_super->s_dev, type); 586 mp->m_super->s_dev, type);
583} 587}