diff options
authorMatthew Wilcox (Oracle) <>2021-04-29 22:55:29 -0700
committerLinus Torvalds <>2021-04-30 11:20:37 -0700
commit79e3094c53c56d0d4da23f578de271e7602ba5ed (patch)
parentd31fa86a27b3ecdc32bf19326c4d3bba854542e2 (diff)
mm/filemap: drop check for truncated page after I/O
If the I/O completed successfully, the page will remain Uptodate, even if it is subsequently truncated. If the I/O completed with an error, this check would cause us to retry the I/O if the page were truncated before we woke up. There is no need to retry the I/O; the I/O to fill the page failed, so we can legitimately just return -EIO. This code was originally added by commit 56f0d5fe6851 ("[PATCH] readpage-vs-invalidate fix") in 2005 (this commit ID is from the linux-fullhistory tree; it is also commit ba1f08f14b52 in tglx-history). At the time, truncate_complete_page() called ClearPageUptodate(), and so this was fixing a real bug. In 2008, commit 84209e02de48 ("mm: dont clear PG_uptodate on truncate/invalidate") removed the call to ClearPageUptodate, and this check has been unnecessary ever since. It doesn't do any real harm, but there's no need to keep it. Link: Signed-off-by: Matthew Wilcox (Oracle) <> Acked-by: William Kucharski <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
1 files changed, 0 insertions, 2 deletions
diff --git a/mm/filemap.c b/mm/filemap.c
index 84e7f3c7d667..9620696f880c 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2348,8 +2348,6 @@ static int filemap_read_page(struct file *file, struct address_space *mapping,
return error;
if (PageUptodate(page))
return 0;
- if (!page->mapping) /* page truncated */
return -EIO;