From fa625f8622651a9acc9cf48a796153717c027e7a Mon Sep 17 00:00:00 2001 From: Paul Lawrence Date: Wed, 15 Nov 2023 14:29:23 -0800 Subject: [PATCH] BACKPORT: ANDROID: fuse-bpf: Ignore readaheads unless they go to the daemon readpages will be triggered on the fuse fs in passthrough mode though system calls like fadvise. If the daemon isn't aware of the file, this will likely cause a hang. For the moment, simply ignore fadvise in this situation Bug: 301201239 Test: fuse_test, atest ScopedStorageDeviceTest both pass Signed-off-by: Paul Lawrence (cherry picked from https://android-review.googlesource.com/q/commit:ac9071df3ba6715219a16a44d4711f041b0c25de) Merged-In: I524a84aeeb1b1593e51264fcc37f7cfa66757168 Change-Id: I524a84aeeb1b1593e51264fcc37f7cfa66757168 --- fs/fuse/file.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index ac3b4e9f5668..cad73bad9c90 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1033,6 +1033,19 @@ static int fuse_readpages_fill(void *_data, struct page *page) struct inode *inode = data->inode; struct fuse_conn *fc = get_fuse_conn(inode); +#ifdef CONFIG_FUSE_BPF + /* + * Currently no meaningful readahead is possible with fuse-bpf within + * the kernel, so unless the daemon is aware of this file, ignore this + * call. + */ + if (!get_fuse_inode(inode)->nodeid) + return -EIO; +#endif + + if (fuse_is_bad(inode)) + return -EIO; + fuse_wait_on_page_writeback(inode, page->index); if (ap->num_pages &&