Skip to content

Commit

Permalink
Merge tag 'xfs-5.0-fixes-1' of git://git.kernel.org/pub/scm/fs/xfs/xf…
Browse files Browse the repository at this point in the history
…s-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
  • Loading branch information
torvalds committed Feb 8, 2019
2 parents adcbc92 + add46b3 commit bd5ff86
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
11 changes: 8 additions & 3 deletions fs/xfs/scrub/repair.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/*
Expand Down
2 changes: 2 additions & 0 deletions fs/xfs/xfs_aops.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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;
}
Expand Down
19 changes: 17 additions & 2 deletions fs/xfs/xfs_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -1536,8 +1552,7 @@ __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);
xfs_buf_ioend(bp);
return -EIO;
}

Expand Down

0 comments on commit bd5ff86

Please sign in to comment.