From nobody Thu Apr 25 10:24:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1534157397517994.6957497098629; Mon, 13 Aug 2018 03:49:57 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 53D3430820CB; Mon, 13 Aug 2018 10:49:53 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DE4B8ABDD2; Mon, 13 Aug 2018 10:49:51 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D99674A460; Mon, 13 Aug 2018 10:49:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7DAnmqV016904 for ; Mon, 13 Aug 2018 06:49:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id E3C1B1C5AA; Mon, 13 Aug 2018 10:49:47 +0000 (UTC) Received: from localhost.localdomain (ovpn-204-61.brq.redhat.com [10.40.204.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C1F11C599 for ; Mon, 13 Aug 2018 10:49:45 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 13 Aug 2018 12:49:37 +0200 Message-Id: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] storage: Don't hold storage pool locked during wipeVol X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Mon, 13 Aug 2018 10:49:55 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Currently the way virStorageVolWipe() works is it looks up pool containing given volume and hold it locked throughout while API execution. This is suboptimal because wiping a volume means writing data to it which can take ages. And if the whole pool is locked during that operation no other API can be issued (nor pool-list). Signed-off-by: Michal Privoznik --- src/storage/storage_backend_iscsi_direct.c | 5 +++++ src/storage/storage_backend_rbd.c | 7 ++++++- src/storage/storage_util.c | 8 +++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/storage/storage_backend_iscsi_direct.c b/src/storage/stora= ge_backend_iscsi_direct.c index 1624066e9c..58d25557f1 100644 --- a/src/storage/storage_backend_iscsi_direct.c +++ b/src/storage/storage_backend_iscsi_direct.c @@ -691,6 +691,9 @@ virStorageBackenISCSIDirectWipeVol(virStoragePoolObjPtr= pool, if (!(iscsi =3D virStorageBackendISCSIDirectSetConnection(pool, NULL))) return -1; =20 + vol->in_use++; + virObjectUnlock(pool); + switch ((virStorageVolWipeAlgorithm) algorithm) { case VIR_STORAGE_VOL_WIPE_ALG_ZERO: if (virStorageBackendISCSIDirectVolWipeZero(vol, iscsi) < 0) { @@ -719,6 +722,8 @@ virStorageBackenISCSIDirectWipeVol(virStoragePoolObjPtr= pool, cleanup: virISCSIDirectDisconnect(iscsi); iscsi_destroy_context(iscsi); + virObjectLock(pool); + vol->in_use--; return ret; } =20 diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backen= d_rbd.c index 642cacb673..30c94c109b 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -1212,7 +1212,10 @@ virStorageBackendRBDVolWipe(virStoragePoolObjPtr poo= l, VIR_DEBUG("Wiping RBD image %s/%s", def->source.name, vol->name); =20 if (!(ptr =3D virStorageBackendRBDNewState(pool))) - goto cleanup; + return -1; + + vol->in_use++; + virObjectUnlock(pool); =20 if ((r =3D rbd_open(ptr->ioctx, vol->name, &image, NULL)) < 0) { virReportSystemError(-r, _("failed to open the RBD image %s"), @@ -1271,6 +1274,8 @@ virStorageBackendRBDVolWipe(virStoragePoolObjPtr pool, rbd_close(image); =20 virStorageBackendRBDFreeState(&ptr); + virObjectLock(pool); + vol->in_use--; =20 return ret; } diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 42a9b6abf0..5c1fb7b7d3 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -2750,7 +2750,7 @@ storageBackendVolWipePloop(virStorageVolDefPtr vol, =20 =20 int -virStorageBackendVolWipeLocal(virStoragePoolObjPtr pool ATTRIBUTE_UNUSED, +virStorageBackendVolWipeLocal(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, unsigned int algorithm, unsigned int flags) @@ -2759,6 +2759,9 @@ virStorageBackendVolWipeLocal(virStoragePoolObjPtr po= ol ATTRIBUTE_UNUSED, =20 virCheckFlags(0, -1); =20 + vol->in_use++; + virObjectUnlock(pool); + VIR_DEBUG("Wiping volume with path '%s' and algorithm %u", vol->target.path, algorithm); =20 @@ -2769,6 +2772,9 @@ virStorageBackendVolWipeLocal(virStoragePoolObjPtr po= ol ATTRIBUTE_UNUSED, vol->target.allocation, false= ); } =20 + virObjectLock(pool); + vol->in_use--; + return ret; } =20 --=20 2.16.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list