All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tao Lyu <tao.lyu@epfl.ch>
To: Trond Myklebust <trondmy@hammerspace.com>,
	"linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>
Subject: Re: Question about O_APPEND | O_DIRECT
Date: Mon, 27 Nov 2023 15:28:16 +0000	[thread overview]
Message-ID: <7d2d17e4d3904d29b75fadcfd916b2a3@epfl.ch> (raw)
In-Reply-To: <2d948b43fa625952e50589e4bedf9551df7ee112.camel@hammerspace.com>

>> Hi,
>> 
>> Sorry to bother you here.
>> 
>> I'm using NFS and realize it doesn't support opening a file with
>> "O_DIRECT | O_APPEND".
>> 
>> After checking the source code, 
>> I found it has one function that checks explicitly whether there is a
>> combination flag of "O_APPEND | O_DIRECT".
>> If so, it will return invalid arguments.
>> 
>> int nfs_check_flags(int flags)
>> {
>>     if ((flags & (O_APPEND | O_DIRECT)) == (O_APPEND | O_DIRECT))
>>         return -EINVAL;
>> 
>>     return 0;
>> }
>> 
>> But I don't understand why NFS doesn't support this flag combination.
>> I'd appreciate it if someone could explain this to me.
>
>
> Why do you need O_APPEND|O_DIRECT?
>
> In order to implement O_APPEND|O_DIRECT, we would need to add an APPEND
> operation, which does not exist in the NFS protocol. The WRITE
> operation does not suffice, because it requires you to know the offset
> at which you will be writing the data.

Hi Trond,

Thank you so much for your reply.

O_APPEND | O_DIRECT can be used to bypass the client cache for multiple threads writing data without caring of the orders (e.g., logs).

Yes, to support O_APPEND | O_DIRECT, NFS must first support APPEND.
But the key point is that looks like NFS has supported O_APPEND already.
I can successfully open a file with "O_RDWR|O_APPEND".

My confusion is why NFS supports O_RDWR and O_APPEND individually but does not support this combination.

Thank you in advance for helping me.

Best,
Tao

  reply	other threads:[~2023-11-27 15:28 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-23 18:14 Question about O_APPEND | O_DIRECT Tao Lyu
2023-11-25 23:54 ` Trond Myklebust
2023-11-27 15:28   ` Tao Lyu [this message]
2023-11-27 16:36     ` Christoph Hellwig
2023-11-27 16:41       ` Tao Lyu
2023-11-27 16:50       ` Chuck Lever III
2023-11-27 16:55         ` Christoph Hellwig
2023-11-27 16:59           ` Chuck Lever III
2023-11-28 13:06             ` Christoph Hellwig
2023-11-28  1:50         ` Rick Macklem
2023-11-28 13:09           ` Christoph Hellwig
2023-11-28 18:28             ` Trond Myklebust
2023-11-27 17:08       ` Trond Myklebust
2023-11-27 17:19         ` hch
2023-11-27 17:23           ` Tao Lyu

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=7d2d17e4d3904d29b75fadcfd916b2a3@epfl.ch \
    --to=tao.lyu@epfl.ch \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trondmy@hammerspace.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.