From d8905b0d05d41e48d02533aa44a256cb11c1f03f Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Tue, 3 Mar 2015 14:48:21 +1100 Subject: [PATCH] Deallocate removed directories. --- samples/memfs/fs.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/samples/memfs/fs.go b/samples/memfs/fs.go index 31fe9f4..840f7a5 100644 --- a/samples/memfs/fs.go +++ b/samples/memfs/fs.go @@ -169,6 +169,12 @@ func (fs *memFS) allocateInode( return } +// EXCLUSIVE_LOCKS_REQUIRED(fs.mu) +func (fs *memFS) deallocateInode(id fuse.InodeID) { + fs.freeInodes = append(fs.freeInodes, id) + fs.inodes[id] = nil +} + //////////////////////////////////////////////////////////////////////// // FileSystem methods //////////////////////////////////////////////////////////////////////// @@ -326,8 +332,9 @@ func (fs *memFS) RmDir( // Remove the entry within the parent. parent.RemoveChild(req.Name) - // TODO(jacobsa): Remove the child when it's forgotten. (Can we get a failing - // test by looking at inode ID allocation?) + // TODO(jacobsa): Don't remove the child until it's forgotten. Can we get a + // failing test by continuing to read from an opened dir handle? + fs.deallocateInode(childID) return }