[RFC PATCH v6 7/7] erofs: implement .fadvise for page cache share
From: Hongzhen Luo
Date: Sat Mar 01 2025 - 09:51:12 EST
This patch implements the .fadvise interface for page cache share.
Similar to overlayfs, it drops those clean, unused pages through
vfs_fadvise().
Signed-off-by: Hongzhen Luo <hongzhen@xxxxxxxxxxxxxxxxx>
---
fs/erofs/ishare.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/fs/erofs/ishare.c b/fs/erofs/ishare.c
index e68bb1a6cf4b..a7c2be5d6f25 100644
--- a/fs/erofs/ishare.c
+++ b/fs/erofs/ishare.c
@@ -230,6 +230,14 @@ static int erofs_ishare_mmap(struct file *file, struct vm_area_struct *vma)
return 0;
}
+static int erofs_ishare_fadvice(struct file *realfile, loff_t offset, loff_t len,
+ int advice)
+{
+ struct file *file = realfile->private_data;
+
+ return vfs_fadvise(file, offset, len, advice);
+}
+
const struct file_operations erofs_ishare_fops = {
.open = erofs_ishare_file_open,
.llseek = generic_file_llseek,
@@ -238,6 +246,7 @@ const struct file_operations erofs_ishare_fops = {
.release = erofs_ishare_file_release,
.get_unmapped_area = thp_get_unmapped_area,
.splice_read = filemap_splice_read,
+ .fadvise = erofs_ishare_fadvice,
};
void erofs_read_begin(struct erofs_read_ctx *rdctx)
--
2.43.5