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.

Signed-off-by: Yunlei He <[email protected]>
Signed-off-by: Yongpeng Yang <[email protected]>
---
 fs/f2fs/gc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index 6afd57fa5387..d138648d2b97 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -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;
 }
 
-- 
2.43.0



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

Reply via email to