Re: [RFC PATCH] fuse: modification of FUSE passthrough call sequence

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2025-07-16 at 14:14 +0200, Amir Goldstein wrote:
> 
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
> 
> 
> On Wed, Jul 16, 2025 at 1:49 PM Qi Han <hanqi@xxxxxxxx> wrote:
> > 
> > Hi, Amir
> 
> Hi Qi,
> 
> > In the commit [1], performing read/write operations with DIRECT_IO
> > on
> > a FUSE file path does not trigger FUSE passthrough. I am unclear
> > about
> > the reason behind this behavior. Is it possible to modify the call
> > sequence to support passthrough for files opened with DIRECT_IO?
> 
> Are you talking about files opened by user with O_DIRECT or
> files open by server with FOPEN_DIRECT_IO?
> 
> Those are two different things.
> IIRC, O_DIRECT to a backing passthrough file should be possible.
> 
> > Thank you!
> > 
> > [1]
> > https://lore.kernel.org/all/20240206142453.1906268-7-amir73il@xxxxxxxxx/
> > 
> > Reported-by: Lei Liu <liulei.rjpt@xxxxxxxx>
> > Signed-off-by: Qi Han <hanqi@xxxxxxxx>
> > ---
> >  fs/fuse/file.c | 15 +++++++--------
> >  1 file changed, 7 insertions(+), 8 deletions(-)
> > 
> > diff --git a/fs/fuse/file.c b/fs/fuse/file.c
> > index 2ddfb3bb6483..689f9ee938f1 100644
> > --- a/fs/fuse/file.c
> > +++ b/fs/fuse/file.c
> > @@ -1711,11 +1711,11 @@ static ssize_t fuse_file_read_iter(struct
> > kiocb *iocb, struct iov_iter *to)
> >         if (FUSE_IS_DAX(inode))
> >                 return fuse_dax_read_iter(iocb, to);
> > 
> > -       /* FOPEN_DIRECT_IO overrides FOPEN_PASSTHROUGH */
> > -       if (ff->open_flags & FOPEN_DIRECT_IO)
> > -               return fuse_direct_read_iter(iocb, to);
> > -       else if (fuse_file_passthrough(ff))
> > +
> > +       if (fuse_file_passthrough(ff))
> >                 return fuse_passthrough_read_iter(iocb, to);
> > +       else if (ff->open_flags & FOPEN_DIRECT_IO)
> > +               return fuse_direct_read_iter(iocb, to);
> >         else
> >                 return fuse_cache_read_iter(iocb, to);
> >  }
> > @@ -1732,11 +1732,10 @@ static ssize_t fuse_file_write_iter(struct
> > kiocb *iocb, struct iov_iter *from)
> >         if (FUSE_IS_DAX(inode))
> >                 return fuse_dax_write_iter(iocb, from);
> > 
> > -       /* FOPEN_DIRECT_IO overrides FOPEN_PASSTHROUGH */
> > -       if (ff->open_flags & FOPEN_DIRECT_IO)
> > -               return fuse_direct_write_iter(iocb, from);
> > -       else if (fuse_file_passthrough(ff))
> > +       if (fuse_file_passthrough(ff))
> >                 return fuse_passthrough_write_iter(iocb, from);
> > +       else if (ff->open_flags & FOPEN_DIRECT_IO)
> > +               return fuse_direct_write_iter(iocb, from);
> >         else
> >                 return fuse_cache_write_iter(iocb, from);
> >  }
> > --
> 
> When server requests to open a file with FOPEN_DIRECT_IO,
> it affects how FUSE_READ/FUSE_WRITE requests are made.
> 
> When server requests to open a file with FOPEN_PASSTHROUGH,
> it means that FUSE_READ/FUSE_WRITE requests are not to be
> expected at all, so these two options are somewhat conflicting.
> 
> Therefore, I do not know what you aim to achieve by your patch.
> 
> However, please note this comment in iomode.c:
>  * A combination of FOPEN_PASSTHROUGH and FOPEN_DIRECT_IO
>    means that read/write
>  * operations go directly to the server, but mmap is done on the
> backing file.
> 
> So this is a special mode that the server can request in order to do
> passthrough mmap but still send FUSE_READ/FUSE_WRITE requests
> to the server.

Hi Amir,

In most cases, when using passthrough, the server shouldn't set
FOPEN_DIRECT_IO, since these two options are conceptually conflicting,
unless the server specifically wants this special mode (passthrough
mmap but still send r/w requests). Is that correct?

It can be confusing. Maybe the documentation could clarify this special
case, or the passthrough flags for mmap and r/w could be separate...

> 
> What is your use case? What are you trying to achieve that is not
> currently possible?
> 
> Thanks,
> Amir.
> 

Hi Qi,

I just notice that Android's FuseDaemon doesn't seem to recognize this
special mode. It sets both FOPEN_DIRECT_IO and FOPEN_PASSTHROUGH when
the user sets O_DIRECT and the server has passthrough enabled.

If that's your case, I think Android FuseDaemon may need some fixes.

Best,
Ed Tsai.




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux