From 13865ca284e1c05069ae9e37cbd9e35a95e3e22a Mon Sep 17 00:00:00 2001 From: Steve Slaven Date: Fri, 7 Aug 2009 10:02:55 -0700 Subject: Added a method to free blocks before unlink, just doing ftruncate then unlink left the "empty" file and "empty" block with an extra ref for every unlink since we never freed those blocks diff --git a/FuseArchive/ChunkFile.py b/FuseArchive/ChunkFile.py index 7cc8e07..e19a9fb 100644 --- a/FuseArchive/ChunkFile.py +++ b/FuseArchive/ChunkFile.py @@ -476,6 +476,13 @@ class ChunkFile(object): logging.debug( "_fflush exit" ) return 1 + def pre_unlink(self): + # Release all our blocks and our main file key + logging.debug( "Unlocking all our chunks for unlink" ) + for key in self.chunks: + unlock_chunk( key ) + + unlock_chunk( self.original_key ) # Currently we treat fsync as flush since we don't keep any data # hanging around anyway in fh stuff diff --git a/FuseArchive/FileSystem.py b/FuseArchive/FileSystem.py index 16e5b2c..dfb5515 100644 --- a/FuseArchive/FileSystem.py +++ b/FuseArchive/FileSystem.py @@ -47,9 +47,9 @@ class FileSystem(fuse.Fuse): yield fuse.Direntry(e) def unlink(self, path): - # Do a truncate to free our chunks + # Ask our file to release it's chunks f = ChunkFile( path, os.O_RDWR, 0 ) - f.ftruncate( 0 ) + f.pre_unlink() f.release( 0 ) os.unlink("./tree" + path) -- cgit v0.10.2