Re: dcache problems with vfat

Alexander Viro (viro@math.psu.edu)
Mon, 11 Jan 1999 14:28:44 -0500 (EST)


On Sat, 9 Jan 1999, Guest section DW wrote:

> From: "Steven N. Hirsch" <shirsch@adelphia.net>
>
> On 6 Jan 1999, Magnus Ahltorp wrote:
>
> > > Oh, crap. The list_empty(&dentry->d_subdirs) test in d_invalidate() should
> > > be a test for d_children, not d_subdirs!
>
> [Nice to see d_children used intuitively here - I wrote the same independently]
>
> > Are these lists only documented in code, or are they documented
> > somewhere else? It's not very easy to get hold of what all these lists
> > do when you see them for the first time.
>
> I couldn't agree more.
>
> Please find some notes below that I wrote yesterday or so to get
> a feeling how this dentry stuff works. Roughly speaking the code
> is a pleasure to read, but some vfat and nfs stuff is very ugly,

I've cleaned the vfat stuff up. Nothing for NFS yet.

> and the rename code in various filesystems is bad as well.

Oh, yes. I've fixed some parts of this stuff, but it's still ugly.

> Anyway - some fragments of text below. Enjoy (or complain about
> mistakes or misunderstandings). Maybe I can find time to write
> part two one of these days.
>
> Andries
[snip]
> [The d_hash field is referred to in many places that should
> not know about its existence, in the phrase
> if (list_empty(&dentry->d_hash)) ...
> No doubt there should be a line
> #define unhashed(d) (list_empty(&(d)->d_hash))
> in dcache.h, together with a comment describing the semantics
> of being unhashed. Then all these occurrences of d_hash can
> be removed. Next, d_drop() should be renamed d_unhash().]
>
> The dentry for the root of a mounted filesystem is returned by
> d_alloc_root() and is unhashed.

Umm... Little addition: this function is used to allocate dentries for
sockets and pipes. IMHO they should have separate superblocks (maybe
one for each address family).

> d_move(D,T) is the routine called by the filesystem code
> just before finishing the rename(D,T) call. Since both
> dentries D and T may be busy we cannot just throw one away.
> Instead they are partially interchanged:
> D and T interchange names, and D is put into T's hash queue,
> and T is unhashed; D and T interchange parents, and are put
> on the list of children of their new parent.
> The result is that the file D that got renamed is now in perfect
> shape again - it has been renamed. T, if it existed, lost its
> name string, if it was short, but perhaps this is harmless -
> let us hope no-one will ever ask for T's name anymore.

Addition: current code will break and burn if the target is unhashed. I've
rolled a patch for that (and for bunch of races in rename()) but looks
like Linus didn't apply it.

Please, look at ftp://math.psu.edu/pub/viro/splitup.tar.gz
There sits the latest portion of patches I've done for VFS and
filesystems. I'm going to feed at least some of them to Linus before
2.2.0 final.
Cheers,
Al

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/