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

[win-pv-devel] [PATCH 1/3] Make sure we don't end up with duplicate PDOs



In a tight loop of network attach/detach it's possible to end up with
duplicate PDOs because, as soon as a PDO gets set to 'missing' a new one
with the same name can be created. This leads to races in accessing the
vif areas in xenstore and things can get very confused.

This patch makes sure that a new PDO cannot be created until a previous
incarnation is in the 'deleted' state, which means there will definitely
be no conflict in interactions with xenstore.

Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx>
---
 src/xenvif/fdo.c | 32 +++++++++++++++++---------------
 1 file changed, 17 insertions(+), 15 deletions(-)

diff --git a/src/xenvif/fdo.c b/src/xenvif/fdo.c
index dae1ad8..d665586 100644
--- a/src/xenvif/fdo.c
+++ b/src/xenvif/fdo.c
@@ -749,7 +749,7 @@ __FdoEnumerate(
         PXENVIF_DX      Dx = CONTAINING_RECORD(ListEntry, XENVIF_DX, 
ListEntry);
         PXENVIF_PDO     Pdo = Dx->Pdo;
 
-        if (!PdoIsMissing(Pdo) && PdoGetDevicePnpState(Pdo) != Deleted) {
+        if (PdoGetDevicePnpState(Pdo) != Deleted) {
             PCHAR           Name;
             BOOLEAN         Missing;
 
@@ -771,20 +771,22 @@ __FdoEnumerate(
                 }
             }
 
-            if (PdoIsEjectRequested(Pdo)) {
-                IoRequestDeviceEject(PdoGetDeviceObject(Pdo));
-            } else if (Missing) {
-                PdoSetMissing(Pdo, "device disappeared");
-
-                // If the PDO has not yet been enumerated then we can
-                // go ahead and mark it as deleted, otherwise we need
-                // to notify PnP manager and wait for the REMOVE_DEVICE
-                // IRP.
-                if (PdoGetDevicePnpState(Pdo) == Present) {
-                    PdoSetDevicePnpState(Pdo, Deleted);
-                    PdoDestroy(Pdo);
-                } else {
-                    NeedInvalidate = TRUE;
+            if (!PdoIsMissing(Pdo)) {
+                if (PdoIsEjectRequested(Pdo)) {
+                    IoRequestDeviceEject(PdoGetDeviceObject(Pdo));
+                } else if (Missing) {
+                    PdoSetMissing(Pdo, "device disappeared");
+
+                    // If the PDO has not yet been enumerated then we can
+                    // go ahead and mark it as deleted, otherwise we need
+                    // to notify PnP manager and wait for the REMOVE_DEVICE
+                    // IRP.
+                    if (PdoGetDevicePnpState(Pdo) == Present) {
+                        PdoSetDevicePnpState(Pdo, Deleted);
+                        PdoDestroy(Pdo);
+                    } else {
+                        NeedInvalidate = TRUE;
+                    }
                 }
             }
         }
-- 
2.1.1


_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel

 


Rackspace

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