aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorEric Sandeen <sandeen@sandeen.net>2015-02-23 06:39:13 -0500
committerDave Chinner <david@fromorbit.com>2015-02-23 06:39:13 -0500
commit5fb5aeeeb65726c62dc39986d7a080309259e29c (patch)
tree5eef97a1acb0e3c01020a25867ca1891fa63fe01 /fs/xfs
parentc29aad41159829c0e1dcbf06c8e02284993b7901 (diff)
xfs: pass mp to XFS_WANT_CORRUPTED_RETURN
Today, if we hit an XFS_WANT_CORRUPTED_RETURN we don't print any information about which filesystem hit it. Passing in the mp allows us to print the filesystem (device) name, which is a pretty critical piece of information. Tested by running fsfuzzer 'til I hit some. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/libxfs/xfs_alloc.c29
-rw-r--r--fs/xfs/libxfs/xfs_bmap.c13
-rw-r--r--fs/xfs/libxfs/xfs_btree.c6
-rw-r--r--fs/xfs/libxfs/xfs_dir2_data.c39
-rw-r--r--fs/xfs/libxfs/xfs_ialloc.c18
-rw-r--r--fs/xfs/xfs_error.h4
-rw-r--r--fs/xfs/xfs_itable.c2
7 files changed, 59 insertions, 52 deletions
diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index d38d69a64af4..14a222fdc665 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -315,6 +315,9 @@ xfs_alloc_fixup_trees(
315 xfs_agblock_t nfbno2; /* second new free startblock */ 315 xfs_agblock_t nfbno2; /* second new free startblock */
316 xfs_extlen_t nflen1=0; /* first new free length */ 316 xfs_extlen_t nflen1=0; /* first new free length */
317 xfs_extlen_t nflen2=0; /* second new free length */ 317 xfs_extlen_t nflen2=0; /* second new free length */
318 struct xfs_mount *mp;
319
320 mp = cnt_cur->bc_mp;
318 321
319 /* 322 /*
320 * Look up the record in the by-size tree if necessary. 323 * Look up the record in the by-size tree if necessary.
@@ -323,13 +326,13 @@ xfs_alloc_fixup_trees(
323#ifdef DEBUG 326#ifdef DEBUG
324 if ((error = xfs_alloc_get_rec(cnt_cur, &nfbno1, &nflen1, &i))) 327 if ((error = xfs_alloc_get_rec(cnt_cur, &nfbno1, &nflen1, &i)))
325 return error; 328 return error;
326 XFS_WANT_CORRUPTED_RETURN( 329 XFS_WANT_CORRUPTED_RETURN(mp,
327 i == 1 && nfbno1 == fbno && nflen1 == flen); 330 i == 1 && nfbno1 == fbno && nflen1 == flen);
328#endif 331#endif
329 } else { 332 } else {
330 if ((error = xfs_alloc_lookup_eq(cnt_cur, fbno, flen, &i))) 333 if ((error = xfs_alloc_lookup_eq(cnt_cur, fbno, flen, &i)))
331 return error; 334 return error;
332 XFS_WANT_CORRUPTED_RETURN(i == 1); 335 XFS_WANT_CORRUPTED_RETURN(mp, i == 1);
333 } 336 }
334 /* 337 /*
335 * Look up the record in the by-block tree if necessary. 338 * Look up the record in the by-block tree if necessary.
@@ -338,13 +341,13 @@ xfs_alloc_fixup_trees(
338#ifdef DEBUG 341#ifdef DEBUG
339 if ((error = xfs_alloc_get_rec(bno_cur, &nfbno1, &nflen1, &i))) 342 if ((error = xfs_alloc_get_rec(bno_cur, &nfbno1, &nflen1, &i)))
340 return error; 343 return error;
341 XFS_WANT_CORRUPTED_RETURN( 344 XFS_WANT_CORRUPTED_RETURN(mp,
342 i == 1 && nfbno1 == fbno && nflen1 == flen); 345 i == 1 && nfbno1 == fbno && nflen1 == flen);
343#endif 346#endif
344 } else { 347 } else {
345 if ((error = xfs_alloc_lookup_eq(bno_cur, fbno, flen, &i))) 348 if ((error = xfs_alloc_lookup_eq(bno_cur, fbno, flen, &i)))
346 return error; 349 return error;
347 XFS_WANT_CORRUPTED_RETURN(i == 1); 350 XFS_WANT_CORRUPTED_RETURN(mp, i == 1);
348 } 351 }
349 352
350#ifdef DEBUG 353#ifdef DEBUG
@@ -355,7 +358,7 @@ xfs_alloc_fixup_trees(
355 bnoblock = XFS_BUF_TO_BLOCK(bno_cur->bc_bufs[0]); 358 bnoblock = XFS_BUF_TO_BLOCK(bno_cur->bc_bufs[0]);
356 cntblock = XFS_BUF_TO_BLOCK(cnt_cur->bc_bufs[0]); 359 cntblock = XFS_BUF_TO_BLOCK(cnt_cur->bc_bufs[0]);
357 360
358 XFS_WANT_CORRUPTED_RETURN( 361 XFS_WANT_CORRUPTED_RETURN(mp,
359 bnoblock->bb_numrecs == cntblock->bb_numrecs); 362 bnoblock->bb_numrecs == cntblock->bb_numrecs);
360 } 363 }
361#endif 364#endif
@@ -386,25 +389,25 @@ xfs_alloc_fixup_trees(
386 */ 389 */
387 if ((error = xfs_btree_delete(cnt_cur, &i))) 390 if ((error = xfs_btree_delete(cnt_cur, &i)))
388 return error; 391 return error;
389 XFS_WANT_CORRUPTED_RETURN(i == 1); 392 XFS_WANT_CORRUPTED_RETURN(mp, i == 1);
390 /* 393 /*
391 * Add new by-size btree entry(s). 394 * Add new by-size btree entry(s).
392 */ 395 */
393 if (nfbno1 != NULLAGBLOCK) { 396 if (nfbno1 != NULLAGBLOCK) {
394 if ((error = xfs_alloc_lookup_eq(cnt_cur, nfbno1, nflen1, &i))) 397 if ((error = xfs_alloc_lookup_eq(cnt_cur, nfbno1, nflen1, &i)))
395 return error; 398 return error;
396 XFS_WANT_CORRUPTED_RETURN(i == 0); 399 XFS_WANT_CORRUPTED_RETURN(mp, i == 0);
397 if ((error = xfs_btree_insert(cnt_cur, &i))) 400 if ((error = xfs_btree_insert(cnt_cur, &i)))
398 return error; 401 return error;
399 XFS_WANT_CORRUPTED_RETURN(i == 1); 402 XFS_WANT_CORRUPTED_RETURN(mp, i == 1);
400 } 403 }
401 if (nfbno2 != NULLAGBLOCK) { 404 if (nfbno2 != NULLAGBLOCK) {
402 if ((error = xfs_alloc_lookup_eq(cnt_cur, nfbno2, nflen2, &i))) 405 if ((error = xfs_alloc_lookup_eq(cnt_cur, nfbno2, nflen2, &i)))
403 return error; 406 return error;
404 XFS_WANT_CORRUPTED_RETURN(i == 0); 407 XFS_WANT_CORRUPTED_RETURN(mp, i == 0);
405 if ((error = xfs_btree_insert(cnt_cur, &i))) 408 if ((error = xfs_btree_insert(cnt_cur, &i)))
406 return error; 409 return error;
407 XFS_WANT_CORRUPTED_RETURN(i == 1); 410 XFS_WANT_CORRUPTED_RETURN(mp, i == 1);
408 } 411 }
409 /* 412 /*
410 * Fix up the by-block btree entry(s). 413 * Fix up the by-block btree entry(s).
@@ -415,7 +418,7 @@ xfs_alloc_fixup_trees(
415 */ 418 */
416 if ((error = xfs_btree_delete(bno_cur, &i))) 419 if ((error = xfs_btree_delete(bno_cur, &i)))
417 return error; 420 return error;
418 XFS_WANT_CORRUPTED_RETURN(i == 1); 421 XFS_WANT_CORRUPTED_RETURN(mp, i == 1);
419 } else { 422 } else {
420 /* 423 /*
421 * Update the by-block entry to start later|be shorter. 424 * Update the by-block entry to start later|be shorter.
@@ -429,10 +432,10 @@ xfs_alloc_fixup_trees(
429 */ 432 */
430 if ((error = xfs_alloc_lookup_eq(bno_cur, nfbno2, nflen2, &i))) 433 if ((error = xfs_alloc_lookup_eq(bno_cur, nfbno2, nflen2, &i)))
431 return error; 434 return error;
432 XFS_WANT_CORRUPTED_RETURN(i == 0); 435 XFS_WANT_CORRUPTED_RETURN(mp, i == 0);
433 if ((error = xfs_btree_insert(bno_cur, &i))) 436 if ((error = xfs_btree_insert(bno_cur, &i)))
434 return error; 437 return error;
435 XFS_WANT_CORRUPTED_RETURN(i == 1); 438 XFS_WANT_CORRUPTED_RETURN(mp, i == 1);
436 } 439 }
437 return 0; 440 return 0;
438} 441}
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index c52ef579b86c..60cfa90163b8 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -5460,6 +5460,7 @@ xfs_bmse_merge(
5460 struct xfs_bmbt_irec left; 5460 struct xfs_bmbt_irec left;
5461 xfs_filblks_t blockcount; 5461 xfs_filblks_t blockcount;
5462 int error, i; 5462 int error, i;
5463 struct xfs_mount *mp = ip->i_mount;
5463 5464
5464 xfs_bmbt_get_all(gotp, &got); 5465 xfs_bmbt_get_all(gotp, &got);
5465 xfs_bmbt_get_all(leftp, &left); 5466 xfs_bmbt_get_all(leftp, &left);
@@ -5494,19 +5495,19 @@ xfs_bmse_merge(
5494 got.br_blockcount, &i); 5495 got.br_blockcount, &i);
5495 if (error) 5496 if (error)
5496 return error; 5497 return error;
5497 XFS_WANT_CORRUPTED_RETURN(i == 1); 5498 XFS_WANT_CORRUPTED_RETURN(mp, i == 1);
5498 5499
5499 error = xfs_btree_delete(cur, &i); 5500 error = xfs_btree_delete(cur, &i);
5500 if (error) 5501 if (error)
5501 return error; 5502 return error;
5502 XFS_WANT_CORRUPTED_RETURN(i == 1); 5503 XFS_WANT_CORRUPTED_RETURN(mp, i == 1);
5503 5504
5504 /* lookup and update size of the previous extent */ 5505 /* lookup and update size of the previous extent */
5505 error = xfs_bmbt_lookup_eq(cur, left.br_startoff, left.br_startblock, 5506 error = xfs_bmbt_lookup_eq(cur, left.br_startoff, left.br_startblock,
5506 left.br_blockcount, &i); 5507 left.br_blockcount, &i);
5507 if (error) 5508 if (error)
5508 return error; 5509 return error;
5509 XFS_WANT_CORRUPTED_RETURN(i == 1); 5510 XFS_WANT_CORRUPTED_RETURN(mp, i == 1);
5510 5511
5511 left.br_blockcount = blockcount; 5512 left.br_blockcount = blockcount;
5512 5513
@@ -5528,6 +5529,7 @@ xfs_bmse_shift_one(
5528 int *logflags) 5529 int *logflags)
5529{ 5530{
5530 struct xfs_ifork *ifp; 5531 struct xfs_ifork *ifp;
5532 struct xfs_mount *mp;
5531 xfs_fileoff_t startoff; 5533 xfs_fileoff_t startoff;
5532 struct xfs_bmbt_rec_host *leftp; 5534 struct xfs_bmbt_rec_host *leftp;
5533 struct xfs_bmbt_irec got; 5535 struct xfs_bmbt_irec got;
@@ -5535,13 +5537,14 @@ xfs_bmse_shift_one(
5535 int error; 5537 int error;
5536 int i; 5538 int i;
5537 5539
5540 mp = ip->i_mount;
5538 ifp = XFS_IFORK_PTR(ip, whichfork); 5541 ifp = XFS_IFORK_PTR(ip, whichfork);
5539 5542
5540 xfs_bmbt_get_all(gotp, &got); 5543 xfs_bmbt_get_all(gotp, &got);
5541 startoff = got.br_startoff - offset_shift_fsb; 5544 startoff = got.br_startoff - offset_shift_fsb;
5542 5545
5543 /* delalloc extents should be prevented by caller */ 5546 /* delalloc extents should be prevented by caller */
5544 XFS_WANT_CORRUPTED_RETURN(!isnullstartblock(got.br_startblock)); 5547 XFS_WANT_CORRUPTED_RETURN(mp, !isnullstartblock(got.br_startblock));
5545 5548
5546 /* 5549 /*
5547 * Check for merge if we've got an extent to the left, otherwise make 5550 * Check for merge if we've got an extent to the left, otherwise make
@@ -5580,7 +5583,7 @@ xfs_bmse_shift_one(
5580 got.br_blockcount, &i); 5583 got.br_blockcount, &i);
5581 if (error) 5584 if (error)
5582 return error; 5585 return error;
5583 XFS_WANT_CORRUPTED_RETURN(i == 1); 5586 XFS_WANT_CORRUPTED_RETURN(mp, i == 1);
5584 5587
5585 got.br_startoff = startoff; 5588 got.br_startoff = startoff;
5586 return xfs_bmbt_update(cur, got.br_startoff, got.br_startblock, 5589 return xfs_bmbt_update(cur, got.br_startoff, got.br_startblock,
diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
index 8c5ce10e65b3..c72283dd8d44 100644
--- a/fs/xfs/libxfs/xfs_btree.c
+++ b/fs/xfs/libxfs/xfs_btree.c
@@ -168,7 +168,7 @@ xfs_btree_check_lptr(
168 xfs_fsblock_t bno, /* btree block disk address */ 168 xfs_fsblock_t bno, /* btree block disk address */
169 int level) /* btree block level */ 169 int level) /* btree block level */
170{ 170{
171 XFS_WANT_CORRUPTED_RETURN( 171 XFS_WANT_CORRUPTED_RETURN(cur->bc_mp,
172 level > 0 && 172 level > 0 &&
173 bno != NULLFSBLOCK && 173 bno != NULLFSBLOCK &&
174 XFS_FSB_SANITY_CHECK(cur->bc_mp, bno)); 174 XFS_FSB_SANITY_CHECK(cur->bc_mp, bno));
@@ -187,7 +187,7 @@ xfs_btree_check_sptr(
187{ 187{
188 xfs_agblock_t agblocks = cur->bc_mp->m_sb.sb_agblocks; 188 xfs_agblock_t agblocks = cur->bc_mp->m_sb.sb_agblocks;
189 189
190 XFS_WANT_CORRUPTED_RETURN( 190 XFS_WANT_CORRUPTED_RETURN(cur->bc_mp,
191 level > 0 && 191 level > 0 &&
192 bno != NULLAGBLOCK && 192 bno != NULLAGBLOCK &&
193 bno != 0 && 193 bno != 0 &&
@@ -1825,7 +1825,7 @@ xfs_btree_lookup(
1825 error = xfs_btree_increment(cur, 0, &i); 1825 error = xfs_btree_increment(cur, 0, &i);
1826 if (error) 1826 if (error)
1827 goto error0; 1827 goto error0;
1828 XFS_WANT_CORRUPTED_RETURN(i == 1); 1828 XFS_WANT_CORRUPTED_RETURN(cur->bc_mp, i == 1);
1829 XFS_BTREE_TRACE_CURSOR(cur, XBT_EXIT); 1829 XFS_BTREE_TRACE_CURSOR(cur, XBT_EXIT);
1830 *stat = 1; 1830 *stat = 1;
1831 return 0; 1831 return 0;
diff --git a/fs/xfs/libxfs/xfs_dir2_data.c b/fs/xfs/libxfs/xfs_dir2_data.c
index 5ff31be9b1cd..de1ea16f5748 100644
--- a/fs/xfs/libxfs/xfs_dir2_data.c
+++ b/fs/xfs/libxfs/xfs_dir2_data.c
@@ -89,7 +89,7 @@ __xfs_dir3_data_check(
89 * so just ensure that the count falls somewhere inside the 89 * so just ensure that the count falls somewhere inside the
90 * block right now. 90 * block right now.
91 */ 91 */
92 XFS_WANT_CORRUPTED_RETURN(be32_to_cpu(btp->count) < 92 XFS_WANT_CORRUPTED_RETURN(mp, be32_to_cpu(btp->count) <
93 ((char *)btp - p) / sizeof(struct xfs_dir2_leaf_entry)); 93 ((char *)btp - p) / sizeof(struct xfs_dir2_leaf_entry));
94 break; 94 break;
95 case cpu_to_be32(XFS_DIR3_DATA_MAGIC): 95 case cpu_to_be32(XFS_DIR3_DATA_MAGIC):
@@ -107,21 +107,21 @@ __xfs_dir3_data_check(
107 bf = ops->data_bestfree_p(hdr); 107 bf = ops->data_bestfree_p(hdr);
108 count = lastfree = freeseen = 0; 108 count = lastfree = freeseen = 0;
109 if (!bf[0].length) { 109 if (!bf[0].length) {
110 XFS_WANT_CORRUPTED_RETURN(!bf[0].offset); 110 XFS_WANT_CORRUPTED_RETURN(mp, !bf[0].offset);
111 freeseen |= 1 << 0; 111 freeseen |= 1 << 0;
112 } 112 }
113 if (!bf[1].length) { 113 if (!bf[1].length) {
114 XFS_WANT_CORRUPTED_RETURN(!bf[1].offset); 114 XFS_WANT_CORRUPTED_RETURN(mp, !bf[1].offset);
115 freeseen |= 1 << 1; 115 freeseen |= 1 << 1;
116 } 116 }
117 if (!bf[2].length) { 117 if (!bf[2].length) {
118 XFS_WANT_CORRUPTED_RETURN(!bf[2].offset); 118 XFS_WANT_CORRUPTED_RETURN(mp, !bf[2].offset);
119 freeseen |= 1 << 2; 119 freeseen |= 1 << 2;
120 } 120 }
121 121
122 XFS_WANT_CORRUPTED_RETURN(be16_to_cpu(bf[0].length) >= 122 XFS_WANT_CORRUPTED_RETURN(mp, be16_to_cpu(bf[0].length) >=
123 be16_to_cpu(bf[1].length)); 123 be16_to_cpu(bf[1].length));
124 XFS_WANT_CORRUPTED_RETURN(be16_to_cpu(bf[1].length) >= 124 XFS_WANT_CORRUPTED_RETURN(mp, be16_to_cpu(bf[1].length) >=
125 be16_to_cpu(bf[2].length)); 125 be16_to_cpu(bf[2].length));
126 /* 126 /*
127 * Loop over the data/unused entries. 127 * Loop over the data/unused entries.
@@ -134,18 +134,18 @@ __xfs_dir3_data_check(
134 * doesn't need to be there. 134 * doesn't need to be there.
135 */ 135 */
136 if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) { 136 if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) {
137 XFS_WANT_CORRUPTED_RETURN(lastfree == 0); 137 XFS_WANT_CORRUPTED_RETURN(mp, lastfree == 0);
138 XFS_WANT_CORRUPTED_RETURN( 138 XFS_WANT_CORRUPTED_RETURN(mp,
139 be16_to_cpu(*xfs_dir2_data_unused_tag_p(dup)) == 139 be16_to_cpu(*xfs_dir2_data_unused_tag_p(dup)) ==
140 (char *)dup - (char *)hdr); 140 (char *)dup - (char *)hdr);
141 dfp = xfs_dir2_data_freefind(hdr, bf, dup); 141 dfp = xfs_dir2_data_freefind(hdr, bf, dup);
142 if (dfp) { 142 if (dfp) {
143 i = (int)(dfp - bf); 143 i = (int)(dfp - bf);
144 XFS_WANT_CORRUPTED_RETURN( 144 XFS_WANT_CORRUPTED_RETURN(mp,
145 (freeseen & (1 << i)) == 0); 145 (freeseen & (1 << i)) == 0);
146 freeseen |= 1 << i; 146 freeseen |= 1 << i;
147 } else { 147 } else {
148 XFS_WANT_CORRUPTED_RETURN( 148 XFS_WANT_CORRUPTED_RETURN(mp,
149 be16_to_cpu(dup->length) <= 149 be16_to_cpu(dup->length) <=
150 be16_to_cpu(bf[2].length)); 150 be16_to_cpu(bf[2].length));
151 } 151 }
@@ -160,13 +160,13 @@ __xfs_dir3_data_check(
160 * The linear search is crude but this is DEBUG code. 160 * The linear search is crude but this is DEBUG code.
161 */ 161 */
162 dep = (xfs_dir2_data_entry_t *)p; 162 dep = (xfs_dir2_data_entry_t *)p;
163 XFS_WANT_CORRUPTED_RETURN(dep->namelen != 0); 163 XFS_WANT_CORRUPTED_RETURN(mp, dep->namelen != 0);
164 XFS_WANT_CORRUPTED_RETURN( 164 XFS_WANT_CORRUPTED_RETURN(mp,
165 !xfs_dir_ino_validate(mp, be64_to_cpu(dep->inumber))); 165 !xfs_dir_ino_validate(mp, be64_to_cpu(dep->inumber)));
166 XFS_WANT_CORRUPTED_RETURN( 166 XFS_WANT_CORRUPTED_RETURN(mp,
167 be16_to_cpu(*ops->data_entry_tag_p(dep)) == 167 be16_to_cpu(*ops->data_entry_tag_p(dep)) ==
168 (char *)dep - (char *)hdr); 168 (char *)dep - (char *)hdr);
169 XFS_WANT_CORRUPTED_RETURN( 169 XFS_WANT_CORRUPTED_RETURN(mp,
170 ops->data_get_ftype(dep) < XFS_DIR3_FT_MAX); 170 ops->data_get_ftype(dep) < XFS_DIR3_FT_MAX);
171 count++; 171 count++;
172 lastfree = 0; 172 lastfree = 0;
@@ -183,14 +183,15 @@ __xfs_dir3_data_check(
183 be32_to_cpu(lep[i].hashval) == hash) 183 be32_to_cpu(lep[i].hashval) == hash)
184 break; 184 break;
185 } 185 }
186 XFS_WANT_CORRUPTED_RETURN(i < be32_to_cpu(btp->count)); 186 XFS_WANT_CORRUPTED_RETURN(mp,
187 i < be32_to_cpu(btp->count));
187 } 188 }
188 p += ops->data_entsize(dep->namelen); 189 p += ops->data_entsize(dep->namelen);
189 } 190 }
190 /* 191 /*
191 * Need to have seen all the entries and all the bestfree slots. 192 * Need to have seen all the entries and all the bestfree slots.
192 */ 193 */
193 XFS_WANT_CORRUPTED_RETURN(freeseen == 7); 194 XFS_WANT_CORRUPTED_RETURN(mp, freeseen == 7);
194 if (hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) || 195 if (hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) ||
195 hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)) { 196 hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)) {
196 for (i = stale = 0; i < be32_to_cpu(btp->count); i++) { 197 for (i = stale = 0; i < be32_to_cpu(btp->count); i++) {
@@ -198,13 +199,13 @@ __xfs_dir3_data_check(
198 cpu_to_be32(XFS_DIR2_NULL_DATAPTR)) 199 cpu_to_be32(XFS_DIR2_NULL_DATAPTR))
199 stale++; 200 stale++;
200 if (i > 0) 201 if (i > 0)
201 XFS_WANT_CORRUPTED_RETURN( 202 XFS_WANT_CORRUPTED_RETURN(mp,
202 be32_to_cpu(lep[i].hashval) >= 203 be32_to_cpu(lep[i].hashval) >=
203 be32_to_cpu(lep[i - 1].hashval)); 204 be32_to_cpu(lep[i - 1].hashval));
204 } 205 }
205 XFS_WANT_CORRUPTED_RETURN(count == 206 XFS_WANT_CORRUPTED_RETURN(mp, count ==
206 be32_to_cpu(btp->count) - be32_to_cpu(btp->stale)); 207 be32_to_cpu(btp->count) - be32_to_cpu(btp->stale));
207 XFS_WANT_CORRUPTED_RETURN(stale == be32_to_cpu(btp->stale)); 208 XFS_WANT_CORRUPTED_RETURN(mp, stale == be32_to_cpu(btp->stale));
208 } 209 }
209 return 0; 210 return 0;
210} 211}
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index f95c4ae46e28..db0444893e96 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -700,7 +700,7 @@ xfs_ialloc_next_rec(
700 error = xfs_inobt_get_rec(cur, rec, &i); 700 error = xfs_inobt_get_rec(cur, rec, &i);
701 if (error) 701 if (error)
702 return error; 702 return error;
703 XFS_WANT_CORRUPTED_RETURN(i == 1); 703 XFS_WANT_CORRUPTED_RETURN(cur->bc_mp, i == 1);
704 } 704 }
705 705
706 return 0; 706 return 0;
@@ -724,7 +724,7 @@ xfs_ialloc_get_rec(
724 error = xfs_inobt_get_rec(cur, rec, &i); 724 error = xfs_inobt_get_rec(cur, rec, &i);
725 if (error) 725 if (error)
726 return error; 726 return error;
727 XFS_WANT_CORRUPTED_RETURN(i == 1); 727 XFS_WANT_CORRUPTED_RETURN(cur->bc_mp, i == 1);
728 } 728 }
729 729
730 return 0; 730 return 0;
@@ -1016,7 +1016,7 @@ xfs_dialloc_ag_finobt_near(
1016 error = xfs_inobt_get_rec(lcur, rec, &i); 1016 error = xfs_inobt_get_rec(lcur, rec, &i);
1017 if (error) 1017 if (error)
1018 return error; 1018 return error;
1019 XFS_WANT_CORRUPTED_RETURN(i == 1); 1019 XFS_WANT_CORRUPTED_RETURN(lcur->bc_mp, i == 1);
1020 1020
1021 /* 1021 /*
1022 * See if we've landed in the parent inode record. The finobt 1022 * See if we've landed in the parent inode record. The finobt
@@ -1095,7 +1095,7 @@ xfs_dialloc_ag_finobt_newino(
1095 error = xfs_inobt_get_rec(cur, rec, &i); 1095 error = xfs_inobt_get_rec(cur, rec, &i);
1096 if (error) 1096 if (error)
1097 return error; 1097 return error;
1098 XFS_WANT_CORRUPTED_RETURN(i == 1); 1098 XFS_WANT_CORRUPTED_RETURN(cur->bc_mp, i == 1);
1099 return 0; 1099 return 0;
1100 } 1100 }
1101 } 1101 }
@@ -1106,12 +1106,12 @@ xfs_dialloc_ag_finobt_newino(
1106 error = xfs_inobt_lookup(cur, 0, XFS_LOOKUP_GE, &i); 1106 error = xfs_inobt_lookup(cur, 0, XFS_LOOKUP_GE, &i);
1107 if (error) 1107 if (error)
1108 return error; 1108 return error;
1109 XFS_WANT_CORRUPTED_RETURN(i == 1); 1109 XFS_WANT_CORRUPTED_RETURN(cur->bc_mp, i == 1);
1110 1110
1111 error = xfs_inobt_get_rec(cur, rec, &i); 1111 error = xfs_inobt_get_rec(cur, rec, &i);
1112 if (error) 1112 if (error)
1113 return error; 1113 return error;
1114 XFS_WANT_CORRUPTED_RETURN(i == 1); 1114 XFS_WANT_CORRUPTED_RETURN(cur->bc_mp, i == 1);
1115 1115
1116 return 0; 1116 return 0;
1117} 1117}
@@ -1133,19 +1133,19 @@ xfs_dialloc_ag_update_inobt(
1133 error = xfs_inobt_lookup(cur, frec->ir_startino, XFS_LOOKUP_EQ, &i); 1133 error = xfs_inobt_lookup(cur, frec->ir_startino, XFS_LOOKUP_EQ, &i);
1134 if (error) 1134 if (error)
1135 return error; 1135 return error;
1136 XFS_WANT_CORRUPTED_RETURN(i == 1); 1136 XFS_WANT_CORRUPTED_RETURN(cur->bc_mp, i == 1);
1137 1137
1138 error = xfs_inobt_get_rec(cur, &rec, &i); 1138 error = xfs_inobt_get_rec(cur, &rec, &i);
1139 if (error) 1139 if (error)
1140 return error; 1140 return error;
1141 XFS_WANT_CORRUPTED_RETURN(i == 1); 1141 XFS_WANT_CORRUPTED_RETURN(cur->bc_mp, i == 1);
1142 ASSERT((XFS_AGINO_TO_OFFSET(cur->bc_mp, rec.ir_startino) % 1142 ASSERT((XFS_AGINO_TO_OFFSET(cur->bc_mp, rec.ir_startino) %
1143 XFS_INODES_PER_CHUNK) == 0); 1143 XFS_INODES_PER_CHUNK) == 0);
1144 1144
1145 rec.ir_free &= ~XFS_INOBT_MASK(offset); 1145 rec.ir_free &= ~XFS_INOBT_MASK(offset);
1146 rec.ir_freecount--; 1146 rec.ir_freecount--;
1147 1147
1148 XFS_WANT_CORRUPTED_RETURN((rec.ir_free == frec->ir_free) && 1148 XFS_WANT_CORRUPTED_RETURN(cur->bc_mp, (rec.ir_free == frec->ir_free) &&
1149 (rec.ir_freecount == frec->ir_freecount)); 1149 (rec.ir_freecount == frec->ir_freecount));
1150 1150
1151 return xfs_inobt_update(cur, &rec); 1151 return xfs_inobt_update(cur, &rec);
diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h
index 13eeca300281..c0394ed126fc 100644
--- a/fs/xfs/xfs_error.h
+++ b/fs/xfs/xfs_error.h
@@ -52,13 +52,13 @@ extern void xfs_verifier_error(struct xfs_buf *bp);
52 } \ 52 } \
53 } 53 }
54 54
55#define XFS_WANT_CORRUPTED_RETURN(x) \ 55#define XFS_WANT_CORRUPTED_RETURN(mp, x) \
56 { \ 56 { \
57 int fs_is_ok = (x); \ 57 int fs_is_ok = (x); \
58 ASSERT(fs_is_ok); \ 58 ASSERT(fs_is_ok); \
59 if (unlikely(!fs_is_ok)) { \ 59 if (unlikely(!fs_is_ok)) { \
60 XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_RETURN", \ 60 XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_RETURN", \
61 XFS_ERRLEVEL_LOW, NULL); \ 61 XFS_ERRLEVEL_LOW, mp); \
62 return -EFSCORRUPTED; \ 62 return -EFSCORRUPTED; \
63 } \ 63 } \
64 } 64 }
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
index 82e314258f73..80429891dc9b 100644
--- a/fs/xfs/xfs_itable.c
+++ b/fs/xfs/xfs_itable.c
@@ -229,7 +229,7 @@ xfs_bulkstat_grab_ichunk(
229 error = xfs_inobt_get_rec(cur, irec, &stat); 229 error = xfs_inobt_get_rec(cur, irec, &stat);
230 if (error) 230 if (error)
231 return error; 231 return error;
232 XFS_WANT_CORRUPTED_RETURN(stat == 1); 232 XFS_WANT_CORRUPTED_RETURN(cur->bc_mp, stat == 1);
233 233
234 /* Check if the record contains the inode in request */ 234 /* Check if the record contains the inode in request */
235 if (irec->ir_startino + XFS_INODES_PER_CHUNK <= agino) { 235 if (irec->ir_startino + XFS_INODES_PER_CHUNK <= agino) {