From 10bd6b32965265688fa277d166ab224de8e86eb2 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Wed, 26 Aug 2026 16:11:59 +0200 Subject: [PATCH] fuse: fall back to copy_splice_read() on FOPEN_DIRECT_IO Yafang Shao reports: "After upgrading the kernel from 6.1.y to 6.18.y on production servers, some containers failed to read lxcfs data. The root cause is that our lxcfs is still at the old v3.0.4, which does not include commit 25982f5 ("Set the file size to 4k") [0]. Between 6.1.y and 6.18.y, the FUSE splice_read path was converted from generic_file_splice_read() to filemap_splice_read() by commit 2cb1e08985e3 ("splice: Use filemap_splice_read() instead of generic_file_splice_read()"). Unlike generic_file_splice_read(), filemap_splice_read() strictly checks i_size and refuses to read from zero-size files, which breaks virtual FUSE filesystems like the old lxcfs." Fix by using copy_splice_read() for the FOPEN_DIRECT_IO case, just like the VFS does for DAX and O_DIRECT files. Reported-by: Yafang Shao Closes: https://lore.kernel.org/all/20260706025705.58301-1-laoar.shao@gmail.com/ Reported-by: Changyuan Lyu Closes: https://lore.kernel.org/all/20260901213412.1763253-1-changyuanl@google.com/ Fixes: 2cb1e08985e3 ("splice: Use filemap_splice_read() instead of generic_file_splice_read()") Tested-and-acked-by: Yafang Shao Signed-off-by: Miklos Szeredi --- fs/fuse/file.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 368664acb43a..4bdf5dec2cb9 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1876,7 +1876,10 @@ static ssize_t fuse_splice_read(struct file *in, loff_t *ppos, struct fuse_file *ff = in->private_data; /* FOPEN_DIRECT_IO overrides FOPEN_PASSTHROUGH */ - if (fuse_file_passthrough(ff) && !(ff->open_flags & FOPEN_DIRECT_IO)) + + if (ff->open_flags & FOPEN_DIRECT_IO) + return copy_splice_read(in, ppos, pipe, len, flags); + else if (fuse_file_passthrough(ff)) return fuse_passthrough_splice_read(in, ppos, pipe, len, flags); else return filemap_splice_read(in, ppos, pipe, len, flags);