Re: [PATCH v1 2/3] fuse: use offset_in_folio() for large folio offset calculations
From: Chunsheng Luo
Date: Mon Jan 19 2026 - 03:23:31 EST
On 1/17/26 7:56 AM, Joanne Koong wrote:
> Use offset_in_folio() instead of manually calculating the folio offset.
>
> Signed-off-by: Joanne Koong <joannelkoong@xxxxxxxxx>
> ---
> fs/fuse/dev.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
> index 698289b5539e..4dda4e24cc90 100644
> --- a/fs/fuse/dev.c
> +++ b/fs/fuse/dev.c
> @@ -1812,7 +1812,7 @@ static int fuse_notify_store(struct fuse_conn *fc, unsigned int size,
> if (IS_ERR(folio))
> goto out_iput;
> - folio_offset = ((index - folio->index) << PAGE_SHIFT) + offset;
> + folio_offset = offset_in_folio(folio, outarg.offset);
offset is a loop variable, and later offset maybe set to 0. Replacing it
with outarg.offset here would change the behavior. The same below.
Will this cause any problems?
Thanks,
Chunsheng Luo
> nr_bytes = min_t(unsigned, num, folio_size(folio) - folio_offset);
> nr_pages = DIV_ROUND_UP(offset + nr_bytes, PAGE_SIZE);
> @@ -1916,7 +1916,7 @@ static int fuse_retrieve(struct fuse_mount *fm, struct inode *inode,
> if (IS_ERR(folio))
> break;
> - folio_offset = ((index - folio->index) << PAGE_SHIFT) + offset;
> + folio_offset = offset_in_folio(folio, outarg->offset);
> nr_bytes = min(folio_size(folio) - folio_offset, num);
> nr_pages = DIV_ROUND_UP(offset + nr_bytes, PAGE_SIZE);
>