diff --git a/src/storage/storage_backend.h b/src/storage/storage_backend.h index 5587f844077fb7a7b1d276bce188e4a127a9a514..6e74f855236373868cf6e6c616227462d472241a 100644 --- a/src/storage/storage_backend.h +++ b/src/storage/storage_backend.h @@ -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, diff --git a/src/storage/storage_backend_iscsi_direct.c b/src/storage/storage_backend_iscsi_direct.c index 0d7d6ba9c36e83727891c6aff9df5017af61221f..5c1b251a17b702d7a8e4a7229c292329438b6e68 100644 --- a/src/storage/storage_backend_iscsi_direct.c +++ b/src/storage/storage_backend_iscsi_direct.c @@ -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) { diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c index c6fb791a81f599b6a9f3c13bc45ed01facd80e4d..2cba678b721ce036511b536fd3456ba5d9eb6458 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -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) { diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 9edd5df119fc51d9a03c2ab1fa00fece515cab23..8943df1f847f819197473a6f3aafb4dd3cebea33 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -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);