Rather than passing/returning a pointer to a boolean to indicate that perhaps we should try again - adjust the return of the call to return the count of LU's found during processing, then let the caller decide what to do with that value. Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx> --- src/storage/storage_backend_scsi.c | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c index ae3cd9a..b98311c 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -430,10 +430,9 @@ processLU(virStoragePoolObjPtr pool, } -static int -virStorageBackendSCSIFindLUsInternal(virStoragePoolObjPtr pool, - uint32_t scanhost, - bool *found) +int +virStorageBackendSCSIFindLUs(virStoragePoolObjPtr pool, + uint32_t scanhost) { int retval = 0; uint32_t bus, target, lun; @@ -441,6 +440,7 @@ virStorageBackendSCSIFindLUsInternal(virStoragePoolObjPtr pool, DIR *devicedir = NULL; struct dirent *lun_dirent = NULL; char devicepattern[64]; + int found = 0; VIR_DEBUG("Discovering LUs on host %u", scanhost); @@ -456,7 +456,6 @@ virStorageBackendSCSIFindLUsInternal(virStoragePoolObjPtr pool, snprintf(devicepattern, sizeof(devicepattern), "%u:%%u:%%u:%%u\n", scanhost); - *found = false; while ((retval = virDirRead(devicedir, &lun_dirent, device_path)) > 0) { if (sscanf(lun_dirent->d_name, devicepattern, &bus, &target, &lun) != 3) { @@ -466,25 +465,20 @@ virStorageBackendSCSIFindLUsInternal(virStoragePoolObjPtr pool, VIR_DEBUG("Found possible LU '%s'", lun_dirent->d_name); if (processLU(pool, scanhost, bus, target, lun) == 0) - *found = true; + found++; } - if (!*found) - VIR_DEBUG("No LU found for pool %s", pool->def->name); - closedir(devicedir); - return retval; -} + if (retval < 0) + return -1; -int -virStorageBackendSCSIFindLUs(virStoragePoolObjPtr pool, - uint32_t scanhost) -{ - bool found; /* This path doesn't care whether found or not */ - return virStorageBackendSCSIFindLUsInternal(pool, scanhost, &found); + VIR_DEBUG("Found %d LUs for pool %s", found, pool->def->name); + + return found; } + static int virStorageBackendSCSITriggerRescan(uint32_t host) { @@ -571,7 +565,7 @@ virStoragePoolFCRefreshThread(void *opaque) const char *name = cbdata->name; virStoragePoolObjPtr pool = cbdata->pool; unsigned int host; - bool found = false; + int found; int tries = 2; do { @@ -587,7 +581,7 @@ virStoragePoolFCRefreshThread(void *opaque) virGetSCSIHostNumber(name, &host) == 0 && virStorageBackendSCSITriggerRescan(host) == 0) { virStoragePoolObjClearVols(pool); - virStorageBackendSCSIFindLUsInternal(pool, host, &found); + found = virStorageBackendSCSIFindLUs(pool, host); } virStoragePoolObjUnlock(pool); } while (!found && --tries); @@ -910,7 +904,7 @@ virStorageBackendSCSIRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED, if (virStorageBackendSCSITriggerRescan(host) < 0) goto out; - virStorageBackendSCSIFindLUs(pool, host); + ignore_value(virStorageBackendSCSIFindLUs(pool, host)); ret = 0; out: -- 2.1.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list