stratosphere: use SdkMutex/SdkRecursiveMutex over Mutex

This commit is contained in:
Michael Scire 2021-09-29 22:52:50 -07:00
parent a4fe1bb5d8
commit 41ab4c2c68
70 changed files with 188 additions and 645 deletions

View file

@ -192,7 +192,7 @@ namespace ams::fssystem {
size_t peak_free_size;
size_t peak_total_allocatable_size;
size_t retried_count;
mutable os::Mutex mutex;
mutable os::SdkRecursiveMutex mutex;
public:
static constexpr size_t QueryWorkBufferSize(s32 max_cache_count, s32 max_order) {
const auto buddy_size = FileSystemBuddyHeap::QueryWorkBufferSize(max_order);
@ -200,7 +200,7 @@ namespace ams::fssystem {
return buddy_size + table_size;
}
public:
FileSystemBufferManager() : total_size(), peak_free_size(), peak_total_allocatable_size(), retried_count(), mutex(true) { /* ... */ }
FileSystemBufferManager() : total_size(), peak_free_size(), peak_total_allocatable_size(), retried_count(), mutex() { /* ... */ }
virtual ~FileSystemBufferManager() { /* ... */ }

View file

@ -33,7 +33,7 @@ namespace ams::fssystem {
char key[2][KeySize];
char iv[IvSize];
const size_t block_size;
os::Mutex mutex;
os::SdkMutex mutex;
public:
AesXtsStorage(IStorage *base, const void *key1, const void *key2, size_t key_size, const void *iv, size_t iv_size, size_t block_size);

View file

@ -34,7 +34,7 @@ namespace ams::fssystem {
virtual ~DirectoryRedirectionFileSystem();
protected:
inline util::optional<std::scoped_lock<os::Mutex>> GetAccessorLock() const {
inline util::optional<std::scoped_lock<os::SdkMutex>> GetAccessorLock() const {
/* No accessor lock is needed. */
return util::nullopt;
}

View file

@ -24,7 +24,7 @@ namespace ams::fssystem {
using PathResolutionFileSystem = impl::IPathResolutionFileSystem<DirectorySaveDataFileSystem>;
friend class impl::IPathResolutionFileSystem<DirectorySaveDataFileSystem>;
private:
os::Mutex accessor_mutex;
os::SdkMutex accessor_mutex;
s32 open_writable_files;
public:
DirectorySaveDataFileSystem(std::shared_ptr<fs::fsa::IFileSystem> fs);
@ -33,9 +33,9 @@ namespace ams::fssystem {
virtual ~DirectorySaveDataFileSystem();
protected:
inline util::optional<std::scoped_lock<os::Mutex>> GetAccessorLock() {
inline util::optional<std::scoped_lock<os::SdkMutex>> GetAccessorLock() {
/* We have a real accessor lock that we want to use. */
return util::make_optional<std::scoped_lock<os::Mutex>>(this->accessor_mutex);
return util::make_optional<std::scoped_lock<os::SdkMutex>>(this->accessor_mutex);
}
private:
Result AllocateWorkBuffer(std::unique_ptr<u8[]> *out, size_t *out_size, size_t ideal_size);

View file

@ -30,11 +30,11 @@ namespace ams::fssystem {
private:
save::HierarchicalIntegrityVerificationStorage integrity_storage;
save::FileSystemBufferManagerSet buffers;
os::Mutex mutex;
os::SdkRecursiveMutex mutex;
Hash master_hash;
std::unique_ptr<fs::MemoryStorage> master_hash_storage;
public:
IntegrityRomFsStorage() : mutex(true) { /* ... */ }
IntegrityRomFsStorage() : mutex() { /* ... */ }
virtual ~IntegrityRomFsStorage() override { this->Finalize(); }
Result Initialize(save::HierarchicalIntegrityVerificationInformation level_hash_info, Hash master_hash, save::HierarchicalIntegrityVerificationStorage::HierarchicalStorageInformation storage_info, IBufferManager *bm);

View file

@ -32,7 +32,7 @@ namespace ams::fssystem {
virtual ~SubDirectoryFileSystem();
protected:
inline util::optional<std::scoped_lock<os::Mutex>> GetAccessorLock() const {
inline util::optional<std::scoped_lock<os::SdkMutex>> GetAccessorLock() const {
/* No accessor lock is needed. */
return util::nullopt;
}

View file

@ -62,7 +62,7 @@ namespace ams::fssystem::save {
};
private:
IBufferManager *buffer_manager;
os::Mutex *mutex;
os::SdkRecursiveMutex *mutex;
std::unique_ptr<CacheEntry[], ::ams::fs::impl::Deleter> entries;
IStorage *data_storage;
Result last_result;
@ -78,7 +78,7 @@ namespace ams::fssystem::save {
BlockCacheBufferedStorage();
virtual ~BlockCacheBufferedStorage() override;
Result Initialize(IBufferManager *bm, os::Mutex *mtx, IStorage *data, s64 data_size, size_t verif_block_size, s32 max_cache_entries, bool is_real_data, s8 buffer_level, bool is_keep_burst_mode, fs::StorageType storage_type);
Result Initialize(IBufferManager *bm, os::SdkRecursiveMutex *mtx, IStorage *data, s64 data_size, size_t verif_block_size, s32 max_cache_entries, bool is_real_data, s8 buffer_level, bool is_keep_burst_mode, fs::StorageType storage_type);
void Finalize();
virtual Result Read(s64 offset, void *buffer, size_t size) override;

View file

@ -38,7 +38,7 @@ namespace ams::fssystem::save {
s32 cache_count;
Cache *next_acquire_cache;
Cache *next_fetch_cache;
os::Mutex mutex;
os::SdkMutex mutex;
bool bulk_read_enabled;
public:
BufferedStorage();

View file

@ -147,7 +147,7 @@ namespace ams::fssystem::save {
}
private:
FileSystemBufferManagerSet *buffers;
os::Mutex *mutex;
os::SdkRecursiveMutex *mutex;
IntegrityVerificationStorage verify_storages[MaxLayers - 1];
BlockCacheBufferedStorage buffer_storages[MaxLayers - 1];
s64 data_size;
@ -157,7 +157,7 @@ namespace ams::fssystem::save {
HierarchicalIntegrityVerificationStorage() : buffers(nullptr), mutex(nullptr), data_size(-1), is_written_for_rollback(false) { /* ... */ }
virtual ~HierarchicalIntegrityVerificationStorage() override { this->Finalize(); }
Result Initialize(const HierarchicalIntegrityVerificationInformation &info, HierarchicalStorageInformation storage, FileSystemBufferManagerSet *bufs, os::Mutex *mtx, fs::StorageType storage_type);
Result Initialize(const HierarchicalIntegrityVerificationInformation &info, HierarchicalStorageInformation storage, FileSystemBufferManagerSet *bufs, os::SdkRecursiveMutex *mtx, fs::StorageType storage_type);
void Finalize();
virtual Result Read(s64 offset, void *buffer, size_t size) override;