[Samba] A samba locking question
Patrik.Gustavsson at Sun.COM
Tue Feb 10 08:39:01 GMT 2004
Well, you should know.
But if Samba is doing byte ranged lock using fcntl, then
I don't understand why my tests failed.
The first test I did was:
I simulated a NFS client and did byte range lock on a file,
a document in this case 8K in size, and tried to open that from
client using Samba and it failed becuse is was locked.
The second test I did was:
When a client opened the file using samba, with a
DENY_WRITE lock (output from smbstatus) and I used the same simulated
NFS client that did a byte range write lock using fcntl() on that
I would assume that the byte range lock would fail, but it didn't it
That surprised me.
The third test I did on my Solaris box was:
I wrote a 'new' fcntl() function and that was preloaded when smbd was
started. This 'new' function call logged all fcntl-calls before it
called the real fcntl() call and returned the result.
I opened the file from the client and tracked the filedesriptor for
the opened file in /proc and compared with logging information from
the fcntl calls.
The only fcntl calls for that file was that smbd was asking for F_GETLK
That lead me to the fact that smbd is not doing any byte range locks
Mayby I am wrong, but I can't where.
On Tue, 2004-02-10 at 08:15, Jeremy Allison wrote:
> On Tue, Feb 10, 2004 at 07:46:11AM +0100, Patrik Gustavsson wrote:
> > Yes, your are wright. But Samba will not
> > do a byte ranged lock using fcntl() on the file
> > when lock range is below 2^31 as stated in the docs.
> No, you've got it wrong (I *wrote* the mapping code). Samba checks
> a lock request against the internal 64-bit unsigned locking database.
> If that lock request would be granted (no other Windows locks
> conflict) then it tries to map the 64-bit unsigned Windows
> lock onto either (a) a 64-bit signed POSIX lock or (b) a 32-bit
> signed POSIX lock (depending on what the underlying UNIX supports).
> If it can also get that lock then the lock is granted, if not
> then it rolls back the lock entry in the internal Windows
> locking database and returns a lock error to the client.
> It can be complicated by the fact there is a parameter to
> tell Samba whether to map onto POSIX locks or not, and also
> a client may ask for a blocking lock which may delay the
"In a world without fences who needs Gates"
Patrik Gustavsson, Senior Technical Consultant
patrik.gustavsson at sun.com Telephone: +46 60 671540
http://glen.sweden Mobile: +46 70 3551040
SUN MICROSYSTEMS Fax: +46 60 671550
More information about the samba