[libvirt] [PATCH 0/1] Update nodedev scsi_host data

While investigating https://bugzilla.redhat.com/show_bug.cgi?id=597998 I noticed that my nodedev-create operations were timing out more often than not. This patch works around a race between udev generating a new device event and the corresponding sysfs entries being populated. This behavior has appeared before, but previously it was limited to incorrect WWNs; now no FC capability appears at all until the nodedev entry is refreshed. David Allan (1): Update nodedev scsi_host data before use src/node_device/node_device_driver.c | 19 +++---------------- 1 files changed, 3 insertions(+), 16 deletions(-)

* It appears that the udev event for HBA creation arrives before the associated sysfs data is fully populated, resulting in bogus data for the nodedev entry until the entry is refreshed. This problem is particularly troublesome when creating NPIV vHBAs because it results in libvirt failing to find the newly created adapter and waiting for the full timeout period before erroneously failing the create operation. This patch forces an update before any attempt to use any scsi_host nodedev entry. --- src/node_device/node_device_driver.c | 19 +++---------------- 1 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c index 8fb062c..f7e2f69 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -45,23 +45,9 @@ static int update_caps(virNodeDeviceObjPtr dev) virNodeDevCapsDefPtr cap = dev->def->caps; while (cap) { - /* The only cap that currently needs updating is the WWN of FC HBAs. */ + /* The only caps that currently need updating are FC related. */ if (cap->type == VIR_NODE_DEV_CAP_SCSI_HOST) { - if (cap->data.scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST) { - if (read_wwn(cap->data.scsi_host.host, - "port_name", - &cap->data.scsi_host.wwpn) == -1) { - VIR_ERROR(_("Failed to refresh WWPN for host%d"), - cap->data.scsi_host.host); - } - - if (read_wwn(cap->data.scsi_host.host, - "node_name", - &cap->data.scsi_host.wwnn) == -1) { - VIR_ERROR(_("Failed to refresh WWNN for host%d"), - cap->data.scsi_host.host); - } - } + check_fc_host(&dev->def->caps->data); } cap = cap->next; } @@ -239,6 +225,7 @@ nodeDeviceLookupByWWN(virConnectPtr conn, while (cap) { if (cap->type == VIR_NODE_DEV_CAP_SCSI_HOST) { + check_fc_host(&cap->data); if (cap->data.scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST) { -- 1.7.0.1

On 06/02/2010 10:04 PM, David Allan wrote:
* It appears that the udev event for HBA creation arrives before the associated sysfs data is fully populated, resulting in bogus data for the nodedev entry until the entry is refreshed. This problem is particularly troublesome when creating NPIV vHBAs because it results in libvirt failing to find the newly created adapter and waiting for the full timeout period before erroneously failing the create operation. This patch forces an update before any attempt to use any scsi_host nodedev entry. --- src/node_device/node_device_driver.c | 19 +++---------------- 1 files changed, 3 insertions(+), 16 deletions(-)
ACK. It's always nice when a net reduction in lines solves a race condition. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On 06/03/2010 12:04 AM, David Allan wrote:
* It appears that the udev event for HBA creation arrives before the associated sysfs data is fully populated, resulting in bogus data for the nodedev entry until the entry is refreshed. This problem is particularly troublesome when creating NPIV vHBAs because it results in libvirt failing to find the newly created adapter and waiting for the full timeout period before erroneously failing the create operation. This patch forces an update before any attempt to use any scsi_host nodedev entry. --- src/node_device/node_device_driver.c | 19 +++---------------- 1 files changed, 3 insertions(+), 16 deletions(-)
diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c index 8fb062c..f7e2f69 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -45,23 +45,9 @@ static int update_caps(virNodeDeviceObjPtr dev) virNodeDevCapsDefPtr cap = dev->def->caps;
while (cap) { - /* The only cap that currently needs updating is the WWN of FC HBAs. */ + /* The only caps that currently need updating are FC related. */ if (cap->type == VIR_NODE_DEV_CAP_SCSI_HOST) { - if (cap->data.scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST) { - if (read_wwn(cap->data.scsi_host.host, - "port_name", - &cap->data.scsi_host.wwpn) == -1) { - VIR_ERROR(_("Failed to refresh WWPN for host%d"), - cap->data.scsi_host.host); - } - - if (read_wwn(cap->data.scsi_host.host, - "node_name", - &cap->data.scsi_host.wwnn) == -1) { - VIR_ERROR(_("Failed to refresh WWNN for host%d"), - cap->data.scsi_host.host); - } - } + check_fc_host(&dev->def->caps->data); } cap = cap->next; } @@ -239,6 +225,7 @@ nodeDeviceLookupByWWN(virConnectPtr conn, while (cap) {
if (cap->type == VIR_NODE_DEV_CAP_SCSI_HOST) { + check_fc_host(&cap->data); if (cap->data.scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST) {
ACK - Cole

On Thu, Jun 03, 2010 at 09:53:07AM -0400, Cole Robinson wrote:
On 06/03/2010 12:04 AM, David Allan wrote:
* It appears that the udev event for HBA creation arrives before the associated sysfs data is fully populated, resulting in bogus data for the nodedev entry until the entry is refreshed. This problem is particularly troublesome when creating NPIV vHBAs because it results in libvirt failing to find the newly created adapter and waiting for the full timeout period before erroneously failing the create operation. This patch forces an update before any attempt to use any scsi_host nodedev entry. --- src/node_device/node_device_driver.c | 19 +++---------------- 1 files changed, 3 insertions(+), 16 deletions(-)
diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c index 8fb062c..f7e2f69 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -45,23 +45,9 @@ static int update_caps(virNodeDeviceObjPtr dev) virNodeDevCapsDefPtr cap = dev->def->caps;
while (cap) { - /* The only cap that currently needs updating is the WWN of FC HBAs. */ + /* The only caps that currently need updating are FC related. */ if (cap->type == VIR_NODE_DEV_CAP_SCSI_HOST) { - if (cap->data.scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST) { - if (read_wwn(cap->data.scsi_host.host, - "port_name", - &cap->data.scsi_host.wwpn) == -1) { - VIR_ERROR(_("Failed to refresh WWPN for host%d"), - cap->data.scsi_host.host); - } - - if (read_wwn(cap->data.scsi_host.host, - "node_name", - &cap->data.scsi_host.wwnn) == -1) { - VIR_ERROR(_("Failed to refresh WWNN for host%d"), - cap->data.scsi_host.host); - } - } + check_fc_host(&dev->def->caps->data); } cap = cap->next; } @@ -239,6 +225,7 @@ nodeDeviceLookupByWWN(virConnectPtr conn, while (cap) {
if (cap->type == VIR_NODE_DEV_CAP_SCSI_HOST) { + check_fc_host(&cap->data); if (cap->data.scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST) {
ACK
- Cole
Thanks--pushed. Dave
participants (4)
-
Cole Robinson
-
Dave Allan
-
David Allan
-
Eric Blake