提交 ccb0d6e3 编写于 作者: J John Ferlan

nodedev: Keep the node device lock longer in nodeDeviceDestroy

While perhaps improbable, it could be possible that after finding our
object that another thread running essentially in parallel could attempt
to delete the same vHBA.

So rather than dropping the lock right after finding the object, keep
the lock around while we drop the object lock and work on deleting the
object. Once the delete occurs we can safely drop the driver lock again.

Cleanup some of the usage of cleanup instead out for the goto label.
上级 4b6ee784
...@@ -646,21 +646,18 @@ nodeDeviceDestroy(virNodeDevicePtr dev) ...@@ -646,21 +646,18 @@ nodeDeviceDestroy(virNodeDevicePtr dev)
int parent_host = -1; int parent_host = -1;
nodeDeviceLock(); nodeDeviceLock();
obj = virNodeDeviceFindByName(&driver->devs, dev->name); if (!(obj = virNodeDeviceFindByName(&driver->devs, dev->name))) {
nodeDeviceUnlock();
if (!obj) {
virReportError(VIR_ERR_NO_NODE_DEVICE, virReportError(VIR_ERR_NO_NODE_DEVICE,
_("no node device with matching name '%s'"), _("no node device with matching name '%s'"),
dev->name); dev->name);
goto out; goto cleanup;
} }
if (virNodeDeviceDestroyEnsureACL(dev->conn, obj->def) < 0) if (virNodeDeviceDestroyEnsureACL(dev->conn, obj->def) < 0)
goto out; goto cleanup;
if (virNodeDeviceGetWWNs(obj->def, &wwnn, &wwpn) == -1) if (virNodeDeviceGetWWNs(obj->def, &wwnn, &wwpn) < 0)
goto out; goto cleanup;
/* virNodeDeviceGetParentHost will cause the device object's lock to be /* virNodeDeviceGetParentHost will cause the device object's lock to be
...@@ -670,20 +667,21 @@ nodeDeviceDestroy(virNodeDevicePtr dev) ...@@ -670,20 +667,21 @@ nodeDeviceDestroy(virNodeDevicePtr dev)
if (VIR_STRDUP(parent_name, obj->def->parent) < 0) { if (VIR_STRDUP(parent_name, obj->def->parent) < 0) {
virNodeDeviceObjUnlock(obj); virNodeDeviceObjUnlock(obj);
obj = NULL; obj = NULL;
goto out; goto cleanup;
} }
virNodeDeviceObjUnlock(obj); virNodeDeviceObjUnlock(obj);
obj = NULL; obj = NULL;
if (virNodeDeviceGetParentHost(&driver->devs, dev->name, parent_name, if (virNodeDeviceGetParentHost(&driver->devs, dev->name, parent_name,
&parent_host) < 0) &parent_host) < 0)
goto out; goto cleanup;
if (virVHBAManageVport(parent_host, wwpn, wwnn, VPORT_DELETE) < 0) if (virVHBAManageVport(parent_host, wwpn, wwnn, VPORT_DELETE) < 0)
goto out; goto cleanup;
ret = 0; ret = 0;
out: cleanup:
nodeDeviceUnlock();
if (obj) if (obj)
virNodeDeviceObjUnlock(obj); virNodeDeviceObjUnlock(obj);
VIR_FREE(parent_name); VIR_FREE(parent_name);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册