From: John Groves <john@groves.net>
To: Miklos Szeredi <miklos@szeredi.hu>, Amir Goldstein <amir73il@gmail.com>
Cc: "T.J. Mercier" <tjmercier@google.com>,
Shai Barack <shayba@google.com>,
fuse-devel@lists.linux.dev, linux-kernel@vger.kernel.org,
Aravind Ramesh <arramesh@micron.com>
Subject: [PATCH] fuse: handle extent map files in fuse_passthrough_fadvise()
Date: Thu, 22 Oct 2026 18:47:47 -0500 [thread overview]
Message-ID: <atqdWUCzGxs3wwXw@groves.net> (raw)
This addresses a collision between the pending backing_file fadvise
patch and the new extent-mapping code for famfs (which falls into the
passthrough bucket.
A file opened with FOPEN_PASSTHROUGH on an extent map backing has no
backing file: fuse_passthrough_open() returns before setting
ff->passthrough and ff->cred. fuse_file_fadvise() routes every
FOPEN_PASSTHROUGH file to fuse_passthrough_fadvise(), which installed
the NULL ff->cred on the task with override_creds() and then passed the
NULL backing file to vfs_fadvise(). Any posix_fadvise(), readahead()
or madvise(MADV_WILLNEED) on such a file oopsed. fio triggers it at
file open with its default invalidate and fadvise_hint settings.
Fall back to generic_fadvise() when there is no backing file, as the
other passthrough helpers fall back to their extent map or generic
implementations. generic_fadvise() already ignores advice on DAX
inodes while keeping the EINVAL and ESPIPE checks.
Reported-by: Aravind Ramesh <arramesh@micron.com>
Fixes: 69f77a06ffad ("fuse: Forward vfs_fadvise to backing_file in passthrough mode")
Tested-by: John Groves <john@groves.net>
Signed-off-by: John Groves <john@groves.net>
---
fs/fuse/file.c | 2 +-
fs/fuse/fuse_i.h | 2 +-
fs/fuse/passthrough.c | 6 +++++-
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index da73d1e183c4..eb5ae11b6010 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -3129,7 +3129,7 @@ static int fuse_file_fadvise(struct file *file, loff_t offset, loff_t len, int a
struct fuse_file *ff = file->private_data;
if (fuse_is_passthrough(ff))
- return fuse_passthrough_fadvise(ff, offset, len, advice);
+ return fuse_passthrough_fadvise(file, offset, len, advice);
return generic_fadvise(file, offset, len, advice);
}
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 311252eef2e9..c91af283aef2 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -1368,7 +1368,7 @@ ssize_t fuse_passthrough_splice_write(struct pipe_inode_info *pipe,
struct file *out, loff_t *ppos,
size_t len, unsigned int flags);
ssize_t fuse_passthrough_mmap(struct file *file, struct vm_area_struct *vma);
-int fuse_passthrough_fadvise(struct fuse_file *ff, loff_t offset, loff_t len, int advice);
+int fuse_passthrough_fadvise(struct file *file, loff_t offset, loff_t len, int advice);
#ifdef CONFIG_SYSCTL
extern int fuse_sysctl_register(void);
diff --git a/fs/fuse/passthrough.c b/fs/fuse/passthrough.c
index 1c1cf1085c9c..0ed964c479d9 100644
--- a/fs/fuse/passthrough.c
+++ b/fs/fuse/passthrough.c
@@ -159,12 +159,16 @@ ssize_t fuse_passthrough_mmap(struct file *file, struct vm_area_struct *vma)
return backing_file_mmap(backing_file, vma, &ctx);
}
-int fuse_passthrough_fadvise(struct fuse_file *ff, loff_t offset, loff_t len, int advice)
+int fuse_passthrough_fadvise(struct file *file, loff_t offset, loff_t len, int advice)
{
+ struct fuse_file *ff = file->private_data;
struct file *backing_file = fuse_file_passthrough(ff);
const struct cred *old_cred;
int ret;
+ if (!backing_file)
+ return generic_fadvise(file, offset, len, advice);
+
old_cred = override_creds(ff->cred);
ret = vfs_fadvise(backing_file, offset, len, advice);
revert_creds(old_cred);
--
2.56.0
reply other threads:[~2026-10-22 23:47 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=atqdWUCzGxs3wwXw@groves.net \
--to=john@groves.net \
--cc=amir73il@gmail.com \
--cc=arramesh@micron.com \
--cc=fuse-devel@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=shayba@google.com \
--cc=tjmercier@google.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 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®