storage_driver: Release pool object lock for some long running jobs

As advertised in previous commit, there are three APIs that might
run for quite some time (because they read/write data from/to a
volume) and these three are: downloadVol, uploadVol, wipeVol.
Release pool object lock and reacquire it later to allow more
concurrency.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
Michal Privoznik 2018-08-19 08:26:04 +02:00
parent f1ae8ecc90
commit ca0ab9cdd2
4 changed files with 29 additions and 3 deletions

View File

@ -64,18 +64,30 @@ typedef int (*virStorageBackendVolumeResize)(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
unsigned long long capacity,
unsigned int flags);
/* Upon entering this callback passed @obj is unlocked. However,
* the pool's asyncjobs counter has been incremented and volume's
* in_use has been adjusted to ensure singular usage. */
typedef int (*virStorageBackendVolumeDownload)(virStoragePoolObjPtr obj,
virStorageVolDefPtr vol,
virStreamPtr stream,
unsigned long long offset,
unsigned long long length,
unsigned int flags);
/* Upon entering this callback passed @obj is unlocked. However,
* the pool's asyncjobs counter has been incremented and volume's
* in_use has been adjusted to ensure singular usage. */
typedef int (*virStorageBackendVolumeUpload)(virStoragePoolObjPtr obj,
virStorageVolDefPtr vol,
virStreamPtr stream,
unsigned long long offset,
unsigned long long len,
unsigned int flags);
/* Upon entering this callback passed @obj is unlocked. However,
* the pool's asyncjobs counter has been incremented and volume's
* in_use has been adjusted to ensure singular usage. */
typedef int (*virStorageBackendVolumeWipe)(virStoragePoolObjPtr pool,
virStorageVolDefPtr vol,
unsigned int algorithm,

View File

@ -693,7 +693,11 @@ virStorageBackenISCSIDirectWipeVol(virStoragePoolObjPtr pool,
virCheckFlags(0, -1);
if (!(iscsi = virStorageBackendISCSIDirectSetConnection(pool, NULL)))
virObjectLock(pool);
iscsi = virStorageBackendISCSIDirectSetConnection(pool, NULL);
virObjectUnlock(pool);
if (!iscsi)
return -1;
switch ((virStorageVolWipeAlgorithm) algorithm) {

View File

@ -1200,7 +1200,7 @@ virStorageBackendRBDVolWipe(virStoragePoolObjPtr pool,
unsigned int flags)
{
virStorageBackendRBDStatePtr ptr = NULL;
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
virStoragePoolDefPtr def;
rbd_image_t image = NULL;
rbd_image_info_t info;
uint64_t stripe_count;
@ -1209,9 +1209,13 @@ virStorageBackendRBDVolWipe(virStoragePoolObjPtr pool,
virCheckFlags(0, -1);
virObjectLock(pool);
def = virStoragePoolObjGetDef(pool);
VIR_DEBUG("Wiping RBD image %s/%s", def->source.name, vol->name);
ptr = virStorageBackendRBDNewState(pool);
virObjectUnlock(pool);
if (!(ptr = virStorageBackendRBDNewState(pool)))
if (!ptr)
goto cleanup;
if ((r = rbd_open(ptr->ioctx, vol->name, &image, NULL)) < 0) {

View File

@ -2178,9 +2178,11 @@ storageVolDownload(virStorageVolPtr vol,
virStoragePoolObjIncrAsyncjobs(obj);
voldef->in_use++;
virObjectUnlock(obj);
ret = backend->downloadVol(obj, voldef, stream, offset, length, flags);
virObjectLock(obj);
voldef->in_use--;
virStoragePoolObjDecrAsyncjobs(obj);
@ -2378,9 +2380,11 @@ storageVolUpload(virStorageVolPtr vol,
virStoragePoolObjIncrAsyncjobs(obj);
voldef->in_use++;
virObjectUnlock(obj);
rc = backend->uploadVol(obj, voldef, stream, offset, length, flags);
virObjectLock(obj);
voldef->in_use--;
virStoragePoolObjDecrAsyncjobs(obj);
@ -2554,9 +2558,11 @@ storageVolWipePattern(virStorageVolPtr vol,
virStoragePoolObjIncrAsyncjobs(obj);
voldef->in_use++;
virObjectUnlock(obj);
rc = backend->wipeVol(obj, voldef, algorithm, flags);
virObjectLock(obj);
voldef->in_use--;
virStoragePoolObjDecrAsyncjobs(obj);