Re: pre-patch2.1.45-3 lookin' good

Bill Hawes (
Sun, 13 Jul 1997 20:55:07 -0400

Linus Torvalds wrote:
> However, the problem with the code is that a dentry now depends on two
> things: both iput() and dput() can result in a dentry being free. And that
> is why the code is so complex: dput cannot on its own decide whether it
> can free stuff, it needs help from iput..

It seems that it shouldn't be too complex deciding when to free the
dentry: if iput() walks the dentry chain and sets a flag, then any
dentry with dcount == 0 and "may free" set can be freed. iput() can
just count the nodes on the i_dentry chain to get the correct dependency

> Generally, I don't want those kinds of dependencies: at least in my
> opinion a circular dependency (inodes depend on dentries which depend on
> inodes) tends to drive complexity not up by two, but by a power of two..

Agreed that circular dependencies drive up complexity, but in this case
you've already done the hard work: the inode dentry chain shows what
dentries depend on an inode, and the dentry tree shows the dependency on
other dentries. When a leaf node satisfies d_count == 0 and "may free",
just chop it off and let the effects ripple through. The LRU stuff can
be added later once the basic operations are solid.

I guess my view is very "inode-centric", but I think the above approach
would work well with waht we've got, and could be implemented to be 100%
free of races.