Commit bd5ff862 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'xfs-5.0-fixes-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux

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
parents adcbc921 add46b3b
......@@ -768,18 +768,23 @@ xrep_findroot_block(
if (!uuid_equal(&btblock->bb_u.s.bb_uuid,
&mp->m_sb.sb_meta_uuid))
goto out;
/*
* Read verifiers can reference b_ops, so we set the pointer
* here. If the verifier fails we'll reset the buffer state
* to what it was before we touched the buffer.
*/
bp->b_ops = fab->buf_ops;
fab->buf_ops->verify_read(bp);
if (bp->b_error) {
bp->b_ops = NULL;
bp->b_error = 0;
goto out;
}
/*
* Some read verifiers will (re)set b_ops, so we must be
* careful not to blow away any such assignment.
* careful not to change b_ops after running the verifier.
*/
if (!bp->b_ops)
bp->b_ops = fab->buf_ops;
}
/*
......
......@@ -449,6 +449,7 @@ xfs_map_blocks(
}
wpc->imap = imap;
xfs_trim_extent_eof(&wpc->imap, ip);
trace_xfs_map_blocks_found(ip, offset, count, wpc->io_type, &imap);
return 0;
allocate_blocks:
......@@ -459,6 +460,7 @@ xfs_map_blocks(
ASSERT(whichfork == XFS_COW_FORK || cow_fsb == NULLFILEOFF ||
imap.br_startoff + imap.br_blockcount <= cow_fsb);
wpc->imap = imap;
xfs_trim_extent_eof(&wpc->imap, ip);
trace_xfs_map_blocks_alloc(ip, offset, count, wpc->io_type, &imap);
return 0;
}
......
......@@ -776,10 +776,26 @@ _xfs_buf_read(
}
/*
* Set buffer ops on an unchecked buffer and validate it, if possible.
*
* If the caller passed in an ops structure and the buffer doesn't have ops
* assigned, set the ops and use them to verify the contents. If the contents
* cannot be verified, we'll clear XBF_DONE. We assume the buffer has no
* recorded errors and is already in XBF_DONE state.
*
* Under normal operations, every in-core buffer must have buffer ops assigned
* to them when the buffer is read in from disk so that we can validate the
* metadata.
*
* However, there are two scenarios where one can encounter in-core buffers
* that don't have buffer ops. The first is during log recovery of buffers on
* a V4 filesystem, though these buffers are purged at the end of recovery.
*
* The other is online repair, which tries to match arbitrary metadata blocks
* with btree types in order to find the root. If online repair doesn't match
* the buffer with /any/ btree type, the buffer remains in memory in DONE state
* with no ops, and a subsequent read_buf call from elsewhere will not set the
* ops. This function helps us fix this situation.
*/
int
xfs_buf_ensure_ops(
......@@ -1536,7 +1552,6 @@ __xfs_buf_submit(
xfs_buf_ioerror(bp, -EIO);
bp->b_flags &= ~XBF_DONE;
xfs_buf_stale(bp);
if (bp->b_flags & XBF_ASYNC)
xfs_buf_ioend(bp);
return -EIO;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment