]> xenbits.xensource.com Git - pvdrivers/win/xenvbd.git/commitdiff
Report disk size and logical sector size in XENDISK...
authorPaul Durrant <paul.durrant@citrix.com>
Tue, 9 Apr 2019 16:03:08 +0000 (17:03 +0100)
committerPaul Durrant <paul.durrant@citrix.com>
Tue, 9 Apr 2019 16:38:05 +0000 (17:38 +0100)
...rather than XENVBD.

This allows us to use the PDO name rather than the more obscure target
number. Also, report the size in MB rather rather than in sectors (now
that sector size may be something other than 512B).

Also fix some whitespace bugs while in the neighbourhood.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
src/xendisk/pdo.c
src/xenvbd/frontend.c

index e91b1da1b2c393adf1a6bac21d77b9c4ae07db08..62e15b299cface188a944fd434e52f872eb9b8ff 100644 (file)
@@ -457,16 +457,17 @@ fail1:
 
 static NTSTATUS
 PdoSendReadCapacity16Synchronous(
-    IN  PXENDISK_PDO            Pdo,
-    OUT PULONG                  SectorSize,
-    OUT PULONG                  PhysSectorSize
+    IN  PXENDISK_PDO        Pdo,
+    OUT PULONG              SectorSize,
+    OUT PULONG              PhysSectorSize,
+    OUT PULONG64            SectorCount
     )
 {
-    SCSI_REQUEST_BLOCK          Srb;
-    PCDB                        Cdb;
-    PREAD_CAPACITY16_DATA       Capacity;
-    ULONG                       Length;
-    NTSTATUS                    status;
+    SCSI_REQUEST_BLOCK       Srb;
+    PCDB                     Cdb;
+    PREAD_CAPACITY16_DATA    Capacity;
+    ULONG                    Length;
+    NTSTATUS                 status;
 
     Trace("====>\n");
 
@@ -501,6 +502,7 @@ PdoSendReadCapacity16Synchronous(
 
     *SectorSize = _byteswap_ulong(Capacity->BytesPerBlock);
     *PhysSectorSize = *SectorSize << Capacity->LogicalPerPhysicalExponent;
+    *SectorCount = _byteswap_uint64(Capacity->LogicalBlockAddress.QuadPart) + 1;
 
     __PdoFree(Capacity);
 
@@ -830,6 +832,8 @@ PdoStartDevice(
 {
     ULONG               SectorSize;
     ULONG               PhysSectorSize;
+    ULONG64             SectorCount;
+    ULONG64             Size;
     POWER_STATE         PowerState;
     NTSTATUS            status;
 
@@ -841,15 +845,22 @@ PdoStartDevice(
     if (!NT_SUCCESS(status))
         goto fail2;
 
-    status = PdoSendReadCapacity16Synchronous(Pdo, &SectorSize, &PhysSectorSize);
+    status = PdoSendReadCapacity16Synchronous(Pdo,
+                                              &SectorSize,
+                                              &PhysSectorSize,
+                                              &SectorCount);
     if (!NT_SUCCESS(status))
         goto fail3;
 
-    Trace("SectorSize = %u PhysSectorSize = %u\n", SectorSize, PhysSectorSize);
-
     Pdo->SectorSize = SectorSize;
     Pdo->PhysSectorSize = PhysSectorSize;
 
+    Size = SectorSize * SectorCount;
+    Size >>= 20; // Scale to megabytes
+
+    Verbose("%s: %luMB (%uB sectors)\n",
+            __PdoGetName(Pdo), Size, SectorSize);
+
     __PdoSetSystemPowerState(Pdo, PowerSystemWorking);
     __PdoSetDevicePowerState(Pdo, PowerDeviceD0);
 
index 3310287f9182b33f02c809f9f3c88cb52f3b9b1c..f90e31c1c3a9e5ac13c4542fa01d5f1e668f078b 100644 (file)
@@ -865,13 +865,13 @@ __ReadDiskInfo(
     }
 
     // dump actual values
-    Verbose("Target[%d] : %lld sectors of %d bytes (%d)\n", Frontend->TargetId,
-            Frontend->DiskInfo.SectorCount, Frontend->DiskInfo.SectorSize,
-            Frontend->DiskInfo.PhysSectorSize);
-    Verbose("Target[%d] : %d %s (%08x) %s\n", Frontend->TargetId,
-            __Size(&Frontend->DiskInfo), __Units(&Frontend->DiskInfo),
-            Frontend->DiskInfo.DiskInfo,
-            Frontend->Caps.SurpriseRemovable ? "SURPRISE_REMOVABLE" : "");
+    Trace("Target[%d] : %lld sectors of %d bytes (%d)\n", Frontend->TargetId,
+          Frontend->DiskInfo.SectorCount, Frontend->DiskInfo.SectorSize,
+          Frontend->DiskInfo.PhysSectorSize);
+    Trace("Target[%d] : %d %s (%08x) %s\n", Frontend->TargetId,
+          __Size(&Frontend->DiskInfo), __Units(&Frontend->DiskInfo),
+          Frontend->DiskInfo.DiskInfo,
+          Frontend->Caps.SurpriseRemovable ? "SURPRISE_REMOVABLE" : "");
 }
 
 static FORCEINLINE VOID