* [PATCH 1/2] fuse: drop unused fuse_mount arg in fuse_writepage_finish
@ 2024-08-19 18:24 Joanne Koong
2024-08-19 18:24 ` [PATCH 2/2] fuse: update stats for pages in dropped aux writeback list Joanne Koong
2024-08-20 1:53 ` [PATCH 1/2] fuse: drop unused fuse_mount arg in fuse_writepage_finish Jingbo Xu
0 siblings, 2 replies; 10+ messages in thread
From: Joanne Koong @ 2024-08-19 18:24 UTC (permalink / raw)
To: miklos, linux-fsdevel; +Cc: josef, bernd.schubert, kernel-team
Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
---
fs/fuse/file.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index f39456c65ed7..63fd5fc6872e 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1769,8 +1769,7 @@ static void fuse_writepage_free(struct fuse_writepage_args *wpa)
kfree(wpa);
}
-static void fuse_writepage_finish(struct fuse_mount *fm,
- struct fuse_writepage_args *wpa)
+static void fuse_writepage_finish(struct fuse_writepage_args *wpa)
{
struct fuse_args_pages *ap = &wpa->ia.ap;
struct inode *inode = wpa->inode;
@@ -1829,7 +1828,7 @@ __acquires(fi->lock)
out_free:
fi->writectr--;
rb_erase(&wpa->writepages_entry, &fi->writepages);
- fuse_writepage_finish(fm, wpa);
+ fuse_writepage_finish(wpa);
spin_unlock(&fi->lock);
/* After fuse_writepage_finish() aux request list is private */
@@ -1959,7 +1958,7 @@ static void fuse_writepage_end(struct fuse_mount *fm, struct fuse_args *args,
fuse_send_writepage(fm, next, inarg->offset + inarg->size);
}
fi->writectr--;
- fuse_writepage_finish(fm, wpa);
+ fuse_writepage_finish(wpa);
spin_unlock(&fi->lock);
fuse_writepage_free(wpa);
}
--
2.43.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/2] fuse: update stats for pages in dropped aux writeback list
2024-08-19 18:24 [PATCH 1/2] fuse: drop unused fuse_mount arg in fuse_writepage_finish Joanne Koong
@ 2024-08-19 18:24 ` Joanne Koong
2024-08-20 2:10 ` Jingbo Xu
2024-08-21 15:56 ` Miklos Szeredi
2024-08-20 1:53 ` [PATCH 1/2] fuse: drop unused fuse_mount arg in fuse_writepage_finish Jingbo Xu
1 sibling, 2 replies; 10+ messages in thread
From: Joanne Koong @ 2024-08-19 18:24 UTC (permalink / raw)
To: miklos, linux-fsdevel; +Cc: josef, bernd.schubert, kernel-team
In the case where the aux writeback list is dropped (eg the pages
have been truncated or the connection is broken), the stats for
its pages and backing device info need to be updated as well.
Fixes: e2653bd53a98 ("fuse: fix leaked aux requests")
Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
---
fs/fuse/file.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 63fd5fc6872e..7ac56be5fee6 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1831,10 +1831,11 @@ __acquires(fi->lock)
fuse_writepage_finish(wpa);
spin_unlock(&fi->lock);
- /* After fuse_writepage_finish() aux request list is private */
+ /* After rb_erase() aux request list is private */
for (aux = wpa->next; aux; aux = next) {
next = aux->next;
aux->next = NULL;
+ fuse_writepage_finish(aux);
fuse_writepage_free(aux);
}
--
2.43.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] fuse: drop unused fuse_mount arg in fuse_writepage_finish
2024-08-19 18:24 [PATCH 1/2] fuse: drop unused fuse_mount arg in fuse_writepage_finish Joanne Koong
2024-08-19 18:24 ` [PATCH 2/2] fuse: update stats for pages in dropped aux writeback list Joanne Koong
@ 2024-08-20 1:53 ` Jingbo Xu
2024-08-20 18:19 ` Joanne Koong
1 sibling, 1 reply; 10+ messages in thread
From: Jingbo Xu @ 2024-08-20 1:53 UTC (permalink / raw)
To: Joanne Koong, miklos, linux-fsdevel; +Cc: josef, bernd.schubert, kernel-team
On 8/20/24 2:24 AM, Joanne Koong wrote:
> Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
> ---
> fs/fuse/file.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/fs/fuse/file.c b/fs/fuse/file.c
> index f39456c65ed7..63fd5fc6872e 100644
> --- a/fs/fuse/file.c
> +++ b/fs/fuse/file.c
> @@ -1769,8 +1769,7 @@ static void fuse_writepage_free(struct fuse_writepage_args *wpa)
> kfree(wpa);
> }
>
> -static void fuse_writepage_finish(struct fuse_mount *fm,
> - struct fuse_writepage_args *wpa)
> +static void fuse_writepage_finish(struct fuse_writepage_args *wpa)
> {
> struct fuse_args_pages *ap = &wpa->ia.ap;
> struct inode *inode = wpa->inode;
> @@ -1829,7 +1828,7 @@ __acquires(fi->lock)
> out_free:
> fi->writectr--;
> rb_erase(&wpa->writepages_entry, &fi->writepages);
> - fuse_writepage_finish(fm, wpa);
> + fuse_writepage_finish(wpa);
> spin_unlock(&fi->lock);
>
> /* After fuse_writepage_finish() aux request list is private */
> @@ -1959,7 +1958,7 @@ static void fuse_writepage_end(struct fuse_mount *fm, struct fuse_args *args,
> fuse_send_writepage(fm, next, inarg->offset + inarg->size);
> }
> fi->writectr--;
> - fuse_writepage_finish(fm, wpa);
> + fuse_writepage_finish(wpa);
> spin_unlock(&fi->lock);
> fuse_writepage_free(wpa);
> }
I'm afraid an empty commit message will trigger a warning when running
checkpatch. Otherwise LGTM.
Reviewed-by: Jingbo Xu <jefflexu@linux.alibaba.com>
--
Thanks,
Jingbo
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] fuse: update stats for pages in dropped aux writeback list
2024-08-19 18:24 ` [PATCH 2/2] fuse: update stats for pages in dropped aux writeback list Joanne Koong
@ 2024-08-20 2:10 ` Jingbo Xu
2024-08-20 18:21 ` Joanne Koong
2024-08-21 15:56 ` Miklos Szeredi
1 sibling, 1 reply; 10+ messages in thread
From: Jingbo Xu @ 2024-08-20 2:10 UTC (permalink / raw)
To: Joanne Koong, miklos, linux-fsdevel; +Cc: josef, bernd.schubert, kernel-team
On 8/20/24 2:24 AM, Joanne Koong wrote:
> In the case where the aux writeback list is dropped (eg the pages
> have been truncated or the connection is broken), the stats for
> its pages and backing device info need to be updated as well.
>
> Fixes: e2653bd53a98 ("fuse: fix leaked aux requests")
> Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
> ---
> fs/fuse/file.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/fuse/file.c b/fs/fuse/file.c
> index 63fd5fc6872e..7ac56be5fee6 100644
> --- a/fs/fuse/file.c
> +++ b/fs/fuse/file.c
> @@ -1831,10 +1831,11 @@ __acquires(fi->lock)
> fuse_writepage_finish(wpa);
> spin_unlock(&fi->lock);
>
> - /* After fuse_writepage_finish() aux request list is private */
> + /* After rb_erase() aux request list is private */
> for (aux = wpa->next; aux; aux = next) {
> next = aux->next;
> aux->next = NULL;
> + fuse_writepage_finish(aux);
> fuse_writepage_free(aux);
> }
>
LGTM.
Besides, there is similar logic of decreasing stats info for replaced
aux (temp) request inside fuse_writepage_add(), though without waking up
fi->page_waitq.
I wonder if we could factor out a new helper function, saying
fuse_writepage_dec_stat(), which could be called both from
fuse_writepage_add() and fuse_send_writepage().
--
Thanks,
Jingbo
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] fuse: drop unused fuse_mount arg in fuse_writepage_finish
2024-08-20 1:53 ` [PATCH 1/2] fuse: drop unused fuse_mount arg in fuse_writepage_finish Jingbo Xu
@ 2024-08-20 18:19 ` Joanne Koong
0 siblings, 0 replies; 10+ messages in thread
From: Joanne Koong @ 2024-08-20 18:19 UTC (permalink / raw)
To: Jingbo Xu; +Cc: miklos, linux-fsdevel, josef, bernd.schubert, kernel-team
On Mon, Aug 19, 2024 at 6:53 PM Jingbo Xu <jefflexu@linux.alibaba.com> wrote:
>
>
> On 8/20/24 2:24 AM, Joanne Koong wrote:
> > Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
> > ---
> > fs/fuse/file.c | 7 +++----
> > 1 file changed, 3 insertions(+), 4 deletions(-)
> >
> > diff --git a/fs/fuse/file.c b/fs/fuse/file.c
> > index f39456c65ed7..63fd5fc6872e 100644
> > --- a/fs/fuse/file.c
> > +++ b/fs/fuse/file.c
> > @@ -1769,8 +1769,7 @@ static void fuse_writepage_free(struct fuse_writepage_args *wpa)
> > kfree(wpa);
> > }
> >
> > -static void fuse_writepage_finish(struct fuse_mount *fm,
> > - struct fuse_writepage_args *wpa)
> > +static void fuse_writepage_finish(struct fuse_writepage_args *wpa)
> > {
> > struct fuse_args_pages *ap = &wpa->ia.ap;
> > struct inode *inode = wpa->inode;
> > @@ -1829,7 +1828,7 @@ __acquires(fi->lock)
> > out_free:
> > fi->writectr--;
> > rb_erase(&wpa->writepages_entry, &fi->writepages);
> > - fuse_writepage_finish(fm, wpa);
> > + fuse_writepage_finish(wpa);
> > spin_unlock(&fi->lock);
> >
> > /* After fuse_writepage_finish() aux request list is private */
> > @@ -1959,7 +1958,7 @@ static void fuse_writepage_end(struct fuse_mount *fm, struct fuse_args *args,
> > fuse_send_writepage(fm, next, inarg->offset + inarg->size);
> > }
> > fi->writectr--;
> > - fuse_writepage_finish(fm, wpa);
> > + fuse_writepage_finish(wpa);
> > spin_unlock(&fi->lock);
> > fuse_writepage_free(wpa);
> > }
>
> I'm afraid an empty commit message will trigger a warning when running
> checkpatch. Otherwise LGTM.
Gotcha, I'll resubmit this with a commit message. Thanks for taking a look.
>
> Reviewed-by: Jingbo Xu <jefflexu@linux.alibaba.com>
>
> --
> Thanks,
> Jingbo
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] fuse: update stats for pages in dropped aux writeback list
2024-08-20 2:10 ` Jingbo Xu
@ 2024-08-20 18:21 ` Joanne Koong
0 siblings, 0 replies; 10+ messages in thread
From: Joanne Koong @ 2024-08-20 18:21 UTC (permalink / raw)
To: Jingbo Xu; +Cc: miklos, linux-fsdevel, josef, bernd.schubert, kernel-team
On Mon, Aug 19, 2024 at 7:10 PM Jingbo Xu <jefflexu@linux.alibaba.com> wrote:
>
>
>
> On 8/20/24 2:24 AM, Joanne Koong wrote:
> > In the case where the aux writeback list is dropped (eg the pages
> > have been truncated or the connection is broken), the stats for
> > its pages and backing device info need to be updated as well.
> >
> > Fixes: e2653bd53a98 ("fuse: fix leaked aux requests")
> > Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
> > ---
> > fs/fuse/file.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/fs/fuse/file.c b/fs/fuse/file.c
> > index 63fd5fc6872e..7ac56be5fee6 100644
> > --- a/fs/fuse/file.c
> > +++ b/fs/fuse/file.c
> > @@ -1831,10 +1831,11 @@ __acquires(fi->lock)
> > fuse_writepage_finish(wpa);
> > spin_unlock(&fi->lock);
> >
> > - /* After fuse_writepage_finish() aux request list is private */
> > + /* After rb_erase() aux request list is private */
> > for (aux = wpa->next; aux; aux = next) {
> > next = aux->next;
> > aux->next = NULL;
> > + fuse_writepage_finish(aux);
> > fuse_writepage_free(aux);
> > }
> >
>
> LGTM.
>
> Besides, there is similar logic of decreasing stats info for replaced
> aux (temp) request inside fuse_writepage_add(), though without waking up
> fi->page_waitq.
>
> I wonder if we could factor out a new helper function, saying
> fuse_writepage_dec_stat(), which could be called both from
> fuse_writepage_add() and fuse_send_writepage().
This sounds good to me. I'll add this refactoring when I resubmit this
patch series.
Thanks,
Joanne
>
>
> --
> Thanks,
> Jingbo
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] fuse: update stats for pages in dropped aux writeback list
2024-08-19 18:24 ` [PATCH 2/2] fuse: update stats for pages in dropped aux writeback list Joanne Koong
2024-08-20 2:10 ` Jingbo Xu
@ 2024-08-21 15:56 ` Miklos Szeredi
2024-08-21 18:26 ` Bernd Schubert
1 sibling, 1 reply; 10+ messages in thread
From: Miklos Szeredi @ 2024-08-21 15:56 UTC (permalink / raw)
To: Joanne Koong; +Cc: linux-fsdevel, josef, bernd.schubert, kernel-team
On Mon, 19 Aug 2024 at 20:25, Joanne Koong <joannelkoong@gmail.com> wrote:
>
> In the case where the aux writeback list is dropped (eg the pages
> have been truncated or the connection is broken), the stats for
> its pages and backing device info need to be updated as well.
Patch looks good. Thanks.
Do you have a reproducer or was this found by code review only?
Thanks,
Miklos
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] fuse: update stats for pages in dropped aux writeback list
2024-08-21 15:56 ` Miklos Szeredi
@ 2024-08-21 18:26 ` Bernd Schubert
2024-08-21 20:22 ` Joanne Koong
0 siblings, 1 reply; 10+ messages in thread
From: Bernd Schubert @ 2024-08-21 18:26 UTC (permalink / raw)
To: Miklos Szeredi, Joanne Koong; +Cc: linux-fsdevel, josef, kernel-team
On 8/21/24 17:56, Miklos Szeredi wrote:
> On Mon, 19 Aug 2024 at 20:25, Joanne Koong <joannelkoong@gmail.com> wrote:
>>
>> In the case where the aux writeback list is dropped (eg the pages
>> have been truncated or the connection is broken), the stats for
>> its pages and backing device info need to be updated as well.
>
> Patch looks good. Thanks.
>
> Do you have a reproducer or was this found by code review only?
That's indeed a nice catch from Joanne!.
I would have expected that writing to a file and in parallel truncating
it would leak WritebackTmp in /proc/meminfo. But I see it going up and
always to 0 again.
Thanks,
Bernd
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] fuse: update stats for pages in dropped aux writeback list
2024-08-21 18:26 ` Bernd Schubert
@ 2024-08-21 20:22 ` Joanne Koong
2024-08-22 10:54 ` Miklos Szeredi
0 siblings, 1 reply; 10+ messages in thread
From: Joanne Koong @ 2024-08-21 20:22 UTC (permalink / raw)
To: Bernd Schubert; +Cc: Miklos Szeredi, linux-fsdevel, josef, kernel-team
On Wed, Aug 21, 2024 at 11:26 AM Bernd Schubert
<bernd.schubert@fastmail.fm> wrote:
>
>
>
> On 8/21/24 17:56, Miklos Szeredi wrote:
> > On Mon, 19 Aug 2024 at 20:25, Joanne Koong <joannelkoong@gmail.com> wrote:
> >>
> >> In the case where the aux writeback list is dropped (eg the pages
> >> have been truncated or the connection is broken), the stats for
> >> its pages and backing device info need to be updated as well.
> >
> > Patch looks good. Thanks.
> >
> > Do you have a reproducer or was this found by code review only?
Hi Miklos!
I unfortunately don't have a repro, this was found by code review. I
started looking at the writeback code after reading through this
thread
https://lore.kernel.org/all/495d2400-1d96-4924-99d3-8b2952e05fc3@linux.alibaba.com/#t
For v2 of this patchset, I am planning to add a few more refactoring
patches like abstracting out the shared logic between
fuse_writepages_fill() and fuse_writepage_locked(). My plan is to
submit v2 this week.
>
> That's indeed a nice catch from Joanne!.
>
> I would have expected that writing to a file and in parallel truncating
> it would leak WritebackTmp in /proc/meminfo. But I see it going up and
> always to 0 again.
I think we only hit this leaked case when we're writing back to a page
that is already in writeback (which then leads it to being placed on
the auxiliary list). I think in your example, the page isn't already
in writeback?
>
>
> Thanks,
> Bernd
Thanks,
Joanne
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] fuse: update stats for pages in dropped aux writeback list
2024-08-21 20:22 ` Joanne Koong
@ 2024-08-22 10:54 ` Miklos Szeredi
0 siblings, 0 replies; 10+ messages in thread
From: Miklos Szeredi @ 2024-08-22 10:54 UTC (permalink / raw)
To: Joanne Koong; +Cc: Bernd Schubert, linux-fsdevel, josef, kernel-team
On Wed, 21 Aug 2024 at 22:22, Joanne Koong <joannelkoong@gmail.com> wrote:
> I unfortunately don't have a repro, this was found by code review. I
> started looking at the writeback code after reading through this
> thread
> https://lore.kernel.org/all/495d2400-1d96-4924-99d3-8b2952e05fc3@linux.alibaba.com/#t
No problem, I was just curious.
Thanks,
Miklos
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2024-08-22 10:54 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-19 18:24 [PATCH 1/2] fuse: drop unused fuse_mount arg in fuse_writepage_finish Joanne Koong
2024-08-19 18:24 ` [PATCH 2/2] fuse: update stats for pages in dropped aux writeback list Joanne Koong
2024-08-20 2:10 ` Jingbo Xu
2024-08-20 18:21 ` Joanne Koong
2024-08-21 15:56 ` Miklos Szeredi
2024-08-21 18:26 ` Bernd Schubert
2024-08-21 20:22 ` Joanne Koong
2024-08-22 10:54 ` Miklos Szeredi
2024-08-20 1:53 ` [PATCH 1/2] fuse: drop unused fuse_mount arg in fuse_writepage_finish Jingbo Xu
2024-08-20 18:19 ` Joanne Koong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).