Read Capacity issue

We’ve developed a storport driver. The size in 512 sector size is larger than 4G. In this case, FFFFFFFF is returned in SCSIOP_READ_CAPACITY command. And SCSIOP_READ_CAPACITY16 is issued by Windows after this. The driver works fine in previous Win server 2012 R2.

Now we’ve re-installed the OS. It’s still Win server 2012 R2, but there’s no SCSIOP_READ_CAPACITY16 after same return. Is there any patch or setting related to this? Or there’s some feature related to SCSIOP_READ_CAPACITY16 I should return in previous commands issued by Windows?

Thanks.

Are you doing this in your read capacity call to inform storport that you
need the 16 call?

if (blocks.QuadPart > DWORD_MAX) {
max_blocks.LowPart = DWORD_MAX;
}
else {
max_blocks.LowPart = blocks.LowPart - 1;
}

On Fri, Jul 27, 2018 at 11:16 AM xxxxx@gmail.com
wrote:

> We’ve developed a storport driver. The size in 512 sector size is larger
> than 4G. In this case, FFFFFFFF is returned in SCSIOP_READ_CAPACITY
> command. And SCSIOP_READ_CAPACITY16 is issued by Windows after this. The
> driver works fine in previous Win server 2012 R2.
>
> Now we’ve re-installed the OS. It’s still Win server 2012 R2, but there’s
> no SCSIOP_READ_CAPACITY16 after same return. Is there any patch or setting
> related to this? Or there’s some feature related to SCSIOP_READ_CAPACITY16
> I should return in previous commands issued by Windows?
>
> Thanks.
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: <
> http://www.osronline.com/showlists.cfm?list=ntdev&gt;
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
> software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at <
> http://www.osronline.com/page.cfm?name=ListServer&gt;
>


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.
</http:>

Yes.
LogicalBlockAddress in struct READ_CAPACITY_DATA is set to 0xFFFFFFFF.

And this?

REVERSE_BYTES(&read_capacity->BytesPerBlock, &block_size);
REVERSE_BYTES(&read_capacity->LogicalBlockAddress, &max_blocks.LowPart);

Just trying to help you eliminate.

On Fri, Jul 27, 2018 at 11:38 AM xxxxx@gmail.com
wrote:

> Yes.
> LogicalBlockAddress in struct READ_CAPACITY_DATA is set to 0xFFFFFFFF.
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: <
> http://www.osronline.com/showlists.cfm?list=ntdev&gt;
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
> software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at <
> http://www.osronline.com/page.cfm?name=ListServer&gt;
>


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.
</http:>

Also, do you implement read_capacity32? Maybe that is getting called?

I have a similar driver, and read_capacity16 works for me. We’ve not has
any issues on any version of Windows with respect to read_capacity that I
am aware of.

On Fri, Jul 27, 2018 at 11:50 AM Jamey Kirby wrote:

> And this?
>
> REVERSE_BYTES(&read_capacity->BytesPerBlock, &block_size);
> REVERSE_BYTES(&read_capacity->LogicalBlockAddress, &max_blocks.LowPart);
>
> Just trying to help you eliminate.
>
> On Fri, Jul 27, 2018 at 11:38 AM xxxxx@gmail.com
> wrote:
>
>> Yes.
>> LogicalBlockAddress in struct READ_CAPACITY_DATA is set to 0xFFFFFFFF.
>>
>>
>> —
>> NTDEV is sponsored by OSR
>>
>> Visit the list online at: <
>> http://www.osronline.com/showlists.cfm?list=ntdev&gt;
>>
>> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
>> software drivers!
>> Details at http:
>>
>> To unsubscribe, visit the List Server section of OSR Online at <
>> http://www.osronline.com/page.cfm?name=ListServer&gt;
>>
>
>
> –
> 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.

>


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.
</http:>

Code is like this:

if (lastLba & 0xFFFFFFFF00000000) {
ret_lastLba = 0xFFFFFFFF;
}
else {
ret_lastLba = lastLba;
}
REVERSE_BYTES(&pReadCapacityData->LogicalBlockAddress, &ret_lastLba);
REVERSE_BYTES(&pReadCapacityData->BytesPerBlock, &lba_length);

if (allocLength > 0 && allocLength < READ_CAP_10_PARM_DATA_SIZE) {
StorPortCopyMemory(respBuf, pReadCapacityData, allocLength);
}
pReadCapacityData = (PREAD_CAPACITY_DATA)respBuf;
SrbSetDataTransferLength(pSrb, min(allocLength, READ_CAP_10_PARM_DATA_SIZE));

There’s extra print info for this:
"original size 200000000, ret_lastLba ffffffff, lba_length 512, trans length 8?

And there’s no extra read capacity like read capacity 16 or read capacity 32 command issued.

After install, the disk size shows 4096G in the system. When the size is increased, it always shows 4096G.

This is how I handle it:

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;

On Fri, Jul 27, 2018 at 9:17 PM xxxxx@gmail.com
wrote:

> Code is like this:
> ===========================================
> if (lastLba & 0xFFFFFFFF00000000) {
> ret_lastLba = 0xFFFFFFFF;
> }
> else {
> ret_lastLba = lastLba;
> }
> REVERSE_BYTES(&pReadCapacityData->LogicalBlockAddress, &ret_lastLba);
> REVERSE_BYTES(&pReadCapacityData->BytesPerBlock, &lba_length);
>
> if (allocLength > 0 && allocLength < READ_CAP_10_PARM_DATA_SIZE) {
> StorPortCopyMemory(respBuf, pReadCapacityData, allocLength);
> }
> pReadCapacityData = (PREAD_CAPACITY_DATA)respBuf;
> SrbSetDataTransferLength(pSrb, min(allocLength,
> READ_CAP_10_PARM_DATA_SIZE));
> ==================================================
> There’s extra print info for this:
> "original size 200000000, ret_lastLba ffffffff, lba_length 512, trans
> length 8?
> ==================================================
>
> And there’s no extra read capacity like read capacity 16 or read capacity
> 32 command issued.
>
> After install, the disk size shows 4096G in the system. When the size is
> increased, it always shows 4096G.
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: <
> http://www.osronline.com/showlists.cfm?list=ntdev&gt;
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
> software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at <
> http://www.osronline.com/page.cfm?name=ListServer&gt;
>


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.
</http:>

I proxy up to user-mode, so this code is in user-mode. But the idea is the
same.

On Fri, Jul 27, 2018 at 10:09 PM Jamey Kirby wrote:

> This is how I handle it:
>
> 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;
>
>
> On Fri, Jul 27, 2018 at 9:17 PM xxxxx@gmail.com
> wrote:
>
>> Code is like this:
>> ===========================================
>> if (lastLba & 0xFFFFFFFF00000000) {
>> ret_lastLba = 0xFFFFFFFF;
>> }
>> else {
>> ret_lastLba = lastLba;
>> }
>> REVERSE_BYTES(&pReadCapacityData->LogicalBlockAddress, &ret_lastLba);
>> REVERSE_BYTES(&pReadCapacityData->BytesPerBlock, &lba_length);
>>
>> if (allocLength > 0 && allocLength < READ_CAP_10_PARM_DATA_SIZE) {
>> StorPortCopyMemory(respBuf, pReadCapacityData, allocLength);
>> }
>> pReadCapacityData = (PREAD_CAPACITY_DATA)respBuf;
>> SrbSetDataTransferLength(pSrb, min(allocLength,
>> READ_CAP_10_PARM_DATA_SIZE));
>> ==================================================
>> There’s extra print info for this:
>> "original size 200000000, ret_lastLba ffffffff, lba_length 512, trans
>> length 8?
>> ==================================================
>>
>> And there’s no extra read capacity like read capacity 16 or read capacity
>> 32 command issued.
>>
>> After install, the disk size shows 4096G in the system. When the size is
>> increased, it always shows 4096G.
>>
>> —
>> NTDEV is sponsored by OSR
>>
>> Visit the list online at: <
>> http://www.osronline.com/showlists.cfm?list=ntdev&gt;
>>
>> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
>> software drivers!
>> Details at http:
>>
>> To unsubscribe, visit the List Server section of OSR Online at <
>> http://www.osronline.com/page.cfm?name=ListServer&gt;
>>
>
>
> –
> 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.

>


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.
</http:>