]> xenbits.xensource.com Git - pvdrivers/win/xenvbd.git/commitdiff
Stop mis-interpreting the 'removable' node in xenstore...
authorPaul Durrant <pdurrant@amazon.com>
Fri, 28 Aug 2020 16:49:47 +0000 (17:49 +0100)
committerPaul Durrant <pdurrant@amazon.com>
Fri, 28 Aug 2020 17:45:58 +0000 (18:45 +0100)
... and the VDISK_REMOVABLE bit in the value of the 'info' node.

They both apply to the media and not the device itself. PV devices are always
removable.
The comment in libxl_disk.c concerning the 'removable' flag states that:

"Currently there is only one removable device -- CDROM"

This is not conclusive but it is reasonable to infer from that the removabilty
refers to the media and not the drive itself. (CDROM drives in typical servers
are not removable).
The code in Linux xen-blkback/xenbus.c sets VDISK_REMOVABLE if the underlying
block device has the GENHD_FL_REMOVABLE flag, and the comment above the
definition of that flag in genhd.h states:

"``GENHD_FL_REMOVABLE`` (0x0001): indicates that the block device gives access
to removable media.
When set, the device remains present even when media is not inserted.
Must not be set for devices which are removed entirely when the media is
removed."

This patch, therefore, stops using these values to indicate the removability
of the target devices and instead uses them as they were intended, to indicate
the removability of the media.

NOTE: The code in XENCRSH is modified to simply ignore the 'removable' node.
      The value currently sampled is not used.
      The Removable BOOLEAN field currently in XENVBD_CAPS is also moved into
      XENVBD_FEATURES for consistency with other values sampled from xenstore
      nodes.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
src/xencrsh/frontend.c
src/xencrsh/frontend.h
src/xenvbd/adapter.c
src/xenvbd/frontend.c
src/xenvbd/frontend.h
src/xenvbd/target.c
src/xenvbd/target.h

index b46c05323bd6e0540976d61bbe09c8667cc2eac9..a64e79d54f57f42d3c21a23082e2726836b1de3a 100644 (file)
@@ -460,13 +460,6 @@ __ReadFeatures(
     NTSTATUS    Status;
     PCHAR       Buffer;
 
-    Status = StoreRead(NULL, Frontend->BackendPath, 
-                        "removable", &Buffer);
-    if (NT_SUCCESS(Status)) {
-        Frontend->Removable = (strtoul(Buffer, NULL, 10) == 1);
-        AustereFree(Buffer);
-    }
-
     Status = StoreRead(NULL, Frontend->BackendPath,
                         "feature-barrier", &Buffer);
     if (NT_SUCCESS(Status)) {
@@ -485,9 +478,8 @@ __ReadFeatures(
         Frontend->FeatureDiscard = FALSE;
     }
 
-    LogVerbose("Features: DomId=%d, RingOrder=0, %s %s %s\n", 
+    LogVerbose("Features: DomId=%d, RingOrder=0, %s %s\n",
                 Frontend->BackendId,
-                Frontend->Removable ? "REMOVABLE" : "NOT_REMOVABLE",
                 Frontend->FeatureBarrier ? "BARRIER" : "NOT_BARRIER",
                 Frontend->FeatureDiscard ? "DISCARD" : "NOT_DISCARD");
 }
index 5dd30f70c542c8dd54dba9b10447cbe1c39db285..bd3cf6bdf9b80f325675939b4fcc0b26a22639e8 100644 (file)
@@ -60,8 +60,6 @@ typedef struct _XENVBD_FRONTEND {
 
     // Capabilities
     BOOLEAN                     Connected;
-    BOOLEAN                     Removable;
-    BOOLEAN                     SurpriseRemovable;
     BOOLEAN                     FeatureBarrier;
     BOOLEAN                     FeatureDiscard;
     BOOLEAN                     Paging;
@@ -132,4 +130,4 @@ FrontendPushRequestAndCheckNotify(
     IN  PXENVBD_FRONTEND        Frontend
     );
 
-#endif // _XENVBD_FRONTEND_H
\ No newline at end of file
+#endif // _XENVBD_FRONTEND_H
index 5e2094465c21e9efd19be38417daf8b9cc0fb4c1..721c97ff83c7679d2226edd184150fe72cf1c12e 100644 (file)
@@ -1892,9 +1892,9 @@ __AdapterSrbPnp(
     case StorQueryCapabilities: {
         PSTOR_DEVICE_CAPABILITIES Caps = Srb->DataBuffer;
 
-        Caps->Removable = TargetGetRemovable(Target);
-        Caps->EjectSupported = TargetGetRemovable(Target);
-        Caps->SurpriseRemovalOK = TargetGetSurpriseRemovable(Target);
+        Caps->Removable = 1;
+        Caps->EjectSupported = 1;
+        Caps->SurpriseRemovalOK = 1;
         Caps->UniqueID = 1;
 
         } break;
index d74f0b37eebe175a78d17e4c800f22fa4adca78a..d7b2e6614d66741813bd05f05241781f7625844b 100644 (file)
@@ -847,7 +847,6 @@ __ReadDiskInfo(
     if (!Changed)
         return;
 
-    Frontend->Caps.SurpriseRemovable = !!(Frontend->DiskInfo.DiskInfo & VDISK_REMOVABLE);
     if (Frontend->DiskInfo.DiskInfo & VDISK_READONLY) {
         Warning("Target[%d] : DiskInfo contains VDISK_READONLY flag!\n", Frontend->TargetId);
     }
@@ -868,10 +867,9 @@ __ReadDiskInfo(
     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,
+    Trace("Target[%d] : %d %s (%08x)\n", Frontend->TargetId,
           __Size(&Frontend->DiskInfo), __Units(&Frontend->DiskInfo),
-          Frontend->DiskInfo.DiskInfo,
-          Frontend->Caps.SurpriseRemovable ? "SURPRISE_REMOVABLE" : "");
+          Frontend->DiskInfo.DiskInfo);
 }
 
 static FORCEINLINE VOID
@@ -883,7 +881,7 @@ FrontendReadFeatures(
 
     Changed = FrontendReadFeature(Frontend,
                                   FeatureRemovable,
-                                  &Frontend->Caps.Removable);
+                                  &Frontend->Features.Removable);
     Changed |= FrontendReadValue32(Frontend,
                                    FeatureMaxIndirectSegments,
                                    TRUE,
@@ -899,7 +897,7 @@ FrontendReadFeatures(
             Frontend->TargetId,
             Frontend->Features.Persistent ? "PERSISTENT " : "",
             Frontend->Features.Indirect ? "INDIRECT " : "",
-            Frontend->Caps.Removable ? "REMOVABLE" : "");
+            Frontend->Features.Removable ? "REMOVABLE" : "");
 
     if (Frontend->Features.Indirect) {
         Verbose("Target[%d] : INDIRECT %x\n",
@@ -1636,19 +1634,18 @@ FrontendDebugCallback(
 
     XENBUS_DEBUG(Printf,
                  &Frontend->DebugInterface,
-                 "Caps: %s%s%s%s%s%s\n",
+                 "Caps: %s%s%s%s\n",
                  Frontend->Caps.Connected ? "CONNECTED " : "",
-                 Frontend->Caps.Removable ? "REMOVABLE " : "",
-                 Frontend->Caps.SurpriseRemovable ? "SURPRISE " : "",
                  Frontend->Caps.Paging ? "PAGING " : "",
                  Frontend->Caps.Hibernation ? "HIBER " : "",
                  Frontend->Caps.DumpFile ? "DUMP " : "");
 
     XENBUS_DEBUG(Printf,
                  &Frontend->DebugInterface,
-                 "Features: %s%s%s%s%s\n",
+                 "Features: %s%s%s%s%s%s\n",
                  Frontend->Features.Persistent ? "PERSISTENT " : "",
                  Frontend->Features.Indirect > 0 ? "INDIRECT " : "",
+                 Frontend->Features.Removable ? "REMOVABLE " : "",
                  Frontend->DiskInfo.Barrier ? "BARRIER " : "",
                  Frontend->DiskInfo.FlushCache ? "FLUSH " : "",
                  Frontend->DiskInfo.Discard ? "DISCARD " : "");
index fcf5632996f4031a9fd9390671d85ac70d692037..19c5cc87741bbdb61c9893746753710e2689171b 100644 (file)
@@ -46,8 +46,6 @@ typedef enum _XENVBD_STATE {
 
 typedef struct _XENVBD_CAPS {
     BOOLEAN                     Connected;
-    BOOLEAN                     Removable;
-    BOOLEAN                     SurpriseRemovable;
     BOOLEAN                     Paging;
     BOOLEAN                     Hibernation;
     BOOLEAN                     DumpFile;
@@ -56,6 +54,7 @@ typedef struct _XENVBD_CAPS {
 typedef struct _XENVBD_FEATURES {
     ULONG                       Indirect;
     BOOLEAN                     Persistent;
+    BOOLEAN                     Removable;
 } XENVBD_FEATURES, *PXENVBD_FEATURES;
 
 typedef struct _XENVBD_DISKINFO {
index 4919db2a9e71982a180797792bd7b0dfbf632c72..839860c046b5b48336ccf55fde26335839dc0d30 100644 (file)
@@ -641,11 +641,11 @@ TargetInquiryStd(
     IN  PSCSI_REQUEST_BLOCK Srb
     )
 {
+    PXENVBD_FEATURES        Features =  FrontendGetFeatures(Target->Frontend);
+    PXENVBD_DISKINFO        DiskInfo = FrontendGetDiskInfo(Target->Frontend);
     PINQUIRYDATA            Data = Srb->DataBuffer;
     ULONG                   Length = Srb->DataTransferLength;
 
-    UNREFERENCED_PARAMETER(Target);
-
     Srb->SrbStatus = SRB_STATUS_ERROR;
 
     if (Data == NULL)
@@ -658,6 +658,8 @@ TargetInquiryStd(
     RtlZeroMemory(Data, Length);
     Data->DeviceType            = DIRECT_ACCESS_DEVICE;
     Data->DeviceTypeQualifier   = DEVICE_CONNECTED;
+    Data->RemovableMedia        = Features->Removable ||
+                                  (DiskInfo->DiskInfo & VDISK_REMOVABLE);
     Data->Versions              = 4;
     Data->ResponseDataFormat    = 2;
     Data->AdditionalLength      = INQUIRYDATABUFFERSIZE - 4;
@@ -1470,24 +1472,6 @@ TargetGetDeviceId(
     return FrontendGetDeviceId(Target->Frontend);
 }
 
-//TARGET_GET_PROPERTY(Removable, BOOLEAN)
-BOOLEAN
-TargetGetRemovable(
-    IN  PXENVBD_TARGET  Target
-    )
-{
-    return FrontendGetCaps(Target->Frontend)->Removable;
-}
-
-//TARGET_GET_PROPERTY(SurpriseRemovable, BOOLEAN)
-BOOLEAN
-TargetGetSurpriseRemovable(
-    IN  PXENVBD_TARGET  Target
-    )
-{
-    return FrontendGetCaps(Target->Frontend)->SurpriseRemovable;
-}
-
 TARGET_GET_PROPERTY(DevicePnpState, DEVICE_PNP_STATE)
 //TARGET_GET_PROPERTY(Missing, BOOLEAN)
 
index cbd0ba4be278efa1f2ddf0f0c0311654419c8f08..6feecc11943d8ded94b707604cf8b0d37bd0199e 100644 (file)
@@ -132,8 +132,6 @@ TARGET_GET_PROPERTY(Adapter, PXENVBD_ADAPTER)
 TARGET_GET_PROPERTY(DeviceObject, PDEVICE_OBJECT)
 TARGET_GET_PROPERTY(TargetId, ULONG)
 TARGET_GET_PROPERTY(DeviceId, ULONG)
-TARGET_GET_PROPERTY(Removable, BOOLEAN)
-TARGET_GET_PROPERTY(SurpriseRemovable, BOOLEAN)
 TARGET_GET_PROPERTY(DevicePnpState, DEVICE_PNP_STATE)
 TARGET_GET_PROPERTY(Missing, BOOLEAN)