[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [win-pv-devel] [PATCH] Fix > 2TB disks
On Fri, 11 Oct 2019 at 14:51, Owen Smith <owen.smith@xxxxxxxxxx> wrote: > > In order to determine the size of a disk, Windows will issue a > SCSIOP_READ_CAPACITY. Disks larger than 2TB will respond with a max LBA > of 0xFFFFFFFF, which causes Windows to issue a SCSIOP_READ_CAPACITY16. > The read capacity 16 is passed with a 12 byte buffer to be filled in > using the READ_CAPACITY_DATA_EX structure, not the 16 or 32byte > (depending on packing) READ_CAPACITY16_DATA buffer. > Also adds Error labels to the failure conditions. > > Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx> Acked-by: Paul Durrant <paul@xxxxxxx> > --- > src/xenvbd/target.c | 40 +++++++++++++++++++++++++++++++--------- > 1 file changed, 31 insertions(+), 9 deletions(-) > > diff --git a/src/xenvbd/target.c b/src/xenvbd/target.c > index e322949..4919db2 100644 > --- a/src/xenvbd/target.c > +++ b/src/xenvbd/target.c > @@ -545,14 +545,14 @@ TargetReadCapacity( > Srb->SrbStatus = SRB_STATUS_ERROR; > > if (Data == NULL) > - return; > + goto fail1; > RtlZeroMemory(Data, Length); > > if (Length < sizeof(READ_CAPACITY_DATA)) > - return; > + goto fail2; > > if (Cdb_PMI(Srb) == 0 && Cdb_LogicalBlock(Srb) != 0) > - return; > + goto fail3; > > SectorCount = DiskInfo->SectorCount; > SectorSize = DiskInfo->SectorSize; > @@ -567,6 +567,15 @@ TargetReadCapacity( > > Srb->DataTransferLength = sizeof(READ_CAPACITY_DATA); > Srb->SrbStatus = SRB_STATUS_SUCCESS; > + > + return; > + > +fail3: > + Error("fail3\n"); > +fail2: > + Error("fail2\n"); > +fail1: > + Error("fail1\n"); > } > > static DECLSPEC_NOINLINE VOID > @@ -587,14 +596,14 @@ TargetReadCapacity16( > Srb->SrbStatus = SRB_STATUS_ERROR; > > if (Data == NULL) > - return; > + goto fail1; > RtlZeroMemory(Data, Length); > > - if (Length < sizeof(READ_CAPACITY16_DATA)) > - return; > + if (Length < sizeof(READ_CAPACITY_DATA_EX)) > + goto fail2; > > if (Cdb_PMI(Srb) == 0 && Cdb_LogicalBlock(Srb) != 0) > - return; > + goto fail3; > > SectorCount = DiskInfo->SectorCount; > SectorSize = DiskInfo->SectorSize; > @@ -607,10 +616,23 @@ TargetReadCapacity16( > > Data->LogicalBlockAddress.QuadPart = _byteswap_uint64(SectorCount - 1); > Data->BytesPerBlock = _byteswap_ulong(SectorSize); > - Data->LogicalPerPhysicalExponent = (UCHAR)LogicalPerPhysicalExponent; > > - Srb->DataTransferLength = sizeof(READ_CAPACITY16_DATA); > + if (Length == sizeof(READ_CAPACITY16_DATA)) > + Data->LogicalPerPhysicalExponent = (UCHAR)LogicalPerPhysicalExponent; > + else > + Length = sizeof(READ_CAPACITY_DATA_EX); > + > + Srb->DataTransferLength = Length; > Srb->SrbStatus = SRB_STATUS_SUCCESS; > + > + return; > + > +fail3: > + Error("fail3\n"); > +fail2: > + Error("fail2\n"); > +fail1: > + Error("fail1\n"); > } > > static FORCEINLINE VOID > -- > 2.16.2.windows.1 > > > _______________________________________________ > win-pv-devel mailing list > win-pv-devel@xxxxxxxxxxxxxxxxxxxx > https://lists.xenproject.org/mailman/listinfo/win-pv-devel _______________________________________________ win-pv-devel mailing list win-pv-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/win-pv-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |