[VFS] Fix BlockToHashBlockOffset's level 2 case (blockStep0 -> blockStep1)

& changed code to switch statement instead.
This commit is contained in:
emoose 2020-01-11 09:31:31 +00:00 committed by illusion
parent deb9661852
commit c552a853e0
1 changed files with 20 additions and 16 deletions

View File

@ -654,24 +654,28 @@ size_t StfsContainerDevice::BlockToHashBlockOffset(uint64_t block,
}
uint64_t backing_num = 0;
if (hash_level == 0) {
switch (hash_level) {
case 0:
backing_num = (block / 0xAA) * blockStep0;
if (block / 0xAA == 0) {
return BackingBlockToOffsetSTFS(backing_num);
}
backing_num = backing_num + ((block / 0x70E4) + 1) * numTables;
backing_num += ((block / 0x70E4) + 1) * numTables;
if (block / 0x70E4 == 0) {
return BackingBlockToOffsetSTFS(backing_num);
}
} else if (hash_level == 1) {
break;
case 1:
backing_num = (block / 0x70E4) * blockStep1;
if (block / 0x70E4 == 0) {
return BackingBlockToOffsetSTFS(backing_num + blockStep0);
}
} else {
return BackingBlockToOffsetSTFS(blockStep0);
break;
default:
return BackingBlockToOffsetSTFS(blockStep1);
}
return BackingBlockToOffsetSTFS(backing_num + numTables);
}