Skip to content

Commit c2dc7e5

Browse files
Christoph Hellwigbrauner
authored andcommitted
iomap: move the PF_MEMALLOC check to iomap_writepages
The iomap writepage implementation has been removed in commit 478af19 ("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>
1 parent 432acd5 commit c2dc7e5

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

fs/iomap/buffered-io.c

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1902,20 +1902,6 @@ static int iomap_do_writepage(struct folio *folio,
19021902

19031903
trace_iomap_writepage(inode, folio_pos(folio), folio_size(folio));
19041904

1905-
/*
1906-
* Refuse to write the folio out if we're called from reclaim context.
1907-
*
1908-
* This avoids stack overflows when called from deeply used stacks in
1909-
* random callers for direct reclaim or memcg reclaim. We explicitly
1910-
* allow reclaim from kswapd as the stack usage there is relatively low.
1911-
*
1912-
* This should never happen except in the case of a VM regression so
1913-
* warn about it.
1914-
*/
1915-
if (WARN_ON_ONCE((current->flags & (PF_MEMALLOC|PF_KSWAPD)) ==
1916-
PF_MEMALLOC))
1917-
goto redirty;
1918-
19191905
/*
19201906
* Is this folio beyond the end of the file?
19211907
*
@@ -1981,8 +1967,6 @@ static int iomap_do_writepage(struct folio *folio,
19811967

19821968
return iomap_writepage_map(wpc, wbc, inode, folio, end_pos);
19831969

1984-
redirty:
1985-
folio_redirty_for_writepage(wbc, folio);
19861970
unlock:
19871971
folio_unlock(folio);
19881972
return 0;
@@ -1995,6 +1979,14 @@ iomap_writepages(struct address_space *mapping, struct writeback_control *wbc,
19951979
{
19961980
int ret;
19971981

1982+
/*
1983+
* Writeback from reclaim context should never happen except in the case
1984+
* of a VM regression so warn about it and refuse to write the data.
1985+
*/
1986+
if (WARN_ON_ONCE((current->flags & (PF_MEMALLOC | PF_KSWAPD)) ==
1987+
PF_MEMALLOC))
1988+
return -EIO;
1989+
19981990
wpc->ops = ops;
19991991
ret = write_cache_pages(mapping, wbc, iomap_do_writepage, wpc);
20001992
if (!wpc->ioend)

0 commit comments

Comments
 (0)