kernel support for open share modes
J. Bruce Fields
bfields at fieldses.org
Wed Feb 9 22:01:46 GMT 2005
On Fri, Feb 04, 2005 at 12:07:07PM -0800, Jeremy Allison wrote:
> On Fri, Feb 04, 2005 at 02:26:23PM -0500, J. Bruce Fields wrote:
> > How does Samba currently handle deny share modes? Are they coordinated
> > with local access? (Does a local open fail if the file is opened with a
> > conflicting deny mode by a samba client?)
> > I'm interested because we'd like to support something similar for NFSv4,
> > and it doesn't seem that existing kernel support is sufficient to do it
> > correctly.
> > This looks like a hard problem, but I'd be curious whether anyone had
> > thought about it and had any ideas.
> In Linux Samba makes a kernel call to flock to tell the kernel about
> Samba-related deny modes, but only on Linux. Look for the kernel_flock
> code in smbd/open.c. Samba handles deny modes in memory, and they are
> not coordinated with local access.
OK, that's very interesting, I hadn't noticed the LOCK_MAND, LOCK_READ,
and LOCK_WRITE constants before.
One problem is that NFSv4 at least seems to require the setting of deny
modes to be atomic with open()--so it would be incorrect if, for
example, we created a file but allowed someone else to beat us to the
flock(). From a quick look at the use of kernel_flock() it looks like
this is also a requirement for Samba, and (am I understanding this
right?) this race is avoided only on the assumption that smbd is the
*only* user of LOCK_MAND?
More information about the samba-technical