[PATCH] flock() files even with a permissive share mode.
jra at samba.org
Wed Feb 6 22:44:01 UTC 2019
On Wed, Feb 06, 2019 at 05:38:11PM -0500, J. Bruce Fields via samba-technical wrote:
> On Wed, Feb 06, 2019 at 02:01:31PM -0800, Jeremy Allison wrote:
> > On Wed, Feb 06, 2019 at 04:15:06PM -0500, J. Bruce Fields via samba-technical wrote:
> > > On Wed, Feb 06, 2019 at 09:26:09PM +0100, Volker Lendecke wrote:
> > > > On Wed, Feb 06, 2019 at 03:13:28PM -0500, J. Bruce Fields via samba-technical wrote:
> > > > > I could help write up or compile some sort of "introduction to NFS
> > > > > locking for SMB developers". NFSv4 has byte-range locks, share locks,
> > > > > and delegations, you're interested in all three?
> > > >
> > > > Very much so. For a start:
> > > >
> > > > brlocks == brlocks (how similar are they to Posix in NFS?)
> > >
> > > Right. They're the same as posix locks, so the documentation under
> > > "Advisory record locking" in the fcntl(2) man page should all apply.
> > > They're fully implemented and commonly used on both the client and
> > > server side.
> > Quick comment. SMB2+ (and Samba) implements F_OFD locks
> > these days which have slightly different semantics to
> > standard POSIX locks (i.e. locks on a different file
> > descriptor from the same process can conflict). Does
> > NFSv4+ make any allowances for OFD locks these days ?
> The Linux client supports OFD locks. No changes are required to NFS
> servers or to the NFS protocol. The server doesn't know which kind of
> locks (traditional POSIX or OFD) you're using, the differences are all
> in "who" the client chooses to tell you owns each lock.
Cool - that's pretty much the way Windows/OFD locks work
in Samba also. In SMB2+ the owner (lock context in SMB2
parlance) is set to be the persistent part of the file
handle. In SMB1 the client sets the owner, so can chose
between POSIX/OFD semantics. The Linux SMB1/CIFS client
does this correctly for OFD locks, the libsmbclient code
doesn't for the SMB1 UNIX extensions (it uses calling process
pid for lock context) but the good news is that no code
out there in the wild could use that API (it's internal only
and not exposed from libsmbclient).
More information about the samba-technical