Rsync and open files
scl at sasha.acc.Virginia.EDU
Mon Aug 2 20:42:04 GMT 2004
> anyone happen to know how NetApp's DataONTAP handles open files?
> On Aug 2, 2004, at 3:04 PM, Jim Salter wrote:
> > Rsync does not handle open files. Your operating system does. Either
> > the OS allows rsync access, or it doesn't. Quick crib sheet:
When rsync copies a file, it creates a temporary file with a new,
unused name. That way rsync never overwrites an existing file.
After the new file is written, then rsync renames it into place,
which unlinks (removes) the old file. This does not disturb any
processes that still have the old file open. Unix does not
destroy an unlinked file until all processes have closed it, so
you can usually remove a LOCAL file that processes have open without
causing any trouble. The system behaves just as if you waited until
all processes closed the file before removing it.
But we are talking about rsync and ONTAP, which means we are talking
Since NFS is stateless, ONTAP does not know which files NFS clients
have open. Each NFS client keeps track of which files it has open,
but does not know about files that other NFS clients have open.
If one process has a NFS file open and a second process ON THE SAME NFS
CLIENT unlinks the file, then the NFS client actually renames the file
to a name beginning with ".nfs" instead of telling the NFS server to
unlink it. The first process continues undisturbed, unaware that
the file has been renamed. When the first process closes the renamed
file, then the NFS client unlinks it by telling the NFS server to
unlink it. This behavior mimics LOCAL files. But alas, it doesn't
work across NFS clients.
If a process has a file open and a second process on a different
NFS client unlinks the file, then the NFS server unlinks the file.
This whips the rug out from under the first process. If it tries
to continue reading or writing the file, then it fails with
"Stale NFS handle" errors.
So if one NFS client has files open and you run rsync on a second
NFS client and it replaces those files, then the first NFS client
will get "stale NFS handle" errors whenever it tries to access an
open file that was unlinked out from under it.
Steve Losen scl at virginia.edu phone: 434-924-0640
University of Virginia ITC Unix Support
More information about the rsync