From 1e13eff4354af1d6f9c774d90995151aa94e78d0 Mon Sep 17 00:00:00 2001 From: John Ferlan Date: Thu, 16 Apr 2015 21:22:35 -0400 Subject: [PATCH] scsi: Change return values for virStorageBackendSCSIFindLUs 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. --- 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 b97b2b01ed..ab8d23d5c0 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -434,10 +434,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; @@ -445,6 +444,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); @@ -460,7 +460,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) { @@ -470,25 +469,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) { @@ -575,7 +569,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 { @@ -591,7 +585,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); @@ -914,7 +908,7 @@ virStorageBackendSCSIRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED, if (virStorageBackendSCSITriggerRescan(host) < 0) goto out; - virStorageBackendSCSIFindLUs(pool, host); + ignore_value(virStorageBackendSCSIFindLUs(pool, host)); ret = 0; out: -- GitLab