Re: Question : are concurrent write() calls with O_APPEND on local files atomic ?

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

 



On Wed, 2009-08-19 at 20:10 -0600, Andreas Dilger wrote:
> On Aug 19, 2009  09:17 -0400, Josef Bacik wrote:
> > > - does this guarantee also hold for remote filesystems (nfs / smb) ?
> > 
> > This I'm more likely to be wrong on, but I don't think so.  It would be atomic
> > on the local machine, but if there is somebody else on another machine writing
> > to the same file I think you would probably be screwed.
> 
> With NFS at least, there is absolutely no guarantee of any kind when
> multiple clients write to the same file, even with non-overlapping
> writes (i.e. no O_APPEND, but application seeks to different file
> offsets).  That is because an NFS client does not necessarily flush
> its local cache until it closes the file.

That's not the main problem. NFS clients can (and do) flush writes
immediately if you use O_DIRECT or synchronous writes.

The real issue is rather that the NFS protocol does not support an
atomic APPEND operation. Instead it requires the client to simulate
append semantics, by first retrieving the file size (so that it can
calculate the end-of-file offset) and then issuing the write. This means
that races with other clients can always occur unless they are using
some locking mechanism to prevent it.

I believe the same is true of CIFS.

Cheers
  Trond

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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