About file lease (F_SETLEASE), Samba's oplock implementation

Matej Kenda matej.kenda at hermes.si
Wed Jul 17 02:04:02 GMT 2002


I am looking for any kind of design information for file lease
implementation in the Linux kernel 2.4, namely the fcntl(fd,

We are implementing a virtual file system for HSM application that lays
on top of an existing file system (ext3 or XFS). The main role of the
kernel module is to capture access to the files on the disk and get the
file from offline storage (tape) when it is accessed.

This works fine as long as the file system is accessed locally or via
NFS. Samba uses file lease to implement opportunistic locks (oplocks).

If kernel oplocks are turned on, then smbd gets a signal that the file
has changed and releases the oplock so that our application can write
actual file contents. open succeeds after the file lease expires (seen
in the dmesg output).

This works when the file is accessed via Samba for the first time. If I
understand the design of oplocks and file lease correctly (by reading
the source code), this is the expected behaviour.

The second time (and all subsequent times) the file can't be opened any
more. open() returns the error "12: Cannot allocate memory".

      * Is that expected?

      * Why should an application that does not use file lease at all be
        affected by file leases, used by other applications?

      * Are file leases described anywhere?

We use RedHat 7.3 and SuSE 8.0 with vanilla kernel 2.4.18 + EA patch and
Samba 2.2.5, compiled from sources.

If the kernel oplocks are turned off in Samba (kernel oplocks = no) then
everything works OK.

I have seen some posts that indicate that file lease implementation
might be broken. Is that true?

      * Mathew Wilcox: broken flock():

      * Michael Kerrisk: Problems/bugs with file leases (F_SETLEASE)?:

Thank you very much in advance for clarifying this.



More information about the samba-technical mailing list