提交 1e13eff4 编写于 作者: J John Ferlan

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.
上级 adb182fa
......@@ -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:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册