DiscIO: Fix edge case where blocks could get scrubbed accidentally

If we start 31 KiB into a 32 KiB block and want to mark 2 KiB
of data as used, we need to mark 2 blocks as used, not just 1.

This problem is avoided when calling MarkAsUsed from
MarkAsUsedE, since MarkAsUsedE aligns to 32 KiB on its own.
Most calls to MarkAsUsed are from MarkAsUsedE, which is why
this hasn't been a noticeable problem in the past.
This commit is contained in:
JosJuice 2020-04-10 16:21:51 +02:00
parent dae2c14f7f
commit cefc2a7baa
1 changed files with 2 additions and 2 deletions

View File

@ -58,8 +58,8 @@ bool DiscScrubber::CanBlockBeScrubbed(u64 offset) const
void DiscScrubber::MarkAsUsed(u64 offset, u64 size)
{
u64 current_offset = offset;
const u64 end_offset = current_offset + size;
u64 current_offset = Common::AlignDown(offset, CLUSTER_SIZE);
const u64 end_offset = offset + size;
DEBUG_LOG(DISCIO, "Marking 0x%016" PRIx64 " - 0x%016" PRIx64 " as used", offset, end_offset);