From nobody Thu Nov 28 10:47:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1692896464; cv=none; d=zohomail.com; s=zohoarc; b=JGgcp7MZl54NobgB4+Sn0WZqwieZUVFVQz7erDbgBuqehGTXk0WmEt813BpcaxSnN7zz+UaSiAcSfKGlFvpLwvJUpg6jQXH8nF+MJoV8d/5okJVjVSMPTNwG5/qL/fqmdEhaakezynI08sNsaWwCG602LxpctrCS8userlOO+4Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692896464; h=Content-Transfer-Encoding:Cc: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=EJD2LIajjQtoGeGPnYi+7JdF7CSvrKKy9cQB+BYrwtY=; b=ElTXgC8lG9//W16y063dbMxdwSNIS1zQrJEj92+9UBSfkTYmC5p6RfuS5JUZSM+d9isXA6Yl00ll2oJH5I1QEbGE9tgyefBLmIhxE+LRf7Fv1XFpWgj5wacwdIVhNz1uIW7Tk4xgJydO52Lg3TPAowbhLOkgEZL1yfuLIVOOKN0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1692896464473202.12729238739598; Thu, 24 Aug 2023 10:01:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZDfj-0006H4-6x; Thu, 24 Aug 2023 12:59:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qZDfh-0006F0-1C for qemu-devel@nongnu.org; Thu, 24 Aug 2023 12:59:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qZDfe-0003S2-G0 for qemu-devel@nongnu.org; Thu, 24 Aug 2023 12:59:00 -0400 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-76-z2cB3R2PPDmWc3PD1CgTFg-1; Thu, 24 Aug 2023 12:58:53 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 39AE0101A528; Thu, 24 Aug 2023 16:58:53 +0000 (UTC) Received: from localhost (unknown [10.39.194.213]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9CA11140E962; Thu, 24 Aug 2023 16:58:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692896337; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EJD2LIajjQtoGeGPnYi+7JdF7CSvrKKy9cQB+BYrwtY=; b=D5HVb0WUE9L7nwUVJrws87gG1zP/BY6ZKOeoy/KF8xRMDDbDJErAmv3GPiqw79uzngK9EO FHOWuqEiLIUeQV2WdPSlAHl1OMgWmE39QtqR9L11VP2BwJaCqsjwlAFKyYkJ3FF4646kPL 7ubI+HeG3/co4hhrYukxXnDCBdfjdDQ= X-MC-Unique: z2cB3R2PPDmWc3PD1CgTFg-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Peter Xu , Thomas Huth , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Kevin Wolf , Juan Quintela , Fam Zheng , Paolo Bonzini , Laurent Vivier , Stefan Hajnoczi , Marcel Apfelbaum , John Snow , Jeuk Kim , Hanna Reitz , Leonardo Bras , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Vladimir Sementsov-Ogievskiy , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , "Michael S. Tsirkin" , Eric Blake , "Denis V . Lunev" , Andrey Drobyshev Subject: [PULL 6/8] block: add subcluster_size field to BlockDriverInfo Date: Thu, 24 Aug 2023 12:58:31 -0400 Message-ID: <20230824165833.1689137-7-stefanha@redhat.com> In-Reply-To: <20230824165833.1689137-1-stefanha@redhat.com> References: <20230824165833.1689137-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=stefanha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1692896469675100001 Content-Type: text/plain; charset="utf-8" From: Andrey Drobyshev via This is going to be used in the subsequent commit as requests alignment (in particular, during copy-on-read). This value only makes sense for the formats which support subclusters (currently QCOW2 only). If this field isn't set by driver's own bdrv_get_info() implementation, we simply set it equal to the cluster size thus treating each cluster as having a single subcluster. Reviewed-by: Eric Blake Reviewed-by: Denis V. Lunev Signed-off-by: Andrey Drobyshev Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Stefan Hajnoczi Message-ID: <20230711172553.234055-2-andrey.drobyshev@virtuozzo.com> --- include/block/block-common.h | 5 +++++ block.c | 7 +++++++ block/qcow2.c | 1 + 3 files changed, 13 insertions(+) diff --git a/include/block/block-common.h b/include/block/block-common.h index e15395f2cb..df5ffc8d09 100644 --- a/include/block/block-common.h +++ b/include/block/block-common.h @@ -132,6 +132,11 @@ typedef struct BlockZoneWps { typedef struct BlockDriverInfo { /* in bytes, 0 if irrelevant */ int cluster_size; + /* + * A fraction of cluster_size, if supported (currently QCOW2 only); if + * disabled or unsupported, set equal to cluster_size. + */ + int subcluster_size; /* offset at which the VM state can be saved (0 if not possible) */ int64_t vm_state_offset; bool is_dirty; diff --git a/block.c b/block.c index a307c151a8..0af890f647 100644 --- a/block.c +++ b/block.c @@ -6480,6 +6480,13 @@ int coroutine_fn bdrv_co_get_info(BlockDriverState *= bs, BlockDriverInfo *bdi) } memset(bdi, 0, sizeof(*bdi)); ret =3D drv->bdrv_co_get_info(bs, bdi); + if (bdi->subcluster_size =3D=3D 0) { + /* + * If the driver left this unset, subclusters are not supported. + * Then it is safe to treat each cluster as having only one subclu= ster. + */ + bdi->subcluster_size =3D bdi->cluster_size; + } if (ret < 0) { return ret; } diff --git a/block/qcow2.c b/block/qcow2.c index c51388e99d..b48cd9ce63 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -5197,6 +5197,7 @@ qcow2_co_get_info(BlockDriverState *bs, BlockDriverIn= fo *bdi) { BDRVQcow2State *s =3D bs->opaque; bdi->cluster_size =3D s->cluster_size; + bdi->subcluster_size =3D s->subcluster_size; bdi->vm_state_offset =3D qcow2_vm_state_offset(s); bdi->is_dirty =3D s->incompatible_features & QCOW2_INCOMPAT_DIRTY; return 0; --=20 2.41.0