Skip to contentSkip to conversation

f2fs: remove non-uptodate folio from the page cache in move_data_block

PATCH Superseded Yongpeng Yang 1 participant 1 message Dec 26, 2025 F2FS file system

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 f2fs: remove non-uptodate folio from the page cache in move_data_block

From: Yongpeng Yang <[email protected]>

During data movement, move_data_block acquires file folio without triggering a file read. Such folio are typically not uptodate, they need to be removed from the page cache after gc complete. This patch marks folio with the PG_dropbehind flag and uses folio_end_dropbehind to remove folio from the page cache.

---
 fs/f2fs/gc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
fs/f2fs/gc.c +7 -1
index 6afd57fa5387..d138648d2b97 100644
@@ -1453,7 +1453,13 @@ static int move_data_block(struct inode *inode, block_t bidx,
 put_out:
 	f2fs_put_dnode(&dn);
 out:
-	f2fs_folio_put(folio, true);
+	if (!folio_test_uptodate(folio))
+		__folio_set_dropbehind(folio);
+	folio_unlock(folio);
+	folio_end_dropbehind(folio);
+	/* folio_trylock(folio) may fail, so the flag must be cleared. */
+	folio_clear_dropbehind(folio);
+	folio_put(folio);
 	return err;
 }
 
Signature · 8 lines
2.43.0



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel