[ovs-dev] [PATCH 4/7] datapath: Hold dp->mutex when calling new_vport().

Jesse Gross jesse at nicira.com
Wed Dec 29 23:41:32 UTC 2010


On datapath creation we hold dp_mutex but not dp->mutex when
creating the vport for the datapath device.  However, there are
lockdep checks that validate that we hold dp->mutex during the call
to new_vport().  The lock isn't actually necessary in this case
because no one else can access the datapath but it's good to have
the lock assertions, so this wraps the call to new_vport() with
dp->mutex.

Found with lockdep.

Signed-off-by: Jesse Gross <jesse at nicira.com>
---
 datapath/datapath.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/datapath/datapath.c b/datapath/datapath.c
index 67f6730..13afe59 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -268,7 +268,10 @@ static int create_dp(int dp_idx, const char __user *devnamep)
 	BUILD_BUG_ON(sizeof(internal_dev_port.devname) != sizeof(devname));
 	strcpy(internal_dev_port.devname, devname);
 	strcpy(internal_dev_port.type, "internal");
+
+	mutex_lock(&dp->mutex);
 	err = new_vport(dp, &internal_dev_port, ODPP_LOCAL);
+	mutex_unlock(&dp->mutex);
 	if (err) {
 		if (err == -EBUSY)
 			err = -EEXIST;
@@ -348,7 +351,7 @@ out:
 	return err;
 }
 
-/* Called with RTNL lock and dp_mutex. */
+/* Called with RTNL lock and dp->mutex. */
 static int new_vport(struct datapath *dp, struct odp_port *odp_port, int port_no)
 {
 	struct vport_parms parms;
-- 
1.7.1





More information about the dev mailing list