[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [win-pv-devel] [PATCH 1/5] Fix target enumeration
From: Owen Smith <owen.smith@xxxxxxxxxx> Issues were found when enumeration races with plug/unplug. This patch should fix these problems. Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx> Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx> --- src/xenvbd/fdo.c | 36 +++++++++++++++++------------------- src/xenvbd/pdo.c | 12 ++++++++++-- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/xenvbd/fdo.c b/src/xenvbd/fdo.c index f240a97..b146f7c 100644 --- a/src/xenvbd/fdo.c +++ b/src/xenvbd/fdo.c @@ -619,31 +619,29 @@ __FdoEnumerate( *NeedReboot = FALSE; for (TargetId = 0; TargetId < XENVBD_MAX_TARGETS; ++TargetId) { + BOOLEAN Missing = TRUE; + Pdo = __FdoGetPdo(Fdo, TargetId); if (Pdo == NULL) continue; - if (!PdoIsMissing(Pdo)) { - BOOLEAN Missing = TRUE; - for (Device = Devices; *Device; Device = __NextSz(Device)) { - ULONG DeviceTargetId = __ParseVbd(Device); - if (TargetId == DeviceTargetId) { - Missing = FALSE; - break; - } - } - if (Missing) { - PdoSetMissing(Pdo, "Device Dissappeared"); - if (PdoGetDevicePnpState(Pdo) == Present) - PdoSetDevicePnpState(Pdo, Deleted); - else - *NeedInvalidate = TRUE; + for (Device = Devices; *Device; Device = __NextSz(Device)) { + ULONG DeviceTargetId = __ParseVbd(Device); + if (TargetId == DeviceTargetId) { + Missing = FALSE; + break; } } - - if (PdoIsMissing(Pdo) && - PdoGetDevicePnpState(Pdo) == Deleted) { - // drop reference count before destroying + + if (Missing && !PdoIsMissing(Pdo)) { + PdoSetMissing(Pdo, "Device Disappeared"); + if (PdoGetDevicePnpState(Pdo) == Present) + PdoSetDevicePnpState(Pdo, Deleted); + else + *NeedInvalidate = TRUE; + } + + if (PdoGetDevicePnpState(Pdo) == Deleted) { PdoDereference(Pdo); PdoDestroy(Pdo); } else { diff --git a/src/xenvbd/pdo.c b/src/xenvbd/pdo.c index c5ec9b6..89bfc5a 100644 --- a/src/xenvbd/pdo.c +++ b/src/xenvbd/pdo.c @@ -415,8 +415,16 @@ PdoSetDevicePnpState( __in DEVICE_PNP_STATE State ) { - ASSERT(Pdo->DevicePnpState != Deleted || State == Deleted); - Verbose("Target[%d] : PNP %s to %s\n", PdoGetTargetId(Pdo), __PnpStateName(Pdo->DevicePnpState), __PnpStateName(State)); + Verbose("Target[%d] : PNP %s to %s\n", + PdoGetTargetId(Pdo), + __PnpStateName(Pdo->DevicePnpState), + __PnpStateName(State)); + + if (Pdo->DevicePnpState == Deleted) { + ASSERT(State == Deleted); + return; + } + Pdo->PrevPnpState = Pdo->DevicePnpState; Pdo->DevicePnpState = State; } -- 2.1.1 _______________________________________________ win-pv-devel mailing list win-pv-devel@xxxxxxxxxxxxxxxxxxxx http://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |