I have a virtual miniport that exposes a “disk drive” and I am attempting to partition and format it
using DiskPart:
select disk 1
create partition primary
format fs=ntfs quick
Unfortunately the format command fails with:
DiskPart has encountered an error: The parameter is incorrect.
See the System Event Log for more information.
And when I check the System log in the Event viewer there is no additional information.
Any suggestions on how to debug this problem? This is on Windows 8 with WinDbg attached.
My virtual miniport implements the CDB’s REPORT_LUNS,
TEST_UNIT_READY, INQUIRY, MODE_SENSE, READ_CAPACITY, READ, WRITE, SYNCHRONIZE_CACHE, UNMAP and the
various variants. It also implements SRB_FUNCTION_PNP/StorQueryCapabilities. I only fail
SRB_FUNCTION_IO_CONTROL and MODE_SENSE for unknown pages.
Thank you.
Are you implementing READ, READ16, WRITE, and WRITE16?
How about READ_CAPACITY and READ_CAPACITY16? READ_CAPACITY is a little
tricky as it gets called before READ_CAPACITY16 and it’s return determines
if READ_CAPACITY16 is called.
And last but not least, VERIFY and VERIFY16?
I’ve done what you are doing, and I had no such issues.
On Tue, Jan 8, 2019 at 6:34 PM Bill_Zissimopoulos
wrote:
> OSR https://community.osr.com/
> Bill_Zissimopoulos started a new discussion: DiskPart error while
> formatting storport virtual miniport
>
> I have a virtual miniport that exposes a “disk drive” and I am attempting
> to partition and format it
>
> using DiskPart:
>
> select disk 1 create partition primary format fs=ntfs quick
>
> Unfortunately the format command fails with:
>
> DiskPart has encountered an error: The parameter is incorrect. See the
> System Event Log for more information.
>
> And when I check the System log in the Event viewer there is no
> additional information.
>
> Any suggestions on how to debug this problem? This is on Windows 8 with
> WinDbg attached.
>
> My virtual miniport implements the CDB’s REPORT_LUNS,
>
> TEST_UNIT_READY, INQUIRY, MODE_SENSE, READ_CAPACITY, READ, WRITE,
> SYNCHRONIZE_CACHE, UNMAP and the
>
> various variants. It also implements
> SRB_FUNCTION_PNP/StorQueryCapabilities. I only fail
>
> SRB_FUNCTION_IO_CONTROL and MODE_SENSE for unknown pages.
>
> Thank you.
>
> –
> Reply to this email directly or follow the link below to check it out:
>
> https://community.osr.com/discussion/290924/diskpart-error-while-formatting-storport-virtual-miniport
>
> Check it out:
> https://community.osr.com/discussion/290924/diskpart-error-while-formatting-storport-virtual-miniport
>
Jamey, thanks for your response.
Are you implementing READ, READ16, WRITE, and WRITE16?
How about READ_CAPACITY and READ_CAPACITY16?
Yes, I am implementing all of these CDB’s.
And last but not least, VERIFY and VERIFY16?
I am not implementing these as I did not think they were necessary. I could try implementing them, but I log all SRB’s that fail for any reason and I have never seen Windows send me a VERIFY or VERIFY16 SRB.
Can you post your READ_CAPACITY code?
On Tue, Jan 8, 2019 at 11:32 PM Bill_Zissimopoulos
wrote:
> OSR https://community.osr.com/
> Bill_Zissimopoulos commented on DiskPart error while formatting storport
> virtual miniport
>
> Jamey, thanks for your response.
>
> > Are you implementing READ, READ16, WRITE, and WRITE16?
> >
> > How about READ_CAPACITY and READ_CAPACITY16?
>
> Yes, I am implementing all of these CDB’s.
>
> > And last but not least, VERIFY and VERIFY16?
>
> I am not implementing these as I did not think they were necessary. I
> could try implementing them, but I log all SRB’s that fail for any reason
> and I have never seen Windows send me a VERIFY or VERIFY16 SRB.
>
> –
> Reply to this email directly or follow the link below to check it out:
> https://community.osr.com/discussion/comment/292079#Comment_292079
>
> Check it out:
> https://community.osr.com/discussion/comment/292079#Comment_292079
>
Just a thought: For storage diagnostic purposes, we’ve found Mike Beehan’s busTRACE utility super helpful. While we don’t normally advocate the use of software only trace programs (we tend to favor hardware bus analyzers when tracing is needed) busTRACE does a nice job of identifying problem sequences … and works on virtual storPort drivers.
For the record: We have no relationship with or financial interest in this tool or it’s developers, beyond that of being a satisfied user.
Peter
Jamey Kirby wrote:
Can you post your READ_CAPACITY code?
The READ CAPACITY code is available here:
https://github.com/billziss-gh/winspd/blob/master/src/sys/scsi.c#L438
(This is an open source project.)
Peter Viscarola wrote:
Just a thought: For storage diagnostic purposes, we’ve found Mike Beehan’s busTRACE utility super helpful.
Thanks for the pointer. I know about busTRACE from your OSR articles about writing virtual storports. I looked into purchasing it, but did not like the software’s subscription model; I like to have free use of the software that I pay for.
As an (not so good) alternative I have been developing my own tooling for testing and have also been using sg3_utils via Cygwin.
Here is a snippet of how to deal with READ_CAPACITY.
On Wed, Jan 9, 2019 at 8:44 AM Bill_Zissimopoulos
wrote:
> OSR https://community.osr.com/
> Bill_Zissimopoulos commented on DiskPart error while formatting storport
> virtual miniport
>
> Jamey Kirby wrote:
>
> > Can you post your READ_CAPACITY code?
>
> The READ CAPACITY code is available here:
>
> https://github.com/billziss-gh/winspd/blob/master/src/sys/scsi.c#L438
>
> (This is an open source project.)
>
> Peter Viscarola wrote:
>
> > Just a thought: For storage diagnostic purposes, we’ve found Mike
> Beehan’s busTRACE utility super helpful.
>
> Thanks for the pointer. I know about busTRACE from your OSR articles about
> writing virtual storports. I looked into purchasing it, but did not like
> the software’s subscription model; I like to have free use of the software
> that I pay for.
>
> As an (not so good) alternative I have been developing my own tooling for
> testing and have also been using sg3_utils via Cygwin.
>
> –
> Reply to this email directly or follow the link below to check it out:
> https://community.osr.com/discussion/comment/292083#Comment_292083
>
> Check it out:
> https://community.osr.com/discussion/comment/292083#Comment_292083
>
Oops…
case SCSIOP_READ_CAPACITY:
RtlZeroMemory(request->io_buffer, request->transfer_bytes);
read_capacity = (PREAD_CAPACITY_DATA)request->io_buffer;
block_size = r_pool->GetBlockSize();
LARGE_INTEGER blocks;
blocks = r_pool->GetBlockCount();
if (blocks.QuadPart > DWORD_MAX) {
max_blocks.LowPart = DWORD_MAX;
}
else {
max_blocks.LowPart = blocks.LowPart - 1;
}
REVERSE_BYTES(&read_capacity->BytesPerBlock, &block_size);
REVERSE_BYTES(&read_capacity->LogicalBlockAddress, &max_blocks.LowPart);
break;
case SCSIOP_READ_CAPACITY16:
RtlZeroMemory(request->io_buffer, request->transfer_bytes);
read_capacity16 = (PREAD_CAPACITY16_DATA)request->io_buffer;
block_size = r_pool->GetBlockSize();
max_blocks = r_pool->GetBlockCount();
max_blocks.QuadPart–;
REVERSE_BYTES(&read_capacity16->BytesPerBlock, &block_size);
REVERSE_BYTES_QUAD(&read_capacity16->LogicalBlockAddress, &max_blocks);
break;
READ_CAPACITY will get called first. If block count is greater than
DWORD_MAX it sets the value to DWORD_MAX and returns. The the port driver
will then call READ_CAPACITY16. I’m also not quite sure why you are
accessing the CDB at a byte level. Let the compiler facilitate.
On Wed, Jan 9, 2019 at 11:20 AM Jamey Kirby <kirby.jamey> wrote:
> Here is a snippet of how to deal with READ_CAPACITY.
>
> On Wed, Jan 9, 2019 at 8:44 AM Bill_Zissimopoulos
> wrote:
>
>> OSR https://community.osr.com/
>> Bill_Zissimopoulos commented on DiskPart error while formatting storport
>> virtual miniport
>>
>> Jamey Kirby wrote:
>>
>> > Can you post your READ_CAPACITY code?
>>
>> The READ CAPACITY code is available here:
>>
>> https://github.com/billziss-gh/winspd/blob/master/src/sys/scsi.c#L438
>>
>> (This is an open source project.)
>>
>> Peter Viscarola wrote:
>>
>> > Just a thought: For storage diagnostic purposes, we’ve found Mike
>> Beehan’s busTRACE utility super helpful.
>>
>> Thanks for the pointer. I know about busTRACE from your OSR articles
>> about writing virtual storports. I looked into purchasing it, but did not
>> like the software’s subscription model; I like to have free use of the
>> software that I pay for.
>>
>> As an (not so good) alternative I have been developing my own tooling
>> for testing and have also been using sg3_utils via Cygwin.
>>
>> –
>> Reply to this email directly or follow the link below to check it out:
>> https://community.osr.com/discussion/comment/292083#Comment_292083
>>
>> Check it out:
>> https://community.osr.com/discussion/comment/292083#Comment_292083
>>
>
>
> –
> Jamey Kirby
> Disrupting the establishment since 1964
>
> This is a personal email account and as such, emails are not subject to
> archiving. Nothing else really matters.
></kirby.jamey>
Jamie, thanks. Looking through your code it looks to me that we are handling READ CAPACITY (10) and (16) in a similar fashion. One difference is that I set the LBPME bit in READ CAPACITY (16); I understand this to be one of the requirements to support the UNMAP command.
FWIW, I have now tested on Server 2012 R2 and was able to get some possibly useful information, because on this platform there is indeed an error logged in the system log:
VDS fails to write boot code on a disk during clean operation. Error code: 80070013@02070008
I do not know about the 02070008 part, but the 80070013 part looks to me like the Win32 error 0x13 wrapped in an NTSTATUS (or HRESULT?). Win32 error 0x13 is ERROR_WRITE_PROTECT. So the error message together with the error code suggests that Windows thinks that the disk is write-protected.
I have no idea why this is so, but perhaps I have screwed up in one of my SCSI responses; the SCSI specs are quite hard to parse for me. (Would busTRACE capture something like this? Hmmm…)
I like to have free use of the software that I pay for
I recently declined to “purchase” another software tool for this exact reason, so I sympathize entirely.
Peter
I wrote:
FWIW, I have now tested on Server 2012 R2 and was able to get some possibly useful information, because on this platform there is indeed an error logged in the system log:
VDS fails to write boot code on a disk during clean operation. Error code: 80070013@02070008
Turns out that this is due to a “SAN policy” on Windows Server. More information here:
To overcome this I now have the following diskpart commands in my test scripts:
attribute disk clear readonly noerr
online disk noerr
Unfortunately the original problem (“the parameter is incorrect” during format) remains unresolved.
There were several problems found and fixed or worked around. I list them here for the benefit of others:
-
During completion of WRITE SRB’s the DataTransferLength was erroneously set to 0. This resulted in NtWriteFile returning SUCCESS with 0 bytes transferred and format.com determining that the drive was read-only.
-
Windows does not appear to respect the “MAXIMUM TRANSFER LENGTH” of the Block Limits VPD page (at least on Win8). I was setting this to (the correct number of blocks for) 64K, but routinely got transfers for 128k. My driver was failing these requests with the appropriate Sense code, but nevertheless format.com was failing.
- I will create a separate NTDEV post for this as I believe it merits its own discussion.
-
Windows regularly sends READ (and WRITE?) SRB’s with a zero DataBuffer. My driver was failing such requests with SRB_STATUS_INTERNAL_ERROR.