open cookies

Robert Watson rwatson at freebsd.org
Mon Nov 17 10:13:06 PST 2003


On Sun, 16 Nov 2003, Alfred Perlstein wrote:

> I'm starting to do the gruntwork of getting us per-open cookies for file
> operations.  If someone can explain what needs to be done that would
> speed things up. :) 
> 
> If you're unclear as to what I'm talking about, what I mean is the
> "private_data" field in Linux's "struct file". 
> 
> Please keep me cc'd as this is the only list I'm currently subscribed
> to. 
> 
> My main question is... should the cookies be returned from VOP_CREATE,
> VOP_LOOKUP, VOP_MKNOD, etc.. (all the ones that have and OUT/INOUT of
> *vpp) or should we only care about VOP_OPEN? 

I implemented about 90% of this previously and did not commit it.  In
general, the notion of "session" corresponds well to the notion of "file
descriptor"; I found that this meant only VOPs that could be performed on
a vnode pulled out of a file descriptor were relevant.  When a VOP is
dual-purpose: i.e., can be called using both "by name" and "with a
session", or even just "without a session", I used NULL for the cookie
argument to the VOP.  Since we nominally support file system stacking, I
found that, much as you concluded, we needed a cookie rather than passing
struct file into each VOP, which works with the top layer but not for
lower layers.  As we stuff a lower layer vnode reference into the
per-vnode state, we now have to stuff per-open state material into each
layer's per-open state.

My general conclusion was that this over-complicated our VFS
substantially, and that the struct file state in Linux was generally used
only for multiply instantiated devices.  With devfs cloning, all the cases
I was interested in (things like /dev vmware nodes) are addressed.  Since
none of our non-specfs nodes required any notion of state, I found I was
touching a lot of code to minimal benefit.  What's your motivation for
adding this support, and can it be added in a way that doesn't introduce
new arguments to most VOPs, and introduce a host of potential bugs?  I
don't doubt it can be done right, but it's a fairly complex solution that
has to be motivated by complex requirements... 

Robert N M Watson             FreeBSD Core Team, TrustedBSD Projects
robert at fledge.watson.org      Network Associates Laboratories




More information about the freebsd-fs mailing list