fs: properly implement OperateRangeWithBuffer, correct OperationId names.

This commit is contained in:
Michael Scire
2021-04-29 20:09:45 -07:00
parent eb5542963f
commit 0dc308d92a
17 changed files with 54 additions and 34 deletions

View File

@@ -189,7 +189,7 @@ namespace ams::fssystem {
Result AesCtrCounterExtendedStorage::OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) {
switch (op_id) {
case fs::OperationId::InvalidateCache:
case fs::OperationId::Invalidate:
{
/* Validate preconditions. */
AMS_ASSERT(offset >= 0);

View File

@@ -236,7 +236,7 @@ namespace ams::fssystem {
{
s64 storage_size;
R_TRY(this->node_storage.GetSize(std::addressof(storage_size)));
R_TRY(this->node_storage.OperateRange(fs::OperationId::InvalidateCache, 0, storage_size));
R_TRY(this->node_storage.OperateRange(fs::OperationId::Invalidate, 0, storage_size));
}
/* Refresh start/end offsets. */
@@ -270,7 +270,7 @@ namespace ams::fssystem {
{
s64 storage_size;
R_TRY(this->entry_storage.GetSize(std::addressof(storage_size)));
R_TRY(this->entry_storage.OperateRange(fs::OperationId::InvalidateCache, 0, storage_size));
R_TRY(this->entry_storage.OperateRange(fs::OperationId::Invalidate, 0, storage_size));
}
return ResultSuccess();

View File

@@ -120,7 +120,7 @@ namespace ams::fssystem {
Result IndirectStorage::OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) {
switch (op_id) {
case fs::OperationId::InvalidateCache:
case fs::OperationId::Invalidate:
{
if (size > 0) {
/* Validate arguments. */

View File

@@ -269,7 +269,7 @@ namespace ams::fssystem {
virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override {
switch (op_id) {
case fs::OperationId::InvalidateCache:
case fs::OperationId::Invalidate:
{
R_TRY(this->true_storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size));
R_TRY(this->false_storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size));

View File

@@ -87,7 +87,7 @@ namespace ams::fssystem {
virtual Result DoOperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override final {
/* Validate preconditions for operation. */
switch (op_id) {
case fs::OperationId::InvalidateCache:
case fs::OperationId::Invalidate:
R_UNLESS((this->mode & fs::OpenMode_Read) != 0, fs::ResultReadNotPermitted());
R_UNLESS((this->mode & fs::OpenMode_Write) == 0, fs::ResultUnsupportedOperationInPartitionFileB());
break;

View File

@@ -92,7 +92,7 @@ namespace ams::fssystem {
AMS_ASSERT(util::IsAligned(size, this->block_size));
/* If invalidating cache, invalidate our blocks. */
if (op_id == fs::OperationId::InvalidateCache) {
if (op_id == fs::OperationId::Invalidate) {
R_UNLESS(offset >= 0, fs::ResultInvalidOffset());
std::scoped_lock lk(this->mutex);

View File

@@ -73,7 +73,7 @@ namespace ams::fssystem {
virtual Result DoOperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override {
switch (op_id) {
case fs::OperationId::InvalidateCache:
case fs::OperationId::Invalidate:
case fs::OperationId::QueryRange:
{
R_UNLESS(offset >= 0, fs::ResultOutOfRange());

View File

@@ -389,17 +389,17 @@ namespace ams::fssystem::save {
AMS_ASSERT(this->data_storage != nullptr);
switch (op_id) {
case fs::OperationId::Clear:
case fs::OperationId::FillZero:
{
R_TRY(this->ClearImpl(offset, size));
return ResultSuccess();
}
case fs::OperationId::ClearSignature:
case fs::OperationId::DestroySignature:
{
R_TRY(this->ClearSignatureImpl(offset, size));
return ResultSuccess();
}
case fs::OperationId::InvalidateCache:
case fs::OperationId::Invalidate:
{
R_UNLESS(this->storage_type != fs::StorageType_SaveData, fs::ResultUnsupportedOperationInBlockCacheBufferedStorageB());
R_TRY(this->InvalidateCacheImpl(offset, size));
@@ -531,7 +531,7 @@ namespace ams::fssystem::save {
R_SUCCEED_IF(start_offset == end_offset);
/* Clear the signature for the aligned range. */
R_TRY(this->UpdateLastResult(this->data_storage->OperateRange(fs::OperationId::Clear, start_offset, end_offset - start_offset)));
R_TRY(this->UpdateLastResult(this->data_storage->OperateRange(fs::OperationId::FillZero, start_offset, end_offset - start_offset)));
/* Set blocking buffer manager allocations. */
buffers::EnableBlockingBufferManagerAllocation();
@@ -558,7 +558,7 @@ namespace ams::fssystem::save {
R_TRY(this->UpdateLastResult(this->FlushRangeCacheEntries(offset, size, true)));
/* Clear the signature for the aligned range. */
R_TRY(this->UpdateLastResult(this->data_storage->OperateRange(fs::OperationId::ClearSignature, start_offset, end_offset - start_offset)));
R_TRY(this->UpdateLastResult(this->data_storage->OperateRange(fs::OperationId::DestroySignature, start_offset, end_offset - start_offset)));
/* Set blocking buffer manager allocations. */
buffers::EnableBlockingBufferManagerAllocation();
@@ -583,7 +583,7 @@ namespace ams::fssystem::save {
/* Invalidate the aligned range. */
{
Result result = this->data_storage->OperateRange(fs::OperationId::InvalidateCache, aligned_offset, aligned_size);
Result result = this->data_storage->OperateRange(fs::OperationId::Invalidate, aligned_offset, aligned_size);
AMS_ASSERT(!fs::ResultBufferAllocationFailed::Includes(result));
R_TRY(result);
}

View File

@@ -718,7 +718,7 @@ namespace ams::fssystem::save {
AMS_ASSERT(this->IsInitialized());
/* Invalidate caches, if we should. */
if (op_id == fs::OperationId::InvalidateCache) {
if (op_id == fs::OperationId::Invalidate) {
SharedCache cache(this);
while (cache.AcquireNextOverlappedCache(offset, size)) {
cache.Invalidate();

View File

@@ -316,14 +316,14 @@ namespace ams::fssystem::save {
Result HierarchicalIntegrityVerificationStorage::OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) {
switch (op_id) {
case fs::OperationId::Clear:
case fs::OperationId::ClearSignature:
case fs::OperationId::FillZero:
case fs::OperationId::DestroySignature:
{
R_TRY(this->buffer_storages[this->max_layers - 2].OperateRange(dst, dst_size, op_id, offset, size, src, src_size));
this->is_written_for_rollback = true;
return ResultSuccess();
}
case fs::OperationId::InvalidateCache:
case fs::OperationId::Invalidate:
case fs::OperationId::QueryRange:
{
R_TRY(this->buffer_storages[this->max_layers - 2].OperateRange(dst, dst_size, op_id, offset, size, src, src_size));

View File

@@ -256,7 +256,7 @@ namespace ams::fssystem::save {
AMS_ASSERT(util::IsAligned(size, static_cast<size_t>(this->verification_block_size)));
switch (op_id) {
case fs::OperationId::Clear:
case fs::OperationId::FillZero:
{
/* Clear should only be called for save data. */
AMS_ASSERT(this->storage_type == fs::StorageType_SaveData);
@@ -289,7 +289,7 @@ namespace ams::fssystem::save {
return ResultSuccess();
}
case fs::OperationId::ClearSignature:
case fs::OperationId::DestroySignature:
{
/* Clear Signature should only be called for save data. */
AMS_ASSERT(this->storage_type == fs::StorageType_SaveData);
@@ -319,7 +319,7 @@ namespace ams::fssystem::save {
/* Write the cleared signature. */
return this->hash_storage.Write(sign_offset, buf.get(), sign_size);
}
case fs::OperationId::InvalidateCache:
case fs::OperationId::Invalidate:
{
/* Only allow cache invalidation for RomFs. */
R_UNLESS(this->storage_type != fs::StorageType_SaveData, fs::ResultUnsupportedOperationInIntegrityVerificationStorageB());