[RFC PATCH 1/3] mm/filemap: Do not use is_partially_uptodate for entire folio

From: Chi Zhiling
Date: Wed Jul 23 2025 - 06:20:07 EST


From: Chi Zhiling <chizhiling@xxxxxxxxxx>

When reading the entire folio, we should not use is_partially_uptodate()
to determine if the folio is up-to-date. If the folio is not marked as
uptodate, then it is not safe to treat the entire folio as up-to-date,
even if the partial check returns true.

If all data in a folio is actually up-to-date but the folio lacks the
uptodate flag, this could cause issues during pipe reads

This change adds a condition to skip the partial check for the entire folio
case, ensuring that we only consider a folio as up-to-date for the entire
range if it is marked as uptodate.

Signed-off-by: Chi Zhiling <chizhiling@xxxxxxxxxx>
---
mm/filemap.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/mm/filemap.c b/mm/filemap.c
index bada249b9fb7..af12d1cecc7d 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2446,6 +2446,9 @@ static bool filemap_range_uptodate(struct address_space *mapping,
pos -= folio_pos(folio);
}

+ if (pos == 0 && count >= folio_size(folio))
+ return false;
+
return mapping->a_ops->is_partially_uptodate(folio, pos, count);
}

--
2.43.0