Skip to contentSkip to conversation

xfs: restore shutdown check in mapped write fault path

PATCH In review Brian Foster 4 participants 4 messages Feb 10, 2021 – Feb 11, 2021 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: restore shutdown check in mapped write fault path

XFS triggers an iomap warning in the write fault path due to a !PageUptodate() page if a write fault happens to occur on a page that recently failed writeback. The iomap writeback error handling code can clear the Uptodate flag if no portion of the page is submitted for I/O. This is reproduced by fstest generic/019, which combines various forms of I/O with simulated disk failures that inevitably lead to filesystem shutdown (which then unconditionally fails page writeback).

This is a regression introduced by commit f150b4234397 ("xfs: split the iomap ops for buffered vs direct writes") due to the removal of a shutdown check and explicit error return in the ->iomap_begin() path used by the write fault path. The explicit error return historically translated to a SIGBUS, but now carries on with iomap processing where it complains about the unexpected state. Restore the shutdown check to xfs_buffered_write_iomap_begin() to restore historical behavior.

Fixes f150b4234397 ("xfs: split the iomap ops for buffered vs direct writes")
---
 fs/xfs/xfs_iomap.c | 3 +++
 1 file changed, 3 insertions(+)
fs/xfs/xfs_iomap.c +3 -0
index 70c341658c01..6594f572096e 100644
@@ -860,6 +860,9 @@ xfs_buffered_write_iomap_begin(
 	int			allocfork = XFS_DATA_FORK;
 	int			error = 0;
 
+	if (XFS_FORCED_SHUTDOWN(mp))
+		return -EIO;
+
 	/* we can't use delayed allocations when using extent size hints */
 	if (xfs_get_extsz_hint(ip))
 		return xfs_direct_write_iomap_begin(inode, offset, count,
Signature · 1 line
2.26.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines · Brian Foster

XFS triggers an iomap warning in the write fault path due to a !PageUptodate() page if a write fault happens to occur on a page that recently failed writeback. The iomap writeback error handling code can clear the Uptodate flag if no portion of the page is submitted for I/O. This is reproduced by fstest generic/019, which combines various forms of I/O with simulated disk failures that inevitably lead to filesystem shutdown (which then unconditionally fails page writeback).

This is a regression introduced by commit f150b4234397 ("xfs: split the iomap ops for buffered vs direct writes") due to the removal of a shutdown check and explicit error return in the ->iomap_begin() path used by the write fault path. The explicit error return historically translated to a SIGBUS, but now carries on with iomap processing where it complains about the unexpected state. Restore the shutdown check to xfs_buffered_write_iomap_begin() to restore historical behavior.

Quoted 2 lines
Fixes f150b4234397 ("xfs: split the iomap ops for buffered vs direct writes")

Looks good to me

Quoted 19 lines
---
 fs/xfs/xfs_iomap.c | 3 +++
 1 file changed, 3 insertions(+)
fs/xfs/xfs_iomap.c +3 -0
index 70c341658c01..6594f572096e 100644
@@ -860,6 +860,9 @@ xfs_buffered_write_iomap_begin(
 	int			allocfork = XFS_DATA_FORK;
 	int			error = 0;
 
+	if (XFS_FORCED_SHUTDOWN(mp))
+		return -EIO;
+
 	/* we can't use delayed allocations when using extent size hints */
 	if (xfs_get_extsz_hint(ip))
 		return xfs_direct_write_iomap_begin(inode, offset, count,
Reviewed-by on v1 1/1
#2 lore raw
In reply to Brian Foster
Quoted 18 lines · Brian Foster

XFS triggers an iomap warning in the write fault path due to a !PageUptodate() page if a write fault happens to occur on a page that recently failed writeback. The iomap writeback error handling code can clear the Uptodate flag if no portion of the page is submitted for I/O. This is reproduced by fstest generic/019, which combines various forms of I/O with simulated disk failures that inevitably lead to filesystem shutdown (which then unconditionally fails page writeback).

This is a regression introduced by commit f150b4234397 ("xfs: split the iomap ops for buffered vs direct writes") due to the removal of a shutdown check and explicit error return in the ->iomap_begin() path used by the write fault path. The explicit error return historically translated to a SIGBUS, but now carries on with iomap processing where it complains about the unexpected state. Restore the shutdown check to xfs_buffered_write_iomap_begin() to restore historical behavior.

Quoted 2 lines
Fixes f150b4234397 ("xfs: split the iomap ops for buffered vs direct writes")

Looks fine,

--D

Quoted 21 lines
---
 fs/xfs/xfs_iomap.c | 3 +++
 1 file changed, 3 insertions(+)
fs/xfs/xfs_iomap.c +3 -0
index 70c341658c01..6594f572096e 100644
@@ -860,6 +860,9 @@ xfs_buffered_write_iomap_begin(
 	int			allocfork = XFS_DATA_FORK;
 	int			error = 0;
 
+	if (XFS_FORCED_SHUTDOWN(mp))
+		return -EIO;
+
 	/* we can't use delayed allocations when using extent size hints */
 	if (xfs_get_extsz_hint(ip))
 		return xfs_direct_write_iomap_begin(inode, offset, count,
Signature · 1 line
2.26.2
Reviewed-by on v1 1/1
#3 lore raw
In reply to Brian Foster
Quoted 18 lines · Brian Foster

XFS triggers an iomap warning in the write fault path due to a !PageUptodate() page if a write fault happens to occur on a page that recently failed writeback. The iomap writeback error handling code can clear the Uptodate flag if no portion of the page is submitted for I/O. This is reproduced by fstest generic/019, which combines various forms of I/O with simulated disk failures that inevitably lead to filesystem shutdown (which then unconditionally fails page writeback).

This is a regression introduced by commit f150b4234397 ("xfs: split the iomap ops for buffered vs direct writes") due to the removal of a shutdown check and explicit error return in the ->iomap_begin() path used by the write fault path. The explicit error return historically translated to a SIGBUS, but now carries on with iomap processing where it complains about the unexpected state. Restore the shutdown check to xfs_buffered_write_iomap_begin() to restore historical behavior.

Quoted 2 lines
Fixes f150b4234397 ("xfs: split the iomap ops for buffered vs direct writes")

Taking some time on the internal discussion thread, I also think SIGBUS is also appropriate after fs shutdown rather than dirty this page anyway.

Thanks,
Gao Xiang