[Samba] Custom VFS

Jeremy Allison jra at samba.org
Wed Jul 25 14:08:33 MDT 2012

On Wed, Jul 25, 2012 at 09:44:25AM -0700, Andrew Scherpbier wrote:
> Interesting stuff.  Right now I'm letting default_vfs do all the
> low-level I/O, so any improvements in speed you guys make should
> immediately be useful!
> So does this mean that the VFS module will need to be changed to be
> thread-safe?  That actually will be a significant issue.  I'm not
> too familiar with pthreads and don't know too much about the low
> level implications WRT errno, etc.   (I'm mostly a Java weenie
> nowadays, sorry!  Last time I used threads in C++ was a couple years
> ago using Boost under Windows)

No, you won't need to make your VFS module thread-safe
unless you're using threads internally. Most of Samba is
not thread-safe (although we're moving very slowly there)
so you have to be very careful in how you use them.

Check out modules/vfs_aio_pthread.c for an example
if you're interested.

> I'd like to see is at least a call flow to make it easier for module
> writers to figure out what calls to hook.  For example, does
> create_file call open or do both need to be implemented/hooked?  I
> unfortunately happen to have lots of experience with windows kernel
> calls because I also wrote a filter-driver based FS for windows in a
> previous life, so I know how complicated the create_file call is
> (Thanks, Microsoft!).  The fact that you don't need to hook it is
> awesome, but that's not explained anywhere I could find.

Yeah - that one is hard. It's really a 2-level VFS at that point.
The default implementation of CreateFile calls open() internally
to get the fd.

> Or at least detailed docs on the individual hooks, what they are
> supposed to do, why they are called, what their side effects are
> supposed to be, etc.  (Doxygen docs in the code would be awesome!)
> I spend way too much time running "grep -rn something" on the samba
> source and following ctags right now  :-(
> Don't get me wrong!  I love working on this stuff, but the VFS
> module is a small (but important) part of the bigger system and I
> end up spending a disproportionate amount of time on the module
> because of the lack of documentation.

Thanks for the feedback. We'll see what we can fix.



More information about the samba mailing list