sim_disk.c - Optimized read operations from unallocated VHD blocks
This commit is contained in:
parent
ed463a94fc
commit
a74c2d22dd
1 changed files with 4 additions and 8 deletions
12
sim_disk.c
12
sim_disk.c
|
@ -3244,14 +3244,13 @@ while (sects) {
|
||||||
uint32 BitMapBytes = (7+(NtoHl (hVHD->Dynamic.BlockSize)/SectorSize))/8;
|
uint32 BitMapBytes = (7+(NtoHl (hVHD->Dynamic.BlockSize)/SectorSize))/8;
|
||||||
uint32 BitMapSectors = (BitMapBytes+SectorSize-1)/SectorSize;
|
uint32 BitMapSectors = (BitMapBytes+SectorSize-1)/SectorSize;
|
||||||
|
|
||||||
SectorsInRead = 1;
|
SectorsInRead = SectorsPerBlock - lba%SectorsPerBlock;
|
||||||
|
if (SectorsInRead > sects)
|
||||||
|
SectorsInRead = sects;
|
||||||
if (hVHD->BAT[BlockNumber] == VHD_BAT_FREE_ENTRY) {
|
if (hVHD->BAT[BlockNumber] == VHD_BAT_FREE_ENTRY) {
|
||||||
if (!hVHD->Parent)
|
if (!hVHD->Parent)
|
||||||
memset (buf, 0, SectorSize);
|
memset (buf, 0, SectorSize*SectorSize);
|
||||||
else {
|
else {
|
||||||
SectorsInRead = SectorsPerBlock - lba%SectorsPerBlock;
|
|
||||||
if (SectorsInRead > sects)
|
|
||||||
SectorsInRead = sects;
|
|
||||||
if (ReadVirtualDiskSectors(hVHD->Parent,
|
if (ReadVirtualDiskSectors(hVHD->Parent,
|
||||||
buf,
|
buf,
|
||||||
SectorsInRead,
|
SectorsInRead,
|
||||||
|
@ -3266,9 +3265,6 @@ while (sects) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
BlockOffset = SectorSize*((uint64)(NtoHl (hVHD->BAT[BlockNumber]) + lba%SectorsPerBlock + BitMapSectors));
|
BlockOffset = SectorSize*((uint64)(NtoHl (hVHD->BAT[BlockNumber]) + lba%SectorsPerBlock + BitMapSectors));
|
||||||
SectorsInRead = SectorsPerBlock - lba%SectorsPerBlock;
|
|
||||||
if (SectorsInRead > sects)
|
|
||||||
SectorsInRead = sects;
|
|
||||||
if (ReadFilePosition(hVHD->File,
|
if (ReadFilePosition(hVHD->File,
|
||||||
buf,
|
buf,
|
||||||
SectorsInRead*SectorSize,
|
SectorsInRead*SectorSize,
|
||||||
|
|
Loading…
Add table
Reference in a new issue