Moazam Raja
2010-Sep-22 17:22 UTC
[zfs-discuss] ZFS COW and simultaneous read & write of files
Hi all, I have a ZFS question related to COW and scope. If user A is reading a file while user B is writing to the same file, when do the changes introduced by user B become visible to everyone? Is there a block level scope, or file level, or something else? Thanks!
Neil Perrin
2010-Sep-22 18:30 UTC
[zfs-discuss] ZFS COW and simultaneous read & write of files
On 09/22/10 11:22, Moazam Raja wrote:> Hi all, I have a ZFS question related to COW and scope. > > If user A is reading a file while user B is writing to the same file, > when do the changes introduced by user B become visible to everyone? > Is there a block level scope, or file level, or something else? > > Thanks! >Assuming the user is using read and write against zfs files. ZFS has reader/writer range locking within files. If thread A is trying to read the same section that thread B is writing it will block until the data is written. Note, written in this case means written into the zfs cache and not to the disks. If thread A requires that changes to the file be stable (on disk) before reading it can use the little known O_RSYNC flag. Neil.
Nicolas Williams
2010-Sep-22 18:57 UTC
[zfs-discuss] ZFS COW and simultaneous read & write of files
On Wed, Sep 22, 2010 at 12:30:58PM -0600, Neil Perrin wrote:> On 09/22/10 11:22, Moazam Raja wrote: > >Hi all, I have a ZFS question related to COW and scope. > > > >If user A is reading a file while user B is writing to the same file, > >when do the changes introduced by user B become visible to everyone? > >Is there a block level scope, or file level, or something else? > > > >Thanks! > > Assuming the user is using read and write against zfs files. > ZFS has reader/writer range locking within files. > If thread A is trying to read the same section that thread B is > writing it will > block until the data is written. Note, written in this case means > written into the zfs > cache and not to the disks. If thread A requires that changes to the > file be stable (on disk) > before reading it can use the little known O_RSYNC flag.That''s assuming local access (i.e., POSIX semantics). It''s different if NFS is involved (because of NFS'' close-to-open semantics). It might be different if SMB is involved (dunno). Nico --