[Samba] Problems with file locking over gnome-vfs (esp. OpenOffice.org)

Jeremy Allison jra at samba.org
Thu Oct 16 16:30:03 GMT 2008


On Thu, Oct 16, 2008 at 10:05:45AM +0200, Lars Erik Kolden wrote:
> Hi.
> 
> First of all, I will probably post this question several places, at
> least here, on the ubuntu forums, and perhaps OpenOffice forums. It is
> a problem that I'm not sure if really is samba related, Openoffice
> related or perhaps even OS related. As stated in the heading, it's
> about file locking, so many apps come into play.
> 
> I work at a school where we teachers use mainly Ubuntu Hardy and
> OpenOffice.org to edit files on samba shares on a Debian 4.0 box.
> Samba version is 3.0.24-6etch10. There are also some users using
> OpenOffice from XP, and some Mac users (both neooffice and OOo). The
> ubuntu clients mounts the samba share thru gnome-vfs (that is, GNOME
> desktop->places->connect to server->windows share).
> 
> The problem we have is that file locking between linux clients is not
> working. Users will write to the same files in the same shares
> simultaneously, causing data corruption and very angry users (yes, I
> find myself in a very tight spot now, and probably should get myself a
> copy of The Little Book of Calm).
> 
> On the other hand you have the XP users. If a document is opened in
> Ubuntu, the XP user will open the file in read only mode. The other
> way around, when opened first in XP, the OOo on the ubuntu client will
> show a "general internet error" and close. Looks stupid, but is better
> than data loss, so if this was the case between ubuntu clients as
> well, I'd be very happy.
> 
> I have tried turning secure locking off in samba, also to turn oplocks
> off (maybe they're the same?), but there's no difference. Also, I can
> find no lck files on the samba server, if there should be any.
> 
> Does anyone have any solutions to this, or some troubleshooting tips?
> There must be some way for samba to lock files, even if
> OpenOffice.org's file locking scheme is flawed?
> 
> Also, I read somewhere that maybe mounting the shares with cifs could
> work, but I'm not sure how to do that in gnome-vfs?

Ok, the reason it works between XP -> XP is that the XP clients
open with deny modes (not locking) that prevent two simultaneous
read/write opens.

The reason it works XP -> Linux is the same as the above. The
XP client opens with DENY_WRITE, the Linux client opens with
DENY_NONE - these modes conflict. Not a great error message,
from the Gnome VFS open, but there you go. Probably doesn't
know what to do with the lower level "sharing violation"
error from libsmbclient.

The one that bites is Linux -> Linux. This is because
the Gnome VFS has no locking primitives (not an expert
on Gnome VFS so people with more knowledge feel free
to contradict me).

So what happens is client1 opens with sharing mode
DENY_NONE (typical Unix open), client2 opens with
sharing mode DENY_NONE. There's no conflict.

Now when this happens on a local Linux filesystem
the OO clients do fcntl byte range locks after the
open to do exclusion, and to tell if there's another
client with this file open.

Over Gnome VFS those fcntl lock calls get dropped
on the floor - no way to remote them to the Samba
server.

The reason it works with CIFSFS is that CIFSFS
will remote those lock requests correctly.

So, get the local clients to mount the share
on a local directory, and then it should work
as the fcntl locks will get remoted for the Linux
clients, and the share modes will protect you
for the XP clients.

Without locking support in Gnome VFS I don't think
there's a way to properly do this using Gnome VFS.

Jeremy.


More information about the samba mailing list