From nobody Fri Nov 29 05:36:06 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 209.132.183.28 is neither permitted nor denied by domain of redhat.com) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 209.132.183.28 is neither permitted nor denied by domain of redhat.com) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 150408214126678.54623401066908; Wed, 30 Aug 2017 01:35:41 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 141FA81240; Wed, 30 Aug 2017 08:35:39 +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 E0B8B8D55C; Wed, 30 Aug 2017 08:35:38 +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 A42E84EE50; Wed, 30 Aug 2017 08:35:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7U8ZMga013091 for ; Wed, 30 Aug 2017 04:35:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4D67D202660E; Wed, 30 Aug 2017 08:35:22 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.rdu2.redhat.com [10.11.55.5]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 484BC2026E1F for ; Wed, 30 Aug 2017 08:35:22 +0000 (UTC) Received: from mx1.ioa.cn (mx0.ioa.cn [103.231.69.152]) by mx1.redhat.com (Postfix) with ESMTP id 947C5402B03B for ; Wed, 30 Aug 2017 08:35:16 +0000 (UTC) Received: by xxx.smtp.chinacmail.com (Postfix, from userid 12301) id 0D3E2C05C8; Wed, 30 Aug 2017 16:04:43 +0800 (CST) Received: from host-172-16-90-85.openstacklocal (unknown [221.228.240.122]) by xxx.smtp.chinacmail.com (Postfix) with ESMTPA id D923EC041E; Wed, 30 Aug 2017 16:04:42 +0800 (CST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 141FA81240 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=huayun.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 141FA81240 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 947C5402B03B Authentication-Results: ext-mx03.extmail.prod.ext.rdu2.redhat.com; dmarc=none (p=none dis=none) header.from=huayun.com Authentication-Results: ext-mx03.extmail.prod.ext.rdu2.redhat.com; spf=none smtp.mailfrom=liuqing@huayun.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 947C5402B03B X-HY-TRUST: YES X-HY-SID: 7656.206.1504080305.851461 X-HY-SPAM: NO Date: Wed, 30 Aug 2017 16:07:16 +0800 From: Liu Qing To: libvir-list@redhat.com Message-ID: <20170830080716.GA24713@host-172-16-90-85.openstacklocal> References: <1504078368-23949-1-git-send-email-liuqing@huayun.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1504078368-23949-1-git-send-email-liuqing@huayun.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Greylist: Delayed for 00:30:05 by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 30 Aug 2017 08:35:18 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 30 Aug 2017 08:35:18 +0000 (UTC) for IP:'103.231.69.152' DOMAIN:'mx0.ioa.cn' HELO:'mx1.ioa.cn' FROM:'liuqing@huayun.com' RCPT:'' X-RedHat-Spam-Score: 0.8 (BAYES_50) 103.231.69.152 mx0.ioa.cn 103.231.69.152 mx0.ioa.cn X-Scanned-By: MIMEDefang 2.78 on 10.11.55.5 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: liuqing@huayun.com Subject: [libvirt] [PATCH] Add qcow2 cache configuration 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 30 Aug 2017 08:35:39 +0000 (UTC) X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Random write IOPS will drop dramatically if qcow2 l2 cache could not cover the whole disk. This patch give libvirt user a chance to adjust the qcow2 cache configuration. Signed-off-by: Liu Qing --- src/conf/domain_conf.c | 30 ++++++++++++++++++++++++++++++ src/qemu/qemu_command.c | 6 ++++++ src/util/virstoragefile.c | 3 +++ src/util/virstoragefile.h | 4 ++++ 4 files changed, 43 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d97aab4..06ca1de 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8590,6 +8590,30 @@ virDomainDiskDefDriverParseXML(virDomainDiskDefPtr d= ef, VIR_FREE(tmp); } =20 + if ((tmp =3D virXMLPropString(cur, "l2-cache-size")) && + (virStrToLong_ui(tmp, NULL, 10, &def->src->l2_cache_size) < 0)) { + virReportError(VIR_ERR_XML_ERROR, + _("Invalid l2-cache-size attribute in disk driver e= lement: %s"), + tmp); + goto cleanup; + } + + if ((tmp =3D virXMLPropString(cur, "refcount-cache-size")) && + (virStrToLong_ui(tmp, NULL, 10, &def->src->refcount_cache_size) < = 0)) { + virReportError(VIR_ERR_XML_ERROR, + _("Invalid refcount-cache-size attribute in disk dr= iver element: %s"), + tmp); + goto cleanup; + } + + if ((tmp =3D virXMLPropString(cur, "cache-clean-interval")) && + (virStrToLong_ui(tmp, NULL, 10, &def->src->cache_clean_interval) <= 0)) { + virReportError(VIR_ERR_XML_ERROR, + _("Invalid cache-clean-interval attribute in disk d= river element: %s"), + tmp); + goto cleanup; + } + if ((tmp =3D virXMLPropString(cur, "detect_zeroes")) && (def->detect_zeroes =3D virDomainDiskDetectZeroesTypeFromString(tm= p)) <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -21887,6 +21911,12 @@ virDomainDiskDefFormat(virBufferPtr buf, virBufferAsprintf(&driverBuf, " iothread=3D'%u'", def->iothread); if (def->detect_zeroes) virBufferAsprintf(&driverBuf, " detect_zeroes=3D'%s'", detect_zero= es); + if (def->src->l2_cache_size > 0) + virBufferAsprintf(&driverBuf, " l2-cache-size=3D'%u'", def->src->l= 2_cache_size); + if (def->src->refcount_cache_size > 0) + virBufferAsprintf(&driverBuf, " refcount-cache-size=3D'%u'", def->= src->refcount_cache_size); + if (def->src->cache_clean_interval > 0) + virBufferAsprintf(&driverBuf, " cache-clean-interval=3D'%u'", def-= >src->cache_clean_interval); =20 virDomainVirtioOptionsFormat(&driverBuf, def->virtio); =20 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 9a27987..7996eed 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1430,6 +1430,12 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk, qemuformat =3D "luks"; virBufferAsprintf(buf, "format=3D%s,", qemuformat); } + if (disk->src->format =3D=3D VIR_STORAGE_FILE_QCOW2 && disk->src->l2_c= ache_size > 0) + virBufferAsprintf(buf, "l2-cache-size=3D%u,", disk->src->l2_cache_= size); + if (disk->src->format =3D=3D VIR_STORAGE_FILE_QCOW2 && disk->src->refc= ount_cache_size > 0) + virBufferAsprintf(buf, "refcount-cache-size=3D%u,", disk->src->ref= count_cache_size); + if (disk->src->format =3D=3D VIR_STORAGE_FILE_QCOW2 && disk->src->cach= e_clean_interval > 0) + virBufferAsprintf(buf, "cache-clean-interval=3D%u,", disk->src->ca= che_clean_interval); =20 ret =3D 0; =20 diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index fbc8245..c685331 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2038,6 +2038,9 @@ virStorageSourceCopy(const virStorageSource *src, ret->physical =3D src->physical; ret->readonly =3D src->readonly; ret->shared =3D src->shared; + ret->l2_cache_size =3D src->l2_cache_size; + ret->refcount_cache_size =3D src->refcount_cache_size; + ret->cache_clean_interval =3D src->cache_clean_interval; =20 /* storage driver metadata are not copied */ ret->drv =3D NULL; diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 6c388b1..e7889d9 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -280,6 +280,10 @@ struct _virStorageSource { /* metadata that allows identifying given storage source */ char *nodeformat; /* name of the format handler object */ char *nodestorage; /* name of the storage object */ + + unsigned l2_cache_size; /* qcow2 l2 cache size */ + unsigned refcount_cache_size; /* qcow2 reference count table cache siz= e */ + unsigned cache_clean_interval; /* clean unused cache entries interval = */ }; =20 =20 --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list