History

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

Linus Torvalds committed 7 years ago

Commit bd5ff862 parents adcbc92 add46b33 files · +27 −5Browse files

Unified · Split

3 files
  1. fs/xfs/scrub/repair.c +8 −3
  2. fs/xfs/xfs_aops.c +2 −0
  3. fs/xfs/xfs_buf.c +17 −2
fs/xfs/scrub/repair.c+8−3
@@ -768,18 +768,23 @@ xrep_findroot_block( · 767 unmodified lines
768768 if (!uuid_equal(&btblock->bb_u.s.bb_uuid,
769769 &mp->m_sb.sb_meta_uuid))
770770 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;
771777 fab->buf_ops->verify_read(bp);
772778 if (bp->b_error) {
779+ bp->b_ops = NULL;
773780 bp->b_error = 0;
774781 goto out;
775782 }
776783
777784 /*
778785 * 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.
780787 */
781− if (!bp->b_ops)
782− bp->b_ops = fab->buf_ops;
783788 }
784789
785790 /*
fs/xfs/xfs_aops.c+2−0
@@ -449,6 +449,7 @@ xfs_map_blocks( · 448 unmodified lines
449449 }
450450
451451 wpc->imap = imap;
452+ xfs_trim_extent_eof(&wpc->imap, ip);
452453 trace_xfs_map_blocks_found(ip, offset, count, wpc->io_type, &imap);
453454 return 0;
454455 allocate_blocks:
@@ -459,6 +460,7 @@ allocate_blocks: · 4 unmodified lines
459460 ASSERT(whichfork == XFS_COW_FORK || cow_fsb == NULLFILEOFF ||
460461 imap.br_startoff + imap.br_blockcount <= cow_fsb);
461462 wpc->imap = imap;
463+ xfs_trim_extent_eof(&wpc->imap, ip);
462464 trace_xfs_map_blocks_alloc(ip, offset, count, wpc->io_type, &imap);
463465 return 0;
464466 }
fs/xfs/xfs_buf.c+17−2
@@ -776,10 +776,26 @@ _xfs_buf_read( · 775 unmodified lines
776776 }
777777
778778 /*
779+ * Set buffer ops on an unchecked buffer and validate it, if possible.
780+ *
779781 * If the caller passed in an ops structure and the buffer doesn't have ops
780782 * assigned, set the ops and use them to verify the contents. If the contents
781783 * cannot be verified, we'll clear XBF_DONE. We assume the buffer has no
782784 * 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.
783799 */
784800 int
785801 xfs_buf_ensure_ops(
@@ -1536,8 +1552,7 @@ __xfs_buf_submit( · 750 unmodified lines
15361552 xfs_buf_ioerror(bp, -EIO);
15371553 bp->b_flags &= ~XBF_DONE;
15381554 xfs_buf_stale(bp);
1539− if (bp->b_flags & XBF_ASYNC)
1540− xfs_buf_ioend(bp);
1555+ xfs_buf_ioend(bp);
15411556 return -EIO;
15421557 }
15431558

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t