[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH xenvbd] Stop mis-interpreting the 'removable' node in xenstore...
From: Paul Durrant <pdurrant@xxxxxxxxxx> ... 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@xxxxxxxxxx> --- src/xencrsh/frontend.c | 10 +--------- src/xencrsh/frontend.h | 4 +--- src/xenvbd/adapter.c | 6 +++--- src/xenvbd/frontend.c | 17 +++++++---------- src/xenvbd/frontend.h | 3 +-- src/xenvbd/target.c | 24 ++++-------------------- src/xenvbd/target.h | 2 -- 7 files changed, 17 insertions(+), 49 deletions(-) diff --git a/src/xencrsh/frontend.c b/src/xencrsh/frontend.c index b46c053..a64e79d 100644 --- a/src/xencrsh/frontend.c +++ b/src/xencrsh/frontend.c @@ -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"); } diff --git a/src/xencrsh/frontend.h b/src/xencrsh/frontend.h index 5dd30f7..bd3cf6b 100644 --- a/src/xencrsh/frontend.h +++ b/src/xencrsh/frontend.h @@ -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 diff --git a/src/xenvbd/adapter.c b/src/xenvbd/adapter.c index 5e20944..721c97f 100644 --- a/src/xenvbd/adapter.c +++ b/src/xenvbd/adapter.c @@ -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; diff --git a/src/xenvbd/frontend.c b/src/xenvbd/frontend.c index d74f0b3..d7b2e66 100644 --- a/src/xenvbd/frontend.c +++ b/src/xenvbd/frontend.c @@ -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 " : ""); diff --git a/src/xenvbd/frontend.h b/src/xenvbd/frontend.h index fcf5632..19c5cc8 100644 --- a/src/xenvbd/frontend.h +++ b/src/xenvbd/frontend.h @@ -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 { diff --git a/src/xenvbd/target.c b/src/xenvbd/target.c index 4919db2..839860c 100644 --- a/src/xenvbd/target.c +++ b/src/xenvbd/target.c @@ -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) diff --git a/src/xenvbd/target.h b/src/xenvbd/target.h index cbd0ba4..6feecc1 100644 --- a/src/xenvbd/target.h +++ b/src/xenvbd/target.h @@ -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) -- 2.17.1
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |