mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v10 10/10] erofs: implement .fadvise for page cache share
@ 2025-12-23  2:00 Hongbo Li
  2025-12-23  8:38 ` Gao Xiang
  0 siblings, 1 reply; 2+ messages in thread
From: Hongbo Li @ 2025-12-23  2:00 UTC (permalink / raw)
  To: hsiangkao, chao, brauner, djwong, amir73il, hch
  Cc: linux-fsdevel, linux-erofs, linux-kernel, lihongbo22

From: Hongzhen Luo <hongzhen@linux.alibaba.com>

This patch implements the .fadvise interface for page cache share.
Similar to overlayfs, it drops those clean, unused pages through
vfs_fadvise().

Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Signed-off-by: Hongzhen Luo <hongzhen@linux.alibaba.com>
Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
 fs/erofs/ishare.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/fs/erofs/ishare.c b/fs/erofs/ishare.c
index 269b53b3ed79..d7231953cba2 100644
--- a/fs/erofs/ishare.c
+++ b/fs/erofs/ishare.c
@@ -187,6 +187,16 @@ static int erofs_ishare_mmap(struct file *file, struct vm_area_struct *vma)
 	return generic_file_readonly_mmap(file, vma);
 }
 
+static int erofs_ishare_fadvise(struct file *file, loff_t offset,
+				      loff_t len, int advice)
+{
+	struct file *realfile = file->private_data;
+
+	if (!realfile)
+		return -EINVAL;
+	return vfs_fadvise(realfile, offset, len, advice);
+}
+
 const struct file_operations erofs_ishare_fops = {
 	.open		= erofs_ishare_file_open,
 	.llseek		= generic_file_llseek,
@@ -195,6 +205,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_fadvise,
 };
 
 /*
-- 
2.22.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v10 10/10] erofs: implement .fadvise for page cache share
  2025-12-23  2:00 [PATCH v10 10/10] erofs: implement .fadvise for page cache share Hongbo Li
@ 2025-12-23  8:38 ` Gao Xiang
  0 siblings, 0 replies; 2+ messages in thread
From: Gao Xiang @ 2025-12-23  8:38 UTC (permalink / raw)
  To: Hongbo Li
  Cc: linux-fsdevel, linux-erofs, linux-kernel, Chao Yu, brauner,
	Darrick J. Wong, Amir Goldstein, hch



On 2025/12/23 10:00, Hongbo Li wrote:
> From: Hongzhen Luo <hongzhen@linux.alibaba.com>
> 
> This patch implements the .fadvise interface for page cache share.
> Similar to overlayfs, it drops those clean, unused pages through
> vfs_fadvise().
> 
> Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
> Signed-off-by: Hongzhen Luo <hongzhen@linux.alibaba.com>
> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>

This should be sent out together within the series next time.

> ---
>   fs/erofs/ishare.c | 11 +++++++++++
>   1 file changed, 11 insertions(+)
> 
> diff --git a/fs/erofs/ishare.c b/fs/erofs/ishare.c
> index 269b53b3ed79..d7231953cba2 100644
> --- a/fs/erofs/ishare.c
> +++ b/fs/erofs/ishare.c
> @@ -187,6 +187,16 @@ static int erofs_ishare_mmap(struct file *file, struct vm_area_struct *vma)
>   	return generic_file_readonly_mmap(file, vma);
>   }
>   
> +static int erofs_ishare_fadvise(struct file *file, loff_t offset,
> +				      loff_t len, int advice)
> +{
> +	struct file *realfile = file->private_data;
> +
> +	if (!realfile)
> +		return -EINVAL;

BTW, when file->private_data == NULL here?

I think it can only happen if buggy, so just:

	return vfs_fadvise((struct file *)file->private_data,
			   offset, len, advice);
Thanks,
Gao Xiang

> +	return vfs_fadvise(realfile, offset, len, advice);
> +}
> +
>   const struct file_operations erofs_ishare_fops = {
>   	.open		= erofs_ishare_file_open,
>   	.llseek		= generic_file_llseek,
> @@ -195,6 +205,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_fadvise,
>   };
>   
>   /*


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-12-23  8:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-23  2:00 [PATCH v10 10/10] erofs: implement .fadvise for page cache share Hongbo Li
2025-12-23  8:38 ` Gao Xiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®