.. | .. |
---|
10 | 10 | #include "xfs_log_format.h" |
---|
11 | 11 | #include "xfs_trans_resv.h" |
---|
12 | 12 | #include "xfs_bit.h" |
---|
13 | | -#include "xfs_sb.h" |
---|
14 | 13 | #include "xfs_mount.h" |
---|
15 | 14 | #include "xfs_defer.h" |
---|
16 | | -#include "xfs_da_format.h" |
---|
17 | | -#include "xfs_da_btree.h" |
---|
18 | 15 | #include "xfs_btree.h" |
---|
19 | 16 | #include "xfs_trans.h" |
---|
20 | 17 | #include "xfs_alloc.h" |
---|
21 | 18 | #include "xfs_rmap.h" |
---|
22 | 19 | #include "xfs_rmap_btree.h" |
---|
23 | | -#include "xfs_trans_space.h" |
---|
24 | 20 | #include "xfs_trace.h" |
---|
25 | 21 | #include "xfs_errortag.h" |
---|
26 | 22 | #include "xfs_error.h" |
---|
27 | | -#include "xfs_extent_busy.h" |
---|
28 | | -#include "xfs_bmap.h" |
---|
29 | 23 | #include "xfs_inode.h" |
---|
30 | | -#include "xfs_ialloc.h" |
---|
31 | 24 | |
---|
32 | 25 | /* |
---|
33 | 26 | * Lookup the first record less than or equal to [bno, len, owner, offset] |
---|
.. | .. |
---|
86 | 79 | union xfs_btree_rec rec; |
---|
87 | 80 | int error; |
---|
88 | 81 | |
---|
89 | | - trace_xfs_rmap_update(cur->bc_mp, cur->bc_private.a.agno, |
---|
| 82 | + trace_xfs_rmap_update(cur->bc_mp, cur->bc_ag.agno, |
---|
90 | 83 | irec->rm_startblock, irec->rm_blockcount, |
---|
91 | 84 | irec->rm_owner, irec->rm_offset, irec->rm_flags); |
---|
92 | 85 | |
---|
.. | .. |
---|
98 | 91 | error = xfs_btree_update(cur, &rec); |
---|
99 | 92 | if (error) |
---|
100 | 93 | trace_xfs_rmap_update_error(cur->bc_mp, |
---|
101 | | - cur->bc_private.a.agno, error, _RET_IP_); |
---|
| 94 | + cur->bc_ag.agno, error, _RET_IP_); |
---|
102 | 95 | return error; |
---|
103 | 96 | } |
---|
104 | 97 | |
---|
.. | .. |
---|
114 | 107 | int i; |
---|
115 | 108 | int error; |
---|
116 | 109 | |
---|
117 | | - trace_xfs_rmap_insert(rcur->bc_mp, rcur->bc_private.a.agno, agbno, |
---|
| 110 | + trace_xfs_rmap_insert(rcur->bc_mp, rcur->bc_ag.agno, agbno, |
---|
118 | 111 | len, owner, offset, flags); |
---|
119 | 112 | |
---|
120 | 113 | error = xfs_rmap_lookup_eq(rcur, agbno, len, owner, offset, flags, &i); |
---|
121 | 114 | if (error) |
---|
122 | 115 | goto done; |
---|
123 | | - XFS_WANT_CORRUPTED_GOTO(rcur->bc_mp, i == 0, done); |
---|
| 116 | + if (XFS_IS_CORRUPT(rcur->bc_mp, i != 0)) { |
---|
| 117 | + error = -EFSCORRUPTED; |
---|
| 118 | + goto done; |
---|
| 119 | + } |
---|
124 | 120 | |
---|
125 | 121 | rcur->bc_rec.r.rm_startblock = agbno; |
---|
126 | 122 | rcur->bc_rec.r.rm_blockcount = len; |
---|
.. | .. |
---|
130 | 126 | error = xfs_btree_insert(rcur, &i); |
---|
131 | 127 | if (error) |
---|
132 | 128 | goto done; |
---|
133 | | - XFS_WANT_CORRUPTED_GOTO(rcur->bc_mp, i == 1, done); |
---|
| 129 | + if (XFS_IS_CORRUPT(rcur->bc_mp, i != 1)) { |
---|
| 130 | + error = -EFSCORRUPTED; |
---|
| 131 | + goto done; |
---|
| 132 | + } |
---|
134 | 133 | done: |
---|
135 | 134 | if (error) |
---|
136 | 135 | trace_xfs_rmap_insert_error(rcur->bc_mp, |
---|
137 | | - rcur->bc_private.a.agno, error, _RET_IP_); |
---|
| 136 | + rcur->bc_ag.agno, error, _RET_IP_); |
---|
138 | 137 | return error; |
---|
139 | 138 | } |
---|
140 | 139 | |
---|
.. | .. |
---|
150 | 149 | int i; |
---|
151 | 150 | int error; |
---|
152 | 151 | |
---|
153 | | - trace_xfs_rmap_delete(rcur->bc_mp, rcur->bc_private.a.agno, agbno, |
---|
| 152 | + trace_xfs_rmap_delete(rcur->bc_mp, rcur->bc_ag.agno, agbno, |
---|
154 | 153 | len, owner, offset, flags); |
---|
155 | 154 | |
---|
156 | 155 | error = xfs_rmap_lookup_eq(rcur, agbno, len, owner, offset, flags, &i); |
---|
157 | 156 | if (error) |
---|
158 | 157 | goto done; |
---|
159 | | - XFS_WANT_CORRUPTED_GOTO(rcur->bc_mp, i == 1, done); |
---|
| 158 | + if (XFS_IS_CORRUPT(rcur->bc_mp, i != 1)) { |
---|
| 159 | + error = -EFSCORRUPTED; |
---|
| 160 | + goto done; |
---|
| 161 | + } |
---|
160 | 162 | |
---|
161 | 163 | error = xfs_btree_delete(rcur, &i); |
---|
162 | 164 | if (error) |
---|
163 | 165 | goto done; |
---|
164 | | - XFS_WANT_CORRUPTED_GOTO(rcur->bc_mp, i == 1, done); |
---|
| 166 | + if (XFS_IS_CORRUPT(rcur->bc_mp, i != 1)) { |
---|
| 167 | + error = -EFSCORRUPTED; |
---|
| 168 | + goto done; |
---|
| 169 | + } |
---|
165 | 170 | done: |
---|
166 | 171 | if (error) |
---|
167 | 172 | trace_xfs_rmap_delete_error(rcur->bc_mp, |
---|
168 | | - rcur->bc_private.a.agno, error, _RET_IP_); |
---|
| 173 | + rcur->bc_ag.agno, error, _RET_IP_); |
---|
169 | 174 | return error; |
---|
170 | 175 | } |
---|
171 | 176 | |
---|
.. | .. |
---|
175 | 180 | union xfs_btree_rec *rec, |
---|
176 | 181 | struct xfs_rmap_irec *irec) |
---|
177 | 182 | { |
---|
178 | | - irec->rm_flags = 0; |
---|
179 | 183 | irec->rm_startblock = be32_to_cpu(rec->rmap.rm_startblock); |
---|
180 | 184 | irec->rm_blockcount = be32_to_cpu(rec->rmap.rm_blockcount); |
---|
181 | 185 | irec->rm_owner = be64_to_cpu(rec->rmap.rm_owner); |
---|
.. | .. |
---|
193 | 197 | int *stat) |
---|
194 | 198 | { |
---|
195 | 199 | struct xfs_mount *mp = cur->bc_mp; |
---|
196 | | - xfs_agnumber_t agno = cur->bc_private.a.agno; |
---|
| 200 | + xfs_agnumber_t agno = cur->bc_ag.agno; |
---|
197 | 201 | union xfs_btree_rec *rec; |
---|
198 | 202 | int error; |
---|
199 | 203 | |
---|
.. | .. |
---|
256 | 260 | struct xfs_find_left_neighbor_info *info = priv; |
---|
257 | 261 | |
---|
258 | 262 | trace_xfs_rmap_find_left_neighbor_candidate(cur->bc_mp, |
---|
259 | | - cur->bc_private.a.agno, rec->rm_startblock, |
---|
| 263 | + cur->bc_ag.agno, rec->rm_startblock, |
---|
260 | 264 | rec->rm_blockcount, rec->rm_owner, rec->rm_offset, |
---|
261 | 265 | rec->rm_flags); |
---|
262 | 266 | |
---|
263 | 267 | if (rec->rm_owner != info->high.rm_owner) |
---|
264 | | - return XFS_BTREE_QUERY_RANGE_CONTINUE; |
---|
| 268 | + return 0; |
---|
265 | 269 | if (!XFS_RMAP_NON_INODE_OWNER(rec->rm_owner) && |
---|
266 | 270 | !(rec->rm_flags & XFS_RMAP_BMBT_BLOCK) && |
---|
267 | 271 | rec->rm_offset + rec->rm_blockcount - 1 != info->high.rm_offset) |
---|
268 | | - return XFS_BTREE_QUERY_RANGE_CONTINUE; |
---|
| 272 | + return 0; |
---|
269 | 273 | |
---|
270 | 274 | *info->irec = *rec; |
---|
271 | 275 | *info->stat = 1; |
---|
272 | | - return XFS_BTREE_QUERY_RANGE_ABORT; |
---|
| 276 | + return -ECANCELED; |
---|
273 | 277 | } |
---|
274 | 278 | |
---|
275 | 279 | /* |
---|
.. | .. |
---|
308 | 312 | info.stat = stat; |
---|
309 | 313 | |
---|
310 | 314 | trace_xfs_rmap_find_left_neighbor_query(cur->bc_mp, |
---|
311 | | - cur->bc_private.a.agno, bno, 0, owner, offset, flags); |
---|
| 315 | + cur->bc_ag.agno, bno, 0, owner, offset, flags); |
---|
312 | 316 | |
---|
313 | 317 | error = xfs_rmap_query_range(cur, &info.high, &info.high, |
---|
314 | 318 | xfs_rmap_find_left_neighbor_helper, &info); |
---|
315 | | - if (error == XFS_BTREE_QUERY_RANGE_ABORT) |
---|
| 319 | + if (error == -ECANCELED) |
---|
316 | 320 | error = 0; |
---|
317 | 321 | if (*stat) |
---|
318 | 322 | trace_xfs_rmap_find_left_neighbor_result(cur->bc_mp, |
---|
319 | | - cur->bc_private.a.agno, irec->rm_startblock, |
---|
| 323 | + cur->bc_ag.agno, irec->rm_startblock, |
---|
320 | 324 | irec->rm_blockcount, irec->rm_owner, |
---|
321 | 325 | irec->rm_offset, irec->rm_flags); |
---|
322 | 326 | return error; |
---|
.. | .. |
---|
332 | 336 | struct xfs_find_left_neighbor_info *info = priv; |
---|
333 | 337 | |
---|
334 | 338 | trace_xfs_rmap_lookup_le_range_candidate(cur->bc_mp, |
---|
335 | | - cur->bc_private.a.agno, rec->rm_startblock, |
---|
| 339 | + cur->bc_ag.agno, rec->rm_startblock, |
---|
336 | 340 | rec->rm_blockcount, rec->rm_owner, rec->rm_offset, |
---|
337 | 341 | rec->rm_flags); |
---|
338 | 342 | |
---|
339 | 343 | if (rec->rm_owner != info->high.rm_owner) |
---|
340 | | - return XFS_BTREE_QUERY_RANGE_CONTINUE; |
---|
| 344 | + return 0; |
---|
341 | 345 | if (!XFS_RMAP_NON_INODE_OWNER(rec->rm_owner) && |
---|
342 | 346 | !(rec->rm_flags & XFS_RMAP_BMBT_BLOCK) && |
---|
343 | 347 | (rec->rm_offset > info->high.rm_offset || |
---|
344 | 348 | rec->rm_offset + rec->rm_blockcount <= info->high.rm_offset)) |
---|
345 | | - return XFS_BTREE_QUERY_RANGE_CONTINUE; |
---|
| 349 | + return 0; |
---|
346 | 350 | |
---|
347 | 351 | *info->irec = *rec; |
---|
348 | 352 | *info->stat = 1; |
---|
349 | | - return XFS_BTREE_QUERY_RANGE_ABORT; |
---|
| 353 | + return -ECANCELED; |
---|
350 | 354 | } |
---|
351 | 355 | |
---|
352 | 356 | /* |
---|
.. | .. |
---|
381 | 385 | info.stat = stat; |
---|
382 | 386 | |
---|
383 | 387 | trace_xfs_rmap_lookup_le_range(cur->bc_mp, |
---|
384 | | - cur->bc_private.a.agno, bno, 0, owner, offset, flags); |
---|
| 388 | + cur->bc_ag.agno, bno, 0, owner, offset, flags); |
---|
385 | 389 | error = xfs_rmap_query_range(cur, &info.high, &info.high, |
---|
386 | 390 | xfs_rmap_lookup_le_range_helper, &info); |
---|
387 | | - if (error == XFS_BTREE_QUERY_RANGE_ABORT) |
---|
| 391 | + if (error == -ECANCELED) |
---|
388 | 392 | error = 0; |
---|
389 | 393 | if (*stat) |
---|
390 | 394 | trace_xfs_rmap_lookup_le_range_result(cur->bc_mp, |
---|
391 | | - cur->bc_private.a.agno, irec->rm_startblock, |
---|
| 395 | + cur->bc_ag.agno, irec->rm_startblock, |
---|
392 | 396 | irec->rm_blockcount, irec->rm_owner, |
---|
393 | 397 | irec->rm_offset, irec->rm_flags); |
---|
394 | 398 | return error; |
---|
.. | .. |
---|
414 | 418 | return 0; |
---|
415 | 419 | |
---|
416 | 420 | /* Make sure the unwritten flag matches. */ |
---|
417 | | - XFS_WANT_CORRUPTED_GOTO(mp, (flags & XFS_RMAP_UNWRITTEN) == |
---|
418 | | - (rec->rm_flags & XFS_RMAP_UNWRITTEN), out); |
---|
| 421 | + if (XFS_IS_CORRUPT(mp, |
---|
| 422 | + (flags & XFS_RMAP_UNWRITTEN) != |
---|
| 423 | + (rec->rm_flags & XFS_RMAP_UNWRITTEN))) { |
---|
| 424 | + error = -EFSCORRUPTED; |
---|
| 425 | + goto out; |
---|
| 426 | + } |
---|
419 | 427 | |
---|
420 | 428 | /* Make sure the owner matches what we expect to find in the tree. */ |
---|
421 | | - XFS_WANT_CORRUPTED_GOTO(mp, owner == rec->rm_owner, out); |
---|
| 429 | + if (XFS_IS_CORRUPT(mp, owner != rec->rm_owner)) { |
---|
| 430 | + error = -EFSCORRUPTED; |
---|
| 431 | + goto out; |
---|
| 432 | + } |
---|
422 | 433 | |
---|
423 | 434 | /* Check the offset, if necessary. */ |
---|
424 | 435 | if (XFS_RMAP_NON_INODE_OWNER(owner)) |
---|
425 | 436 | goto out; |
---|
426 | 437 | |
---|
427 | 438 | if (flags & XFS_RMAP_BMBT_BLOCK) { |
---|
428 | | - XFS_WANT_CORRUPTED_GOTO(mp, rec->rm_flags & XFS_RMAP_BMBT_BLOCK, |
---|
429 | | - out); |
---|
| 439 | + if (XFS_IS_CORRUPT(mp, |
---|
| 440 | + !(rec->rm_flags & XFS_RMAP_BMBT_BLOCK))) { |
---|
| 441 | + error = -EFSCORRUPTED; |
---|
| 442 | + goto out; |
---|
| 443 | + } |
---|
430 | 444 | } else { |
---|
431 | | - XFS_WANT_CORRUPTED_GOTO(mp, rec->rm_offset <= offset, out); |
---|
432 | | - XFS_WANT_CORRUPTED_GOTO(mp, |
---|
433 | | - ltoff + rec->rm_blockcount >= offset + len, |
---|
434 | | - out); |
---|
| 445 | + if (XFS_IS_CORRUPT(mp, rec->rm_offset > offset)) { |
---|
| 446 | + error = -EFSCORRUPTED; |
---|
| 447 | + goto out; |
---|
| 448 | + } |
---|
| 449 | + if (XFS_IS_CORRUPT(mp, |
---|
| 450 | + offset + len > ltoff + rec->rm_blockcount)) { |
---|
| 451 | + error = -EFSCORRUPTED; |
---|
| 452 | + goto out; |
---|
| 453 | + } |
---|
435 | 454 | } |
---|
436 | 455 | |
---|
437 | 456 | out: |
---|
.. | .. |
---|
458 | 477 | */ |
---|
459 | 478 | STATIC int |
---|
460 | 479 | xfs_rmap_unmap( |
---|
461 | | - struct xfs_btree_cur *cur, |
---|
462 | | - xfs_agblock_t bno, |
---|
463 | | - xfs_extlen_t len, |
---|
464 | | - bool unwritten, |
---|
465 | | - struct xfs_owner_info *oinfo) |
---|
| 480 | + struct xfs_btree_cur *cur, |
---|
| 481 | + xfs_agblock_t bno, |
---|
| 482 | + xfs_extlen_t len, |
---|
| 483 | + bool unwritten, |
---|
| 484 | + const struct xfs_owner_info *oinfo) |
---|
466 | 485 | { |
---|
467 | | - struct xfs_mount *mp = cur->bc_mp; |
---|
468 | | - struct xfs_rmap_irec ltrec; |
---|
469 | | - uint64_t ltoff; |
---|
470 | | - int error = 0; |
---|
471 | | - int i; |
---|
472 | | - uint64_t owner; |
---|
473 | | - uint64_t offset; |
---|
474 | | - unsigned int flags; |
---|
475 | | - bool ignore_off; |
---|
| 486 | + struct xfs_mount *mp = cur->bc_mp; |
---|
| 487 | + struct xfs_rmap_irec ltrec; |
---|
| 488 | + uint64_t ltoff; |
---|
| 489 | + int error = 0; |
---|
| 490 | + int i; |
---|
| 491 | + uint64_t owner; |
---|
| 492 | + uint64_t offset; |
---|
| 493 | + unsigned int flags; |
---|
| 494 | + bool ignore_off; |
---|
476 | 495 | |
---|
477 | 496 | xfs_owner_info_unpack(oinfo, &owner, &offset, &flags); |
---|
478 | 497 | ignore_off = XFS_RMAP_NON_INODE_OWNER(owner) || |
---|
479 | 498 | (flags & XFS_RMAP_BMBT_BLOCK); |
---|
480 | 499 | if (unwritten) |
---|
481 | 500 | flags |= XFS_RMAP_UNWRITTEN; |
---|
482 | | - trace_xfs_rmap_unmap(mp, cur->bc_private.a.agno, bno, len, |
---|
| 501 | + trace_xfs_rmap_unmap(mp, cur->bc_ag.agno, bno, len, |
---|
483 | 502 | unwritten, oinfo); |
---|
484 | 503 | |
---|
485 | 504 | /* |
---|
.. | .. |
---|
490 | 509 | error = xfs_rmap_lookup_le(cur, bno, len, owner, offset, flags, &i); |
---|
491 | 510 | if (error) |
---|
492 | 511 | goto out_error; |
---|
493 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, out_error); |
---|
| 512 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 513 | + error = -EFSCORRUPTED; |
---|
| 514 | + goto out_error; |
---|
| 515 | + } |
---|
494 | 516 | |
---|
495 | 517 | error = xfs_rmap_get_rec(cur, <rec, &i); |
---|
496 | 518 | if (error) |
---|
497 | 519 | goto out_error; |
---|
498 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, out_error); |
---|
| 520 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 521 | + error = -EFSCORRUPTED; |
---|
| 522 | + goto out_error; |
---|
| 523 | + } |
---|
499 | 524 | trace_xfs_rmap_lookup_le_range_result(cur->bc_mp, |
---|
500 | | - cur->bc_private.a.agno, ltrec.rm_startblock, |
---|
| 525 | + cur->bc_ag.agno, ltrec.rm_startblock, |
---|
501 | 526 | ltrec.rm_blockcount, ltrec.rm_owner, |
---|
502 | 527 | ltrec.rm_offset, ltrec.rm_flags); |
---|
503 | 528 | ltoff = ltrec.rm_offset; |
---|
.. | .. |
---|
510 | 535 | * be the case that the "left" extent goes all the way to EOFS. |
---|
511 | 536 | */ |
---|
512 | 537 | if (owner == XFS_RMAP_OWN_NULL) { |
---|
513 | | - XFS_WANT_CORRUPTED_GOTO(mp, bno >= ltrec.rm_startblock + |
---|
514 | | - ltrec.rm_blockcount, out_error); |
---|
| 538 | + if (XFS_IS_CORRUPT(mp, |
---|
| 539 | + bno < |
---|
| 540 | + ltrec.rm_startblock + ltrec.rm_blockcount)) { |
---|
| 541 | + error = -EFSCORRUPTED; |
---|
| 542 | + goto out_error; |
---|
| 543 | + } |
---|
515 | 544 | goto out_done; |
---|
516 | 545 | } |
---|
517 | 546 | |
---|
.. | .. |
---|
534 | 563 | error = xfs_rmap_get_rec(cur, &rtrec, &i); |
---|
535 | 564 | if (error) |
---|
536 | 565 | goto out_error; |
---|
537 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, out_error); |
---|
| 566 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 567 | + error = -EFSCORRUPTED; |
---|
| 568 | + goto out_error; |
---|
| 569 | + } |
---|
538 | 570 | if (rtrec.rm_startblock >= bno + len) |
---|
539 | 571 | goto out_done; |
---|
540 | 572 | } |
---|
541 | 573 | |
---|
542 | 574 | /* Make sure the extent we found covers the entire freeing range. */ |
---|
543 | | - XFS_WANT_CORRUPTED_GOTO(mp, ltrec.rm_startblock <= bno && |
---|
544 | | - ltrec.rm_startblock + ltrec.rm_blockcount >= |
---|
545 | | - bno + len, out_error); |
---|
| 575 | + if (XFS_IS_CORRUPT(mp, |
---|
| 576 | + ltrec.rm_startblock > bno || |
---|
| 577 | + ltrec.rm_startblock + ltrec.rm_blockcount < |
---|
| 578 | + bno + len)) { |
---|
| 579 | + error = -EFSCORRUPTED; |
---|
| 580 | + goto out_error; |
---|
| 581 | + } |
---|
546 | 582 | |
---|
547 | 583 | /* Check owner information. */ |
---|
548 | 584 | error = xfs_rmap_free_check_owner(mp, ltoff, <rec, len, owner, |
---|
.. | .. |
---|
552 | 588 | |
---|
553 | 589 | if (ltrec.rm_startblock == bno && ltrec.rm_blockcount == len) { |
---|
554 | 590 | /* exact match, simply remove the record from rmap tree */ |
---|
555 | | - trace_xfs_rmap_delete(mp, cur->bc_private.a.agno, |
---|
| 591 | + trace_xfs_rmap_delete(mp, cur->bc_ag.agno, |
---|
556 | 592 | ltrec.rm_startblock, ltrec.rm_blockcount, |
---|
557 | 593 | ltrec.rm_owner, ltrec.rm_offset, |
---|
558 | 594 | ltrec.rm_flags); |
---|
559 | 595 | error = xfs_btree_delete(cur, &i); |
---|
560 | 596 | if (error) |
---|
561 | 597 | goto out_error; |
---|
562 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, out_error); |
---|
| 598 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 599 | + error = -EFSCORRUPTED; |
---|
| 600 | + goto out_error; |
---|
| 601 | + } |
---|
563 | 602 | } else if (ltrec.rm_startblock == bno) { |
---|
564 | 603 | /* |
---|
565 | 604 | * overlap left hand side of extent: move the start, trim the |
---|
.. | .. |
---|
627 | 666 | else |
---|
628 | 667 | cur->bc_rec.r.rm_offset = offset + len; |
---|
629 | 668 | cur->bc_rec.r.rm_flags = flags; |
---|
630 | | - trace_xfs_rmap_insert(mp, cur->bc_private.a.agno, |
---|
| 669 | + trace_xfs_rmap_insert(mp, cur->bc_ag.agno, |
---|
631 | 670 | cur->bc_rec.r.rm_startblock, |
---|
632 | 671 | cur->bc_rec.r.rm_blockcount, |
---|
633 | 672 | cur->bc_rec.r.rm_owner, |
---|
.. | .. |
---|
639 | 678 | } |
---|
640 | 679 | |
---|
641 | 680 | out_done: |
---|
642 | | - trace_xfs_rmap_unmap_done(mp, cur->bc_private.a.agno, bno, len, |
---|
| 681 | + trace_xfs_rmap_unmap_done(mp, cur->bc_ag.agno, bno, len, |
---|
643 | 682 | unwritten, oinfo); |
---|
644 | 683 | out_error: |
---|
645 | 684 | if (error) |
---|
646 | | - trace_xfs_rmap_unmap_error(mp, cur->bc_private.a.agno, |
---|
| 685 | + trace_xfs_rmap_unmap_error(mp, cur->bc_ag.agno, |
---|
647 | 686 | error, _RET_IP_); |
---|
648 | 687 | return error; |
---|
649 | 688 | } |
---|
.. | .. |
---|
653 | 692 | */ |
---|
654 | 693 | int |
---|
655 | 694 | xfs_rmap_free( |
---|
656 | | - struct xfs_trans *tp, |
---|
657 | | - struct xfs_buf *agbp, |
---|
658 | | - xfs_agnumber_t agno, |
---|
659 | | - xfs_agblock_t bno, |
---|
660 | | - xfs_extlen_t len, |
---|
661 | | - struct xfs_owner_info *oinfo) |
---|
| 695 | + struct xfs_trans *tp, |
---|
| 696 | + struct xfs_buf *agbp, |
---|
| 697 | + xfs_agnumber_t agno, |
---|
| 698 | + xfs_agblock_t bno, |
---|
| 699 | + xfs_extlen_t len, |
---|
| 700 | + const struct xfs_owner_info *oinfo) |
---|
662 | 701 | { |
---|
663 | | - struct xfs_mount *mp = tp->t_mountp; |
---|
664 | | - struct xfs_btree_cur *cur; |
---|
665 | | - int error; |
---|
| 702 | + struct xfs_mount *mp = tp->t_mountp; |
---|
| 703 | + struct xfs_btree_cur *cur; |
---|
| 704 | + int error; |
---|
666 | 705 | |
---|
667 | 706 | if (!xfs_sb_version_hasrmapbt(&mp->m_sb)) |
---|
668 | 707 | return 0; |
---|
.. | .. |
---|
710 | 749 | */ |
---|
711 | 750 | STATIC int |
---|
712 | 751 | xfs_rmap_map( |
---|
713 | | - struct xfs_btree_cur *cur, |
---|
714 | | - xfs_agblock_t bno, |
---|
715 | | - xfs_extlen_t len, |
---|
716 | | - bool unwritten, |
---|
717 | | - struct xfs_owner_info *oinfo) |
---|
| 752 | + struct xfs_btree_cur *cur, |
---|
| 753 | + xfs_agblock_t bno, |
---|
| 754 | + xfs_extlen_t len, |
---|
| 755 | + bool unwritten, |
---|
| 756 | + const struct xfs_owner_info *oinfo) |
---|
718 | 757 | { |
---|
719 | | - struct xfs_mount *mp = cur->bc_mp; |
---|
720 | | - struct xfs_rmap_irec ltrec; |
---|
721 | | - struct xfs_rmap_irec gtrec; |
---|
722 | | - int have_gt; |
---|
723 | | - int have_lt; |
---|
724 | | - int error = 0; |
---|
725 | | - int i; |
---|
726 | | - uint64_t owner; |
---|
727 | | - uint64_t offset; |
---|
728 | | - unsigned int flags = 0; |
---|
729 | | - bool ignore_off; |
---|
| 758 | + struct xfs_mount *mp = cur->bc_mp; |
---|
| 759 | + struct xfs_rmap_irec ltrec; |
---|
| 760 | + struct xfs_rmap_irec gtrec; |
---|
| 761 | + int have_gt; |
---|
| 762 | + int have_lt; |
---|
| 763 | + int error = 0; |
---|
| 764 | + int i; |
---|
| 765 | + uint64_t owner; |
---|
| 766 | + uint64_t offset; |
---|
| 767 | + unsigned int flags = 0; |
---|
| 768 | + bool ignore_off; |
---|
730 | 769 | |
---|
731 | 770 | xfs_owner_info_unpack(oinfo, &owner, &offset, &flags); |
---|
732 | 771 | ASSERT(owner != 0); |
---|
.. | .. |
---|
734 | 773 | (flags & XFS_RMAP_BMBT_BLOCK); |
---|
735 | 774 | if (unwritten) |
---|
736 | 775 | flags |= XFS_RMAP_UNWRITTEN; |
---|
737 | | - trace_xfs_rmap_map(mp, cur->bc_private.a.agno, bno, len, |
---|
| 776 | + trace_xfs_rmap_map(mp, cur->bc_ag.agno, bno, len, |
---|
738 | 777 | unwritten, oinfo); |
---|
739 | 778 | ASSERT(!xfs_rmap_should_skip_owner_update(oinfo)); |
---|
740 | 779 | |
---|
.. | .. |
---|
751 | 790 | error = xfs_rmap_get_rec(cur, <rec, &have_lt); |
---|
752 | 791 | if (error) |
---|
753 | 792 | goto out_error; |
---|
754 | | - XFS_WANT_CORRUPTED_GOTO(mp, have_lt == 1, out_error); |
---|
| 793 | + if (XFS_IS_CORRUPT(mp, have_lt != 1)) { |
---|
| 794 | + error = -EFSCORRUPTED; |
---|
| 795 | + goto out_error; |
---|
| 796 | + } |
---|
755 | 797 | trace_xfs_rmap_lookup_le_range_result(cur->bc_mp, |
---|
756 | | - cur->bc_private.a.agno, ltrec.rm_startblock, |
---|
| 798 | + cur->bc_ag.agno, ltrec.rm_startblock, |
---|
757 | 799 | ltrec.rm_blockcount, ltrec.rm_owner, |
---|
758 | 800 | ltrec.rm_offset, ltrec.rm_flags); |
---|
759 | 801 | |
---|
.. | .. |
---|
761 | 803 | have_lt = 0; |
---|
762 | 804 | } |
---|
763 | 805 | |
---|
764 | | - XFS_WANT_CORRUPTED_GOTO(mp, |
---|
765 | | - have_lt == 0 || |
---|
766 | | - ltrec.rm_startblock + ltrec.rm_blockcount <= bno, out_error); |
---|
| 806 | + if (XFS_IS_CORRUPT(mp, |
---|
| 807 | + have_lt != 0 && |
---|
| 808 | + ltrec.rm_startblock + ltrec.rm_blockcount > bno)) { |
---|
| 809 | + error = -EFSCORRUPTED; |
---|
| 810 | + goto out_error; |
---|
| 811 | + } |
---|
767 | 812 | |
---|
768 | 813 | /* |
---|
769 | 814 | * Increment the cursor to see if we have a right-adjacent record to our |
---|
.. | .. |
---|
777 | 822 | error = xfs_rmap_get_rec(cur, >rec, &have_gt); |
---|
778 | 823 | if (error) |
---|
779 | 824 | goto out_error; |
---|
780 | | - XFS_WANT_CORRUPTED_GOTO(mp, have_gt == 1, out_error); |
---|
781 | | - XFS_WANT_CORRUPTED_GOTO(mp, bno + len <= gtrec.rm_startblock, |
---|
782 | | - out_error); |
---|
| 825 | + if (XFS_IS_CORRUPT(mp, have_gt != 1)) { |
---|
| 826 | + error = -EFSCORRUPTED; |
---|
| 827 | + goto out_error; |
---|
| 828 | + } |
---|
| 829 | + if (XFS_IS_CORRUPT(mp, bno + len > gtrec.rm_startblock)) { |
---|
| 830 | + error = -EFSCORRUPTED; |
---|
| 831 | + goto out_error; |
---|
| 832 | + } |
---|
783 | 833 | trace_xfs_rmap_find_right_neighbor_result(cur->bc_mp, |
---|
784 | | - cur->bc_private.a.agno, gtrec.rm_startblock, |
---|
| 834 | + cur->bc_ag.agno, gtrec.rm_startblock, |
---|
785 | 835 | gtrec.rm_blockcount, gtrec.rm_owner, |
---|
786 | 836 | gtrec.rm_offset, gtrec.rm_flags); |
---|
787 | 837 | if (!xfs_rmap_is_mergeable(>rec, owner, flags)) |
---|
.. | .. |
---|
820 | 870 | * result: |rrrrrrrrrrrrrrrrrrrrrrrrrrrrr| |
---|
821 | 871 | */ |
---|
822 | 872 | ltrec.rm_blockcount += gtrec.rm_blockcount; |
---|
823 | | - trace_xfs_rmap_delete(mp, cur->bc_private.a.agno, |
---|
| 873 | + trace_xfs_rmap_delete(mp, cur->bc_ag.agno, |
---|
824 | 874 | gtrec.rm_startblock, |
---|
825 | 875 | gtrec.rm_blockcount, |
---|
826 | 876 | gtrec.rm_owner, |
---|
.. | .. |
---|
829 | 879 | error = xfs_btree_delete(cur, &i); |
---|
830 | 880 | if (error) |
---|
831 | 881 | goto out_error; |
---|
832 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, out_error); |
---|
| 882 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 883 | + error = -EFSCORRUPTED; |
---|
| 884 | + goto out_error; |
---|
| 885 | + } |
---|
833 | 886 | } |
---|
834 | 887 | |
---|
835 | 888 | /* point the cursor back to the left record and update */ |
---|
.. | .. |
---|
868 | 921 | cur->bc_rec.r.rm_owner = owner; |
---|
869 | 922 | cur->bc_rec.r.rm_offset = offset; |
---|
870 | 923 | cur->bc_rec.r.rm_flags = flags; |
---|
871 | | - trace_xfs_rmap_insert(mp, cur->bc_private.a.agno, bno, len, |
---|
| 924 | + trace_xfs_rmap_insert(mp, cur->bc_ag.agno, bno, len, |
---|
872 | 925 | owner, offset, flags); |
---|
873 | 926 | error = xfs_btree_insert(cur, &i); |
---|
874 | 927 | if (error) |
---|
875 | 928 | goto out_error; |
---|
876 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, out_error); |
---|
| 929 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 930 | + error = -EFSCORRUPTED; |
---|
| 931 | + goto out_error; |
---|
| 932 | + } |
---|
877 | 933 | } |
---|
878 | 934 | |
---|
879 | | - trace_xfs_rmap_map_done(mp, cur->bc_private.a.agno, bno, len, |
---|
| 935 | + trace_xfs_rmap_map_done(mp, cur->bc_ag.agno, bno, len, |
---|
880 | 936 | unwritten, oinfo); |
---|
881 | 937 | out_error: |
---|
882 | 938 | if (error) |
---|
883 | | - trace_xfs_rmap_map_error(mp, cur->bc_private.a.agno, |
---|
| 939 | + trace_xfs_rmap_map_error(mp, cur->bc_ag.agno, |
---|
884 | 940 | error, _RET_IP_); |
---|
885 | 941 | return error; |
---|
886 | 942 | } |
---|
.. | .. |
---|
890 | 946 | */ |
---|
891 | 947 | int |
---|
892 | 948 | xfs_rmap_alloc( |
---|
893 | | - struct xfs_trans *tp, |
---|
894 | | - struct xfs_buf *agbp, |
---|
895 | | - xfs_agnumber_t agno, |
---|
896 | | - xfs_agblock_t bno, |
---|
897 | | - xfs_extlen_t len, |
---|
898 | | - struct xfs_owner_info *oinfo) |
---|
| 949 | + struct xfs_trans *tp, |
---|
| 950 | + struct xfs_buf *agbp, |
---|
| 951 | + xfs_agnumber_t agno, |
---|
| 952 | + xfs_agblock_t bno, |
---|
| 953 | + xfs_extlen_t len, |
---|
| 954 | + const struct xfs_owner_info *oinfo) |
---|
899 | 955 | { |
---|
900 | | - struct xfs_mount *mp = tp->t_mountp; |
---|
901 | | - struct xfs_btree_cur *cur; |
---|
902 | | - int error; |
---|
| 956 | + struct xfs_mount *mp = tp->t_mountp; |
---|
| 957 | + struct xfs_btree_cur *cur; |
---|
| 958 | + int error; |
---|
903 | 959 | |
---|
904 | 960 | if (!xfs_sb_version_hasrmapbt(&mp->m_sb)) |
---|
905 | 961 | return 0; |
---|
.. | .. |
---|
929 | 985 | */ |
---|
930 | 986 | STATIC int |
---|
931 | 987 | xfs_rmap_convert( |
---|
932 | | - struct xfs_btree_cur *cur, |
---|
933 | | - xfs_agblock_t bno, |
---|
934 | | - xfs_extlen_t len, |
---|
935 | | - bool unwritten, |
---|
936 | | - struct xfs_owner_info *oinfo) |
---|
| 988 | + struct xfs_btree_cur *cur, |
---|
| 989 | + xfs_agblock_t bno, |
---|
| 990 | + xfs_extlen_t len, |
---|
| 991 | + bool unwritten, |
---|
| 992 | + const struct xfs_owner_info *oinfo) |
---|
937 | 993 | { |
---|
938 | | - struct xfs_mount *mp = cur->bc_mp; |
---|
939 | | - struct xfs_rmap_irec r[4]; /* neighbor extent entries */ |
---|
940 | | - /* left is 0, right is 1, prev is 2 */ |
---|
941 | | - /* new is 3 */ |
---|
| 994 | + struct xfs_mount *mp = cur->bc_mp; |
---|
| 995 | + struct xfs_rmap_irec r[4]; /* neighbor extent entries */ |
---|
| 996 | + /* left is 0, right is 1, */ |
---|
| 997 | + /* prev is 2, new is 3 */ |
---|
942 | 998 | uint64_t owner; |
---|
943 | 999 | uint64_t offset; |
---|
944 | 1000 | uint64_t new_endoff; |
---|
.. | .. |
---|
954 | 1010 | (flags & (XFS_RMAP_ATTR_FORK | XFS_RMAP_BMBT_BLOCK)))); |
---|
955 | 1011 | oldext = unwritten ? XFS_RMAP_UNWRITTEN : 0; |
---|
956 | 1012 | new_endoff = offset + len; |
---|
957 | | - trace_xfs_rmap_convert(mp, cur->bc_private.a.agno, bno, len, |
---|
| 1013 | + trace_xfs_rmap_convert(mp, cur->bc_ag.agno, bno, len, |
---|
958 | 1014 | unwritten, oinfo); |
---|
959 | 1015 | |
---|
960 | 1016 | /* |
---|
.. | .. |
---|
965 | 1021 | error = xfs_rmap_lookup_le(cur, bno, len, owner, offset, oldext, &i); |
---|
966 | 1022 | if (error) |
---|
967 | 1023 | goto done; |
---|
968 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); |
---|
| 1024 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 1025 | + error = -EFSCORRUPTED; |
---|
| 1026 | + goto done; |
---|
| 1027 | + } |
---|
969 | 1028 | |
---|
970 | 1029 | error = xfs_rmap_get_rec(cur, &PREV, &i); |
---|
971 | 1030 | if (error) |
---|
972 | 1031 | goto done; |
---|
973 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); |
---|
| 1032 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 1033 | + error = -EFSCORRUPTED; |
---|
| 1034 | + goto done; |
---|
| 1035 | + } |
---|
974 | 1036 | trace_xfs_rmap_lookup_le_range_result(cur->bc_mp, |
---|
975 | | - cur->bc_private.a.agno, PREV.rm_startblock, |
---|
| 1037 | + cur->bc_ag.agno, PREV.rm_startblock, |
---|
976 | 1038 | PREV.rm_blockcount, PREV.rm_owner, |
---|
977 | 1039 | PREV.rm_offset, PREV.rm_flags); |
---|
978 | 1040 | |
---|
.. | .. |
---|
1003 | 1065 | error = xfs_rmap_get_rec(cur, &LEFT, &i); |
---|
1004 | 1066 | if (error) |
---|
1005 | 1067 | goto done; |
---|
1006 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); |
---|
1007 | | - XFS_WANT_CORRUPTED_GOTO(mp, |
---|
1008 | | - LEFT.rm_startblock + LEFT.rm_blockcount <= bno, |
---|
1009 | | - done); |
---|
| 1068 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 1069 | + error = -EFSCORRUPTED; |
---|
| 1070 | + goto done; |
---|
| 1071 | + } |
---|
| 1072 | + if (XFS_IS_CORRUPT(mp, |
---|
| 1073 | + LEFT.rm_startblock + LEFT.rm_blockcount > |
---|
| 1074 | + bno)) { |
---|
| 1075 | + error = -EFSCORRUPTED; |
---|
| 1076 | + goto done; |
---|
| 1077 | + } |
---|
1010 | 1078 | trace_xfs_rmap_find_left_neighbor_result(cur->bc_mp, |
---|
1011 | | - cur->bc_private.a.agno, LEFT.rm_startblock, |
---|
| 1079 | + cur->bc_ag.agno, LEFT.rm_startblock, |
---|
1012 | 1080 | LEFT.rm_blockcount, LEFT.rm_owner, |
---|
1013 | 1081 | LEFT.rm_offset, LEFT.rm_flags); |
---|
1014 | 1082 | if (LEFT.rm_startblock + LEFT.rm_blockcount == bno && |
---|
.. | .. |
---|
1025 | 1093 | error = xfs_btree_increment(cur, 0, &i); |
---|
1026 | 1094 | if (error) |
---|
1027 | 1095 | goto done; |
---|
1028 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); |
---|
| 1096 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 1097 | + error = -EFSCORRUPTED; |
---|
| 1098 | + goto done; |
---|
| 1099 | + } |
---|
1029 | 1100 | error = xfs_btree_increment(cur, 0, &i); |
---|
1030 | 1101 | if (error) |
---|
1031 | 1102 | goto done; |
---|
.. | .. |
---|
1034 | 1105 | error = xfs_rmap_get_rec(cur, &RIGHT, &i); |
---|
1035 | 1106 | if (error) |
---|
1036 | 1107 | goto done; |
---|
1037 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); |
---|
1038 | | - XFS_WANT_CORRUPTED_GOTO(mp, bno + len <= RIGHT.rm_startblock, |
---|
1039 | | - done); |
---|
| 1108 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 1109 | + error = -EFSCORRUPTED; |
---|
| 1110 | + goto done; |
---|
| 1111 | + } |
---|
| 1112 | + if (XFS_IS_CORRUPT(mp, bno + len > RIGHT.rm_startblock)) { |
---|
| 1113 | + error = -EFSCORRUPTED; |
---|
| 1114 | + goto done; |
---|
| 1115 | + } |
---|
1040 | 1116 | trace_xfs_rmap_find_right_neighbor_result(cur->bc_mp, |
---|
1041 | | - cur->bc_private.a.agno, RIGHT.rm_startblock, |
---|
| 1117 | + cur->bc_ag.agno, RIGHT.rm_startblock, |
---|
1042 | 1118 | RIGHT.rm_blockcount, RIGHT.rm_owner, |
---|
1043 | 1119 | RIGHT.rm_offset, RIGHT.rm_flags); |
---|
1044 | 1120 | if (bno + len == RIGHT.rm_startblock && |
---|
.. | .. |
---|
1056 | 1132 | RIGHT.rm_blockcount > XFS_RMAP_LEN_MAX) |
---|
1057 | 1133 | state &= ~RMAP_RIGHT_CONTIG; |
---|
1058 | 1134 | |
---|
1059 | | - trace_xfs_rmap_convert_state(mp, cur->bc_private.a.agno, state, |
---|
| 1135 | + trace_xfs_rmap_convert_state(mp, cur->bc_ag.agno, state, |
---|
1060 | 1136 | _RET_IP_); |
---|
1061 | 1137 | |
---|
1062 | 1138 | /* reset the cursor back to PREV */ |
---|
1063 | 1139 | error = xfs_rmap_lookup_le(cur, bno, len, owner, offset, oldext, &i); |
---|
1064 | 1140 | if (error) |
---|
1065 | 1141 | goto done; |
---|
1066 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); |
---|
| 1142 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 1143 | + error = -EFSCORRUPTED; |
---|
| 1144 | + goto done; |
---|
| 1145 | + } |
---|
1067 | 1146 | |
---|
1068 | 1147 | /* |
---|
1069 | 1148 | * Switch out based on the FILLING and CONTIG state bits. |
---|
.. | .. |
---|
1079 | 1158 | error = xfs_btree_increment(cur, 0, &i); |
---|
1080 | 1159 | if (error) |
---|
1081 | 1160 | goto done; |
---|
1082 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); |
---|
1083 | | - trace_xfs_rmap_delete(mp, cur->bc_private.a.agno, |
---|
| 1161 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 1162 | + error = -EFSCORRUPTED; |
---|
| 1163 | + goto done; |
---|
| 1164 | + } |
---|
| 1165 | + trace_xfs_rmap_delete(mp, cur->bc_ag.agno, |
---|
1084 | 1166 | RIGHT.rm_startblock, RIGHT.rm_blockcount, |
---|
1085 | 1167 | RIGHT.rm_owner, RIGHT.rm_offset, |
---|
1086 | 1168 | RIGHT.rm_flags); |
---|
1087 | 1169 | error = xfs_btree_delete(cur, &i); |
---|
1088 | 1170 | if (error) |
---|
1089 | 1171 | goto done; |
---|
1090 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); |
---|
| 1172 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 1173 | + error = -EFSCORRUPTED; |
---|
| 1174 | + goto done; |
---|
| 1175 | + } |
---|
1091 | 1176 | error = xfs_btree_decrement(cur, 0, &i); |
---|
1092 | 1177 | if (error) |
---|
1093 | 1178 | goto done; |
---|
1094 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); |
---|
1095 | | - trace_xfs_rmap_delete(mp, cur->bc_private.a.agno, |
---|
| 1179 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 1180 | + error = -EFSCORRUPTED; |
---|
| 1181 | + goto done; |
---|
| 1182 | + } |
---|
| 1183 | + trace_xfs_rmap_delete(mp, cur->bc_ag.agno, |
---|
1096 | 1184 | PREV.rm_startblock, PREV.rm_blockcount, |
---|
1097 | 1185 | PREV.rm_owner, PREV.rm_offset, |
---|
1098 | 1186 | PREV.rm_flags); |
---|
1099 | 1187 | error = xfs_btree_delete(cur, &i); |
---|
1100 | 1188 | if (error) |
---|
1101 | 1189 | goto done; |
---|
1102 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); |
---|
| 1190 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 1191 | + error = -EFSCORRUPTED; |
---|
| 1192 | + goto done; |
---|
| 1193 | + } |
---|
1103 | 1194 | error = xfs_btree_decrement(cur, 0, &i); |
---|
1104 | 1195 | if (error) |
---|
1105 | 1196 | goto done; |
---|
1106 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); |
---|
| 1197 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 1198 | + error = -EFSCORRUPTED; |
---|
| 1199 | + goto done; |
---|
| 1200 | + } |
---|
1107 | 1201 | NEW = LEFT; |
---|
1108 | 1202 | NEW.rm_blockcount += PREV.rm_blockcount + RIGHT.rm_blockcount; |
---|
1109 | 1203 | error = xfs_rmap_update(cur, &NEW); |
---|
.. | .. |
---|
1116 | 1210 | * Setting all of a previous oldext extent to newext. |
---|
1117 | 1211 | * The left neighbor is contiguous, the right is not. |
---|
1118 | 1212 | */ |
---|
1119 | | - trace_xfs_rmap_delete(mp, cur->bc_private.a.agno, |
---|
| 1213 | + trace_xfs_rmap_delete(mp, cur->bc_ag.agno, |
---|
1120 | 1214 | PREV.rm_startblock, PREV.rm_blockcount, |
---|
1121 | 1215 | PREV.rm_owner, PREV.rm_offset, |
---|
1122 | 1216 | PREV.rm_flags); |
---|
1123 | 1217 | error = xfs_btree_delete(cur, &i); |
---|
1124 | 1218 | if (error) |
---|
1125 | 1219 | goto done; |
---|
1126 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); |
---|
| 1220 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 1221 | + error = -EFSCORRUPTED; |
---|
| 1222 | + goto done; |
---|
| 1223 | + } |
---|
1127 | 1224 | error = xfs_btree_decrement(cur, 0, &i); |
---|
1128 | 1225 | if (error) |
---|
1129 | 1226 | goto done; |
---|
1130 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); |
---|
| 1227 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 1228 | + error = -EFSCORRUPTED; |
---|
| 1229 | + goto done; |
---|
| 1230 | + } |
---|
1131 | 1231 | NEW = LEFT; |
---|
1132 | 1232 | NEW.rm_blockcount += PREV.rm_blockcount; |
---|
1133 | 1233 | error = xfs_rmap_update(cur, &NEW); |
---|
.. | .. |
---|
1143 | 1243 | error = xfs_btree_increment(cur, 0, &i); |
---|
1144 | 1244 | if (error) |
---|
1145 | 1245 | goto done; |
---|
1146 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); |
---|
1147 | | - trace_xfs_rmap_delete(mp, cur->bc_private.a.agno, |
---|
| 1246 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 1247 | + error = -EFSCORRUPTED; |
---|
| 1248 | + goto done; |
---|
| 1249 | + } |
---|
| 1250 | + trace_xfs_rmap_delete(mp, cur->bc_ag.agno, |
---|
1148 | 1251 | RIGHT.rm_startblock, RIGHT.rm_blockcount, |
---|
1149 | 1252 | RIGHT.rm_owner, RIGHT.rm_offset, |
---|
1150 | 1253 | RIGHT.rm_flags); |
---|
1151 | 1254 | error = xfs_btree_delete(cur, &i); |
---|
1152 | 1255 | if (error) |
---|
1153 | 1256 | goto done; |
---|
1154 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); |
---|
| 1257 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 1258 | + error = -EFSCORRUPTED; |
---|
| 1259 | + goto done; |
---|
| 1260 | + } |
---|
1155 | 1261 | error = xfs_btree_decrement(cur, 0, &i); |
---|
1156 | 1262 | if (error) |
---|
1157 | 1263 | goto done; |
---|
1158 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); |
---|
| 1264 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 1265 | + error = -EFSCORRUPTED; |
---|
| 1266 | + goto done; |
---|
| 1267 | + } |
---|
1159 | 1268 | NEW = PREV; |
---|
1160 | 1269 | NEW.rm_blockcount = len + RIGHT.rm_blockcount; |
---|
1161 | 1270 | NEW.rm_flags = newext; |
---|
.. | .. |
---|
1217 | 1326 | NEW.rm_blockcount = len; |
---|
1218 | 1327 | NEW.rm_flags = newext; |
---|
1219 | 1328 | cur->bc_rec.r = NEW; |
---|
1220 | | - trace_xfs_rmap_insert(mp, cur->bc_private.a.agno, bno, |
---|
| 1329 | + trace_xfs_rmap_insert(mp, cur->bc_ag.agno, bno, |
---|
1221 | 1330 | len, owner, offset, newext); |
---|
1222 | 1331 | error = xfs_btree_insert(cur, &i); |
---|
1223 | 1332 | if (error) |
---|
1224 | 1333 | goto done; |
---|
1225 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); |
---|
| 1334 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 1335 | + error = -EFSCORRUPTED; |
---|
| 1336 | + goto done; |
---|
| 1337 | + } |
---|
1226 | 1338 | break; |
---|
1227 | 1339 | |
---|
1228 | 1340 | case RMAP_RIGHT_FILLING | RMAP_RIGHT_CONTIG: |
---|
.. | .. |
---|
1261 | 1373 | oldext, &i); |
---|
1262 | 1374 | if (error) |
---|
1263 | 1375 | goto done; |
---|
1264 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 0, done); |
---|
| 1376 | + if (XFS_IS_CORRUPT(mp, i != 0)) { |
---|
| 1377 | + error = -EFSCORRUPTED; |
---|
| 1378 | + goto done; |
---|
| 1379 | + } |
---|
1265 | 1380 | NEW.rm_startblock = bno; |
---|
1266 | 1381 | NEW.rm_owner = owner; |
---|
1267 | 1382 | NEW.rm_offset = offset; |
---|
1268 | 1383 | NEW.rm_blockcount = len; |
---|
1269 | 1384 | NEW.rm_flags = newext; |
---|
1270 | 1385 | cur->bc_rec.r = NEW; |
---|
1271 | | - trace_xfs_rmap_insert(mp, cur->bc_private.a.agno, bno, |
---|
| 1386 | + trace_xfs_rmap_insert(mp, cur->bc_ag.agno, bno, |
---|
1272 | 1387 | len, owner, offset, newext); |
---|
1273 | 1388 | error = xfs_btree_insert(cur, &i); |
---|
1274 | 1389 | if (error) |
---|
1275 | 1390 | goto done; |
---|
1276 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); |
---|
| 1391 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 1392 | + error = -EFSCORRUPTED; |
---|
| 1393 | + goto done; |
---|
| 1394 | + } |
---|
1277 | 1395 | break; |
---|
1278 | 1396 | |
---|
1279 | 1397 | case 0: |
---|
.. | .. |
---|
1296 | 1414 | NEW = PREV; |
---|
1297 | 1415 | NEW.rm_blockcount = offset - PREV.rm_offset; |
---|
1298 | 1416 | cur->bc_rec.r = NEW; |
---|
1299 | | - trace_xfs_rmap_insert(mp, cur->bc_private.a.agno, |
---|
| 1417 | + trace_xfs_rmap_insert(mp, cur->bc_ag.agno, |
---|
1300 | 1418 | NEW.rm_startblock, NEW.rm_blockcount, |
---|
1301 | 1419 | NEW.rm_owner, NEW.rm_offset, |
---|
1302 | 1420 | NEW.rm_flags); |
---|
1303 | 1421 | error = xfs_btree_insert(cur, &i); |
---|
1304 | 1422 | if (error) |
---|
1305 | 1423 | goto done; |
---|
1306 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); |
---|
| 1424 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 1425 | + error = -EFSCORRUPTED; |
---|
| 1426 | + goto done; |
---|
| 1427 | + } |
---|
1307 | 1428 | /* |
---|
1308 | 1429 | * Reset the cursor to the position of the new extent |
---|
1309 | 1430 | * we are about to insert as we can't trust it after |
---|
.. | .. |
---|
1313 | 1434 | oldext, &i); |
---|
1314 | 1435 | if (error) |
---|
1315 | 1436 | goto done; |
---|
1316 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 0, done); |
---|
| 1437 | + if (XFS_IS_CORRUPT(mp, i != 0)) { |
---|
| 1438 | + error = -EFSCORRUPTED; |
---|
| 1439 | + goto done; |
---|
| 1440 | + } |
---|
1317 | 1441 | /* new middle extent - newext */ |
---|
1318 | 1442 | cur->bc_rec.r.rm_flags &= ~XFS_RMAP_UNWRITTEN; |
---|
1319 | 1443 | cur->bc_rec.r.rm_flags |= newext; |
---|
1320 | | - trace_xfs_rmap_insert(mp, cur->bc_private.a.agno, bno, len, |
---|
| 1444 | + trace_xfs_rmap_insert(mp, cur->bc_ag.agno, bno, len, |
---|
1321 | 1445 | owner, offset, newext); |
---|
1322 | 1446 | error = xfs_btree_insert(cur, &i); |
---|
1323 | 1447 | if (error) |
---|
1324 | 1448 | goto done; |
---|
1325 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); |
---|
| 1449 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 1450 | + error = -EFSCORRUPTED; |
---|
| 1451 | + goto done; |
---|
| 1452 | + } |
---|
1326 | 1453 | break; |
---|
1327 | 1454 | |
---|
1328 | 1455 | case RMAP_LEFT_FILLING | RMAP_LEFT_CONTIG | RMAP_RIGHT_CONTIG: |
---|
.. | .. |
---|
1338 | 1465 | ASSERT(0); |
---|
1339 | 1466 | } |
---|
1340 | 1467 | |
---|
1341 | | - trace_xfs_rmap_convert_done(mp, cur->bc_private.a.agno, bno, len, |
---|
| 1468 | + trace_xfs_rmap_convert_done(mp, cur->bc_ag.agno, bno, len, |
---|
1342 | 1469 | unwritten, oinfo); |
---|
1343 | 1470 | done: |
---|
1344 | 1471 | if (error) |
---|
1345 | 1472 | trace_xfs_rmap_convert_error(cur->bc_mp, |
---|
1346 | | - cur->bc_private.a.agno, error, _RET_IP_); |
---|
| 1473 | + cur->bc_ag.agno, error, _RET_IP_); |
---|
1347 | 1474 | return error; |
---|
1348 | 1475 | } |
---|
1349 | 1476 | |
---|
.. | .. |
---|
1354 | 1481 | */ |
---|
1355 | 1482 | STATIC int |
---|
1356 | 1483 | xfs_rmap_convert_shared( |
---|
1357 | | - struct xfs_btree_cur *cur, |
---|
1358 | | - xfs_agblock_t bno, |
---|
1359 | | - xfs_extlen_t len, |
---|
1360 | | - bool unwritten, |
---|
1361 | | - struct xfs_owner_info *oinfo) |
---|
| 1484 | + struct xfs_btree_cur *cur, |
---|
| 1485 | + xfs_agblock_t bno, |
---|
| 1486 | + xfs_extlen_t len, |
---|
| 1487 | + bool unwritten, |
---|
| 1488 | + const struct xfs_owner_info *oinfo) |
---|
1362 | 1489 | { |
---|
1363 | | - struct xfs_mount *mp = cur->bc_mp; |
---|
1364 | | - struct xfs_rmap_irec r[4]; /* neighbor extent entries */ |
---|
1365 | | - /* left is 0, right is 1, prev is 2 */ |
---|
1366 | | - /* new is 3 */ |
---|
| 1490 | + struct xfs_mount *mp = cur->bc_mp; |
---|
| 1491 | + struct xfs_rmap_irec r[4]; /* neighbor extent entries */ |
---|
| 1492 | + /* left is 0, right is 1, */ |
---|
| 1493 | + /* prev is 2, new is 3 */ |
---|
1367 | 1494 | uint64_t owner; |
---|
1368 | 1495 | uint64_t offset; |
---|
1369 | 1496 | uint64_t new_endoff; |
---|
.. | .. |
---|
1379 | 1506 | (flags & (XFS_RMAP_ATTR_FORK | XFS_RMAP_BMBT_BLOCK)))); |
---|
1380 | 1507 | oldext = unwritten ? XFS_RMAP_UNWRITTEN : 0; |
---|
1381 | 1508 | new_endoff = offset + len; |
---|
1382 | | - trace_xfs_rmap_convert(mp, cur->bc_private.a.agno, bno, len, |
---|
| 1509 | + trace_xfs_rmap_convert(mp, cur->bc_ag.agno, bno, len, |
---|
1383 | 1510 | unwritten, oinfo); |
---|
1384 | 1511 | |
---|
1385 | 1512 | /* |
---|
.. | .. |
---|
1391 | 1518 | &PREV, &i); |
---|
1392 | 1519 | if (error) |
---|
1393 | 1520 | goto done; |
---|
1394 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); |
---|
| 1521 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 1522 | + error = -EFSCORRUPTED; |
---|
| 1523 | + goto done; |
---|
| 1524 | + } |
---|
1395 | 1525 | |
---|
1396 | 1526 | ASSERT(PREV.rm_offset <= offset); |
---|
1397 | 1527 | ASSERT(PREV.rm_offset + PREV.rm_blockcount >= new_endoff); |
---|
.. | .. |
---|
1414 | 1544 | goto done; |
---|
1415 | 1545 | if (i) { |
---|
1416 | 1546 | state |= RMAP_LEFT_VALID; |
---|
1417 | | - XFS_WANT_CORRUPTED_GOTO(mp, |
---|
1418 | | - LEFT.rm_startblock + LEFT.rm_blockcount <= bno, |
---|
1419 | | - done); |
---|
| 1547 | + if (XFS_IS_CORRUPT(mp, |
---|
| 1548 | + LEFT.rm_startblock + LEFT.rm_blockcount > |
---|
| 1549 | + bno)) { |
---|
| 1550 | + error = -EFSCORRUPTED; |
---|
| 1551 | + goto done; |
---|
| 1552 | + } |
---|
1420 | 1553 | if (xfs_rmap_is_mergeable(&LEFT, owner, newext)) |
---|
1421 | 1554 | state |= RMAP_LEFT_CONTIG; |
---|
1422 | 1555 | } |
---|
.. | .. |
---|
1431 | 1564 | error = xfs_rmap_get_rec(cur, &RIGHT, &i); |
---|
1432 | 1565 | if (error) |
---|
1433 | 1566 | goto done; |
---|
1434 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); |
---|
1435 | | - XFS_WANT_CORRUPTED_GOTO(mp, bno + len <= RIGHT.rm_startblock, |
---|
1436 | | - done); |
---|
| 1567 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 1568 | + error = -EFSCORRUPTED; |
---|
| 1569 | + goto done; |
---|
| 1570 | + } |
---|
| 1571 | + if (XFS_IS_CORRUPT(mp, bno + len > RIGHT.rm_startblock)) { |
---|
| 1572 | + error = -EFSCORRUPTED; |
---|
| 1573 | + goto done; |
---|
| 1574 | + } |
---|
1437 | 1575 | trace_xfs_rmap_find_right_neighbor_result(cur->bc_mp, |
---|
1438 | | - cur->bc_private.a.agno, RIGHT.rm_startblock, |
---|
| 1576 | + cur->bc_ag.agno, RIGHT.rm_startblock, |
---|
1439 | 1577 | RIGHT.rm_blockcount, RIGHT.rm_owner, |
---|
1440 | 1578 | RIGHT.rm_offset, RIGHT.rm_flags); |
---|
1441 | 1579 | if (xfs_rmap_is_mergeable(&RIGHT, owner, newext)) |
---|
.. | .. |
---|
1451 | 1589 | RIGHT.rm_blockcount > XFS_RMAP_LEN_MAX) |
---|
1452 | 1590 | state &= ~RMAP_RIGHT_CONTIG; |
---|
1453 | 1591 | |
---|
1454 | | - trace_xfs_rmap_convert_state(mp, cur->bc_private.a.agno, state, |
---|
| 1592 | + trace_xfs_rmap_convert_state(mp, cur->bc_ag.agno, state, |
---|
1455 | 1593 | _RET_IP_); |
---|
1456 | 1594 | /* |
---|
1457 | 1595 | * Switch out based on the FILLING and CONTIG state bits. |
---|
.. | .. |
---|
1480 | 1618 | NEW.rm_offset, NEW.rm_flags, &i); |
---|
1481 | 1619 | if (error) |
---|
1482 | 1620 | goto done; |
---|
1483 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); |
---|
| 1621 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 1622 | + error = -EFSCORRUPTED; |
---|
| 1623 | + goto done; |
---|
| 1624 | + } |
---|
1484 | 1625 | NEW.rm_blockcount += PREV.rm_blockcount + RIGHT.rm_blockcount; |
---|
1485 | 1626 | error = xfs_rmap_update(cur, &NEW); |
---|
1486 | 1627 | if (error) |
---|
.. | .. |
---|
1503 | 1644 | NEW.rm_offset, NEW.rm_flags, &i); |
---|
1504 | 1645 | if (error) |
---|
1505 | 1646 | goto done; |
---|
1506 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); |
---|
| 1647 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 1648 | + error = -EFSCORRUPTED; |
---|
| 1649 | + goto done; |
---|
| 1650 | + } |
---|
1507 | 1651 | NEW.rm_blockcount += PREV.rm_blockcount; |
---|
1508 | 1652 | error = xfs_rmap_update(cur, &NEW); |
---|
1509 | 1653 | if (error) |
---|
.. | .. |
---|
1526 | 1670 | NEW.rm_offset, NEW.rm_flags, &i); |
---|
1527 | 1671 | if (error) |
---|
1528 | 1672 | goto done; |
---|
1529 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); |
---|
| 1673 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 1674 | + error = -EFSCORRUPTED; |
---|
| 1675 | + goto done; |
---|
| 1676 | + } |
---|
1530 | 1677 | NEW.rm_blockcount += RIGHT.rm_blockcount; |
---|
1531 | 1678 | NEW.rm_flags = RIGHT.rm_flags; |
---|
1532 | 1679 | error = xfs_rmap_update(cur, &NEW); |
---|
.. | .. |
---|
1546 | 1693 | NEW.rm_offset, NEW.rm_flags, &i); |
---|
1547 | 1694 | if (error) |
---|
1548 | 1695 | goto done; |
---|
1549 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); |
---|
| 1696 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 1697 | + error = -EFSCORRUPTED; |
---|
| 1698 | + goto done; |
---|
| 1699 | + } |
---|
1550 | 1700 | NEW.rm_flags = newext; |
---|
1551 | 1701 | error = xfs_rmap_update(cur, &NEW); |
---|
1552 | 1702 | if (error) |
---|
.. | .. |
---|
1578 | 1728 | NEW.rm_offset, NEW.rm_flags, &i); |
---|
1579 | 1729 | if (error) |
---|
1580 | 1730 | goto done; |
---|
1581 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); |
---|
| 1731 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 1732 | + error = -EFSCORRUPTED; |
---|
| 1733 | + goto done; |
---|
| 1734 | + } |
---|
1582 | 1735 | NEW.rm_blockcount += len; |
---|
1583 | 1736 | error = xfs_rmap_update(cur, &NEW); |
---|
1584 | 1737 | if (error) |
---|
.. | .. |
---|
1620 | 1773 | NEW.rm_offset, NEW.rm_flags, &i); |
---|
1621 | 1774 | if (error) |
---|
1622 | 1775 | goto done; |
---|
1623 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); |
---|
| 1776 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 1777 | + error = -EFSCORRUPTED; |
---|
| 1778 | + goto done; |
---|
| 1779 | + } |
---|
1624 | 1780 | NEW.rm_blockcount = offset - NEW.rm_offset; |
---|
1625 | 1781 | error = xfs_rmap_update(cur, &NEW); |
---|
1626 | 1782 | if (error) |
---|
.. | .. |
---|
1652 | 1808 | NEW.rm_offset, NEW.rm_flags, &i); |
---|
1653 | 1809 | if (error) |
---|
1654 | 1810 | goto done; |
---|
1655 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); |
---|
| 1811 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 1812 | + error = -EFSCORRUPTED; |
---|
| 1813 | + goto done; |
---|
| 1814 | + } |
---|
1656 | 1815 | NEW.rm_blockcount -= len; |
---|
1657 | 1816 | error = xfs_rmap_update(cur, &NEW); |
---|
1658 | 1817 | if (error) |
---|
.. | .. |
---|
1687 | 1846 | NEW.rm_offset, NEW.rm_flags, &i); |
---|
1688 | 1847 | if (error) |
---|
1689 | 1848 | goto done; |
---|
1690 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done); |
---|
| 1849 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 1850 | + error = -EFSCORRUPTED; |
---|
| 1851 | + goto done; |
---|
| 1852 | + } |
---|
1691 | 1853 | NEW.rm_blockcount = offset - NEW.rm_offset; |
---|
1692 | 1854 | error = xfs_rmap_update(cur, &NEW); |
---|
1693 | 1855 | if (error) |
---|
.. | .. |
---|
1718 | 1880 | ASSERT(0); |
---|
1719 | 1881 | } |
---|
1720 | 1882 | |
---|
1721 | | - trace_xfs_rmap_convert_done(mp, cur->bc_private.a.agno, bno, len, |
---|
| 1883 | + trace_xfs_rmap_convert_done(mp, cur->bc_ag.agno, bno, len, |
---|
1722 | 1884 | unwritten, oinfo); |
---|
1723 | 1885 | done: |
---|
1724 | 1886 | if (error) |
---|
1725 | 1887 | trace_xfs_rmap_convert_error(cur->bc_mp, |
---|
1726 | | - cur->bc_private.a.agno, error, _RET_IP_); |
---|
| 1888 | + cur->bc_ag.agno, error, _RET_IP_); |
---|
1727 | 1889 | return error; |
---|
1728 | 1890 | } |
---|
1729 | 1891 | |
---|
.. | .. |
---|
1743 | 1905 | */ |
---|
1744 | 1906 | STATIC int |
---|
1745 | 1907 | xfs_rmap_unmap_shared( |
---|
1746 | | - struct xfs_btree_cur *cur, |
---|
1747 | | - xfs_agblock_t bno, |
---|
1748 | | - xfs_extlen_t len, |
---|
1749 | | - bool unwritten, |
---|
1750 | | - struct xfs_owner_info *oinfo) |
---|
| 1908 | + struct xfs_btree_cur *cur, |
---|
| 1909 | + xfs_agblock_t bno, |
---|
| 1910 | + xfs_extlen_t len, |
---|
| 1911 | + bool unwritten, |
---|
| 1912 | + const struct xfs_owner_info *oinfo) |
---|
1751 | 1913 | { |
---|
1752 | | - struct xfs_mount *mp = cur->bc_mp; |
---|
1753 | | - struct xfs_rmap_irec ltrec; |
---|
1754 | | - uint64_t ltoff; |
---|
1755 | | - int error = 0; |
---|
1756 | | - int i; |
---|
1757 | | - uint64_t owner; |
---|
1758 | | - uint64_t offset; |
---|
1759 | | - unsigned int flags; |
---|
| 1914 | + struct xfs_mount *mp = cur->bc_mp; |
---|
| 1915 | + struct xfs_rmap_irec ltrec; |
---|
| 1916 | + uint64_t ltoff; |
---|
| 1917 | + int error = 0; |
---|
| 1918 | + int i; |
---|
| 1919 | + uint64_t owner; |
---|
| 1920 | + uint64_t offset; |
---|
| 1921 | + unsigned int flags; |
---|
1760 | 1922 | |
---|
1761 | 1923 | xfs_owner_info_unpack(oinfo, &owner, &offset, &flags); |
---|
1762 | 1924 | if (unwritten) |
---|
1763 | 1925 | flags |= XFS_RMAP_UNWRITTEN; |
---|
1764 | | - trace_xfs_rmap_unmap(mp, cur->bc_private.a.agno, bno, len, |
---|
| 1926 | + trace_xfs_rmap_unmap(mp, cur->bc_ag.agno, bno, len, |
---|
1765 | 1927 | unwritten, oinfo); |
---|
1766 | 1928 | |
---|
1767 | 1929 | /* |
---|
.. | .. |
---|
1773 | 1935 | <rec, &i); |
---|
1774 | 1936 | if (error) |
---|
1775 | 1937 | goto out_error; |
---|
1776 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, out_error); |
---|
| 1938 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 1939 | + error = -EFSCORRUPTED; |
---|
| 1940 | + goto out_error; |
---|
| 1941 | + } |
---|
1777 | 1942 | ltoff = ltrec.rm_offset; |
---|
1778 | 1943 | |
---|
1779 | 1944 | /* Make sure the extent we found covers the entire freeing range. */ |
---|
1780 | | - XFS_WANT_CORRUPTED_GOTO(mp, ltrec.rm_startblock <= bno && |
---|
1781 | | - ltrec.rm_startblock + ltrec.rm_blockcount >= |
---|
1782 | | - bno + len, out_error); |
---|
| 1945 | + if (XFS_IS_CORRUPT(mp, |
---|
| 1946 | + ltrec.rm_startblock > bno || |
---|
| 1947 | + ltrec.rm_startblock + ltrec.rm_blockcount < |
---|
| 1948 | + bno + len)) { |
---|
| 1949 | + error = -EFSCORRUPTED; |
---|
| 1950 | + goto out_error; |
---|
| 1951 | + } |
---|
1783 | 1952 | |
---|
1784 | 1953 | /* Make sure the owner matches what we expect to find in the tree. */ |
---|
1785 | | - XFS_WANT_CORRUPTED_GOTO(mp, owner == ltrec.rm_owner, out_error); |
---|
| 1954 | + if (XFS_IS_CORRUPT(mp, owner != ltrec.rm_owner)) { |
---|
| 1955 | + error = -EFSCORRUPTED; |
---|
| 1956 | + goto out_error; |
---|
| 1957 | + } |
---|
1786 | 1958 | |
---|
1787 | 1959 | /* Make sure the unwritten flag matches. */ |
---|
1788 | | - XFS_WANT_CORRUPTED_GOTO(mp, (flags & XFS_RMAP_UNWRITTEN) == |
---|
1789 | | - (ltrec.rm_flags & XFS_RMAP_UNWRITTEN), out_error); |
---|
| 1960 | + if (XFS_IS_CORRUPT(mp, |
---|
| 1961 | + (flags & XFS_RMAP_UNWRITTEN) != |
---|
| 1962 | + (ltrec.rm_flags & XFS_RMAP_UNWRITTEN))) { |
---|
| 1963 | + error = -EFSCORRUPTED; |
---|
| 1964 | + goto out_error; |
---|
| 1965 | + } |
---|
1790 | 1966 | |
---|
1791 | 1967 | /* Check the offset. */ |
---|
1792 | | - XFS_WANT_CORRUPTED_GOTO(mp, ltrec.rm_offset <= offset, out_error); |
---|
1793 | | - XFS_WANT_CORRUPTED_GOTO(mp, offset <= ltoff + ltrec.rm_blockcount, |
---|
1794 | | - out_error); |
---|
| 1968 | + if (XFS_IS_CORRUPT(mp, ltrec.rm_offset > offset)) { |
---|
| 1969 | + error = -EFSCORRUPTED; |
---|
| 1970 | + goto out_error; |
---|
| 1971 | + } |
---|
| 1972 | + if (XFS_IS_CORRUPT(mp, offset > ltoff + ltrec.rm_blockcount)) { |
---|
| 1973 | + error = -EFSCORRUPTED; |
---|
| 1974 | + goto out_error; |
---|
| 1975 | + } |
---|
1795 | 1976 | |
---|
1796 | 1977 | if (ltrec.rm_startblock == bno && ltrec.rm_blockcount == len) { |
---|
1797 | 1978 | /* Exact match, simply remove the record from rmap tree. */ |
---|
.. | .. |
---|
1844 | 2025 | ltrec.rm_offset, ltrec.rm_flags, &i); |
---|
1845 | 2026 | if (error) |
---|
1846 | 2027 | goto out_error; |
---|
1847 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, out_error); |
---|
| 2028 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 2029 | + error = -EFSCORRUPTED; |
---|
| 2030 | + goto out_error; |
---|
| 2031 | + } |
---|
1848 | 2032 | ltrec.rm_blockcount -= len; |
---|
1849 | 2033 | error = xfs_rmap_update(cur, <rec); |
---|
1850 | 2034 | if (error) |
---|
.. | .. |
---|
1870 | 2054 | ltrec.rm_offset, ltrec.rm_flags, &i); |
---|
1871 | 2055 | if (error) |
---|
1872 | 2056 | goto out_error; |
---|
1873 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, out_error); |
---|
| 2057 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 2058 | + error = -EFSCORRUPTED; |
---|
| 2059 | + goto out_error; |
---|
| 2060 | + } |
---|
1874 | 2061 | ltrec.rm_blockcount = bno - ltrec.rm_startblock; |
---|
1875 | 2062 | error = xfs_rmap_update(cur, <rec); |
---|
1876 | 2063 | if (error) |
---|
.. | .. |
---|
1885 | 2072 | goto out_error; |
---|
1886 | 2073 | } |
---|
1887 | 2074 | |
---|
1888 | | - trace_xfs_rmap_unmap_done(mp, cur->bc_private.a.agno, bno, len, |
---|
| 2075 | + trace_xfs_rmap_unmap_done(mp, cur->bc_ag.agno, bno, len, |
---|
1889 | 2076 | unwritten, oinfo); |
---|
1890 | 2077 | out_error: |
---|
1891 | 2078 | if (error) |
---|
1892 | 2079 | trace_xfs_rmap_unmap_error(cur->bc_mp, |
---|
1893 | | - cur->bc_private.a.agno, error, _RET_IP_); |
---|
| 2080 | + cur->bc_ag.agno, error, _RET_IP_); |
---|
1894 | 2081 | return error; |
---|
1895 | 2082 | } |
---|
1896 | 2083 | |
---|
.. | .. |
---|
1905 | 2092 | */ |
---|
1906 | 2093 | STATIC int |
---|
1907 | 2094 | xfs_rmap_map_shared( |
---|
1908 | | - struct xfs_btree_cur *cur, |
---|
1909 | | - xfs_agblock_t bno, |
---|
1910 | | - xfs_extlen_t len, |
---|
1911 | | - bool unwritten, |
---|
1912 | | - struct xfs_owner_info *oinfo) |
---|
| 2095 | + struct xfs_btree_cur *cur, |
---|
| 2096 | + xfs_agblock_t bno, |
---|
| 2097 | + xfs_extlen_t len, |
---|
| 2098 | + bool unwritten, |
---|
| 2099 | + const struct xfs_owner_info *oinfo) |
---|
1913 | 2100 | { |
---|
1914 | | - struct xfs_mount *mp = cur->bc_mp; |
---|
1915 | | - struct xfs_rmap_irec ltrec; |
---|
1916 | | - struct xfs_rmap_irec gtrec; |
---|
1917 | | - int have_gt; |
---|
1918 | | - int have_lt; |
---|
1919 | | - int error = 0; |
---|
1920 | | - int i; |
---|
1921 | | - uint64_t owner; |
---|
1922 | | - uint64_t offset; |
---|
1923 | | - unsigned int flags = 0; |
---|
| 2101 | + struct xfs_mount *mp = cur->bc_mp; |
---|
| 2102 | + struct xfs_rmap_irec ltrec; |
---|
| 2103 | + struct xfs_rmap_irec gtrec; |
---|
| 2104 | + int have_gt; |
---|
| 2105 | + int have_lt; |
---|
| 2106 | + int error = 0; |
---|
| 2107 | + int i; |
---|
| 2108 | + uint64_t owner; |
---|
| 2109 | + uint64_t offset; |
---|
| 2110 | + unsigned int flags = 0; |
---|
1924 | 2111 | |
---|
1925 | 2112 | xfs_owner_info_unpack(oinfo, &owner, &offset, &flags); |
---|
1926 | 2113 | if (unwritten) |
---|
1927 | 2114 | flags |= XFS_RMAP_UNWRITTEN; |
---|
1928 | | - trace_xfs_rmap_map(mp, cur->bc_private.a.agno, bno, len, |
---|
| 2115 | + trace_xfs_rmap_map(mp, cur->bc_ag.agno, bno, len, |
---|
1929 | 2116 | unwritten, oinfo); |
---|
1930 | 2117 | |
---|
1931 | 2118 | /* Is there a left record that abuts our range? */ |
---|
.. | .. |
---|
1946 | 2133 | error = xfs_rmap_get_rec(cur, >rec, &have_gt); |
---|
1947 | 2134 | if (error) |
---|
1948 | 2135 | goto out_error; |
---|
1949 | | - XFS_WANT_CORRUPTED_GOTO(mp, have_gt == 1, out_error); |
---|
| 2136 | + if (XFS_IS_CORRUPT(mp, have_gt != 1)) { |
---|
| 2137 | + error = -EFSCORRUPTED; |
---|
| 2138 | + goto out_error; |
---|
| 2139 | + } |
---|
1950 | 2140 | trace_xfs_rmap_find_right_neighbor_result(cur->bc_mp, |
---|
1951 | | - cur->bc_private.a.agno, gtrec.rm_startblock, |
---|
| 2141 | + cur->bc_ag.agno, gtrec.rm_startblock, |
---|
1952 | 2142 | gtrec.rm_blockcount, gtrec.rm_owner, |
---|
1953 | 2143 | gtrec.rm_offset, gtrec.rm_flags); |
---|
1954 | 2144 | |
---|
.. | .. |
---|
1995 | 2185 | ltrec.rm_offset, ltrec.rm_flags, &i); |
---|
1996 | 2186 | if (error) |
---|
1997 | 2187 | goto out_error; |
---|
1998 | | - XFS_WANT_CORRUPTED_GOTO(mp, i == 1, out_error); |
---|
| 2188 | + if (XFS_IS_CORRUPT(mp, i != 1)) { |
---|
| 2189 | + error = -EFSCORRUPTED; |
---|
| 2190 | + goto out_error; |
---|
| 2191 | + } |
---|
1999 | 2192 | |
---|
2000 | 2193 | error = xfs_rmap_update(cur, <rec); |
---|
2001 | 2194 | if (error) |
---|
.. | .. |
---|
2038 | 2231 | goto out_error; |
---|
2039 | 2232 | } |
---|
2040 | 2233 | |
---|
2041 | | - trace_xfs_rmap_map_done(mp, cur->bc_private.a.agno, bno, len, |
---|
| 2234 | + trace_xfs_rmap_map_done(mp, cur->bc_ag.agno, bno, len, |
---|
2042 | 2235 | unwritten, oinfo); |
---|
2043 | 2236 | out_error: |
---|
2044 | 2237 | if (error) |
---|
2045 | 2238 | trace_xfs_rmap_map_error(cur->bc_mp, |
---|
2046 | | - cur->bc_private.a.agno, error, _RET_IP_); |
---|
| 2239 | + cur->bc_ag.agno, error, _RET_IP_); |
---|
2047 | 2240 | return error; |
---|
2048 | 2241 | } |
---|
2049 | 2242 | |
---|
.. | .. |
---|
2143 | 2336 | |
---|
2144 | 2337 | if (rcur == NULL) |
---|
2145 | 2338 | return; |
---|
2146 | | - agbp = rcur->bc_private.a.agbp; |
---|
| 2339 | + agbp = rcur->bc_ag.agbp; |
---|
2147 | 2340 | xfs_btree_del_cursor(rcur, error); |
---|
2148 | 2341 | if (error) |
---|
2149 | 2342 | xfs_trans_brelse(tp, agbp); |
---|
.. | .. |
---|
2193 | 2386 | * the startblock, get one now. |
---|
2194 | 2387 | */ |
---|
2195 | 2388 | rcur = *pcur; |
---|
2196 | | - if (rcur != NULL && rcur->bc_private.a.agno != agno) { |
---|
| 2389 | + if (rcur != NULL && rcur->bc_ag.agno != agno) { |
---|
2197 | 2390 | xfs_rmap_finish_one_cleanup(tp, rcur, 0); |
---|
2198 | 2391 | rcur = NULL; |
---|
2199 | 2392 | *pcur = NULL; |
---|
.. | .. |
---|
2207 | 2400 | error = xfs_free_extent_fix_freelist(tp, agno, &agbp); |
---|
2208 | 2401 | if (error) |
---|
2209 | 2402 | return error; |
---|
2210 | | - if (!agbp) |
---|
| 2403 | + if (XFS_IS_CORRUPT(tp->t_mountp, !agbp)) |
---|
2211 | 2404 | return -EFSCORRUPTED; |
---|
2212 | 2405 | |
---|
2213 | 2406 | rcur = xfs_rmapbt_init_cursor(mp, tp, agbp, agno); |
---|
.. | .. |
---|
2275 | 2468 | * Record a rmap intent; the list is kept sorted first by AG and then by |
---|
2276 | 2469 | * increasing age. |
---|
2277 | 2470 | */ |
---|
2278 | | -static int |
---|
| 2471 | +static void |
---|
2279 | 2472 | __xfs_rmap_add( |
---|
2280 | 2473 | struct xfs_trans *tp, |
---|
2281 | 2474 | enum xfs_rmap_intent_type type, |
---|
.. | .. |
---|
2294 | 2487 | bmap->br_blockcount, |
---|
2295 | 2488 | bmap->br_state); |
---|
2296 | 2489 | |
---|
2297 | | - ri = kmem_alloc(sizeof(struct xfs_rmap_intent), KM_SLEEP | KM_NOFS); |
---|
| 2490 | + ri = kmem_alloc(sizeof(struct xfs_rmap_intent), KM_NOFS); |
---|
2298 | 2491 | INIT_LIST_HEAD(&ri->ri_list); |
---|
2299 | 2492 | ri->ri_type = type; |
---|
2300 | 2493 | ri->ri_owner = owner; |
---|
.. | .. |
---|
2302 | 2495 | ri->ri_bmap = *bmap; |
---|
2303 | 2496 | |
---|
2304 | 2497 | xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_RMAP, &ri->ri_list); |
---|
2305 | | - return 0; |
---|
2306 | 2498 | } |
---|
2307 | 2499 | |
---|
2308 | 2500 | /* Map an extent into a file. */ |
---|
2309 | | -int |
---|
| 2501 | +void |
---|
2310 | 2502 | xfs_rmap_map_extent( |
---|
2311 | 2503 | struct xfs_trans *tp, |
---|
2312 | 2504 | struct xfs_inode *ip, |
---|
2313 | 2505 | int whichfork, |
---|
2314 | 2506 | struct xfs_bmbt_irec *PREV) |
---|
2315 | 2507 | { |
---|
2316 | | - if (!xfs_rmap_update_is_needed(tp->t_mountp, whichfork)) |
---|
2317 | | - return 0; |
---|
| 2508 | + enum xfs_rmap_intent_type type = XFS_RMAP_MAP; |
---|
2318 | 2509 | |
---|
2319 | | - return __xfs_rmap_add(tp, xfs_is_reflink_inode(ip) ? |
---|
2320 | | - XFS_RMAP_MAP_SHARED : XFS_RMAP_MAP, ip->i_ino, |
---|
2321 | | - whichfork, PREV); |
---|
| 2510 | + if (!xfs_rmap_update_is_needed(tp->t_mountp, whichfork)) |
---|
| 2511 | + return; |
---|
| 2512 | + |
---|
| 2513 | + if (whichfork != XFS_ATTR_FORK && xfs_is_reflink_inode(ip)) |
---|
| 2514 | + type = XFS_RMAP_MAP_SHARED; |
---|
| 2515 | + |
---|
| 2516 | + __xfs_rmap_add(tp, type, ip->i_ino, whichfork, PREV); |
---|
2322 | 2517 | } |
---|
2323 | 2518 | |
---|
2324 | 2519 | /* Unmap an extent out of a file. */ |
---|
2325 | | -int |
---|
| 2520 | +void |
---|
2326 | 2521 | xfs_rmap_unmap_extent( |
---|
2327 | 2522 | struct xfs_trans *tp, |
---|
2328 | 2523 | struct xfs_inode *ip, |
---|
2329 | 2524 | int whichfork, |
---|
2330 | 2525 | struct xfs_bmbt_irec *PREV) |
---|
2331 | 2526 | { |
---|
2332 | | - if (!xfs_rmap_update_is_needed(tp->t_mountp, whichfork)) |
---|
2333 | | - return 0; |
---|
| 2527 | + enum xfs_rmap_intent_type type = XFS_RMAP_UNMAP; |
---|
2334 | 2528 | |
---|
2335 | | - return __xfs_rmap_add(tp, xfs_is_reflink_inode(ip) ? |
---|
2336 | | - XFS_RMAP_UNMAP_SHARED : XFS_RMAP_UNMAP, ip->i_ino, |
---|
2337 | | - whichfork, PREV); |
---|
| 2529 | + if (!xfs_rmap_update_is_needed(tp->t_mountp, whichfork)) |
---|
| 2530 | + return; |
---|
| 2531 | + |
---|
| 2532 | + if (whichfork != XFS_ATTR_FORK && xfs_is_reflink_inode(ip)) |
---|
| 2533 | + type = XFS_RMAP_UNMAP_SHARED; |
---|
| 2534 | + |
---|
| 2535 | + __xfs_rmap_add(tp, type, ip->i_ino, whichfork, PREV); |
---|
2338 | 2536 | } |
---|
2339 | 2537 | |
---|
2340 | 2538 | /* |
---|
.. | .. |
---|
2343 | 2541 | * Note that tp can be NULL here as no transaction is used for COW fork |
---|
2344 | 2542 | * unwritten conversion. |
---|
2345 | 2543 | */ |
---|
2346 | | -int |
---|
| 2544 | +void |
---|
2347 | 2545 | xfs_rmap_convert_extent( |
---|
2348 | 2546 | struct xfs_mount *mp, |
---|
2349 | 2547 | struct xfs_trans *tp, |
---|
.. | .. |
---|
2351 | 2549 | int whichfork, |
---|
2352 | 2550 | struct xfs_bmbt_irec *PREV) |
---|
2353 | 2551 | { |
---|
2354 | | - if (!xfs_rmap_update_is_needed(mp, whichfork)) |
---|
2355 | | - return 0; |
---|
| 2552 | + enum xfs_rmap_intent_type type = XFS_RMAP_CONVERT; |
---|
2356 | 2553 | |
---|
2357 | | - return __xfs_rmap_add(tp, xfs_is_reflink_inode(ip) ? |
---|
2358 | | - XFS_RMAP_CONVERT_SHARED : XFS_RMAP_CONVERT, ip->i_ino, |
---|
2359 | | - whichfork, PREV); |
---|
| 2554 | + if (!xfs_rmap_update_is_needed(mp, whichfork)) |
---|
| 2555 | + return; |
---|
| 2556 | + |
---|
| 2557 | + if (whichfork != XFS_ATTR_FORK && xfs_is_reflink_inode(ip)) |
---|
| 2558 | + type = XFS_RMAP_CONVERT_SHARED; |
---|
| 2559 | + |
---|
| 2560 | + __xfs_rmap_add(tp, type, ip->i_ino, whichfork, PREV); |
---|
2360 | 2561 | } |
---|
2361 | 2562 | |
---|
2362 | 2563 | /* Schedule the creation of an rmap for non-file data. */ |
---|
2363 | | -int |
---|
| 2564 | +void |
---|
2364 | 2565 | xfs_rmap_alloc_extent( |
---|
2365 | 2566 | struct xfs_trans *tp, |
---|
2366 | 2567 | xfs_agnumber_t agno, |
---|
.. | .. |
---|
2371 | 2572 | struct xfs_bmbt_irec bmap; |
---|
2372 | 2573 | |
---|
2373 | 2574 | if (!xfs_rmap_update_is_needed(tp->t_mountp, XFS_DATA_FORK)) |
---|
2374 | | - return 0; |
---|
| 2575 | + return; |
---|
2375 | 2576 | |
---|
2376 | 2577 | bmap.br_startblock = XFS_AGB_TO_FSB(tp->t_mountp, agno, bno); |
---|
2377 | 2578 | bmap.br_blockcount = len; |
---|
2378 | 2579 | bmap.br_startoff = 0; |
---|
2379 | 2580 | bmap.br_state = XFS_EXT_NORM; |
---|
2380 | 2581 | |
---|
2381 | | - return __xfs_rmap_add(tp, XFS_RMAP_ALLOC, owner, XFS_DATA_FORK, &bmap); |
---|
| 2582 | + __xfs_rmap_add(tp, XFS_RMAP_ALLOC, owner, XFS_DATA_FORK, &bmap); |
---|
2382 | 2583 | } |
---|
2383 | 2584 | |
---|
2384 | 2585 | /* Schedule the deletion of an rmap for non-file data. */ |
---|
2385 | | -int |
---|
| 2586 | +void |
---|
2386 | 2587 | xfs_rmap_free_extent( |
---|
2387 | 2588 | struct xfs_trans *tp, |
---|
2388 | 2589 | xfs_agnumber_t agno, |
---|
.. | .. |
---|
2393 | 2594 | struct xfs_bmbt_irec bmap; |
---|
2394 | 2595 | |
---|
2395 | 2596 | if (!xfs_rmap_update_is_needed(tp->t_mountp, XFS_DATA_FORK)) |
---|
2396 | | - return 0; |
---|
| 2597 | + return; |
---|
2397 | 2598 | |
---|
2398 | 2599 | bmap.br_startblock = XFS_AGB_TO_FSB(tp->t_mountp, agno, bno); |
---|
2399 | 2600 | bmap.br_blockcount = len; |
---|
2400 | 2601 | bmap.br_startoff = 0; |
---|
2401 | 2602 | bmap.br_state = XFS_EXT_NORM; |
---|
2402 | 2603 | |
---|
2403 | | - return __xfs_rmap_add(tp, XFS_RMAP_FREE, owner, XFS_DATA_FORK, &bmap); |
---|
| 2604 | + __xfs_rmap_add(tp, XFS_RMAP_FREE, owner, XFS_DATA_FORK, &bmap); |
---|
2404 | 2605 | } |
---|
2405 | 2606 | |
---|
2406 | 2607 | /* Compare rmap records. Returns -1 if a < b, 1 if a > b, and 0 if equal. */ |
---|
.. | .. |
---|
2459 | 2660 | */ |
---|
2460 | 2661 | int |
---|
2461 | 2662 | xfs_rmap_record_exists( |
---|
2462 | | - struct xfs_btree_cur *cur, |
---|
2463 | | - xfs_agblock_t bno, |
---|
2464 | | - xfs_extlen_t len, |
---|
2465 | | - struct xfs_owner_info *oinfo, |
---|
2466 | | - bool *has_rmap) |
---|
| 2663 | + struct xfs_btree_cur *cur, |
---|
| 2664 | + xfs_agblock_t bno, |
---|
| 2665 | + xfs_extlen_t len, |
---|
| 2666 | + const struct xfs_owner_info *oinfo, |
---|
| 2667 | + bool *has_rmap) |
---|
2467 | 2668 | { |
---|
2468 | | - uint64_t owner; |
---|
2469 | | - uint64_t offset; |
---|
2470 | | - unsigned int flags; |
---|
2471 | | - int has_record; |
---|
2472 | | - struct xfs_rmap_irec irec; |
---|
2473 | | - int error; |
---|
| 2669 | + uint64_t owner; |
---|
| 2670 | + uint64_t offset; |
---|
| 2671 | + unsigned int flags; |
---|
| 2672 | + int has_record; |
---|
| 2673 | + struct xfs_rmap_irec irec; |
---|
| 2674 | + int error; |
---|
2474 | 2675 | |
---|
2475 | 2676 | xfs_owner_info_unpack(oinfo, &owner, &offset, &flags); |
---|
2476 | 2677 | ASSERT(XFS_RMAP_NON_INODE_OWNER(owner) || |
---|
.. | .. |
---|
2502 | 2703 | uint64_t owner; |
---|
2503 | 2704 | uint64_t offset; |
---|
2504 | 2705 | unsigned int flags; |
---|
2505 | | - bool has_rmap; |
---|
2506 | 2706 | }; |
---|
2507 | 2707 | |
---|
2508 | 2708 | /* For each rmap given, figure out if it doesn't match the key we want. */ |
---|
.. | .. |
---|
2517 | 2717 | if (rks->owner == rec->rm_owner && rks->offset == rec->rm_offset && |
---|
2518 | 2718 | ((rks->flags & rec->rm_flags) & XFS_RMAP_KEY_FLAGS) == rks->flags) |
---|
2519 | 2719 | return 0; |
---|
2520 | | - rks->has_rmap = true; |
---|
2521 | | - return XFS_BTREE_QUERY_RANGE_ABORT; |
---|
| 2720 | + return -ECANCELED; |
---|
2522 | 2721 | } |
---|
2523 | 2722 | |
---|
2524 | 2723 | /* |
---|
.. | .. |
---|
2530 | 2729 | struct xfs_btree_cur *cur, |
---|
2531 | 2730 | xfs_agblock_t bno, |
---|
2532 | 2731 | xfs_extlen_t len, |
---|
2533 | | - struct xfs_owner_info *oinfo, |
---|
| 2732 | + const struct xfs_owner_info *oinfo, |
---|
2534 | 2733 | bool *has_rmap) |
---|
2535 | 2734 | { |
---|
2536 | 2735 | struct xfs_rmap_irec low = {0}; |
---|
.. | .. |
---|
2539 | 2738 | int error; |
---|
2540 | 2739 | |
---|
2541 | 2740 | xfs_owner_info_unpack(oinfo, &rks.owner, &rks.offset, &rks.flags); |
---|
2542 | | - rks.has_rmap = false; |
---|
| 2741 | + *has_rmap = false; |
---|
2543 | 2742 | |
---|
2544 | 2743 | low.rm_startblock = bno; |
---|
2545 | 2744 | memset(&high, 0xFF, sizeof(high)); |
---|
.. | .. |
---|
2547 | 2746 | |
---|
2548 | 2747 | error = xfs_rmap_query_range(cur, &low, &high, |
---|
2549 | 2748 | xfs_rmap_has_other_keys_helper, &rks); |
---|
2550 | | - *has_rmap = rks.has_rmap; |
---|
| 2749 | + if (error == -ECANCELED) { |
---|
| 2750 | + *has_rmap = true; |
---|
| 2751 | + return 0; |
---|
| 2752 | + } |
---|
| 2753 | + |
---|
2551 | 2754 | return error; |
---|
2552 | 2755 | } |
---|
| 2756 | + |
---|
| 2757 | +const struct xfs_owner_info XFS_RMAP_OINFO_SKIP_UPDATE = { |
---|
| 2758 | + .oi_owner = XFS_RMAP_OWN_NULL, |
---|
| 2759 | +}; |
---|
| 2760 | +const struct xfs_owner_info XFS_RMAP_OINFO_ANY_OWNER = { |
---|
| 2761 | + .oi_owner = XFS_RMAP_OWN_UNKNOWN, |
---|
| 2762 | +}; |
---|
| 2763 | +const struct xfs_owner_info XFS_RMAP_OINFO_FS = { |
---|
| 2764 | + .oi_owner = XFS_RMAP_OWN_FS, |
---|
| 2765 | +}; |
---|
| 2766 | +const struct xfs_owner_info XFS_RMAP_OINFO_LOG = { |
---|
| 2767 | + .oi_owner = XFS_RMAP_OWN_LOG, |
---|
| 2768 | +}; |
---|
| 2769 | +const struct xfs_owner_info XFS_RMAP_OINFO_AG = { |
---|
| 2770 | + .oi_owner = XFS_RMAP_OWN_AG, |
---|
| 2771 | +}; |
---|
| 2772 | +const struct xfs_owner_info XFS_RMAP_OINFO_INOBT = { |
---|
| 2773 | + .oi_owner = XFS_RMAP_OWN_INOBT, |
---|
| 2774 | +}; |
---|
| 2775 | +const struct xfs_owner_info XFS_RMAP_OINFO_INODES = { |
---|
| 2776 | + .oi_owner = XFS_RMAP_OWN_INODES, |
---|
| 2777 | +}; |
---|
| 2778 | +const struct xfs_owner_info XFS_RMAP_OINFO_REFC = { |
---|
| 2779 | + .oi_owner = XFS_RMAP_OWN_REFC, |
---|
| 2780 | +}; |
---|
| 2781 | +const struct xfs_owner_info XFS_RMAP_OINFO_COW = { |
---|
| 2782 | + .oi_owner = XFS_RMAP_OWN_COW, |
---|
| 2783 | +}; |
---|