CIFS + NFS'ing a single filesystem w/ locking

Adam D. Morley adam-samba at gmi.com
Thu Jan 12 02:24:12 GMT 2006


Hi,

I sent the below two emails to the general inquiries list, but I didn't
get any replies.  I thought since I was discussing locking I might need
to post here.  The messages follow, my first post discussing Samba'ing
an NFS-exported UFS on Solaris, while my second email mentions an
attempt to get Samba to honor/see locks made on a Linux host's console.

Summary: locking doesn't seem to work.  I may be doing something wrong.
If so, what?  smb.conf is included for both hosts, in addition to
references to the code in OpenOffice's source tree.

Thanks a bunch!

----- Forwarded message from "Adam D. Morley" <adam-samba at gmi.com> -----
I have a Solaris 10 server exporting UFS directories using built-in NFS.
I've built Samba 3.0.20b from OpenPKG (www.openpkg.org).  I have a
Solaris 10 (x86) client mounting the NFS share and opening OpenDocument
files using StarOffice 8 (SO8, aka OO2.0).  I also have a Windows 2003
Terminal Server mounting the Samba share and opening documents with SO8.
This is a temporary development environment, so I can screw around with
it.  I have a similar, production environment using RHEL3 (clients) and
Solaris 9 (server), with no Samba.  Ie: I would like to export NFS
shares as CIFS shares using Samba.  But: I want file locking.

StarOffice 8/OO2.0 support file locking, whereby the first user to open 
a file will place a lock* on the file, and the other users will get a 
read-only file.  This works fine with NFS & nlockmgr (cross platform, 
linux/solaris).  However, when I add Samba to the mix, it doesn't seem 
to see the locks.  I am under the impression this is because Solaris 
does not support kernel oplocks.  Here is my smb.conf:

---smb.conf---
[global]
workgroup = test
security = share
 
[shared]
path = /export/home/shared
read only = No
guest ok = yes
locking = yes [I've tried leaving this out]
kernel oplocks = yes [I've tried this as yes and left it out]
oplocks = yes [I've tried not setting this, and diff combinations with locking]
level2 oplocks = no [I've tried not setting this]
---smb.conf

I also attempted to NFS mount the share from a RHEL3 box (which should
support kernel oplocks) and then share it back out with Samba.  Locks do
not work here either (yes, I had anon and root properally set).  I would 
think that the kernel oplock code in RHEL3's kernel would allow the locks 
to propegate down from Samba, and back out to the NFS server using lockd.
It could also be that my understanding of what a "lock" is is not
exactly correct.  Ie: NFS lock != Samba lock.  I have some indication of
this based on the locking directory that exists for Samba, and the fact
that lock on Windows is not implemented the same way as on UNIX.

The specific symptoms of the lock not working are the following:

- a file first opened on the solaris client will yield a "file type"
selection box on the windows box (a sign that windows can't read the file,
and a sign it is seeing some kind of lock)
- a file first opened on the windows side, and then opened on the
solaris client side will show read/write status on both clients
	- if the windows client then tries to save, it will get an I/O
error (so it must be seeing some kind of lock...)
	- if the solaris client tries to save, it can save fine, not
being informed that another user has the file open

This is obviously somewhat problmatic!  Am I totally missing something
here, or does NFS/CIFS file locking simply not work?  I seem to remember
reading somewhere that NFS/CIFS from a Linux host works fine, and that
NFS/CIFS on other systems won't work (save IRIX) because they don't have
kernel oplock support for Samba.

So: have I done something wrong, or is this "the way things are?"

OR: Is it that the type of lock placed on the file when *nix OO2.0 opens
a file is incompatible with the type of lock Samba thinks is "ok" wrt
oplocks in the Samba code?

*: It looks like lock type is a F_WRLCK on *nix, and a "dwAccess |=
GENERIC_WRITE" for win32, based on my cursory, vastly under-knowledged
reading of the OpenOffice 2.0 source code (sal/osl/unx/file.cxx and
sal/osl/w32/file.cxx).  Line 2450 in w32/file.cxx, line 548 in
unx/file.cxx.
----- End forwarded message -----
----- Forwarded message from "Adam D. Morley" <adam-samba at gmi.com> -----
On Fri, Jan 06, 2006 at 06:24:22PM -0800, Adam D. Morley wrote:
> Hi,
> 
> I have a Solaris 10 server exporting UFS directories using built-in NFS.
> I've built Samba 3.0.20b from OpenPKG (www.openpkg.org).  I have a
> Solaris 10 (x86) client mounting the NFS share and opening OpenDocument
> files using StarOffice 8 (SO8, aka OO2.0).  I also have a Windows 2003
> Terminal Server mounting the Samba share and opening documents with SO8.
> This is a temporary development environment, so I can screw around with
> it.  I have a similar, production environment using RHEL3 (clients) and
> Solaris 9 (server), with no Samba.  Ie: I would like to export NFS
> shares as CIFS shares using Samba.  But: I want file locking.
[snip]

I did some further testing.  If a file is opened with StarOffice 8 on
the console of a Linux machine (from an ext3 filesystem), thereby
write-locking the file, Samba cannot read the file anymore, even though
other clients logged into the machine can, albeit seeing the write lock
properally.  Here is smb.conf:

[global]
workgroup = test
security = share
  
[shared2]
path = /shared2
read only = No
guest ok = yes
kernel oplocks = Yes
locking = Yes
oplocks = Yes
level2 oplocks = No

In what context does locking actually work with Samba?  Is it only for
clients reading through the CIFS filesystem, or is there some magic
trick to make Samba see write locks from the UNIX side on the Windows
side?  I thought I read that one could export a directory with Samba and
have it honor UNIX-side locks?  What am I doing wrong?
----- End forwarded message -----

Again, thanks.
-- 
adam


More information about the samba-technical mailing list