[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC PATCH 4/6] Report VPD 0xB2 Logical Block Provisioning



This VPD page is required for the detection of discard features by
Classpnp.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>
---
 src/xenvbd/target.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/src/xenvbd/target.c b/src/xenvbd/target.c
index 5109281..3d48ade 100644
--- a/src/xenvbd/target.c
+++ b/src/xenvbd/target.c
@@ -680,6 +680,7 @@ static const UCHAR SupportedPages[] = {
     VPD_DEVICE_IDENTIFIERS,
     VPD_BLOCK_LIMITS,
     VPD_BLOCK_DEVICE_CHARACTERISTICS,
+    VPD_LOGICAL_BLOCK_PROVISIONING,
 };
 
 static FORCEINLINE VOID
@@ -879,6 +880,39 @@ TargetInquiryB1(
     Srb->SrbStatus = SRB_STATUS_SUCCESS;
 }
 
+static VOID
+TargetInquiryB2(
+    IN  PXENVBD_TARGET                      Target,
+    IN  PSCSI_REQUEST_BLOCK                 Srb
+    )
+{
+    PVPD_LOGICAL_BLOCK_PROVISIONING_PAGE    Data = Srb->DataBuffer;
+    ULONG                                   Length = Srb->DataTransferLength;
+
+    UNREFERENCED_PARAMETER(Target);
+
+    Srb->SrbStatus = SRB_STATUS_ERROR;
+
+    if (Data == NULL)
+        return;
+
+    RtlZeroMemory(Data, Length);
+
+    if (Length < sizeof(VPD_LOGICAL_BLOCK_PROVISIONING_PAGE))
+        return;
+
+    Data->PageCode = VPD_LOGICAL_BLOCK_PROVISIONING;
+    Data->PageLength[1] = 4;
+
+    // Even if the current backend doesn't support discard, we might want to
+    // offer discard again when the backend changes. So we have to say that
+    // discard is unconditionally supported here.
+    Data->LBPU = 1;
+
+    Srb->DataTransferLength = sizeof(VPD_LOGICAL_BLOCK_PROVISIONING_PAGE);
+    Srb->SrbStatus = SRB_STATUS_SUCCESS;
+}
+
 static DECLSPEC_NOINLINE VOID
 TargetInquiry(
     IN  PXENVBD_TARGET      Target,
@@ -902,6 +936,9 @@ TargetInquiry(
         case VPD_BLOCK_DEVICE_CHARACTERISTICS:
             TargetInquiryB1(Target, Srb);
             break;
+        case VPD_LOGICAL_BLOCK_PROVISIONING:
+            TargetInquiryB2(Target, Srb);
+            break;
         default:
             Srb->SrbStatus = SRB_STATUS_ERROR;
             break;
-- 
2.51.2.windows.1



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.