summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-02-08 13:46:14 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2019-02-08 13:46:14 -0500
commitbd5ff862ec7855cc7a110891443e7dc6deeb6b84 (patch)
tree23354957126f0867ef70b425b1b9d5f594730bde /fs
parentadcbc921d3dff0bf1657d4d31beee68f92f51538 (diff)
parentadd46b3b021263c02d5a7080c58e5b459479fafd (diff)
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
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/scrub/repair.c11
-rw-r--r--fs/xfs/xfs_aops.c2
-rw-r--r--fs/xfs/xfs_buf.c19
3 files changed, 27 insertions, 5 deletions
diff --git a/fs/xfs/scrub/repair.c b/fs/xfs/scrub/repair.c
index 1c8eecfe52b8..6acf1bfa0bfe 100644
--- a/fs/xfs/scrub/repair.c
+++ b/fs/xfs/scrub/repair.c
@@ -768,18 +768,23 @@ xrep_findroot_block(
768 if (!uuid_equal(&btblock->bb_u.s.bb_uuid, 768 if (!uuid_equal(&btblock->bb_u.s.bb_uuid,
769 &mp->m_sb.sb_meta_uuid)) 769 &mp->m_sb.sb_meta_uuid))
770 goto out; 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 fab->buf_ops->verify_read(bp); 777 fab->buf_ops->verify_read(bp);
772 if (bp->b_error) { 778 if (bp->b_error) {
779 bp->b_ops = NULL;
773 bp->b_error = 0; 780 bp->b_error = 0;
774 goto out; 781 goto out;
775 } 782 }
776 783
777 /* 784 /*
778 * Some read verifiers will (re)set b_ops, so we must be 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 /*
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 338b9d9984e0..d9048bcea49c 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -449,6 +449,7 @@ xfs_map_blocks(
449 } 449 }
450 450
451 wpc->imap = imap; 451 wpc->imap = imap;
452 xfs_trim_extent_eof(&wpc->imap, ip);
452 trace_xfs_map_blocks_found(ip, offset, count, wpc->io_type, &imap); 453 trace_xfs_map_blocks_found(ip, offset, count, wpc->io_type, &imap);
453 return 0; 454 return 0;
454allocate_blocks: 455allocate_blocks:
@@ -459,6 +460,7 @@ allocate_blocks:
459 ASSERT(whichfork == XFS_COW_FORK || cow_fsb == NULLFILEOFF || 460 ASSERT(whichfork == XFS_COW_FORK || cow_fsb == NULLFILEOFF ||
460 imap.br_startoff + imap.br_blockcount <= cow_fsb); 461 imap.br_startoff + imap.br_blockcount <= cow_fsb);
461 wpc->imap = imap; 462 wpc->imap = imap;
463 xfs_trim_extent_eof(&wpc->imap, ip);
462 trace_xfs_map_blocks_alloc(ip, offset, count, wpc->io_type, &imap); 464 trace_xfs_map_blocks_alloc(ip, offset, count, wpc->io_type, &imap);
463 return 0; 465 return 0;
464} 466}
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index eedc5e0156ff..4f5f2ff3f70f 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -776,10 +776,26 @@ _xfs_buf_read(
776} 776}
777 777
778/* 778/*
779 * Set buffer ops on an unchecked buffer and validate it, if possible.
780 *
779 * If the caller passed in an ops structure and the buffer doesn't have ops 781 * If the caller passed in an ops structure and the buffer doesn't have ops
780 * assigned, set the ops and use them to verify the contents. If the contents 782 * assigned, set the ops and use them to verify the contents. If the contents
781 * cannot be verified, we'll clear XBF_DONE. We assume the buffer has no 783 * cannot be verified, we'll clear XBF_DONE. We assume the buffer has no
782 * recorded errors and is already in XBF_DONE state. 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 */
784int 800int
785xfs_buf_ensure_ops( 801xfs_buf_ensure_ops(
@@ -1536,8 +1552,7 @@ __xfs_buf_submit(
1536 xfs_buf_ioerror(bp, -EIO); 1552 xfs_buf_ioerror(bp, -EIO);
1537 bp->b_flags &= ~XBF_DONE; 1553 bp->b_flags &= ~XBF_DONE;
1538 xfs_buf_stale(bp); 1554 xfs_buf_stale(bp);
1539 if (bp->b_flags & XBF_ASYNC) 1555 xfs_buf_ioend(bp);
1540 xfs_buf_ioend(bp);
1541 return -EIO; 1556 return -EIO;
1542 } 1557 }
1543 1558