file system building

Magnus Ahltorp (Magnus.Ahltorp@abc.se)
Fri, 2 Jan 1998 01:47:45 +0100 (MET)


I'm porting a file system right now from {Free,Net,Open}BSD to Linux
(2.0), and I have bumped into a few problems.

When I do a lookup() I post a message to a userland daemon and put myself
on a wait queue. When the userland daemon posts an answer with the right
info I put the result into the dcache. Before I do this, I get a wrapper
inode (called xnode). The xnode has a pointer to the corresponding inode
and the inode has its u.generic_ip pointing to the xnode.

The file system is not inode driven, which forces me to invent a inode
number for the iget(). I choose this inode number to the address of the
xnode.

The problem is, when the inode is cached in the dcache, it must have been
created by the iget(sb,xnode), and the reference count should be 0 (if
noone uses it). But, if I let the reference count drop to 0, the inode
will be deallocated. If I then do a dcache lookup, I will get an inode
number that does not map to an inode anymore. I will try to do an
iget(sb,xnode) on it, but since my read_inode does not do much, I get
something completly useless.

I the above BSD kernels, the reference count is allowed to drop to 0, and
the kernel tells me when it needs it for reuse.

I could of course cache it for only the period it's needed, but then it's
not very efficient.

Thanks for any help,
Magnus