From nobody Sat May 18 12:05:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1692964360; cv=none; d=zohomail.com; s=zohoarc; b=jfciiQFNjjQOGXvmJ4DNxRscf/WXFY2dkgCaFkZwbO6QEhceNxLAUo2MD3qK6FuVweyNUW4m6n4UhHkrC0gbMiWpDem0ia/kwy5h1VOPACCaOI/2Gs/ndppo+B3nQd5jgWLR31Pu9O0vtzslPJ6ZwSBesx4MhTlVvnzAuTGPDLI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692964360; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jNnyBcJun82Pyrhof5ygc0X9OVwSiUB7nLidUMfBHho=; b=Um2St9P9CHGXyV47Ai6/HnnzGT8rZH8vae9yJkLQvAfPgcRxcAHprTjmWIj6v2ohyI90Q+2h7O7WZADRwUMPMe3wEwZsLI2nvssgfqUEvJj4gpdTrj/PQ4BWXoDMnHPQVdnPPE41lYT9Qyl0SFiqWIrxduMgtZn4c/SFTZkLS9g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1692964360641913.1794480097375; Fri, 25 Aug 2023 04:52:40 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-392-XR7w9zv-NiSevw203jzWmA-1; Fri, 25 Aug 2023 07:52:35 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4D76E8D40A7; Fri, 25 Aug 2023 11:52:33 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 66D5A40C2004; Fri, 25 Aug 2023 11:52:32 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D199319465B3; Fri, 25 Aug 2023 11:52:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2733819465A8 for ; Fri, 25 Aug 2023 11:52:21 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id DF9A4492C14; Fri, 25 Aug 2023 11:52:20 +0000 (UTC) Received: from fedora.. (unknown [10.43.2.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B57E4A9004 for ; Fri, 25 Aug 2023 11:52:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692964359; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=jNnyBcJun82Pyrhof5ygc0X9OVwSiUB7nLidUMfBHho=; b=doyqOFzryrHc8KrH1Vlj5AihsILuttsXWI52BbSeZBaPbNapSO6OHzw5Cto0GfTryWMn7X c/N0i7RF9eC/ZgieeAe3nKq4CAeIha/yxK1ILmJRRjP5rjMmM1v+sXy4KND7oP/W/m5ZbF 9WQW4fzxuy5oQKe4C8kikqFETLGrT1E= X-MC-Unique: XR7w9zv-NiSevw203jzWmA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH v2 1/2] conf: add support for discard_granularity Date: Fri, 25 Aug 2023 13:52:14 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1692964362980100002 Content-Type: text/plain; charset="utf-8"; x-default="true" This introduces the ability to set the discard granularity option for a disk. It defines the smallest amount of data that can be discarded in a single operation (useful for managing and optimizing storage). Signed-off-by: Kristina Hanicova Reviewed-by: Peter Krempa --- docs/formatdomain.rst | 6 +++++- src/conf/domain_conf.c | 19 ++++++++++++++++++- src/conf/domain_conf.h | 1 + src/conf/domain_validate.c | 3 ++- src/conf/schemas/domaincommon.rng | 5 +++++ src/qemu/qemu_domain.c | 2 ++ 6 files changed, 33 insertions(+), 3 deletions(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index cd9cb02bf8..0d0812f08c 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -2588,7 +2588,7 @@ paravirtualized driver is specified via the ``disk`` = element. - + @@ -3435,6 +3435,10 @@ paravirtualized driver is specified via the ``disk``= element. this would be the value returned by the BLKPBSZGET ioctl and describ= es the disk's hardware sector size which can be relevant for the alignment = of disk data. + ``discard_granularity`` + The smallest amount of data that can be discarded in a single operat= ion. + It impacts the unmap operations and it must be a multiple of a + ``logical_block_size``. =20 Filesystems ~~~~~~~~~~~ diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 69934026ef..bb4f1fdb94 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8073,6 +8073,10 @@ virDomainDiskDefParseXML(virDomainXMLOption *xmlopt, if (virXMLPropUInt(blockioNode, "physical_block_size", 10, VIR_XML= _PROP_NONE, &def->blockio.physical_block_size) < 0) return NULL; + + if (virXMLPropUInt(blockioNode, "discard_granularity", 10, VIR_XML= _PROP_NONE, + &def->blockio.discard_granularity) < 0) + return NULL; } =20 if ((driverNode =3D virXPathNode("./driver", ctxt))) { @@ -19836,6 +19840,13 @@ virDomainDiskBlockIoCheckABIStability(virDomainDis= kDef *src, dst->blockio.physical_block_size, src->blockio.phys= ical_block_size); return false; } + + if (src->blockio.discard_granularity !=3D dst->blockio.discard_granula= rity) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target disk discard_granularity %1$u does not ma= tch source %2$u"), + dst->blockio.discard_granularity, src->blockio.disc= ard_granularity); + return false; + } return true; } =20 @@ -22132,7 +22143,8 @@ virDomainDiskBlockIoDefFormat(virBuffer *buf, virDomainDiskDef *def) { if (def->blockio.logical_block_size > 0 || - def->blockio.physical_block_size > 0) { + def->blockio.physical_block_size > 0 || + def->blockio.discard_granularity > 0) { virBufferAddLit(buf, "blockio.logical_block_size > 0) { virBufferAsprintf(buf, @@ -22144,6 +22156,11 @@ virDomainDiskBlockIoDefFormat(virBuffer *buf, " physical_block_size=3D'%u'", def->blockio.physical_block_size); } + if (def->blockio.discard_granularity > 0) { + virBufferAsprintf(buf, + " discard_granularity=3D'%u'", + def->blockio.discard_granularity); + } virBufferAddLit(buf, "/>\n"); } } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 8bef097542..ca195a52d2 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -579,6 +579,7 @@ struct _virDomainDiskDef { struct { unsigned int logical_block_size; unsigned int physical_block_size; + unsigned int discard_granularity; } blockio; =20 virDomainBlockIoTuneInfo blkdeviotune; diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index b286990b19..fd3eed3230 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -466,7 +466,8 @@ virDomainDiskVhostUserValidate(const virDomainDiskDef *= disk) } =20 if (disk->blockio.logical_block_size > 0 || - disk->blockio.physical_block_size > 0) { + disk->blockio.physical_block_size > 0 || + disk->blockio.discard_granularity > 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("blockio is not supported with vhostuser disk")); return -1; diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index 2556ac01ed..de3bd1c35c 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -2461,6 +2461,11 @@ + + + + +