summaryrefslogtreecommitdiffstats
path: root/fs/f2fs
diff options
context:
space:
mode:
authorFengnan Chang <changfengnan@vivo.com>2021-11-29 03:13:41 +0100
committerJaegeuk Kim <jaegeuk@kernel.org>2021-12-11 00:48:32 +0100
commite64347ae13dadba7b847776521a51c94c56605e9 (patch)
tree0395168435cca7b25497c159fff6f830e6e3d919 /fs/f2fs
parentf2fs: fix remove page failed in invalidate compress pages (diff)
downloadlinux-e64347ae13dadba7b847776521a51c94c56605e9.tar.xz
linux-e64347ae13dadba7b847776521a51c94c56605e9.zip
f2fs: support POSIX_FADV_DONTNEED drop compressed page cache
Previously, compressed page cache drop when clean page cache, but POSIX_FADV_DONTNEED can't clean compressed page cache because raw page don't have private data, and won't call f2fs_invalidate_compress_pages. This commit call f2fs_invalidate_compress_pages() directly in f2fs_file_fadvise() for POSIX_FADV_DONTNEED case. Signed-off-by: Fengnan Chang <changfengnan@vivo.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs')
-rw-r--r--fs/f2fs/file.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 0802a10a651f..a15f8ba239f0 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -4663,12 +4663,12 @@ out:
static int f2fs_file_fadvise(struct file *filp, loff_t offset, loff_t len,
int advice)
{
- struct inode *inode;
struct address_space *mapping;
struct backing_dev_info *bdi;
+ struct inode *inode = file_inode(filp);
+ int err;
if (advice == POSIX_FADV_SEQUENTIAL) {
- inode = file_inode(filp);
if (S_ISFIFO(inode->i_mode))
return -ESPIPE;
@@ -4685,7 +4685,13 @@ static int f2fs_file_fadvise(struct file *filp, loff_t offset, loff_t len,
return 0;
}
- return generic_fadvise(filp, offset, len, advice);
+ err = generic_fadvise(filp, offset, len, advice);
+ if (!err && advice == POSIX_FADV_DONTNEED &&
+ test_opt(F2FS_I_SB(inode), COMPRESS_CACHE) &&
+ f2fs_compressed_file(inode))
+ f2fs_invalidate_compress_pages(F2FS_I_SB(inode), inode->i_ino);
+
+ return err;
}
#ifdef CONFIG_COMPAT