9ns: Fix dangling negative TFs
authorBarret Rhoden <brho@cs.berkeley.edu>
Thu, 26 Jul 2018 20:55:35 +0000 (16:55 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Mon, 30 Jul 2018 20:05:46 +0000 (16:05 -0400)
commit068317f1255de676fbec659d8abcacd2166683fa
tree6d0ae01a7ac9bfd0c4b451b2f66759d0b1928797
parente218410ad68df122d05695158f0d936e3967c9f1
9ns: Fix dangling negative TFs

If you remove a directory that has negative entries (but not real children
- that would fail), those negative children would keep a reference on their
parent (the directory).  When you finally marked the directory
'disconnected', you'd have a positive refcnt, so we wouldn't free it.  We'd
have a ball of disconnected references, none of which would ever get freed.

Now that directory wasn't freed.  Same with its negative entries.  So far,
it's just wasted memory.  However, since we didn't __tf_free it, we also
kept a reference on *its parent.*  But that parent doesn't have a pointer
to the original directory (it is disconnected).  Now we're leaking
references on another directory.

Later, when you unmounted the filesystem and we tried to purge everything,
we'd hit that directory with the leaked references and panic.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/src/ns/tree_file.c