Skip to content

Commit e64347a

Browse files
Fengnan ChangJaegeuk Kim
authored andcommitted
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 <[email protected]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent d191786 commit e64347a

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

fs/f2fs/file.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4663,12 +4663,12 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
46634663
static int f2fs_file_fadvise(struct file *filp, loff_t offset, loff_t len,
46644664
int advice)
46654665
{
4666-
struct inode *inode;
46674666
struct address_space *mapping;
46684667
struct backing_dev_info *bdi;
4668+
struct inode *inode = file_inode(filp);
4669+
int err;
46694670

46704671
if (advice == POSIX_FADV_SEQUENTIAL) {
4671-
inode = file_inode(filp);
46724672
if (S_ISFIFO(inode->i_mode))
46734673
return -ESPIPE;
46744674

@@ -4685,7 +4685,13 @@ static int f2fs_file_fadvise(struct file *filp, loff_t offset, loff_t len,
46854685
return 0;
46864686
}
46874687

4688-
return generic_fadvise(filp, offset, len, advice);
4688+
err = generic_fadvise(filp, offset, len, advice);
4689+
if (!err && advice == POSIX_FADV_DONTNEED &&
4690+
test_opt(F2FS_I_SB(inode), COMPRESS_CACHE) &&
4691+
f2fs_compressed_file(inode))
4692+
f2fs_invalidate_compress_pages(F2FS_I_SB(inode), inode->i_ino);
4693+
4694+
return err;
46894695
}
46904696

46914697
#ifdef CONFIG_COMPAT

0 commit comments

Comments
 (0)