[PATCH] flock() files even with a permissive share mode.

Volker Lendecke Volker.Lendecke at SerNet.DE
Fri Feb 8 10:32:40 UTC 2019


On Thu, Feb 07, 2019 at 04:31:10PM -0500, J. Bruce Fields wrote:
> > > An NFS client can keep the delegation after it closes the file, I think
> > > of it as independent of any one open.
> > 
> > What is a delegation then? How is this referenced in the protocol?
> 
> You get a "delegation stateid" back from the open call that grants a
> delegation.  It's separate from the "open stateid" that's also returned.
> 
> When the server wants the delegation recalled, it sends the delegation
> stateid to identify the delegation.  And then the client also uses that
> stateid to return the delegation.
> 
> We basically only ever have one delegation per (client, file) pair.

Ok, that sounds promising. Do we have a user-space API for that? Take
such a delegation in user space and get asked if someone else wants
it? One thing I've been looking at is fanotify. If I understand that
correctly, you can block a file from user space. This is probably not
sufficient if we want to pass delegations back and forth between Samba
and NFS, but it might be a start.

Just an example scenario we'd want to cover:

SMB opens a file with exclusive delegation.
NFS also opens that file -> SMB loses its delegation.
SMB opens a 2nd time, attempts to get exclusive delegation again.

This kind of ping-pong of delegation needs to be covered in an API.

> When it comes to designing VFS lease/delegation/oplock interfaces, I
> think we'd associate the delegation with a file description, but does

"file description" meaning the 32-bit fd returned from open(2)?

> this really matter?  I think a server could implement either behavior on
> top of that.

Samba right now is designed to have a fd per client-requested open.
One reason is that we do the kernel access check every time the open
comes in. We don't share os-level fd's across different protocol-level
open-handles. To change this we'd need a call that changes a RDONLY fd
to a RDWR one on the fly as a start.

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: 0551-370000-0, mailto:kontakt at sernet.de
Gesch.F.: Dr. Johannes Loxen und Reinhild Jung
AG Göttingen: HR-B 2816 - http://www.sernet.de



More information about the samba-technical mailing list