mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: hanqi <hanqi@vivo.com>
To: Amir Goldstein <amir73il@gmail.com>, Ed.Tsai@mediatek.com
Cc: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, liulei.rjpt@vivo.com
Subject: Re: [RFC PATCH] fuse: modification of FUSE passthrough call sequence
Date: Thu, 17 Jul 2025 10:23:40 +0800	[thread overview]
Message-ID: <bd44135e-a86f-4556-8219-baa2f73c98c9@vivo.com> (raw)
In-Reply-To: <CAOQ4uxi5gwzkEYqpd+Bb825jwWME_AE0BNykZcownSz6OZjFWQ@mail.gmail.com>



在 2025/7/16 20:14, Amir Goldstein 写道:
> On Wed, Jul 16, 2025 at 1:49 PM Qi Han <hanqi@vivo.com> 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.

Hi, Amir
Thank you for your response. I am performing read/write operations on
a file under a FUSE path opened with O_DIRECT, using code similar to [1].
However, it seems that the FUSE daemon adds FOPEN_DIRECT_IO, as Ed
mentioned. I need to further investigate the FUSE daemon code to confirm
the reason behind this behavior.

[1]
fd_in = open(src_path, O_RDONLY | O_DIRECT);
fd_out = open(dst_path, O_WRONLY | O_CREAT | O_TRUNC | O_DIRECT, 0644);

Thanks,
Qi.

>> Thank you!
>>
>> [1]
>> https://lore.kernel.org/all/20240206142453.1906268-7-amir73il@gmail.com/
>>
>> Reported-by: Lei Liu <liulei.rjpt@vivo.com>
>> Signed-off-by: Qi Han <hanqi@vivo.com>
>> ---
>>   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.
>
> What is your use case? What are you trying to achieve that is not
> currently possible?
>
> Thanks,
> Amir.
>


  parent reply	other threads:[~2025-07-17  2:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-16 12:10 Qi Han
2025-07-16 12:14 ` Amir Goldstein
2025-07-17  1:35   ` Ed Tsai (蔡宗軒)
2025-07-17  6:15     ` Amir Goldstein
2025-07-17  2:23   ` hanqi [this message]
2025-07-17  6:16     ` Amir Goldstein

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=bd44135e-a86f-4556-8219-baa2f73c98c9@vivo.com \
    --to=hanqi@vivo.com \
    --cc=Ed.Tsai@mediatek.com \
    --cc=amir73il@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liulei.rjpt@vivo.com \
    --cc=miklos@szeredi.hu \
    /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®