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

[PATCH 1/2] Correct reporting of unmap granularity


  • To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>
  • Date: Tue, 28 Apr 2026 10:33:41 +0200
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=vates.tech header.i="@vates.tech" header.h="From:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type:Feedback-ID"
  • Cc: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>, Owen Smith <owen.smith@xxxxxxxxxx>
  • Delivery-date: Tue, 28 Apr 2026 08:34:16 +0000
  • Feedback-id: default:8631fc262581453bbf619ec5b2062170:Sweego
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

blkif.h specifies discard-alignment and discard-granularity as being in
byte unit. These values must be converted to LBA unit in the
corresponding inquiry outputs.

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

diff --git a/src/xenvbd/target.c b/src/xenvbd/target.c
index e4a9c03..102e8b8 100644
--- a/src/xenvbd/target.c
+++ b/src/xenvbd/target.c
@@ -842,6 +842,7 @@ TargetInquiryB0(
     )
 {
     PXENVBD_FEATURES        Features = FrontendGetFeatures(Target->Frontend);
+    PXENVBD_DISKINFO        DiskInfo = FrontendGetDiskInfo(Target->Frontend);
     PVPD_BLOCK_LIMITS_PAGE  Data = Srb->DataBuffer;
     ULONG                   Length = Srb->DataTransferLength;
 
@@ -867,8 +868,10 @@ TargetInquiryB0(
      * default.
      */
     *(PULONG)Data->MaximumUnmapBlockDescriptorCount = _byteswap_ulong(8);
-    *(PULONG)Data->OptimalUnmapGranularity = 
_byteswap_ulong(Features->DiscardGranularity);
-    *(PULONG)Data->UnmapGranularityAlignment = 
_byteswap_ulong(Features->DiscardAlignment);
+    *(PULONG)Data->OptimalUnmapGranularity =
+        _byteswap_ulong(Features->DiscardGranularity / DiskInfo->SectorSize);
+    *(PULONG)Data->UnmapGranularityAlignment =
+        _byteswap_ulong(Features->DiscardAlignment / DiskInfo->SectorSize);
     // alignment is only valid if a granularity has been set
     Data->UGAValid = (Features->DiscardGranularity != 0) ? 1 : 0;
 
-- 
2.53.0.windows.2



--
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®.