Re: [PATCH v2 1/2] fuse: preserve FOPEN_PARALLEL_DIRECT_WRITES for passthrough opens

From: Amir Goldstein

Date: Tue Jun 16 2026 - 07:09:50 EST


On Tue, Jun 16, 2026 at 3:44 AM Russ Fellows <russ.fellows@xxxxxxxxx> wrote:
>
> From: Russ Fellows <rfellows@xxxxxxxxxx>
>
> fuse_file_io_open() currently strips FOPEN_PARALLEL_DIRECT_WRITES whenever FOPEN_DIRECT_IO is absent. That rule is correct for the regular direct-IO path, but it is too strict for passthrough opens.
>
> Passthrough I/O already bypasses the page cache through the backing file, so it does not need FOPEN_DIRECT_IO to preserve direct-I/O semantics. Clearing the parallel-write flag for passthrough opens causes the kernel to drop the server's request for parallel direct writes before the passthrough write path ever sees it.
>
> Keep FOPEN_PARALLEL_DIRECT_WRITES for opens that also carry FOPEN_PASSTHROUGH, and continue to clear it for non-passthrough opens that lack FOPEN_DIRECT_IO.
>
> This is a prerequisite for passthrough write parallelism: without it, the subsequent shared-lock path never activates.
>
> Signed-off-by: Russ Fellows <rfellows@xxxxxxxxxx>
> ---
> fs/fuse/iomode.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/fs/fuse/iomode.c b/fs/fuse/iomode.c
> index c99e285f3..0301a48d8 100644
> --- a/fs/fuse/iomode.c
> +++ b/fs/fuse/iomode.c
> @@ -216,9 +216,12 @@ int fuse_file_io_open(struct file *file, struct inode *inode)
> goto fail;
>
> /*
> - * FOPEN_PARALLEL_DIRECT_WRITES requires FOPEN_DIRECT_IO.
> + * FOPEN_PARALLEL_DIRECT_WRITES requires FOPEN_DIRECT_IO, except for
> + * passthrough opens which bypass the page cache regardless and do not
> + * need FOPEN_DIRECT_IO to guarantee direct I/O semantics.

That's a very round about way to say FOPEN_PARALLEL_DIRECT_WRITES requires
open in either direct_io or passthrough mode, but an even better way
of saying this:

#define FOPEN_IOMODE(oflags) ((oflags & (FOPEN_DIRECT_IO | FOPEN_PASSTHROUGH))
#define FOPEN_IOMODE_IS_CACHED(oflags) (FOPEN_IOMODE(oflags) == 0)
#define FOPEN_IOMODE_IS_DIRECT(oflags) (FOPEN_IOMODE(oflags) & FOPEN_DIRECT_IO)
#define FOPEN_IOMODE_IS_PASSTHRPUGH(oflags) (FOPEN_IOMODE(oflags) ==
FOPEN_PASSTHROUGH)

> */
> - if (!(ff->open_flags & FOPEN_DIRECT_IO))
> + if (!(ff->open_flags & FOPEN_DIRECT_IO) &&
> + !(ff->open_flags & FOPEN_PASSTHROUGH))

/* FOPEN_PARALLEL_DIRECT_WRITES is not supported with cached iomode */
if (FOPEN_IOMODE_IS_CACHED(ff->open_flags))
ff->open_flags &= ~FOPEN_PARALLEL_DIRECT_WRITES;

...
if (FOPEN_IOMODE_IS_DIRECT(ff->open_flags))
return 0;

if (FOPEN_IOMODE_IS_PASSTHROUGH(ff->open_flags))
err = fuse_file_passthrough_open(inode, file);
else
err = fuse_file_cached_io_open(inode, ff);

or some variation of this which makes those modes and comments easier
to understand.

Thanks,
Amir.