Pull xfs fixes from Darrick Wong: "Here are a handful of XFS fixes to fix a data corruption problem, a crasher bug, and a deadlock. Summary: - Fix cache coherency problem with writeback mappings - Fix buffer deadlock when shutting fs down - Fix a null pointer dereference when running online repair" * tag 'xfs-5.0-fixes-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux: xfs: set buffer ops when repair probes for btree type xfs: end sync buffer I/O properly on shutdown error xfs: eof trim writeback mapping as soon as it is cached
Unified · Split
| @@ -768,18 +768,23 @@ xrep_findroot_block( · 767 unmodified lines | ||
| 768 | 768 | if (!uuid_equal(&btblock->bb_u.s.bb_uuid, |
| 769 | 769 | &mp->m_sb.sb_meta_uuid)) |
| 770 | 770 | goto out; |
| 771 | + /* | |
| 772 | + * Read verifiers can reference b_ops, so we set the pointer | |
| 773 | + * here. If the verifier fails we'll reset the buffer state | |
| 774 | + * to what it was before we touched the buffer. | |
| 775 | + */ | |
| 776 | + bp->b_ops = fab->buf_ops; | |
| 771 | 777 | fab->buf_ops->verify_read(bp); |
| 772 | 778 | if (bp->b_error) { |
| 779 | + bp->b_ops = NULL; | |
| 773 | 780 | bp->b_error = 0; |
| 774 | 781 | goto out; |
| 775 | 782 | } |
| 776 | 783 | |
| 777 | 784 | /* |
| 778 | 785 | * Some read verifiers will (re)set b_ops, so we must be |
| 779 | − * careful not to blow away any such assignment. | |
| 786 | + * careful not to change b_ops after running the verifier. | |
| 780 | 787 | */ |
| 781 | − if (!bp->b_ops) | |
| 782 | − bp->b_ops = fab->buf_ops; | |
| 783 | 788 | } |
| 784 | 789 | |
| 785 | 790 | /* |
| @@ -449,6 +449,7 @@ xfs_map_blocks( · 448 unmodified lines | ||
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | wpc->imap = imap; |
| 452 | + xfs_trim_extent_eof(&wpc->imap, ip); | |
| 452 | 453 | trace_xfs_map_blocks_found(ip, offset, count, wpc->io_type, &imap); |
| 453 | 454 | return 0; |
| 454 | 455 | allocate_blocks: |
| @@ -459,6 +460,7 @@ allocate_blocks: · 4 unmodified lines | ||
| 459 | 460 | ASSERT(whichfork == XFS_COW_FORK || cow_fsb == NULLFILEOFF || |
| 460 | 461 | imap.br_startoff + imap.br_blockcount <= cow_fsb); |
| 461 | 462 | wpc->imap = imap; |
| 463 | + xfs_trim_extent_eof(&wpc->imap, ip); | |
| 462 | 464 | trace_xfs_map_blocks_alloc(ip, offset, count, wpc->io_type, &imap); |
| 463 | 465 | return 0; |
| 464 | 466 | } |
| @@ -776,10 +776,26 @@ _xfs_buf_read( · 775 unmodified lines | ||
| 776 | 776 | } |
| 777 | 777 | |
| 778 | 778 | /* |
| 779 | + * Set buffer ops on an unchecked buffer and validate it, if possible. | |
| 780 | + * | |
| 779 | 781 | * If the caller passed in an ops structure and the buffer doesn't have ops |
| 780 | 782 | * assigned, set the ops and use them to verify the contents. If the contents |
| 781 | 783 | * cannot be verified, we'll clear XBF_DONE. We assume the buffer has no |
| 782 | 784 | * recorded errors and is already in XBF_DONE state. |
| 785 | + * | |
| 786 | + * Under normal operations, every in-core buffer must have buffer ops assigned | |
| 787 | + * to them when the buffer is read in from disk so that we can validate the | |
| 788 | + * metadata. | |
| 789 | + * | |
| 790 | + * However, there are two scenarios where one can encounter in-core buffers | |
| 791 | + * that don't have buffer ops. The first is during log recovery of buffers on | |
| 792 | + * a V4 filesystem, though these buffers are purged at the end of recovery. | |
| 793 | + * | |
| 794 | + * The other is online repair, which tries to match arbitrary metadata blocks | |
| 795 | + * with btree types in order to find the root. If online repair doesn't match | |
| 796 | + * the buffer with /any/ btree type, the buffer remains in memory in DONE state | |
| 797 | + * with no ops, and a subsequent read_buf call from elsewhere will not set the | |
| 798 | + * ops. This function helps us fix this situation. | |
| 783 | 799 | */ |
| 784 | 800 | int |
| 785 | 801 | xfs_buf_ensure_ops( |
| @@ -1536,8 +1552,7 @@ __xfs_buf_submit( · 750 unmodified lines | ||
| 1536 | 1552 | xfs_buf_ioerror(bp, -EIO); |
| 1537 | 1553 | bp->b_flags &= ~XBF_DONE; |
| 1538 | 1554 | xfs_buf_stale(bp); |
| 1539 | − if (bp->b_flags & XBF_ASYNC) | |
| 1540 | − xfs_buf_ioend(bp); | |
| 1555 | + xfs_buf_ioend(bp); | |
| 1541 | 1556 | return -EIO; |
| 1542 | 1557 | } |
| 1543 | 1558 | |