Skip to content

wrong data written #13

@martin-kudlicka

Description

@martin-kudlicka

Hello,
I am writing sort of disk cache using WinSpd. At the moment I am just mirroring real volume with virtual WinSpd volume. It means all reads/writes are just redirected to real volume. For example my WinSpd write callback contains

  ...
  LARGE_INTEGER distanceToMove;
  distanceToMove.QuadPart = BlockAddress * _sectorSize;
  if (!SetFilePointerEx(_sourceVolume, distanceToMove, Q_NULLPTR, FILE_BEGIN))
  {
    SpdStorageUnitStatusSetSense(Status, SCSI_SENSE_MEDIUM_ERROR, SCSI_ADSENSE_SEEK_ERROR, Q_NULLPTR);
    return FALSE;
  }

  DWORD bytesWritten = 0;
  if (!WriteFile(_sourceVolume, Buffer, BlockCount * _sectorSize, &bytesWritten, Q_NULLPTR))
  {
    SpdStorageUnitStatusSetSense(Status, SCSI_SENSE_MEDIUM_ERROR, SCSI_ADSENSE_WRITE_ERROR, Q_NULLPTR);
    return FALSE;
  }
  ...

_sectorSize is 512 bytes, _sourceVolume is HANDLE to testing volume on VHDX disk.
When writing 60 MB of data some of the data is not correctly written (content doesn't match). It's usually about 10 blocks of size SPD_IOCTL_STORAGE_UNIT_PARAMS::MaxTransferLength which I have set to 65 kB.
I found out when I set SpdStorageUnitStartDispatcher to 1 thread all data are correctly written. It could be somehow connected to #10 .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions