[jlemon@flugsvamp.com: Re: Fw: Re: Implemented OPLOCK for FreeBsd]

Jonathan Lemon jlemon at flugsvamp.com
Fri Sep 7 11:48:01 GMT 2001


FYI - Forwarding back from the mailing list.

----- Forwarded message from Jonathan Lemon <jlemon at flugsvamp.com> -----

Delivered-To: developers at freebsd.org
Date: Fri, 7 Sep 2001 13:29:24 -0500
To: Garrett Wollman <wollman at khavrinen.lcs.mit.edu>
Cc: Jordan Hubbard <jkh at FreeBSD.org>, developers at FreeBSD.org
Subject: Re: Fw: Re: Implemented OPLOCK for FreeBsd

On Fri, Sep 07, 2001 at 02:09:51PM -0400, Garrett Wollman wrote:
> <<On Fri, 07 Sep 2001 10:46:35 -0700, Jordan Hubbard <jkh at FreeBSD.org> said:
> 
> > This is pretty spiffy - for those unfamiliar with Linux's OPLOCK
> > mechanism (Irix has one too, FWIW), it's a kernel mechanism for
> > getting leases on files and having the kernel notify you when someone
> > else grabs a lease or the lease times out (at some configurable
> > interval).
> 
> We can do this better with kqueue's EVFILT_VNODE.

Yup - there's already a hook to hang this off of, too.  It shouldn't
be too difficult to add another filter type either, if it comes to that.

Actually, this seems fairly simple.  The API for samba oplocks has:

/* if a kernel does support oplocks then a structure of the following
   typee is used to describe how to interact with the kernel */
struct kernel_oplocks {
        BOOL (*receive_message)(fd_set *fds, char *buffer, int buffer_len);
        BOOL (*set_oplock)(files_struct *fsp, int oplock_type);
        void (*release_oplock)(files_struct *fsp);
        BOOL (*parse_message)(char *msg_start, int msg_len, SMB_INO_T *inode, SM
B_DEV_T *dev);
        BOOL (*msg_waiting)(fd_set *fds);
        int notification_fd;
}

So this maps into kqueue in the following fashion:

   1. create a dedicated kq for oplocks.  return this as 'notification_fd'.
   2. map 'set_oplock', 'release_oplock' into a kevent() call that either
      registers or deletes a new kevent.
   3. map 'receive_message' into a kevent() call to retrieve status.
   4. map 'msg_waiting' into FD_ISSET(notification_fd).

Done!  (of course, VOP_LEASE() needs to be extended to deliver the
event to the internal knote, and block on the lease timeout if needed)


'oplock_parse' appears to be a NOP in irix/linux, isofar as the kernel
side processing is handled.

Samba appears to only care about write locks, so a first cut at the
implementation doesn't need to worry about read/write locks and the
upgrading to read->write, etc.

-- 
Jonathan

----- End forwarded message -----




More information about the samba-technical mailing list