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.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/storage/storage_backend_scsi.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c
index f246a05..7dd7674 100644
--- a/src/storage/storage_backend_scsi.c
+++ b/src/storage/storage_backend_scsi.c
@@ -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;
--
2.1.0