[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH v2 8/8] 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>
---
 src/storage/storage_backend_iscsi_direct.c | 6 +++++-
 src/storage/storage_backend_rbd.c          | 8 ++++++--
 src/storage/storage_driver.c               | 6 ++++++
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/storage/storage_backend_iscsi_direct.c b/src/storage/storage_backend_iscsi_direct.c
index 0d7d6ba9c3..5c1b251a17 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 c6fb791a81..2cba678b72 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 9edd5df119..8943df1f84 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);
 
-- 
2.16.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]