summaryrefslogtreecommitdiffstats
path: root/fs/iomap
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2023-12-07 08:27:00 +0100
committerChristian Brauner <brauner@kernel.org>2024-02-01 14:20:11 +0100
commitc2dc7e5589a19cff8147f27d4beef7fc0aec2f86 (patch)
treeb3bdcae881bba94c6ee0ffea706534bcc05b2323 /fs/iomap
parentiomap: move the io_folios field out of struct iomap_ioend (diff)
downloadlinux-c2dc7e5589a19cff8147f27d4beef7fc0aec2f86.tar.xz
linux-c2dc7e5589a19cff8147f27d4beef7fc0aec2f86.zip
iomap: move the PF_MEMALLOC check to iomap_writepages
The iomap writepage implementation has been removed in commit 478af190cb6c ("iomap: remove iomap_writepage") and this code is now only called through ->writepages which never happens from memory reclaim. Nove the check from iomap_do_writepage to iomap_writepages so that is only called once per ->writepage invocation. Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20231207072710.176093-5-hch@lst.de Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'fs/iomap')
-rw-r--r--fs/iomap/buffered-io.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index c013d35b07b7..292ab7dade21 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -1903,20 +1903,6 @@ static int iomap_do_writepage(struct folio *folio,
trace_iomap_writepage(inode, folio_pos(folio), folio_size(folio));
/*
- * Refuse to write the folio out if we're called from reclaim context.
- *
- * This avoids stack overflows when called from deeply used stacks in
- * random callers for direct reclaim or memcg reclaim. We explicitly
- * allow reclaim from kswapd as the stack usage there is relatively low.
- *
- * This should never happen except in the case of a VM regression so
- * warn about it.
- */
- if (WARN_ON_ONCE((current->flags & (PF_MEMALLOC|PF_KSWAPD)) ==
- PF_MEMALLOC))
- goto redirty;
-
- /*
* Is this folio beyond the end of the file?
*
* The folio index is less than the end_index, adjust the end_pos
@@ -1981,8 +1967,6 @@ static int iomap_do_writepage(struct folio *folio,
return iomap_writepage_map(wpc, wbc, inode, folio, end_pos);
-redirty:
- folio_redirty_for_writepage(wbc, folio);
unlock:
folio_unlock(folio);
return 0;
@@ -1995,6 +1979,14 @@ iomap_writepages(struct address_space *mapping, struct writeback_control *wbc,
{
int ret;
+ /*
+ * Writeback from reclaim context should never happen except in the case
+ * of a VM regression so warn about it and refuse to write the data.
+ */
+ if (WARN_ON_ONCE((current->flags & (PF_MEMALLOC | PF_KSWAPD)) ==
+ PF_MEMALLOC))
+ return -EIO;
+
wpc->ops = ops;
ret = write_cache_pages(mapping, wbc, iomap_do_writepage, wpc);
if (!wpc->ioend)