mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 06:50:22 +03:00
storage: Don't assume storage pool exists for FC/SCSI refresh thread
https://bugzilla.redhat.com/show_bug.cgi?id=1277781 The virStoragePoolFCRefreshThread had passed a pointer to the pool obj in the virStoragePoolFCRefreshInfoPtr; however, we cannot assume that the pool exists still since we don't keep the pool lock throughout the duration of the thread. Therefore, instead of passing the pool obj pointer, pass the UUID of the pool and perform a lookup. If found, then we can perform the refresh using the locked pool obj pointer; otherwise, we just exit the thread since the pool is now gone.
This commit is contained in:
parent
c3afa6a9a3
commit
d3fa510a75
@ -44,7 +44,7 @@ typedef struct _virStoragePoolFCRefreshInfo virStoragePoolFCRefreshInfo;
|
||||
typedef virStoragePoolFCRefreshInfo *virStoragePoolFCRefreshInfoPtr;
|
||||
struct _virStoragePoolFCRefreshInfo {
|
||||
char *fchost_name;
|
||||
virStoragePoolObjPtr pool;
|
||||
unsigned char pool_uuid[VIR_UUID_BUFLEN];
|
||||
};
|
||||
|
||||
/* Function to check if the type file in the given sysfs_path is a
|
||||
@ -594,7 +594,8 @@ virStoragePoolFCRefreshThread(void *opaque)
|
||||
{
|
||||
virStoragePoolFCRefreshInfoPtr cbdata = opaque;
|
||||
const char *fchost_name = cbdata->fchost_name;
|
||||
virStoragePoolObjPtr pool = cbdata->pool;
|
||||
const unsigned char *pool_uuid = cbdata->pool_uuid;
|
||||
virStoragePoolObjPtr pool = NULL;
|
||||
unsigned int host;
|
||||
int found = 0;
|
||||
int tries = 2;
|
||||
@ -602,12 +603,15 @@ virStoragePoolFCRefreshThread(void *opaque)
|
||||
do {
|
||||
sleep(5); /* Give it time */
|
||||
|
||||
/* Lock the pool, if active, we can get the host number, successfully
|
||||
* rescan, and find LUN's, then we are happy
|
||||
/* Let's see if the pool still exists - */
|
||||
if (!(pool = virStoragePoolObjFindPoolByUUID(pool_uuid)))
|
||||
break;
|
||||
|
||||
/* Return with pool lock, if active, we can get the host number,
|
||||
* successfully, rescan, and find LUN's, then we are happy
|
||||
*/
|
||||
VIR_DEBUG("Attempt FC Refresh for pool='%s' name='%s' tries='%d'",
|
||||
pool->def->name, fchost_name, tries);
|
||||
virStoragePoolObjLock(pool);
|
||||
if (virStoragePoolObjIsActive(pool) &&
|
||||
virGetSCSIHostNumber(fchost_name, &host) == 0 &&
|
||||
virStorageBackendSCSITriggerRescan(host) == 0) {
|
||||
@ -617,7 +621,7 @@ virStoragePoolFCRefreshThread(void *opaque)
|
||||
virStoragePoolObjUnlock(pool);
|
||||
} while (!found && --tries);
|
||||
|
||||
if (!found)
|
||||
if (pool && !found)
|
||||
VIR_DEBUG("FC Refresh Thread failed to find LU's");
|
||||
|
||||
virStoragePoolFCRefreshDataFree(cbdata);
|
||||
@ -798,7 +802,7 @@ createVport(virConnectPtr conn,
|
||||
if ((name = virGetFCHostNameByWWN(NULL, adapter->data.fchost.wwnn,
|
||||
adapter->data.fchost.wwpn))) {
|
||||
if (VIR_ALLOC(cbdata) == 0) {
|
||||
cbdata->pool = pool;
|
||||
memcpy(cbdata->pool_uuid, pool->def->uuid, VIR_UUID_BUFLEN);
|
||||
cbdata->fchost_name = name;
|
||||
name = NULL;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user