Re: Question about O_APPEND | O_DIRECT

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

 



>> 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





[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux