From: Liu Kui <kui.liu@virtuozzo.com>
To: Konstantin Khorenko <khorenko@virtuozzo.com>
Cc: azaitsev@virtuozzo.com, devel@openvz.org,
Liu Kui <kui.liu@virtuozzo.com>
Subject: [Devel] [PATCH hci-8.0 2/2] fs/fuse: unify dropping the fuse file reference of a writeback request
Date: Wed, 23 Sep 2026 20:50:41 +0800 [thread overview]
Message-ID: <20260923-vstor-145614-unify-v1-2-3907084ba107@virtuozzo.com> (raw)
In-Reply-To: <20260923-vstor-145614-unify-v1-0-3907084ba107@virtuozzo.com>
The drop of the wpa's fuse file reference is split between two
functions: fuse_writepage_finish() puts it on close_wait mounts,
fuse_writepage_free() on !close_wait ones. The split requires that
every wpa owning a reference passes through fuse_writepage_finish()
before being freed on close_wait, an invariant silently broken by the
rebase to mainline commit 4046d3adcca4 ("fuse: move fuse file
initialization to wpa allocation time"), which makes every wpa own its
reference from allocation time. Then there are two cases where wpas
are freed without going through fuse_writepage_finish(): the temp page
swap case in fuse_writepage_add() and the killed aux request chain in
fuse_send_writepage(), leaking ff->count, so fuse_release() can hang
forever waiting for ff->count to drain.
Fix the leak by dropping the split: release the reference
unconditionally in fuse_writepage_free(), which every wpa death path
passes exactly once, via fuse_release_ff(), which already handles the
close_wait accounting. The allocation-time ownership model of the
mainline commit stays unmodified, which additionally keeps an aux
wpa's args->ff pinned between creation and promotion.
https://virtuozzo.atlassian.net/browse/VSTOR-145614
Signed-off-by: Liu Kui <kui.liu@virtuozzo.com>
---
fs/fuse/file.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 180f60fc539a..0a7c6d03b13d 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -2181,7 +2181,6 @@ static ssize_t fuse_splice_write(struct pipe_inode_info *pipe, struct file *out,
static void fuse_writepage_free(struct fuse_writepage_args *wpa)
{
struct fuse_args_pages *ap = &wpa->ia.ap;
- struct fuse_conn *fc = wpa->ia.ff->fm->fc;
int i;
if (wpa->bucket)
@@ -2190,8 +2189,7 @@ static void fuse_writepage_free(struct fuse_writepage_args *wpa)
for (i = 0; i < ap->num_pages; i++)
__free_page(ap->pages[i]);
- if (wpa->ia.ff && !fc->close_wait)
- fuse_file_put(wpa->ia.ff, false);
+ fuse_release_ff(wpa->inode, wpa->ia.ff);
kfree(ap->pages);
kfree(wpa);
@@ -2211,12 +2209,8 @@ static void fuse_writepage_finish(struct fuse_writepage_args *wpa)
struct fuse_args_pages *ap = &wpa->ia.ap;
struct inode *inode = wpa->inode;
struct fuse_inode *fi = get_fuse_inode(inode);
- struct fuse_conn *fc = get_fuse_conn(inode);
int i;
- if (wpa->ia.ff && fc->close_wait)
- __fuse_file_put(wpa->ia.ff);
-
for (i = 0; i < ap->num_pages; i++)
fuse_writepage_finish_stat(inode, ap->pages[i]);
--
Git-155)
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-09-23 12:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 12:50 [Devel] [PATCH hci-8.0 0/2] " Liu Kui
2026-09-23 12:50 ` [Devel] [PATCH hci-8.0 1/2] Revert "fs/fuse: fix fuse file refcount leak on close_wait writeback" Liu Kui
2026-09-23 12:50 ` Liu Kui [this message]
2026-09-23 17:26 ` [Devel] [PATCH hci-8.0 2/2] fs/fuse: unify dropping the fuse file reference of a writeback request Konstantin Khorenko
2026-09-23 17:01 ` [Devel] [PATCH hci-8.0 0/2] " Konstantin Khorenko
2026-09-23 17:13 ` Konstantin Khorenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260923-vstor-145614-unify-v1-2-3907084ba107@virtuozzo.com \
--to=kui.liu@virtuozzo.com \
--cc=azaitsev@virtuozzo.com \
--cc=devel@openvz.org \
--cc=khorenko@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.