Patch "xfs: fix and streamline error handling in xfs_end_io" has been added to the 4.9-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
xfs: fix and streamline error handling in xfs_end_io
to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
xfs-fix-and-streamline-error-handling-in-xfs_end_io.patch
and it can be found in the queue-4.9 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
787eb485509f9d58962bd8b4dbc6a5ac6e2034feMon Sep 17 00:00:00 2001
From: Christoph Hellwig <[email protected]>
Date: Thu, 2 Mar 2017 15:02:51 -0800
Subject: xfs: fix and streamline error handling in xfs_end_io
From: Christoph Hellwig <[email protected]>
commit 787eb485509f9d58962bd8b4dbc6a5ac6e2034fe upstream.
There are two different cases of buffered I/O errors:
- first we can have an already shutdown fs. In that case we should skip any on-disk operations and just clean up the appen transaction if present and destroy the ioend
- a real I/O error. In that case we should cleanup any lingering COW blocks. This gets skipped in the current code and is fixed by this patch.
--- fs/xfs/xfs_aops.c | 59 ++++++++++++++++++++++++------------------------------ 1 file changed, 27 insertions(+), 32 deletions(-)
fs/xfs/xfs_aops.c +27 -32
@@ -279,54 +279,49 @@ xfs_end_io(struct xfs_ioend *ioend = container_of(work, struct xfs_ioend, io_work);struct xfs_inode *ip =XFS_I (ioend->io_inode); +xfs_off_t offset = ioend->io_offset; +size_t size = ioend->io_size;int error = ioend->io_bio->bi_error;/* -* Set an error if the mount has shut down and proceed with end I/O -* processing so it can perform whatever cleanups are necessary. +* Just clean up the in-memory strutures if the fs has been shut down. */ -if (XFS_FORCED_SHUTDOWN (ip->i_mount)) +if (XFS_FORCED_SHUTDOWN (ip->i_mount)) { error = -EIO ; + goto done; + }/* -* For a CoW extent, we need to move the mapping from the CoW fork -* to the data fork. If instead an error happened, just dump the -* new blocks. +* Clean up any COW blocks on an I/O error. */ -if (ioend->io_type ==XFS_IO_COW ) { -if (error) - goto done; -if (ioend->io_bio->bi_error) { - error =xfs_reflink_cancel_cow_range (ip, - ioend->io_offset, ioend->io_size, true); - goto done; +if (unlikely (error)) { +switch (ioend->io_type) { +case XFS_IO_COW : +xfs_reflink_cancel_cow_range (ip, offset, size, true); +break ; } - error =xfs_reflink_end_cow (ip, ioend->io_offset, - ioend->io_size); -if (error) - goto done; + + goto done; }/* -* For unwritten extents we need to issue transactions to convert a -* range to normal written extens after the data I/O has finished. -* Detecting and handling completion IO errors is done individually -* for each case as different cleanup operations need to be performed -* on error. +* Success: commit the COW or unwritten blocks if needed. */ -if (ioend->io_type ==XFS_IO_UNWRITTEN ) { -if (error) - goto done; - error =xfs_iomap_write_unwritten (ip, ioend->io_offset, - ioend->io_size); - }else if (ioend->io_append_trans) { - error =xfs_setfilesize_ioend (ioend, error); - }else { -ASSERT (!xfs_ioend_is_append (ioend) || - ioend->io_type ==XFS_IO_COW ); +switch (ioend->io_type) { +case XFS_IO_COW : + error =xfs_reflink_end_cow (ip, offset, size); +break ; +case XFS_IO_UNWRITTEN : + error =xfs_iomap_write_unwritten (ip, offset, size); +break ; +default : +ASSERT (!xfs_ioend_is_append (ioend) || ioend->io_append_trans); +break ; } done: +if (ioend->io_append_trans) + error =xfs_setfilesize_ioend (ioend, error);xfs_destroy_ioend (ioend, error); }
Patches currently in stable-queue which might be from [email protected] are
queue-4.9/xfs-mark-speculative-prealloc-cow-fork-extents-unwritten.patch queue-4.9/xfs-fix-toctou-race-when-locking-an-inode-to-access-the-data-map.patch queue-4.9/xfs-use-iomap-new-flag-for-newly-allocated-delalloc-blocks.patch queue-4.9/xfs-reject-all-unaligned-direct-writes-to-reflinked-files.patch queue-4.9/xfs-allow-unwritten-extents-in-the-cow-fork.patch queue-4.9/xfs-tune-down-agno-asserts-in-the-bmap-code.patch queue-4.9/xfs-verify-free-block-header-fields.patch queue-4.9/xfs-check-for-obviously-bad-level-values-in-the-bmbt-root.patch queue-4.9/xfs-don-t-fail-xfs_extent_busy-allocation.patch queue-4.9/xfs-sync-eofblocks-scans-under-iolock-are-livelock-prone.patch queue-4.9/xfs-use-per-ag-reservations-for-the-finobt.patch queue-4.9/xfs-pull-up-iolock-from-xfs_free_eofblocks.patch queue-4.9/xfs-fail-_dir_open-when-readahead-fails.patch queue-4.9/xfs-update-ctime-and-mtime-on-clone-destinatation-inodes.patch queue-4.9/xfs-only-update-mount-resv-fields-on-success-in-__xfs_ag_resv_init.patch queue-4.9/xfs-use-xfs_icluster_size_fsb-to-calculate-inode-chunk-alignment.patch queue-4.9/xfs-only-reclaim-unwritten-cow-extents-periodically.patch queue-4.9/xfs-try-any-ag-when-allocating-the-first-btree-block-when-reflinking.patch queue-4.9/xfs-fix-and-streamline-error-handling-in-xfs_end_io.patch queue-4.9/xfs-fix-eofblocks-race-with-file-extending-async-dio-writes.patch