Are moves within a Samba share atomic? - SMB
This is a discussion on Are moves within a Samba share atomic? - SMB ; Hi, all. I've got a question about moving files from one location to
another within a Samba share.
I've got 2 boxes that I'm dealing with - 1 Linux box, where the Samba
share lives (running Samba 3.0.10), and a ...
-
Are moves within a Samba share atomic?
Hi, all. I've got a question about moving files from one location to
another within a Samba share.
I've got 2 boxes that I'm dealing with - 1 Linux box, where the Samba
share lives (running Samba 3.0.10), and a Windows box, which mounts the
share. For the sake of illustration, let's say that the Windows box
mounts it at Z:\, and there are an \outcoming and a \stage directory.
If the Windows box creates a file at one location
(Z:\stage\somefile.txt), and then the Windows box moves that file to
another location (Z:\outgoing\somefile.txt), is that move atomic? It's
within the same filesystem, and if it were done on the Linux box, it
would be - but I don't know how Samba handles it.
As you might imagine, I'm trying to avoid a race condition, with a file
created by a process on the Windows box being processed by another
process on the Linux box. If the operation's not atomic, I'll have the
process create something like a somefile.txt.done file after the file
is in place, and have the Linux process look for that, but if I don't
have to, I won't.
Thanks,
Rich
-
Re: Are moves within a Samba share atomic?
On Sat, 17 Jun 2006 04:40:25 -0700, richorama wrote:
> If the Windows box creates a file at one location (Z:\stage\somefile.txt),
> and then the Windows box moves that file to another location
> (Z:\outgoing\somefile.txt), is that move atomic? It's within the same
> filesystem, and if it were done on the Linux box, it would be - but I
> don't know how Samba handles it.
Yes, if they're on the same filesystem they're atomic. Underneath
the covers Samba calls the POSIX rename() system call.
If they're not on the same mounted filesystem (and note this isn't
the same as an exported share point) then Samba has to do a copy
and delete.
Jeremy.
-
Re: Are moves within a Samba share atomic?
Jeremy Allison wrote:
> Yes, if they're on the same filesystem they're atomic. Underneath
> the covers Samba calls the POSIX rename() system call.
>
> If they're not on the same mounted filesystem (and note this isn't
> the same as an exported share point) then Samba has to do a copy
> and delete.
Thanks! I figured this was the case, but didn't want to proceed until
I was sure.
Rich