Use inline for short functions
This commit is contained in:
parent
2347782f6a
commit
6fb46c7e73
@ -130,7 +130,8 @@ unique_ref<FsBlobRef> CryDevice::LoadBlob(const bf::path &path) {
|
||||
|
||||
return std::move(*currentBlob);
|
||||
|
||||
//TODO Running the python script, waiting for "Create files in sequential order...", then going into dir ~/tmp/cryfs-mount-.../Bonnie.../ and calling "ls"
|
||||
//TODO (I think this is resolved, but I should test it)
|
||||
// Running the python script, waiting for "Create files in sequential order...", then going into dir ~/tmp/cryfs-mount-.../Bonnie.../ and calling "ls"
|
||||
// crashes cryfs with a sigsegv.
|
||||
// Possible reason: Many parallel changes to a directory blob are a race condition. Need something like ParallelAccessStore!
|
||||
}
|
||||
|
@ -19,34 +19,6 @@ using cryfs::fsblobstore::SymlinkBlob;
|
||||
namespace cryfs {
|
||||
namespace cachingfsblobstore {
|
||||
|
||||
CachingFsBlobStore::CachingFsBlobStore(unique_ref<FsBlobStore> baseBlobStore)
|
||||
: _baseBlobStore(std::move(baseBlobStore)), _cache() {
|
||||
}
|
||||
|
||||
CachingFsBlobStore::~CachingFsBlobStore() {
|
||||
}
|
||||
|
||||
unique_ref<FileBlobRef> CachingFsBlobStore::createFileBlob() {
|
||||
// This already creates the file blob in the underlying blobstore.
|
||||
// We could also cache this operation, but that is more complicated (blockstore::CachingBlockStore does it)
|
||||
// and probably not worth it here.
|
||||
return make_unique_ref<FileBlobRef>(_baseBlobStore->createFileBlob(), this);
|
||||
}
|
||||
|
||||
unique_ref<DirBlobRef> CachingFsBlobStore::createDirBlob() {
|
||||
// This already creates the file blob in the underlying blobstore.
|
||||
// We could also cache this operation, but that is more complicated (blockstore::CachingBlockStore does it)
|
||||
// and probably not worth it here.
|
||||
return make_unique_ref<DirBlobRef>(_baseBlobStore->createDirBlob(), this);
|
||||
}
|
||||
|
||||
unique_ref<SymlinkBlobRef> CachingFsBlobStore::createSymlinkBlob(const bf::path &target) {
|
||||
// This already creates the file blob in the underlying blobstore.
|
||||
// We could also cache this operation, but that is more complicated (blockstore::CachingBlockStore does it)
|
||||
// and probably not worth it here.
|
||||
return make_unique_ref<SymlinkBlobRef>(_baseBlobStore->createSymlinkBlob(target), this);
|
||||
}
|
||||
|
||||
optional<unique_ref<FsBlobRef>> CachingFsBlobStore::load(const Key &key) {
|
||||
auto fromCache = _cache.pop(key);
|
||||
if (fromCache != none) {
|
||||
@ -74,16 +46,5 @@ namespace cachingfsblobstore {
|
||||
}
|
||||
ASSERT(false, "Unknown blob type");
|
||||
}
|
||||
|
||||
void CachingFsBlobStore::remove(unique_ref<FsBlobRef> blob) {
|
||||
auto baseBlob = blob->releaseBaseBlob();
|
||||
return _baseBlobStore->remove(std::move(baseBlob));
|
||||
}
|
||||
|
||||
void CachingFsBlobStore::releaseForCache(cpputils::unique_ref<fsblobstore::FsBlob> baseBlob) {
|
||||
Key key = baseBlob->key();
|
||||
_cache.push(key, std::move(baseBlob));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,46 @@ namespace cryfs {
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CachingFsBlobStore);
|
||||
};
|
||||
|
||||
|
||||
inline CachingFsBlobStore::CachingFsBlobStore(cpputils::unique_ref<fsblobstore::FsBlobStore> baseBlobStore)
|
||||
: _baseBlobStore(std::move(baseBlobStore)), _cache() {
|
||||
}
|
||||
|
||||
inline CachingFsBlobStore::~CachingFsBlobStore() {
|
||||
}
|
||||
|
||||
inline cpputils::unique_ref<FileBlobRef> CachingFsBlobStore::createFileBlob() {
|
||||
// This already creates the file blob in the underlying blobstore.
|
||||
// We could also cache this operation, but that is more complicated (blockstore::CachingBlockStore does it)
|
||||
// and probably not worth it here.
|
||||
return cpputils::make_unique_ref<FileBlobRef>(_baseBlobStore->createFileBlob(), this);
|
||||
}
|
||||
|
||||
inline cpputils::unique_ref<DirBlobRef> CachingFsBlobStore::createDirBlob() {
|
||||
// This already creates the file blob in the underlying blobstore.
|
||||
// We could also cache this operation, but that is more complicated (blockstore::CachingBlockStore does it)
|
||||
// and probably not worth it here.
|
||||
return cpputils::make_unique_ref<DirBlobRef>(_baseBlobStore->createDirBlob(), this);
|
||||
}
|
||||
|
||||
inline cpputils::unique_ref<SymlinkBlobRef> CachingFsBlobStore::createSymlinkBlob(const boost::filesystem::path &target) {
|
||||
// This already creates the file blob in the underlying blobstore.
|
||||
// We could also cache this operation, but that is more complicated (blockstore::CachingBlockStore does it)
|
||||
// and probably not worth it here.
|
||||
return cpputils::make_unique_ref<SymlinkBlobRef>(_baseBlobStore->createSymlinkBlob(target), this);
|
||||
}
|
||||
|
||||
inline void CachingFsBlobStore::remove(cpputils::unique_ref<FsBlobRef> blob) {
|
||||
auto baseBlob = blob->releaseBaseBlob();
|
||||
return _baseBlobStore->remove(std::move(baseBlob));
|
||||
}
|
||||
|
||||
inline void CachingFsBlobStore::releaseForCache(cpputils::unique_ref<fsblobstore::FsBlob> baseBlob) {
|
||||
blockstore::Key key = baseBlob->key();
|
||||
_cache.push(key, std::move(baseBlob));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,24 +14,6 @@ using std::function;
|
||||
namespace cryfs {
|
||||
namespace fsblobstore {
|
||||
|
||||
FsBlobStore::FsBlobStore(unique_ref<BlobStore> baseBlobStore): _baseBlobStore(std::move(baseBlobStore)) {
|
||||
}
|
||||
|
||||
unique_ref<FileBlob> FsBlobStore::createFileBlob() {
|
||||
auto blob = _baseBlobStore->create();
|
||||
return FileBlob::InitializeEmptyFile(std::move(blob));
|
||||
}
|
||||
|
||||
unique_ref<DirBlob> FsBlobStore::createDirBlob() {
|
||||
auto blob = _baseBlobStore->create();
|
||||
return DirBlob::InitializeEmptyDir(std::move(blob), _getLstatSize());
|
||||
}
|
||||
|
||||
unique_ref<SymlinkBlob> FsBlobStore::createSymlinkBlob(const bf::path &target) {
|
||||
auto blob = _baseBlobStore->create();
|
||||
return SymlinkBlob::InitializeSymlink(std::move(blob), target);
|
||||
}
|
||||
|
||||
boost::optional<unique_ref<FsBlob>> FsBlobStore::load(const blockstore::Key &key) {
|
||||
auto blob = _baseBlobStore->load(key);
|
||||
if (blob == none) {
|
||||
@ -49,17 +31,5 @@ boost::optional<unique_ref<FsBlob>> FsBlobStore::load(const blockstore::Key &key
|
||||
}
|
||||
}
|
||||
|
||||
void FsBlobStore::remove(cpputils::unique_ref<FsBlob> blob) {
|
||||
_baseBlobStore->remove(blob->releaseBaseBlob());
|
||||
}
|
||||
|
||||
function<off_t (const Key &)> FsBlobStore::_getLstatSize() {
|
||||
return [this] (const Key &key) {
|
||||
auto blob = load(key);
|
||||
ASSERT(blob != none, "Blob not found");
|
||||
return (*blob)->lstat_size();
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -31,6 +31,37 @@ namespace cryfs {
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(FsBlobStore);
|
||||
};
|
||||
|
||||
inline FsBlobStore::FsBlobStore(cpputils::unique_ref<blobstore::BlobStore> baseBlobStore)
|
||||
: _baseBlobStore(std::move(baseBlobStore)) {
|
||||
}
|
||||
|
||||
inline cpputils::unique_ref<FileBlob> FsBlobStore::createFileBlob() {
|
||||
auto blob = _baseBlobStore->create();
|
||||
return FileBlob::InitializeEmptyFile(std::move(blob));
|
||||
}
|
||||
|
||||
inline cpputils::unique_ref<DirBlob> FsBlobStore::createDirBlob() {
|
||||
auto blob = _baseBlobStore->create();
|
||||
return DirBlob::InitializeEmptyDir(std::move(blob), _getLstatSize());
|
||||
}
|
||||
|
||||
inline cpputils::unique_ref<SymlinkBlob> FsBlobStore::createSymlinkBlob(const boost::filesystem::path &target) {
|
||||
auto blob = _baseBlobStore->create();
|
||||
return SymlinkBlob::InitializeSymlink(std::move(blob), target);
|
||||
}
|
||||
|
||||
inline void FsBlobStore::remove(cpputils::unique_ref<FsBlob> blob) {
|
||||
_baseBlobStore->remove(blob->releaseBaseBlob());
|
||||
}
|
||||
|
||||
inline std::function<off_t (const blockstore::Key &)> FsBlobStore::_getLstatSize() {
|
||||
return [this] (const blockstore::Key &key) {
|
||||
auto blob = load(key);
|
||||
ASSERT(blob != boost::none, "Blob not found");
|
||||
return (*blob)->lstat_size();
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,11 +17,6 @@ using blockstore::Key;
|
||||
namespace cryfs {
|
||||
namespace parallelaccessfsblobstore {
|
||||
|
||||
ParallelAccessFsBlobStore::ParallelAccessFsBlobStore(unique_ref<CachingFsBlobStore> baseBlobStore)
|
||||
: _baseBlobStore(std::move(baseBlobStore)),
|
||||
_parallelAccessStore(make_unique_ref<ParallelAccessFsBlobStoreAdapter>(_baseBlobStore.get())) {
|
||||
}
|
||||
|
||||
optional<unique_ref<FsBlobRef>> ParallelAccessFsBlobStore::load(const Key &key) {
|
||||
return _parallelAccessStore.load(key, [this] (cachingfsblobstore::FsBlobRef *blob) {
|
||||
cachingfsblobstore::FileBlobRef *fileBlob = dynamic_cast<cachingfsblobstore::FileBlobRef*>(blob);
|
||||
@ -41,11 +36,6 @@ optional<unique_ref<FsBlobRef>> ParallelAccessFsBlobStore::load(const Key &key)
|
||||
});
|
||||
}
|
||||
|
||||
void ParallelAccessFsBlobStore::remove(unique_ref<FsBlobRef> blob) {
|
||||
Key key = blob->key();
|
||||
return _parallelAccessStore.remove(key, std::move(blob));
|
||||
}
|
||||
|
||||
unique_ref<DirBlobRef> ParallelAccessFsBlobStore::createDirBlob() {
|
||||
auto blob = _baseBlobStore->createDirBlob();
|
||||
blob->setLstatSizeGetter(_getLstatSize());
|
||||
@ -77,13 +67,5 @@ unique_ref<SymlinkBlobRef> ParallelAccessFsBlobStore::createSymlinkBlob(const bf
|
||||
});
|
||||
}
|
||||
|
||||
std::function<off_t (const blockstore::Key &key)> ParallelAccessFsBlobStore::_getLstatSize() {
|
||||
return [this] (const blockstore::Key &key) {
|
||||
auto blob = load(key);
|
||||
ASSERT(blob != none, "Blob not found");
|
||||
return (*blob)->lstat_size();
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "DirBlobRef.h"
|
||||
#include "SymlinkBlobRef.h"
|
||||
#include "../cachingfsblobstore/CachingFsBlobStore.h"
|
||||
#include "ParallelAccessFsBlobStoreAdapter.h"
|
||||
|
||||
namespace cryfs {
|
||||
namespace parallelaccessfsblobstore {
|
||||
@ -35,6 +36,25 @@ namespace cryfs {
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ParallelAccessFsBlobStore);
|
||||
};
|
||||
|
||||
inline ParallelAccessFsBlobStore::ParallelAccessFsBlobStore(cpputils::unique_ref<cachingfsblobstore::CachingFsBlobStore> baseBlobStore)
|
||||
: _baseBlobStore(std::move(baseBlobStore)),
|
||||
_parallelAccessStore(cpputils::make_unique_ref<ParallelAccessFsBlobStoreAdapter>(_baseBlobStore.get())) {
|
||||
}
|
||||
|
||||
void ParallelAccessFsBlobStore::remove(cpputils::unique_ref<FsBlobRef> blob) {
|
||||
blockstore::Key key = blob->key();
|
||||
return _parallelAccessStore.remove(key, std::move(blob));
|
||||
}
|
||||
|
||||
std::function<off_t (const blockstore::Key &key)> ParallelAccessFsBlobStore::_getLstatSize() {
|
||||
return [this] (const blockstore::Key &key) {
|
||||
auto blob = load(key);
|
||||
ASSERT(blob != boost::none, "Blob not found");
|
||||
return (*blob)->lstat_size();
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user