* [PATCH v1 2/3] fuse: use offset_in_folio() for large folio offset calculations
2026-01-16 23:56 [PATCH v1 0/3] fuse: clean up offset and page count calculations Joanne Koong
@ 2026-01-16 23:56 ` Joanne Koong
2026-01-19 4:41 ` Chunsheng Luo
2026-01-19 6:24 ` Chunsheng Luo
0 siblings, 2 replies; 6+ messages in thread
From: Joanne Koong @ 2026-01-16 23:56 UTC (permalink / raw)
To: miklos; +Cc: linux-fsdevel, jefflexu
Use offset_in_folio() instead of manually calculating the folio offset.
Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
---
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);
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);
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v1 2/3] fuse: use offset_in_folio() for large folio offset calculations
2026-01-16 23:56 ` [PATCH v1 2/3] fuse: use offset_in_folio() for large folio offset calculations Joanne Koong
@ 2026-01-19 4:41 ` Chunsheng Luo
2026-01-20 18:59 ` Joanne Koong
2026-01-19 6:24 ` Chunsheng Luo
1 sibling, 1 reply; 6+ messages in thread
From: Chunsheng Luo @ 2026-01-19 4:41 UTC (permalink / raw)
To: Joanne Koong, miklos; +Cc: linux-fsdevel, jefflexu
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@gmail.com>
> ---
> 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 will be set to 0. Replacing
it with outarg.offset here would change the behavior. The same applies
to the cases below. Will there be any problem here?
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);
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 2/3] fuse: use offset_in_folio() for large folio offset calculations
2026-01-16 23:56 ` [PATCH v1 2/3] fuse: use offset_in_folio() for large folio offset calculations Joanne Koong
2026-01-19 4:41 ` Chunsheng Luo
@ 2026-01-19 6:24 ` Chunsheng Luo
1 sibling, 0 replies; 6+ messages in thread
From: Chunsheng Luo @ 2026-01-19 6:24 UTC (permalink / raw)
To: joannelkoong; +Cc: jefflexu, linux-fsdevel, miklos
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@gmail.com>
> ---
> 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);
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 2/3] fuse: use offset_in_folio() for large folio offset calculations
@ 2026-01-19 8:23 Chunsheng Luo
2026-01-19 8:34 ` Chunsheng Luo
0 siblings, 1 reply; 6+ messages in thread
From: Chunsheng Luo @ 2026-01-19 8:23 UTC (permalink / raw)
To: miklos; +Cc: amir73il, linux-fsdevel, linux-kernel
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@gmail.com>
> ---
> 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);
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 2/3] fuse: use offset_in_folio() for large folio offset calculations
2026-01-19 8:23 [PATCH v1 2/3] fuse: use offset_in_folio() for large folio offset calculations Chunsheng Luo
@ 2026-01-19 8:34 ` Chunsheng Luo
0 siblings, 0 replies; 6+ messages in thread
From: Chunsheng Luo @ 2026-01-19 8:34 UTC (permalink / raw)
To: miklos; +Cc: amir73il, linux-fsdevel, linux-kernel
Dear Community Members,
I sincerely apologize for the email that was mistakenly sent earlier due
to an operational error on my part.
Please kindly ignore the previous message, and if possible, you may
delete it from your inbox.
My deepest apologies for any inconvenience this may have caused.
Thanks
Chunsheng Luo
On 1/19/26 4:23 PM, Chunsheng Luo wrote:
> 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@gmail.com>
>> ---
>> 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);
>>
>
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 2/3] fuse: use offset_in_folio() for large folio offset calculations
2026-01-19 4:41 ` Chunsheng Luo
@ 2026-01-20 18:59 ` Joanne Koong
0 siblings, 0 replies; 6+ messages in thread
From: Joanne Koong @ 2026-01-20 18:59 UTC (permalink / raw)
To: Chunsheng Luo; +Cc: miklos, linux-fsdevel, jefflexu
On Sun, Jan 18, 2026 at 8:41 PM Chunsheng Luo <luochunsheng@ustc.edu> wrote:
>
> 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@gmail.com>
> > ---
> > 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 will be set to 0. Replacing
> it with outarg.offset here would change the behavior. The same applies
> to the cases below. Will there be any problem here?
Hi Chunsheng,
Good catch, the offset variable should get replaced entirely by
outarg.offset. I'll make this change in v2.
Thanks,
Joanne
>
> 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);
> >
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-01-20 19:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-19 8:23 [PATCH v1 2/3] fuse: use offset_in_folio() for large folio offset calculations Chunsheng Luo
2026-01-19 8:34 ` Chunsheng Luo
-- strict thread matches above, loose matches on Subject: below --
2026-01-16 23:56 [PATCH v1 0/3] fuse: clean up offset and page count calculations Joanne Koong
2026-01-16 23:56 ` [PATCH v1 2/3] fuse: use offset_in_folio() for large folio offset calculations Joanne Koong
2026-01-19 4:41 ` Chunsheng Luo
2026-01-20 18:59 ` Joanne Koong
2026-01-19 6:24 ` Chunsheng Luo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox