Make blocksize configurable

This commit is contained in:
Sebastian Messmer 2016-03-08 23:57:34 +01:00
parent 4dbb380263
commit d7f34c0dfb
4 changed files with 12 additions and 6 deletions

View File

@ -45,8 +45,6 @@ namespace bf = boost::filesystem;
namespace cryfs { namespace cryfs {
constexpr uint32_t CryDevice::BLOCKSIZE_BYTES;
CryDevice::CryDevice(CryConfigFile configFile, unique_ref<BlockStore> blockStore) CryDevice::CryDevice(CryConfigFile configFile, unique_ref<BlockStore> blockStore)
: _fsBlobStore( : _fsBlobStore(
make_unique_ref<ParallelAccessFsBlobStore>( make_unique_ref<ParallelAccessFsBlobStore>(
@ -55,7 +53,7 @@ CryDevice::CryDevice(CryConfigFile configFile, unique_ref<BlockStore> blockStore
make_unique_ref<BlobStoreOnBlocks>( make_unique_ref<BlobStoreOnBlocks>(
make_unique_ref<CachingBlockStore>( make_unique_ref<CachingBlockStore>(
CreateEncryptedBlockStore(*configFile.config(), std::move(blockStore)) CreateEncryptedBlockStore(*configFile.config(), std::move(blockStore))
), BLOCKSIZE_BYTES))) ), configFile.config()->BlocksizeBytes())))
) )
), ),
_rootKey(GetOrCreateRootKey(&configFile)), _rootKey(GetOrCreateRootKey(&configFile)),
@ -140,7 +138,7 @@ void CryDevice::statfs(const bf::path &path, struct statvfs *fsstat) {
callFsActionCallbacks(); callFsActionCallbacks();
uint64_t numUsedBlocks = _fsBlobStore->numBlocks(); uint64_t numUsedBlocks = _fsBlobStore->numBlocks();
uint64_t numFreeBlocks = _fsBlobStore->estimateSpaceForNumBlocksLeft(); uint64_t numFreeBlocks = _fsBlobStore->estimateSpaceForNumBlocksLeft();
fsstat->f_bsize = BLOCKSIZE_BYTES; fsstat->f_bsize = _fsBlobStore->blocksizeBytes();
fsstat->f_blocks = numUsedBlocks + numFreeBlocks; fsstat->f_blocks = numUsedBlocks + numFreeBlocks;
fsstat->f_bfree = numFreeBlocks; fsstat->f_bfree = numFreeBlocks;
fsstat->f_bavail = numFreeBlocks; fsstat->f_bavail = numFreeBlocks;

View File

@ -37,8 +37,6 @@ public:
private: private:
static constexpr uint32_t BLOCKSIZE_BYTES = 32 * 1024;
cpputils::unique_ref<parallelaccessfsblobstore::ParallelAccessFsBlobStore> _fsBlobStore; cpputils::unique_ref<parallelaccessfsblobstore::ParallelAccessFsBlobStore> _fsBlobStore;
blockstore::Key _rootKey; blockstore::Key _rootKey;

View File

@ -24,6 +24,7 @@ namespace cryfs {
cpputils::unique_ref<SymlinkBlobRef> createSymlinkBlob(const boost::filesystem::path &target); cpputils::unique_ref<SymlinkBlobRef> createSymlinkBlob(const boost::filesystem::path &target);
boost::optional<cpputils::unique_ref<FsBlobRef>> load(const blockstore::Key &key); boost::optional<cpputils::unique_ref<FsBlobRef>> load(const blockstore::Key &key);
void remove(cpputils::unique_ref<FsBlobRef> blob); void remove(cpputils::unique_ref<FsBlobRef> blob);
uint64_t blocksizeBytes() const;
uint64_t numBlocks() const; uint64_t numBlocks() const;
uint64_t estimateSpaceForNumBlocksLeft() const; uint64_t estimateSpaceForNumBlocksLeft() const;
@ -80,6 +81,10 @@ namespace cryfs {
_cache.push(key, std::move(baseBlob)); _cache.push(key, std::move(baseBlob));
} }
inline uint64_t CachingFsBlobStore::blocksizeBytes() const {
return _baseBlobStore->blocksizeBytes();
}
inline uint64_t CachingFsBlobStore::numBlocks() const { inline uint64_t CachingFsBlobStore::numBlocks() const {
return _baseBlobStore->numBlocks(); return _baseBlobStore->numBlocks();
} }

View File

@ -26,6 +26,7 @@ namespace cryfs {
cpputils::unique_ref<SymlinkBlobRef> createSymlinkBlob(const boost::filesystem::path &target); cpputils::unique_ref<SymlinkBlobRef> createSymlinkBlob(const boost::filesystem::path &target);
boost::optional<cpputils::unique_ref<FsBlobRef>> load(const blockstore::Key &key); boost::optional<cpputils::unique_ref<FsBlobRef>> load(const blockstore::Key &key);
void remove(cpputils::unique_ref<FsBlobRef> blob); void remove(cpputils::unique_ref<FsBlobRef> blob);
uint64_t blocksizeBytes() const;
uint64_t numBlocks() const; uint64_t numBlocks() const;
uint64_t estimateSpaceForNumBlocksLeft() const; uint64_t estimateSpaceForNumBlocksLeft() const;
@ -57,6 +58,10 @@ namespace cryfs {
}; };
} }
inline uint64_t ParallelAccessFsBlobStore::blocksizeBytes() const {
return _baseBlobStore->blocksizeBytes();
}
inline uint64_t ParallelAccessFsBlobStore::numBlocks() const { inline uint64_t ParallelAccessFsBlobStore::numBlocks() const {
return _baseBlobStore->numBlocks(); return _baseBlobStore->numBlocks();
} }