VFS event hooks in Linux

Jeremy Allison jallison at cthulhu.engr.sgi.com
Tue Jun 29 01:18:21 GMT 1999


Richard Gooch wrote:
> 
> Following on from some private discussions, it's been brought to my
> attention that Samba would benefit from VFS event hooks. Could someone
> please explain what level of support is useful?

ChangeNotify is the SMB call Samba uses to return to a Windows client
that a directory tree has been modified and should be re-scanned
by the client.

ChangeNotify can act just on one directory, or on a complete tree
(realistically it is only used on a per-directory basis).

> The poll(2)-based scheme I implemented requires an open file on each
> inode that you want to watch. This is fine for simple applications
> like a file browser, where you can easily keep the directory open.
> 
> It may not be appropriate for Samba, if you want to be notified when
> *any* file in the exported volume has changed, as it would require a
> ridiculous number of open files.

Agreed. This would not work.

> An alternative scheme I'd devised would allow you to keep just a
> single open file per filesystem, which is used to receive events when
> any inode in that FS is written to. An event queue would be
> maintained, to which the inode number would be written.
> 
> Is this scheme an improvement? If it is, then please give me your
> arguments and I'll raise them with Linus.

That sounds better, and also similar to the kernel oplock
notification system that was already implemented in IRIX
for Samba.

The ideal interface would be one that acted on a direcory
inode and reported changes in any inode (file or directory)
hierarchically "under" that inode. If this is not doable,
then a generic filesystem inode notify is better than nothing,
although may cause many false positives on a heavily used
filesystem (a home directory server for example).

This is also similar to the "FAM" interface in IRIX (one
fd per watched filesystem (via an "imon" pseudo-device)
and would allow me to generalize the Samba ChangeNotify
interface to be fd based. I've been thinking of doing
this based on the IRIX fam interface already, but didn't
want to make Samba look too IRIX-specific (in case people
got funny ideas).

This is good news, as currently Samba has to scan
each watched directory to notice changes (which it does
via a configurable, currently 60 second, timeout).

Cheers,

	Jeremy Allison,
	Samba Team.

-- 
--------------------------------------------------------
Buying an operating system without source is like buying
a self-assembly Space Shuttle with no instructions.
--------------------------------------------------------


More information about the samba-technical mailing list