https://bugzilla.redhat.com/show_bug.cgi?id=
1711789
Starting up or building some types of pools may take a very long
time (e.g. a misconfigured NFS). Holding the pool object locked
throughout the whole time hurts concurrency, e.g. if there's
another thread that is listing all the pools.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
const char *format;
const char *path = def->source.devices[0].path;
+ /* This can take a significant amount of time. */
+ virObjectUnlock(pool);
virWaitForDevices();
+ virObjectLock(pool);
if (!virFileExists(path)) {
virReportError(VIR_ERR_INVALID_ARG,
int format = def->source.format;
const char *fmt;
VIR_AUTOPTR(virCommand) cmd = NULL;
+ int ret = -1;
virCheckFlags(VIR_STORAGE_POOL_BUILD_OVERWRITE |
VIR_STORAGE_POOL_BUILD_NO_OVERWRITE, -1);
"--script",
fmt,
NULL);
- return virCommandRun(cmd, NULL);
+
+ virObjectUnlock(pool);
+ ret = virCommandRun(cmd, NULL);
+ virObjectLock(pool);
+
+ return ret;
}
return -1;
cmd = virStorageBackendFileSystemMountCmd(MOUNT, def, src);
- return virCommandRun(cmd, NULL);
+
+ /* Mounting a shared FS might take a long time. Don't hold
+ * the pool locked meanwhile. */
+ virObjectUnlock(pool);
+ rc = virCommandRun(cmd, NULL);
+ virObjectLock(pool);
+
+ return rc;
}
virReportError(VIR_ERR_OPERATION_INVALID,
_("No source device specified when formatting pool '%s'"),
def->name);
- goto error;
+ return -1;
}
device = def->source.devices[0].path;
format = virStoragePoolFormatFileSystemTypeToString(def->source.format);
VIR_DEBUG("source device: '%s' format: '%s'", device, format);
+ virObjectUnlock(pool);
if (!virFileExists(device)) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("Source device does not exist when formatting pool '%s'"),
ret = virStorageBackendExecuteMKFS(device, format);
error:
+ virObjectLock(pool);
return ret;
}
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
VIR_AUTOPTR(virCommand) cmd = NULL;
+ int ret;
cmd = virStorageBackendLogicalChangeCmd(VGCHANGE, def, on);
- return virCommandRun(cmd, NULL);
+
+ virObjectUnlock(pool);
+ ret = virCommandRun(cmd, NULL);
+ virObjectLock(pool);
+
+ return ret;
}
virCommandAddArg(vgcmd, path);
}
+ virObjectUnlock(pool);
/* Now create the volume group itself */
- if (virCommandRun(vgcmd, NULL) < 0)
- goto cleanup;
-
- ret = 0;
+ ret = virCommandRun(vgcmd, NULL);
+ virObjectLock(pool);
cleanup:
/* On any failure, run through the devices that had pvcreate run in
VIR_AUTOFREE(char *) usr_name = NULL;
VIR_AUTOFREE(char *) mode = NULL;
VIR_AUTOPTR(virCommand) cmd = NULL;
+ int ret;
/* Check the permissions */
if (def->target.perms.mode == (mode_t)-1)
"-g", grp_name, "-u", usr_name,
NULL);
- return virCommandRun(cmd, NULL);
+ /* Mounting a shared FS might take a long time. Don't hold
+ * the pool locked meanwhile. */
+ virObjectUnlock(pool);
+ ret = virCommandRun(cmd, NULL);
+ virObjectLock(pool);
+
+ return ret;
}
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
size_t i;
VIR_AUTOPTR(virCommand) cmd = NULL;
+ int ret = -1;
virCheckFlags(0, -1);
for (i = 0; i < def->source.ndevice; i++)
virCommandAddArg(cmd, def->source.devices[i].path);
- return virCommandRun(cmd, NULL);
+ virObjectUnlock(pool);
+ ret = virCommandRun(cmd, NULL);
+ virObjectLock(pool);
+
+ return ret;
}
static int