]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Make QP Broker locking local to vmciQueuePair.c
authorVMware, Inc <>
Mon, 26 Sep 2011 20:00:34 +0000 (13:00 -0700)
committerMarcelo Vanzin <mvanzin@vmware.com>
Mon, 26 Sep 2011 20:00:34 +0000 (13:00 -0700)
The locking for the VMCI queue pair broker was distributed
across the VMCI driver for the sole reason of being able to
handle a failed copy to user on Linux for queue pair
alloc. After this change, a failed copy to user will still
detach from an allocated queue pair, but a peer may have
attached to the queue pair between the alloc and detach. Since
the copy to user won't fail with a correctly working VMX, this
simplification is justified.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/modules/linux/vmci/common/vmciContext.c
open-vm-tools/modules/linux/vmci/common/vmciContext.h
open-vm-tools/modules/linux/vmci/common/vmciQueuePair.c
open-vm-tools/modules/linux/vmci/common/vmciQueuePair.h
open-vm-tools/modules/linux/vmci/linux/driver.c
open-vm-tools/modules/linux/vmci/linux/vmci_version.h

index 3f0262bd834a31e61f0f4b1cfe9c96cbbbf803a4..1e49d7eacd6229b87b806ef54d46ed1ba10344b5 100644 (file)
@@ -457,7 +457,6 @@ VMCIContextFreeContext(VMCIContext *context)  // IN
 
    tempHandle = VMCIHandleArray_GetEntry(context->queuePairArray, 0);
    while (!VMCI_HANDLE_EQUAL(tempHandle, VMCI_INVALID_HANDLE)) {
-      VMCIQPBroker_Lock();
       if (VMCIQPBroker_Detach(tempHandle, context) < VMCI_SUCCESS) {
          /*
           * When VMCIQPBroker_Detach() succeeds it removes the handle from the
@@ -465,7 +464,6 @@ VMCIContextFreeContext(VMCIContext *context)  // IN
           */
          VMCIHandleArray_RemoveEntry(context->queuePairArray, tempHandle);
       }
-      VMCIQPBroker_Unlock();
       tempHandle = VMCIHandleArray_GetEntry(context->queuePairArray, 0);
    }
 
@@ -2232,12 +2230,133 @@ VMCIContext_SupportsHostQP(VMCIContext *context)    // IN: Context structure
 }
 
 
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * VMCIContext_QueuePairCreate --
+ *
+ *      Registers that a new queue pair handle has been allocated by
+ *      the context.
+ *
+ * Results:
+ *      VMCI_SUCCESS on success, appropriate error code otherewise.
+ *
+ * Side effects:
+ *      None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+VMCIContext_QueuePairCreate(VMCIContext *context, // IN: Context structure
+                            VMCIHandle handle)    // IN
+{
+   VMCILockFlags flags;
+   int result;
+
+   if (context == NULL || VMCI_HANDLE_INVALID(handle)) {
+      return VMCI_ERROR_INVALID_ARGS;
+   }
+
+   VMCI_GrabLock(&context->lock, &flags);
+   if (!VMCIHandleArray_HasEntry(context->queuePairArray, handle)) {
+      VMCIHandleArray_AppendEntry(&context->queuePairArray, handle);
+      result = VMCI_SUCCESS;
+   } else {
+      result = VMCI_ERROR_DUPLICATE_ENTRY;
+   }
+   VMCI_ReleaseLock(&context->lock, flags);
+
+   return result;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * VMCIContext_QueuePairDestroy --
+ *
+ *      Unregisters a queue pair handle that was previously registered
+ *      with VMCIContext_QueuePairCreate.
+ *
+ * Results:
+ *      VMCI_SUCCESS on success, appropriate error code otherewise.
+ *
+ * Side effects:
+ *      None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+VMCIContext_QueuePairDestroy(VMCIContext *context, // IN: Context structure
+                             VMCIHandle handle)    // IN
+{
+   VMCILockFlags flags;
+   VMCIHandle removedHandle;
+
+   if (context == NULL || VMCI_HANDLE_INVALID(handle)) {
+      return VMCI_ERROR_INVALID_ARGS;
+   }
+
+   VMCI_GrabLock(&context->lock, &flags);
+   removedHandle = VMCIHandleArray_RemoveEntry(context->queuePairArray, handle);
+   VMCI_ReleaseLock(&context->lock, flags);
+
+   if (VMCI_HANDLE_INVALID(removedHandle)) {
+      return VMCI_ERROR_NOT_FOUND;
+   } else {
+      return VMCI_SUCCESS;
+   }
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * VMCIContext_QueuePairExists --
+ *
+ *      Determines whether a given queue pair handle is registered
+ *      with the given context.
+ *
+ * Results:
+ *      TRUE, if queue pair is registered with context. FALSE, otherwise.
+ *
+ * Side effects:
+ *      None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+Bool
+VMCIContext_QueuePairExists(VMCIContext *context, // IN: Context structure
+                            VMCIHandle handle)    // IN
+{
+   VMCILockFlags flags;
+   Bool result;
+
+   if (context == NULL || VMCI_HANDLE_INVALID(handle)) {
+      return VMCI_ERROR_INVALID_ARGS;
+   }
+
+   VMCI_GrabLock(&context->lock, &flags);
+   result = VMCIHandleArray_HasEntry(context->queuePairArray, handle);
+   VMCI_ReleaseLock(&context->lock, flags);
+
+   return result;
+}
+
+
 /*
  *----------------------------------------------------------------------
  *
  * VMCIContext_RegisterGuestMem --
  *
- *      Tells the context that guest memory is available for access.
+ *      Tells the context that guest memory is available for
+ *      access. This should only be used when unquiescing the VMCI
+ *      device of a guest.
  *
  * Results:
  *      None.
@@ -2256,7 +2375,12 @@ VMCIContext_RegisterGuestMem(VMCIContext *context) // IN: Context structure
    uint32 numQueuePairs;
    uint32 cur;
 
-   VMCIQPBroker_Lock();
+   /*
+    * It is safe to access the queue pair array here, since no changes
+    * to the queuePairArray can take place until after the unquiescing
+    * is complete.
+    */
+
    numQueuePairs = VMCIHandleArray_GetSize(context->queuePairArray);
    for (cur = 0; cur < numQueuePairs; cur++) {
       VMCIHandle handle;
@@ -2272,7 +2396,6 @@ VMCIContext_RegisterGuestMem(VMCIContext *context) // IN: Context structure
          }
       }
    }
-   VMCIQPBroker_Unlock();
 #endif
 }
 
@@ -2282,7 +2405,9 @@ VMCIContext_RegisterGuestMem(VMCIContext *context) // IN: Context structure
  *
  * VMCIContext_ReleaseGuestMem --
  *
- *      Releases all the contexts references to guest memory.
+ *      Releases all the contexts references to guest memory. This
+ *      should only be used when qiescing or cleaning up the VMCI
+ *      device of a guest.
  *
  * Results:
  *      None.
@@ -2301,6 +2426,12 @@ VMCIContext_ReleaseGuestMem(VMCIContext *context, // IN: Context structure
    uint32 numQueuePairs;
    uint32 cur;
 
+   /*
+    * It is safe to access the queue pair array here, since no changes
+    * to the queuePairArray can take place when the the quiescing
+    * has been initiated.
+    */
+
    numQueuePairs = VMCIHandleArray_GetSize(context->queuePairArray);
    for (cur = 0; cur < numQueuePairs; cur++) {
       VMCIHandle handle;
@@ -2308,14 +2439,12 @@ VMCIContext_ReleaseGuestMem(VMCIContext *context, // IN: Context structure
       if (!VMCI_HANDLE_EQUAL(handle, VMCI_INVALID_HANDLE)) {
          int res;
 
-         VMCIQPBroker_Lock();
          res = VMCIQPBroker_Unmap(handle, context, gid);
          if (res < VMCI_SUCCESS) {
             VMCI_WARNING(("Failed to unmap guest memory for queue pair "
                           "(handle=0x%x:0x%x, res=%d).\n",
                           handle.context, handle.resource, res));
          }
-         VMCIQPBroker_Unlock();
       }
    }
 #endif
index 754cc556b6caf737751bc50a62f9929f891017d0..95487c092c864ba85b32bc1d01064690fb55f3e7 100644 (file)
@@ -76,10 +76,6 @@ void VMCIContext_Release(VMCIContext *context);
 Bool VMCIContext_Exists(VMCIId cid);
 
 VMCIId VMCIContext_GetId(VMCIContext *context);
-int VMCIContext_AddGroupEntry(VMCIContext *context,
-                              VMCIHandle entryHandle);
-VMCIHandle VMCIContext_RemoveGroupEntry(VMCIContext *context,
-                                        VMCIHandle entryHandle);
 int VMCIContext_AddNotification(VMCIId contextID, VMCIId remoteCID);
 int VMCIContext_RemoveNotification(VMCIId contextID, VMCIId remoteCID);
 int VMCIContext_GetCheckpointState(VMCIId contextID, uint32 cptType,
@@ -89,6 +85,10 @@ int VMCIContext_SetCheckpointState(VMCIId contextID, uint32 cptType,
 void VMCIContext_RegisterGuestMem(VMCIContext *context);
 void VMCIContext_ReleaseGuestMem(VMCIContext *context, VMCIGuestMemID gid);
 
+int VMCIContext_QueuePairCreate(VMCIContext *context, VMCIHandle handle);
+int VMCIContext_QueuePairDestroy(VMCIContext *context, VMCIHandle handle);
+Bool VMCIContext_QueuePairExists(VMCIContext *context, VMCIHandle handle);
+
 #ifndef VMX86_SERVER
 void VMCIContext_CheckAndSignalNotify(VMCIContext *context);
 #  ifdef __linux__
index 514d92c6ae967c5187f6b17ac5fd41fad72a3e7d..d1163653590ebbcd4e3e0be72fc21101db3195e8 100644 (file)
@@ -201,6 +201,9 @@ static QueuePairList qpBrokerList;
   static VMCILock hibernateFailedListLock;
 #endif
 
+static void VMCIQPBrokerLock(void);
+static  void VMCIQPBrokerUnlock(void);
+
 static QueuePairEntry *QueuePairList_FindEntry(QueuePairList *qpList,
                                                VMCIHandle handle);
 static void QueuePairList_AddEntry(QueuePairList *qpList,
@@ -426,7 +429,7 @@ QueuePairList_Destroy(QueuePairList *qpList)
 /*
  *-----------------------------------------------------------------------------
  *
- * VMCIQPBroker_Lock --
+ * VMCIQPBrokerLock --
  *
  *      Acquires the mutex protecting a VMCI queue pair broker transaction.
  *
@@ -439,8 +442,8 @@ QueuePairList_Destroy(QueuePairList *qpList)
  *-----------------------------------------------------------------------------
  */
 
-void
-VMCIQPBroker_Lock(void)
+static void
+VMCIQPBrokerLock(void)
 {
    VMCIMutex_Acquire(&qpBrokerList.mutex);
 }
@@ -449,7 +452,7 @@ VMCIQPBroker_Lock(void)
 /*
  *-----------------------------------------------------------------------------
  *
- * VMCIQPBroker_Unlock --
+ * VMCIQPBrokerUnlock --
  *
  *      Releases the mutex protecting a VMCI queue pair broker transaction.
  *
@@ -462,8 +465,8 @@ VMCIQPBroker_Lock(void)
  *-----------------------------------------------------------------------------
  */
 
-void
-VMCIQPBroker_Unlock(void)
+static void
+VMCIQPBrokerUnlock(void)
 {
    VMCIMutex_Release(&qpBrokerList.mutex);
 }
@@ -635,14 +638,14 @@ VMCIQPBroker_Exit(void)
 {
    QPBrokerEntry *entry;
 
-   VMCIQPBroker_Lock();
+   VMCIQPBrokerLock();
 
    while ((entry = (QPBrokerEntry *)QueuePairList_GetHead(&qpBrokerList))) {
       QueuePairList_RemoveEntry(&qpBrokerList, &entry->qp);
       VMCI_FreeKernelMem(entry, sizeof *entry);
    }
 
-   VMCIQPBroker_Unlock();
+   VMCIQPBrokerUnlock();
    QueuePairList_Destroy(&qpBrokerList);
 }
 
@@ -803,7 +806,6 @@ VMCIQueuePairAllocHostWork(VMCIHandle *handle,           // IN/OUT
    ASSERT(context);
 
    entry = NULL;
-   VMCIQPBroker_Lock();
    result = VMCIQPBrokerAllocInt(*handle, peer, flags, privFlags, produceSize,
                                  consumeSize, NULL, context, wakeupCB, clientData,
                                  &entry, &swap);
@@ -825,7 +827,6 @@ VMCIQueuePairAllocHostWork(VMCIHandle *handle,           // IN/OUT
       VMCI_DEBUG_LOG(4, (LGPFX"queue pair broker failed to alloc (result=%d).\n",
                          result));
    }
-   VMCIQPBroker_Unlock();
    VMCIContext_Release(context);
    return result;
 }
@@ -856,9 +857,7 @@ VMCIQueuePairDetachHostWork(VMCIHandle handle) // IN
 
    context = VMCIContext_Get(VMCI_HOST_CONTEXT_ID);
 
-   VMCIQPBroker_Lock();
    result = VMCIQPBroker_Detach(handle, context);
-   VMCIQPBroker_Unlock();
 
    VMCIContext_Release(context);
    return result;
@@ -924,10 +923,13 @@ VMCIQPBrokerAllocInt(VMCIHandle handle,             // IN
 
    ASSERT(vmkernel || !isLocal);
 
-   if (!isLocal && VMCIHandleArray_HasEntry(context->queuePairArray, handle)) {
+   VMCIQPBrokerLock();
+
+   if (!isLocal && VMCIContext_QueuePairExists(context, handle)) {
       VMCI_DEBUG_LOG(4, (LGPFX"Context (ID=0x%x) already attached to queue pair "
                          "(handle=0x%x:0x%x).\n",
                          contextId, handle.context, handle.resource));
+      VMCIQPBrokerUnlock();
       return VMCI_ERROR_ALREADY_EXISTS;
    }
 
@@ -944,6 +946,8 @@ VMCIQPBrokerAllocInt(VMCIHandle handle,             // IN
                                   clientData, ent);
    }
 
+   VMCIQPBrokerUnlock();
+
    if (swap) {
       *swap = (contextId == VMCI_HOST_CONTEXT_ID) && !(create && isLocal);
    }
@@ -1133,8 +1137,7 @@ VMCIQPBrokerCreate(VMCIHandle handle,             // IN
       *ent = entry;
    }
 
-   ASSERT(!VMCIHandleArray_HasEntry(context->queuePairArray, handle));
-   VMCIHandleArray_AppendEntry(&context->queuePairArray, handle);
+   VMCIContext_QueuePairCreate(context, handle);
 
    return VMCI_SUCCESS;
 
@@ -1372,10 +1375,9 @@ VMCIQPBrokerAttach(QPBrokerEntry *entry,          // IN
     */
 
    if (!isLocal) {
-      VMCIHandleArray_AppendEntry(&context->queuePairArray, entry->qp.handle);
+      VMCIContext_QueuePairCreate(context, entry->qp.handle);
    } else {
-      ASSERT(VMCIHandleArray_HasEntry(context->queuePairArray,
-                                      entry->qp.handle));
+      ASSERT(VMCIContext_QueuePairExists(context, entry->qp.handle));
    }
    if (ent != NULL) {
       *ent = entry;
@@ -1428,14 +1430,6 @@ VMCIQPBroker_SetPageStore(VMCIHandle handle,      // IN
       return VMCI_ERROR_INVALID_ARGS;
    }
 
-   if (!VMCIHandleArray_HasEntry(context->queuePairArray, handle)) {
-      VMCI_WARNING((LGPFX"Context (ID=0x%x) not attached to queue pair "
-                    "(handle=0x%x:0x%x).\n", contextId, handle.context,
-                    handle.resource));
-      result = VMCI_ERROR_NOT_FOUND;
-      goto out;
-   }
-
    /*
     * We only support guest to host queue pairs, so the VMX must
     * supply UVAs for the mapped page files.
@@ -1445,6 +1439,16 @@ VMCIQPBroker_SetPageStore(VMCIHandle handle,      // IN
       return VMCI_ERROR_INVALID_ARGS;
    }
 
+   VMCIQPBrokerLock();
+
+   if (!VMCIContext_QueuePairExists(context, handle)) {
+      VMCI_WARNING((LGPFX"Context (ID=0x%x) not attached to queue pair "
+                    "(handle=0x%x:0x%x).\n", contextId, handle.context,
+                    handle.resource));
+      result = VMCI_ERROR_NOT_FOUND;
+      goto out;
+   }
+
    entry = (QPBrokerEntry *)QueuePairList_FindEntry(&qpBrokerList, handle);
    if (!entry) {
       result = VMCI_ERROR_NOT_FOUND;
@@ -1501,8 +1505,8 @@ VMCIQPBroker_SetPageStore(VMCIHandle handle,      // IN
    }
 
    result = VMCI_SUCCESS;
-
 out:
+   VMCIQPBrokerUnlock();
    return result;
 }
 
@@ -1546,16 +1550,20 @@ VMCIQPBroker_Detach(VMCIHandle  handle,   // IN
    const VMCIId contextId = VMCIContext_GetId(context);
    VMCIId peerId;
    Bool isLocal = FALSE;
+   int result;
 
    if (VMCI_HANDLE_INVALID(handle) || !context || contextId == VMCI_INVALID_ID) {
       return VMCI_ERROR_INVALID_ARGS;
    }
 
-   if (!VMCIHandleArray_HasEntry(context->queuePairArray, handle)) {
+   VMCIQPBrokerLock();
+
+   if (!VMCIContext_QueuePairExists(context, handle)) {
       VMCI_DEBUG_LOG(4, (LGPFX"Context (ID=0x%x) not attached to queue pair "
                          "(handle=0x%x:0x%x).\n",
                          contextId, handle.context, handle.resource));
-      return VMCI_ERROR_NOT_FOUND;
+      result = VMCI_ERROR_NOT_FOUND;
+      goto out;
    }
 
    entry = (QPBrokerEntry *)QueuePairList_FindEntry(&qpBrokerList, handle);
@@ -1563,11 +1571,13 @@ VMCIQPBroker_Detach(VMCIHandle  handle,   // IN
       VMCI_DEBUG_LOG(4, (LGPFX"Context (ID=0x%x) reports being attached to queue pair "
                          "(handle=0x%x:0x%x) that isn't present in broker.\n",
                          contextId, handle.context, handle.resource));
-      return VMCI_ERROR_NOT_FOUND;
+      result = VMCI_ERROR_NOT_FOUND;
+      goto out;
    }
 
    if (contextId != entry->createId && contextId != entry->attachId) {
-      return VMCI_ERROR_QUEUEPAIR_NOTATTACHED;
+      result = VMCI_ERROR_QUEUEPAIR_NOTATTACHED;
+      goto out;
    }
 
    if (contextId == entry->createId) {
@@ -1634,7 +1644,7 @@ VMCIQPBroker_Detach(VMCIHandle  handle,   // IN
       VMCIHost_FreeQueue(entry->consumeQ, entry->qp.consumeSize);
       VMCI_FreeKernelMem(entry, sizeof *entry);
 
-      VMCIHandleArray_RemoveEntry(context->queuePairArray, handle);
+      VMCIContext_QueuePairDestroy(context, handle);
    } else {
       ASSERT(peerId != VMCI_INVALID_ID);
       QueuePairNotifyPeer(FALSE, handle, contextId, peerId);
@@ -1644,11 +1654,13 @@ VMCIQPBroker_Detach(VMCIHandle  handle,   // IN
          entry->state = VMCIQPB_SHUTDOWN_NO_MEM;
       }
       if (!isLocal) {
-         VMCIHandleArray_RemoveEntry(context->queuePairArray, handle);
+         VMCIContext_QueuePairDestroy(context, handle);
       }
    }
-
-   return VMCI_SUCCESS;
+   result = VMCI_SUCCESS;
+out:
+   VMCIQPBrokerUnlock();
+   return result;
 }
 
 
@@ -1685,11 +1697,14 @@ VMCIQPBroker_Map(VMCIHandle  handle,      // IN
       return VMCI_ERROR_INVALID_ARGS;
    }
 
-   if (!VMCIHandleArray_HasEntry(context->queuePairArray, handle)) {
+   VMCIQPBrokerLock();
+
+   if (!VMCIContext_QueuePairExists(context, handle)) {
       VMCI_DEBUG_LOG(4, (LGPFX"Context (ID=0x%x) not attached to queue pair "
                          "(handle=0x%x:0x%x).\n",
                          contextId, handle.context, handle.resource));
-      return VMCI_ERROR_NOT_FOUND;
+      result = VMCI_ERROR_NOT_FOUND;
+      goto out;
    }
 
    entry = (QPBrokerEntry *)QueuePairList_FindEntry(&qpBrokerList, handle);
@@ -1697,11 +1712,13 @@ VMCIQPBroker_Map(VMCIHandle  handle,      // IN
       VMCI_DEBUG_LOG(4, (LGPFX"Context (ID=0x%x) reports being attached to queue pair "
                          "(handle=0x%x:0x%x) that isn't present in broker.\n",
                          contextId, handle.context, handle.resource));
-      return VMCI_ERROR_NOT_FOUND;
+      result = VMCI_ERROR_NOT_FOUND;
+      goto out;
    }
 
    if (contextId != entry->createId && contextId != entry->attachId) {
-      return VMCI_ERROR_QUEUEPAIR_NOTATTACHED;
+      result = VMCI_ERROR_QUEUEPAIR_NOTATTACHED;
+      goto out;
    }
 
    isLocal = entry->qp.flags & VMCI_QPFLAG_LOCAL;
@@ -1753,6 +1770,8 @@ VMCIQPBroker_Map(VMCIHandle  handle,      // IN
       result = VMCI_SUCCESS;
    }
 
+out:
+   VMCIQPBrokerUnlock();
    return result;
 }
 
@@ -1848,16 +1867,19 @@ VMCIQPBroker_Unmap(VMCIHandle  handle,   // IN
    QPBrokerEntry *entry;
    const VMCIId contextId = VMCIContext_GetId(context);
    Bool isLocal = FALSE;
+   int result;
 
    if (VMCI_HANDLE_INVALID(handle) || !context || contextId == VMCI_INVALID_ID) {
       return VMCI_ERROR_INVALID_ARGS;
    }
 
-   if (!VMCIHandleArray_HasEntry(context->queuePairArray, handle)) {
+   VMCIQPBrokerLock();
+   if (!VMCIContext_QueuePairExists(context, handle)) {
       VMCI_DEBUG_LOG(4, (LGPFX"Context (ID=0x%x) not attached to queue pair "
                          "(handle=0x%x:0x%x).\n",
                          contextId, handle.context, handle.resource));
-      return VMCI_ERROR_NOT_FOUND;
+      result = VMCI_ERROR_NOT_FOUND;
+      goto out;
    }
 
    entry = (QPBrokerEntry *)QueuePairList_FindEntry(&qpBrokerList, handle);
@@ -1865,18 +1887,18 @@ VMCIQPBroker_Unmap(VMCIHandle  handle,   // IN
       VMCI_DEBUG_LOG(4, (LGPFX"Context (ID=0x%x) reports being attached to queue pair "
                          "(handle=0x%x:0x%x) that isn't present in broker.\n",
                          contextId, handle.context, handle.resource));
-      return VMCI_ERROR_NOT_FOUND;
+      result = VMCI_ERROR_NOT_FOUND;
+      goto out;
    }
 
    if (contextId != entry->createId && contextId != entry->attachId) {
-      return VMCI_ERROR_QUEUEPAIR_NOTATTACHED;
+      result = VMCI_ERROR_QUEUEPAIR_NOTATTACHED;
+      goto out;
    }
 
    isLocal = entry->qp.flags & VMCI_QPFLAG_LOCAL;
 
    if (contextId != VMCI_HOST_CONTEXT_ID) {
-      int result;
-
       ASSERT(entry->state != VMCIQPB_CREATED_NO_MEM &&
              entry->state != VMCIQPB_SHUTDOWN_NO_MEM &&
              entry->state != VMCIQPB_ATTACHED_NO_MEM);
@@ -1914,7 +1936,10 @@ VMCIQPBroker_Unmap(VMCIHandle  handle,   // IN
       VMCI_ReleaseQueueMutex(entry->produceQ);
    }
 
-   return VMCI_SUCCESS;
+   result = VMCI_SUCCESS;
+out:
+   VMCIQPBrokerUnlock();
+   return result;
 }
 
 #if !defined(VMKERNEL)
index 524f4e189f428d2ba260d9c8c8ba21a482926cf3..9c0be14120ce90af0f758238ab81b0e7532333b8 100644 (file)
@@ -76,8 +76,6 @@ VMCI_QP_PAGESTORE_IS_WELLFORMED(QueuePairPageStore *pageStore) // IN
 
 int VMCIQPBroker_Init(void);
 void VMCIQPBroker_Exit(void);
-void VMCIQPBroker_Lock(void);
-void VMCIQPBroker_Unlock(void);
 int VMCIQPBroker_Alloc(VMCIHandle handle, VMCIId peer, uint32 flags,
                        VMCIPrivilegeFlags privFlags,
                        uint64 produceSize, uint64 consumeSize,
index cc49bf134375a63c808f281880b647969a6bd788..f2a8f297a529182d8fd220229ee9c1c6df66185b 100644 (file)
@@ -628,13 +628,11 @@ VMCIDoQPBrokerAlloc(VMCIHandle handle,
 
    cid = VMCIContext_GetId(context);
 
-   VMCIQPBroker_Lock();
    result = VMCIQPBroker_Alloc(handle, peer, flags, VMCI_NO_PRIVILEGE_FLAGS,
                                produceSize, consumeSize, pageStore, context);
    if (result == VMCI_SUCCESS && vmToVm) {
       result = VMCI_SUCCESS_QUEUEPAIR_CREATE;
    }
-   Log(LGPFX"IOCTL_VMCI_QUEUEPAIR_ALLOC (cid=%u,result=%d).\n", cid, result);
    retval = copy_to_user(resultUVA, &result, sizeof result);
    if (retval) {
       retval = -EFAULT;
@@ -644,8 +642,6 @@ VMCIDoQPBrokerAlloc(VMCIHandle handle,
       }
    }
 
-   VMCIQPBroker_Unlock();
-
    return retval;
 }
 
@@ -950,19 +946,13 @@ LinuxDriver_Ioctl(struct inode *inode,
           * VMX is passing down a new VA for the queue pair mapping.
           */
 
-         VMCIQPBroker_Lock();
          result = VMCIQPBroker_Map(setVAInfo.handle, vmciLinux->context, setVAInfo.va);
-         VMCIQPBroker_Unlock();
-         Log(LGPFX"IOCTL_VMCI_QUEUEPAIR_SETVA - map (result=%d).\n", result);
       } else {
          /*
           * The queue pair is about to be unmapped by the VMX.
           */
 
-         VMCIQPBroker_Lock();
          result = VMCIQPBroker_Unmap(setVAInfo.handle, vmciLinux->context, 0);
-         VMCIQPBroker_Unlock();
-         Log(LGPFX"IOCTL_VMCI_QUEUEPAIR_SETVA - unmap (result=%d).\n", result);
       }
 
       retval = copy_to_user(&info->result, &result, sizeof result);
@@ -977,7 +967,6 @@ LinuxDriver_Ioctl(struct inode *inode,
       VMCIQueuePairPageFileInfo pageFileInfo;
       VMCIQueuePairPageFileInfo *info = (VMCIQueuePairPageFileInfo *)ioarg;
       int32 result;
-      VMCIId cid;
 
       if (vmciLinux->userVersion < VMCI_VERSION_HOSTQP ||
           vmciLinux->userVersion >= VMCI_VERSION_NOVMVM) {
@@ -1019,18 +1008,10 @@ LinuxDriver_Ioctl(struct inode *inode,
       result = VMCI_SUCCESS;
       retval = copy_to_user(&info->result, &result, sizeof result);
       if (retval == 0) {
-         VMCIQPBroker_Lock();
-
          result = VMCIQPBroker_SetPageStore(pageFileInfo.handle,
                                             pageFileInfo.produceVA,
                                             pageFileInfo.consumeVA,
                                             vmciLinux->context);
-
-         VMCIQPBroker_Unlock();
-         cid = VMCIContext_GetId(vmciLinux->context);
-         Log(LGPFX"IOCTL_VMCI_QUEUEPAIR_SETPAGEFILE (cid=%u,result=%d).\n",
-             cid, result);
-
          if (result < VMCI_SUCCESS) {
 
             retval = copy_to_user(&info->result, &result, sizeof result);
@@ -1070,7 +1051,6 @@ LinuxDriver_Ioctl(struct inode *inode,
       VMCIQueuePairDetachInfo detachInfo;
       VMCIQueuePairDetachInfo *info = (VMCIQueuePairDetachInfo *)ioarg;
       int32 result;
-      VMCIId cid;
 
       if (vmciLinux->ctType != VMCIOBJ_CONTEXT) {
          Log(LGPFX"IOCTL_VMCI_QUEUEPAIR_DETACH only valid for contexts.\n");
@@ -1084,13 +1064,7 @@ LinuxDriver_Ioctl(struct inode *inode,
          break;
       }
 
-      cid = VMCIContext_GetId(vmciLinux->context);
-      VMCIQPBroker_Lock();
       result = VMCIQPBroker_Detach(detachInfo.handle, vmciLinux->context);
-      Log(LGPFX"IOCTL_VMCI_QUEUEPAIR_DETACH (cid=%u,result=%d).\n",
-          cid, result);
-      VMCIQPBroker_Unlock();
-
       if (result == VMCI_SUCCESS &&
           vmciLinux->userVersion < VMCI_VERSION_NOVMVM) {
          result = VMCI_SUCCESS_LAST_DETACH;
index 8d848855fe3c128525cb703a15d11aeab5649b38..1be2010be70b76b7c616001c1da6062d30dfcf0a 100644 (file)
@@ -25,8 +25,8 @@
 #ifndef _VMCI_VERSION_H_
 #define _VMCI_VERSION_H_
 
-#define VMCI_DRIVER_VERSION          9.3.12.0
-#define VMCI_DRIVER_VERSION_COMMAS   9,3,12,0
-#define VMCI_DRIVER_VERSION_STRING   "9.3.12.0"
+#define VMCI_DRIVER_VERSION          9.3.13.0
+#define VMCI_DRIVER_VERSION_COMMAS   9,3,13,0
+#define VMCI_DRIVER_VERSION_STRING   "9.3.13.0"
 
 #endif /* _VMCI_VERSION_H_ */