On Fri, Aug 4, 2017 at 9:10 PM, Nikolaus Rath <Nikolaus@xxxxxxxx> wrote: > Hello, > > I am confused about how O_APPEND is supposed to interact with the > writeback cache. > > As far as I can tell, the O_APPEND flag is currently passed to the > filesystem process, so my expectation is that the filesystem process is > responsible for ignoring any offset in write requests and instead write > at the current end of the file[1]. > > However, with writeback cache enabled the filesystem process cannot tell > which data is "new" and came from userspace, should be appended, and > which data is old and just made a round-trip to the kernel. So it seems > to me that the filesystem process should probably leave the handling of > O_APPEND to the kernel. But then, shouldn't the kernel filter out this > flag when sending the open request? Indeed, when writing back the cache the kernel should definitely not set O_APPEND. > > On the other hand, when the kernel handles O_APPEND, then it is no > longer atomic (think of a network fuse filesystem). Yes, network filesystem generally needs to handle consistency of caches across nodes and O_APPEND in no exception (i.e. you cannot have two nodes writing O_APPEND to cache at the same time, because that will not work). Thanks, Miklos