From 7e4f9722315dbe0b6c7b5cb32590d6f48ed160dd Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Tue, 30 Nov 2021 10:22:39 -0800 Subject: [PATCH] ANDROID: f2fs: check nr_pages for readahead Old kernel versions have the issue, since upstream f2fs removed this flow by: commit d4384de9eb5e ("f2fs: Remove readahead collision detection"). Bug: 206148707 Signed-off-by: Jaegeuk Kim Fixes: 8c95605c41a1 ("f2fs: avoid readahead race condition") Change-Id: I3a95f0b436d0a5ee420f41d892401a8d79d4fe79 --- fs/f2fs/data.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index d377ea025f74..b30fbd5fd545 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2359,6 +2359,10 @@ int f2fs_mpage_readpages(struct address_space *mapping, unsigned max_nr_pages = nr_pages; int ret = 0; + /* this is real from f2fs_merkle_tree_readahead() in old kernel only. */ + if (!nr_pages) + return 0; + map.m_pblk = 0; map.m_lblk = 0; map.m_len = 0;