storj/storagenode/pieces
Isaac Hess 7d1e28ea30 storagenode: Include trash space when calculating space used
This commit adds functionality to include the space used in the trash
directory when calculating available space on the node.

It also includes this trash value in the space used cache, with methods
to keep the cache up-to-date as files are trashed, restored, and
emptied.

As part of the commit, the RestoreTrash and EmptyTrash methods have
slightly changed signatures. RestoreTrash now also returns the keys that
were restored, while EmptyTrash also returns the total disk space
recovered. Each of these changes makes it possible to keep the cache
up-to-date and know how much space is being used/recovered.

Also changed is the signature of PieceStoreAccess.ContentSize method.
Previously this method returns only the content size of the blob,
removing the size of any header data. This method has been renamed
`Size` and returns both the full disk size and content size of the blob.
This allows us to only stat the file once, and in some instances (i.e.
cache) knowing the full file size is useful.

Note: This commit simply adds the trash size data to the piece size data
we were already collecting. The piece size data is not accurate for all
use-cases (e.g. because it does not contain piece header data); however,
this commit does not fix that problem. Now that the ContentSize (Size)
method returns the full size of the file, it should be easier to fix
this problem in a future commit.

Change-Id: I4a6cae09e262c8452a618116d1dc66b687f59f85
2019-12-23 19:07:03 -07:00
..
cache_test.go storagenode: Include trash space when calculating space used 2019-12-23 19:07:03 -07:00
cache.go storagenode: Include trash space when calculating space used 2019-12-23 19:07:03 -07:00
db_test.go private: rename internal to private (#3573) 2019-11-14 21:46:15 +02:00
pieceexpiration_test.go private: rename internal to private (#3573) 2019-11-14 21:46:15 +02:00
readwrite_test.go private: rename internal to private (#3573) 2019-11-14 21:46:15 +02:00
readwrite.go storagenode: Include trash space when calculating space used 2019-12-23 19:07:03 -07:00
store_test.go storagenode: Include trash space when calculating space used 2019-12-23 19:07:03 -07:00
store.go storagenode: Include trash space when calculating space used 2019-12-23 19:07:03 -07:00
trashchore.go storagenode/pieces: Add EmptyTrash functionality (#3640) 2019-11-26 09:25:21 -07:00