From nobody Sat Apr 20 10:53:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 14957261273691006.5574803184824; Thu, 25 May 2017 08:28:47 -0700 (PDT) Received: from localhost ([::1]:60511 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDugu-0007A4-5J for importer@patchew.org; Thu, 25 May 2017 11:28:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33062) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDufA-0004qH-KA for qemu-devel@nongnu.org; Thu, 25 May 2017 11:26:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDuf5-0002g6-M7 for qemu-devel@nongnu.org; Thu, 25 May 2017 11:26:56 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:32655 helo=relay.sw.ru) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDuf5-0002fB-BO for qemu-devel@nongnu.org; Thu, 25 May 2017 11:26:51 -0400 Received: from kvm.sw.ru (msk-vpn.virtuozzo.com [195.214.232.6]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id v4PFQS1o019102; Thu, 25 May 2017 18:26:29 +0300 (MSK) From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Thu, 25 May 2017 18:26:22 +0300 Message-Id: <20170525152628.37628-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.11.1 In-Reply-To: <20170525152628.37628-1-vsementsov@virtuozzo.com> References: <20170525152628.37628-1-vsementsov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x [fuzzy] X-Received-From: 195.214.232.25 Subject: [Qemu-devel] [PATCH 1/7] block: fix comment for bdrv_get_allocated_file_size() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, armbru@redhat.com, mreitz@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Current comment is not clear enough: which sparseness is meant, coming from sparse image format or from sparse file system? For example, if we have qcow2 above raw file on non-sparse file system, this function will say nothing about unallocated (by qcow2 layer) clusters. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block.c b/block.c index 50ba264143..ba22fc0dfb 100644 --- a/block.c +++ b/block.c @@ -3388,8 +3388,8 @@ int bdrv_truncate(BdrvChild *child, int64_t offset, E= rror **errp) } =20 /** - * Length of a allocated file in bytes. Sparse files are counted by actual - * allocated space. Return < 0 if error or unknown. + * Size of allocated in underlying file system area. Sparseness is taken i= nto + * account for sparse file systems. Return < 0 if error or unknown. */ int64_t bdrv_get_allocated_file_size(BlockDriverState *bs) { --=20 2.11.1 From nobody Sat Apr 20 10:53:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1495726128281132.1642567692753; Thu, 25 May 2017 08:28:48 -0700 (PDT) Received: from localhost ([::1]:60513 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDugw-0007DD-Kw for importer@patchew.org; Thu, 25 May 2017 11:28:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33065) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDufA-0004qL-KH for qemu-devel@nongnu.org; Thu, 25 May 2017 11:26:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDuf5-0002gB-Ml for qemu-devel@nongnu.org; Thu, 25 May 2017 11:26:56 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:41088 helo=relay.sw.ru) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDuf5-0002f8-BJ for qemu-devel@nongnu.org; Thu, 25 May 2017 11:26:51 -0400 Received: from kvm.sw.ru (msk-vpn.virtuozzo.com [195.214.232.6]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id v4PFQS1p019102; Thu, 25 May 2017 18:26:30 +0300 (MSK) From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Thu, 25 May 2017 18:26:23 +0300 Message-Id: <20170525152628.37628-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.11.1 In-Reply-To: <20170525152628.37628-1-vsementsov@virtuozzo.com> References: <20170525152628.37628-1-vsementsov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x [fuzzy] X-Received-From: 195.214.232.25 Subject: [Qemu-devel] [PATCH 2/7] block: add bdrv_get_format_allocated_size format interface X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, armbru@redhat.com, mreitz@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The function should return actually used by top-level format driver space (in it's .file). It differs from bdrv_get_allocated_file_size, which returns allocated on fs file size. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c | 15 +++++++++++++++ include/block/block.h | 1 + include/block/block_int.h | 1 + 3 files changed, 17 insertions(+) diff --git a/block.c b/block.c index ba22fc0dfb..6e1a435490 100644 --- a/block.c +++ b/block.c @@ -3407,6 +3407,21 @@ int64_t bdrv_get_allocated_file_size(BlockDriverStat= e *bs) } =20 /** + * Actually used by top-level format driver space (in it's .file) in bytes + */ +int64_t bdrv_get_format_allocated_size(BlockDriverState *bs) +{ + BlockDriver *drv =3D bs->drv; + if (!drv) { + return -ENOMEDIUM; + } + if (drv->bdrv_get_format_allocated_size) { + return drv->bdrv_get_format_allocated_size(bs); + } + return -ENOTSUP; +} + +/** * Return number of sectors on success, -errno on error. */ int64_t bdrv_nb_sectors(BlockDriverState *bs) diff --git a/include/block/block.h b/include/block/block.h index 9b355e92d8..c36b9ccae4 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -304,6 +304,7 @@ int bdrv_truncate(BdrvChild *child, int64_t offset, Err= or **errp); int64_t bdrv_nb_sectors(BlockDriverState *bs); int64_t bdrv_getlength(BlockDriverState *bs); int64_t bdrv_get_allocated_file_size(BlockDriverState *bs); +int64_t bdrv_get_format_allocated_size(BlockDriverState *bs); void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr); void bdrv_refresh_limits(BlockDriverState *bs, Error **errp); int bdrv_commit(BlockDriverState *bs); diff --git a/include/block/block_int.h b/include/block/block_int.h index 8d3724cce6..e562fa7a5a 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -208,6 +208,7 @@ struct BlockDriver { int64_t (*bdrv_getlength)(BlockDriverState *bs); bool has_variable_length; int64_t (*bdrv_get_allocated_file_size)(BlockDriverState *bs); + int64_t (*bdrv_get_format_allocated_size)(BlockDriverState *bs); =20 int coroutine_fn (*bdrv_co_pwritev_compressed)(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov); --=20 2.11.1 From nobody Sat Apr 20 10:53:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149572642421763.21207741114131; Thu, 25 May 2017 08:33:44 -0700 (PDT) Received: from localhost ([::1]:60538 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDuli-0003UK-TG for importer@patchew.org; Thu, 25 May 2017 11:33:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33059) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDufA-0004qE-K5 for qemu-devel@nongnu.org; Thu, 25 May 2017 11:26:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDuf5-0002fr-In for qemu-devel@nongnu.org; Thu, 25 May 2017 11:26:56 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:29617 helo=relay.sw.ru) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDuf5-0002fF-79 for qemu-devel@nongnu.org; Thu, 25 May 2017 11:26:51 -0400 Received: from kvm.sw.ru (msk-vpn.virtuozzo.com [195.214.232.6]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id v4PFQS1q019102; Thu, 25 May 2017 18:26:30 +0300 (MSK) From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Thu, 25 May 2017 18:26:24 +0300 Message-Id: <20170525152628.37628-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.11.1 In-Reply-To: <20170525152628.37628-1-vsementsov@virtuozzo.com> References: <20170525152628.37628-1-vsementsov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x [fuzzy] X-Received-From: 195.214.232.25 Subject: [Qemu-devel] [PATCH 3/7] qcow2: add .bdrv_get_format_allocated_size X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, armbru@redhat.com, mreitz@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Realize .bdrv_get_format_allocated_size interface. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/qcow2-refcount.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ block/qcow2.c | 2 ++ block/qcow2.h | 2 ++ 3 files changed, 65 insertions(+) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 7c06061aae..45adf6bd1d 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -2931,3 +2931,64 @@ done: qemu_vfree(new_refblock); return ret; } + +typedef struct NbAllocatedClustersCo { + BlockDriverState *bs; + int64_t ret; +} NbAllocatedClustersCo; + +static void coroutine_fn qcow2_get_format_allocated_size_co_entry(void *op= aque) +{ + NbAllocatedClustersCo *nbco =3D opaque; + BlockDriverState *bs =3D nbco->bs; + BDRVQcow2State *s =3D bs->opaque; + int64_t size, nb_clusters, nb_allocated =3D 0, i; + int ret =3D 0; + + size =3D bdrv_getlength(bs->file->bs); + if (size < 0) { + nbco->ret =3D size; + return; + } + + nb_clusters =3D size_to_clusters(s, size); + + qemu_co_mutex_lock(&s->lock); + + for (i =3D 0; i < nb_clusters; ++i) { + uint64_t refcount; + ret =3D qcow2_get_refcount(bs, i, &refcount); + if (ret < 0) { + nbco->ret =3D ret; + qemu_co_mutex_unlock(&s->lock); + return; + } + if (refcount > 0) { + nb_allocated++; + } + } + + qemu_co_mutex_unlock(&s->lock); + + nbco->ret =3D nb_allocated << s->cluster_bits; +} + +int64_t qcow2_get_format_allocated_size(BlockDriverState *bs) +{ + NbAllocatedClustersCo nbco =3D { + .bs =3D bs, + .ret =3D -EINPROGRESS + }; + + if (qemu_in_coroutine()) { + qcow2_get_format_allocated_size_co_entry(&nbco); + } else { + Coroutine *co =3D + qemu_coroutine_create(qcow2_get_format_allocated_size_co_entry, + &nbco); + qemu_coroutine_enter(co); + BDRV_POLL_WHILE(bs, nbco.ret =3D=3D -EINPROGRESS); + } + + return nbco.ret; +} diff --git a/block/qcow2.c b/block/qcow2.c index a8d61f0981..274f213d16 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3469,6 +3469,8 @@ BlockDriver bdrv_qcow2 =3D { =20 .bdrv_detach_aio_context =3D qcow2_detach_aio_context, .bdrv_attach_aio_context =3D qcow2_attach_aio_context, + + .bdrv_get_format_allocated_size =3D qcow2_get_format_allocated_size, }; =20 static void bdrv_qcow2_init(void) diff --git a/block/qcow2.h b/block/qcow2.h index 1801dc30dc..8cc63d9e0e 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -532,6 +532,8 @@ int qcow2_change_refcount_order(BlockDriverState *bs, i= nt refcount_order, BlockDriverAmendStatusCB *status_cb, void *cb_opaque, Error **errp); =20 +int64_t qcow2_get_format_allocated_size(BlockDriverState *bs); + /* qcow2-cluster.c functions */ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size, bool exact_size); --=20 2.11.1 From nobody Sat Apr 20 10:53:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1495726137996816.0736339396552; Thu, 25 May 2017 08:28:57 -0700 (PDT) Received: from localhost ([::1]:60514 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDuh6-0007KY-Fi for importer@patchew.org; Thu, 25 May 2017 11:28:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33061) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDufA-0004qG-KC for qemu-devel@nongnu.org; Thu, 25 May 2017 11:26:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDuf5-0002fd-Ic for qemu-devel@nongnu.org; Thu, 25 May 2017 11:26:56 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:44272 helo=relay.sw.ru) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDuf5-0002fM-75 for qemu-devel@nongnu.org; Thu, 25 May 2017 11:26:51 -0400 Received: from kvm.sw.ru (msk-vpn.virtuozzo.com [195.214.232.6]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id v4PFQS1r019102; Thu, 25 May 2017 18:26:30 +0300 (MSK) From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Thu, 25 May 2017 18:26:25 +0300 Message-Id: <20170525152628.37628-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.11.1 In-Reply-To: <20170525152628.37628-1-vsementsov@virtuozzo.com> References: <20170525152628.37628-1-vsementsov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x [fuzzy] X-Received-From: 195.214.232.25 Subject: [Qemu-devel] [PATCH 4/7] common: make get_human_readable_size public X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, armbru@redhat.com, mreitz@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" To be reused from qemu-img check. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/qapi.c | 2 +- include/qemu-common.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/block/qapi.c b/block/qapi.c index a40922ea26..d249d97142 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -524,7 +524,7 @@ BlockStatsList *qmp_query_blockstats(bool has_query_nod= es, =20 #define NB_SUFFIXES 4 =20 -static char *get_human_readable_size(char *buf, int buf_size, int64_t size) +char *get_human_readable_size(char *buf, int buf_size, int64_t size) { static const char suffixes[NB_SUFFIXES] =3D {'K', 'M', 'G', 'T'}; int64_t base; diff --git a/include/qemu-common.h b/include/qemu-common.h index 387ef520bf..7102ad8dbd 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -152,4 +152,6 @@ void page_size_init(void); * returned. */ bool dump_in_progress(void); =20 +char *get_human_readable_size(char *buf, int buf_size, int64_t size); + #endif --=20 2.11.1 From nobody Sat Apr 20 10:53:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1495726267016324.36047264949923; Thu, 25 May 2017 08:31:07 -0700 (PDT) Received: from localhost ([::1]:60525 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDujB-0000h6-Lh for importer@patchew.org; Thu, 25 May 2017 11:31:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33064) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDufA-0004qJ-KE for qemu-devel@nongnu.org; Thu, 25 May 2017 11:26:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDuf5-0002fj-IU for qemu-devel@nongnu.org; Thu, 25 May 2017 11:26:56 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:3242 helo=relay.sw.ru) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDuf5-0002fA-6w for qemu-devel@nongnu.org; Thu, 25 May 2017 11:26:51 -0400 Received: from kvm.sw.ru (msk-vpn.virtuozzo.com [195.214.232.6]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id v4PFQS1s019102; Thu, 25 May 2017 18:26:30 +0300 (MSK) From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Thu, 25 May 2017 18:26:26 +0300 Message-Id: <20170525152628.37628-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.11.1 In-Reply-To: <20170525152628.37628-1-vsementsov@virtuozzo.com> References: <20170525152628.37628-1-vsementsov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x [fuzzy] X-Received-From: 195.214.232.25 Subject: [Qemu-devel] [PATCH 5/7] qemu-img check: add format unallocated size X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, armbru@redhat.com, mreitz@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Shows format 'sparseness' of the image top level. Signed-off-by: Vladimir Sementsov-Ogievskiy --- qapi/block-core.json | 3 ++- qemu-img.c | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index ea0b3e8b13..c7ed5dc970 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -185,7 +185,8 @@ '*image-end-offset': 'int', '*corruptions': 'int', '*leaks': 'i= nt', '*corruptions-fixed': 'int', '*leaks-fixed': 'int', '*total-clusters': 'int', '*allocated-clusters': 'int', - '*fragmented-clusters': 'int', '*compressed-clusters': 'int' } } + '*fragmented-clusters': 'int', '*compressed-clusters': 'int', + '*format-unallocated-size': 'uint64'} } =20 ## # @MapEntry: diff --git a/qemu-img.c b/qemu-img.c index b506839ef0..cbd09148d2 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -601,6 +601,13 @@ static void dump_human_image_check(ImageCheck *check, = bool quiet) qprintf(quiet, "Image end offset: %" PRId64 "\n", check->image_end_offset= ); } + + if (check->has_format_unallocated_size) { + char u_buf[128]; + qprintf(quiet, "Format unallocated size: %s\n", + get_human_readable_size(u_buf, sizeof(u_buf), + check->format_unallocated_size)); + } } =20 static int collect_image_check(BlockDriverState *bs, @@ -639,6 +646,18 @@ static int collect_image_check(BlockDriverState *bs, check->compressed_clusters =3D result.bfi.compressed_clusters; check->has_compressed_clusters =3D result.bfi.compressed_clusters != =3D 0; =20 + if (bs->file) { + int64_t file_size =3D bdrv_getlength(bs->file->bs); + if (file_size >=3D 0) { + int64_t format_allocated_size =3D bdrv_get_format_allocated_si= ze(bs); + if (format_allocated_size >=3D 0) { + check->format_unallocated_size =3D + file_size - format_allocated_size; + check->has_format_unallocated_size =3D true; + } + } + } + return 0; } =20 --=20 2.11.1 From nobody Sat Apr 20 10:53:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1495726275957116.56742188030807; Thu, 25 May 2017 08:31:15 -0700 (PDT) Received: from localhost ([::1]:60526 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDujK-0000oS-Ek for importer@patchew.org; Thu, 25 May 2017 11:31:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33063) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDufA-0004qI-KK for qemu-devel@nongnu.org; Thu, 25 May 2017 11:26:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDuf5-0002fw-Ik for qemu-devel@nongnu.org; Thu, 25 May 2017 11:26:56 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:47130 helo=relay.sw.ru) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDuf5-0002fD-6z for qemu-devel@nongnu.org; Thu, 25 May 2017 11:26:51 -0400 Received: from kvm.sw.ru (msk-vpn.virtuozzo.com [195.214.232.6]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id v4PFQS1t019102; Thu, 25 May 2017 18:26:30 +0300 (MSK) From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Thu, 25 May 2017 18:26:27 +0300 Message-Id: <20170525152628.37628-7-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.11.1 In-Reply-To: <20170525152628.37628-1-vsementsov@virtuozzo.com> References: <20170525152628.37628-1-vsementsov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x [fuzzy] X-Received-From: 195.214.232.25 Subject: [Qemu-devel] [PATCH 6/7] qemu-img check: add file-size X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, armbru@redhat.com, mreitz@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add bdrv_getlength() of underlying bs->file->bs, to improve 'Format unallocated size' section of qemu-img check output. Signed-off-by: Vladimir Sementsov-Ogievskiy --- qapi/block-core.json | 2 +- qemu-img.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index c7ed5dc970..f720a29512 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -186,7 +186,7 @@ '*corruptions-fixed': 'int', '*leaks-fixed': 'int', '*total-clusters': 'int', '*allocated-clusters': 'int', '*fragmented-clusters': 'int', '*compressed-clusters': 'int', - '*format-unallocated-size': 'uint64'} } + '*format-unallocated-size': 'uint64', '*file-size': 'uint64'} } =20 ## # @MapEntry: diff --git a/qemu-img.c b/qemu-img.c index cbd09148d2..08a2b5ba54 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -603,10 +603,13 @@ static void dump_human_image_check(ImageCheck *check,= bool quiet) } =20 if (check->has_format_unallocated_size) { - char u_buf[128]; - qprintf(quiet, "Format unallocated size: %s\n", + char buf[128], u_buf[128]; + assert(check->has_file_size); + qprintf(quiet, "Format unallocated size: %s/%s =3D %0.2f%%\n", get_human_readable_size(u_buf, sizeof(u_buf), - check->format_unallocated_size)); + check->format_unallocated_size), + get_human_readable_size(buf, sizeof(buf), check->file_size= ), + check->format_unallocated_size * 100.0 / check->file_size); } } =20 @@ -650,6 +653,8 @@ static int collect_image_check(BlockDriverState *bs, int64_t file_size =3D bdrv_getlength(bs->file->bs); if (file_size >=3D 0) { int64_t format_allocated_size =3D bdrv_get_format_allocated_si= ze(bs); + check->file_size =3D file_size; + check->has_file_size =3D true; if (format_allocated_size >=3D 0) { check->format_unallocated_size =3D file_size - format_allocated_size; --=20 2.11.1 From nobody Sat Apr 20 10:53:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1495726128790251.81768641233782; Thu, 25 May 2017 08:28:48 -0700 (PDT) Received: from localhost ([::1]:60512 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDugx-0007Cs-BS for importer@patchew.org; Thu, 25 May 2017 11:28:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33060) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDufA-0004qF-K3 for qemu-devel@nongnu.org; Thu, 25 May 2017 11:26:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDuf5-0002gH-SA for qemu-devel@nongnu.org; Thu, 25 May 2017 11:26:56 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:47737 helo=relay.sw.ru) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDuf5-0002f9-BZ for qemu-devel@nongnu.org; Thu, 25 May 2017 11:26:51 -0400 Received: from kvm.sw.ru (msk-vpn.virtuozzo.com [195.214.232.6]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id v4PFQS1u019102; Thu, 25 May 2017 18:26:30 +0300 (MSK) From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Thu, 25 May 2017 18:26:28 +0300 Message-Id: <20170525152628.37628-8-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.11.1 In-Reply-To: <20170525152628.37628-1-vsementsov@virtuozzo.com> References: <20170525152628.37628-1-vsementsov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x [fuzzy] X-Received-From: 195.214.232.25 Subject: [Qemu-devel] [PATCH 7/7] block: rename _get_allocated_file_size() to _get_fs_allocated_size() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, armbru@redhat.com, mreitz@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" To be in contrast with _get_format_allocated_size() Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c | 8 ++++---- block/file-posix.c | 14 +++++--------- block/file-win32.c | 8 +++----- block/gluster.c | 8 ++++---- block/nfs.c | 8 ++++---- block/qapi.c | 2 +- block/sheepdog.c | 8 ++++---- block/vmdk.c | 8 ++++---- include/block/block.h | 2 +- include/block/block_int.h | 2 +- 10 files changed, 31 insertions(+), 37 deletions(-) diff --git a/block.c b/block.c index 6e1a435490..9f4bb37c54 100644 --- a/block.c +++ b/block.c @@ -3391,17 +3391,17 @@ int bdrv_truncate(BdrvChild *child, int64_t offset,= Error **errp) * Size of allocated in underlying file system area. Sparseness is taken i= nto * account for sparse file systems. Return < 0 if error or unknown. */ -int64_t bdrv_get_allocated_file_size(BlockDriverState *bs) +int64_t bdrv_get_fs_allocated_size(BlockDriverState *bs) { BlockDriver *drv =3D bs->drv; if (!drv) { return -ENOMEDIUM; } - if (drv->bdrv_get_allocated_file_size) { - return drv->bdrv_get_allocated_file_size(bs); + if (drv->bdrv_get_fs_allocated_size) { + return drv->bdrv_get_fs_allocated_size(bs); } if (bs->file) { - return bdrv_get_allocated_file_size(bs->file->bs); + return bdrv_get_fs_allocated_size(bs->file->bs); } return -ENOTSUP; } diff --git a/block/file-posix.c b/block/file-posix.c index 4354d49642..46ca4728b3 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1829,7 +1829,7 @@ static int64_t raw_getlength(BlockDriverState *bs) } #endif =20 -static int64_t raw_get_allocated_file_size(BlockDriverState *bs) +static int64_t raw_get_fs_allocated_size(BlockDriverState *bs) { struct stat st; BDRVRawState *s =3D bs->opaque; @@ -2218,8 +2218,7 @@ BlockDriver bdrv_file =3D { .bdrv_truncate =3D raw_truncate, .bdrv_getlength =3D raw_getlength, .bdrv_get_info =3D raw_get_info, - .bdrv_get_allocated_file_size - =3D raw_get_allocated_file_size, + .bdrv_get_fs_allocated_size =3D raw_get_fs_allocated_size, .bdrv_check_perm =3D raw_check_perm, .bdrv_set_perm =3D raw_set_perm, .bdrv_abort_perm_update =3D raw_abort_perm_update, @@ -2679,8 +2678,7 @@ static BlockDriver bdrv_host_device =3D { .bdrv_truncate =3D raw_truncate, .bdrv_getlength =3D raw_getlength, .bdrv_get_info =3D raw_get_info, - .bdrv_get_allocated_file_size - =3D raw_get_allocated_file_size, + .bdrv_get_fs_allocated_size =3D raw_get_fs_allocated_size, .bdrv_check_perm =3D raw_check_perm, .bdrv_set_perm =3D raw_set_perm, .bdrv_abort_perm_update =3D raw_abort_perm_update, @@ -2803,8 +2801,7 @@ static BlockDriver bdrv_host_cdrom =3D { .bdrv_truncate =3D raw_truncate, .bdrv_getlength =3D raw_getlength, .has_variable_length =3D true, - .bdrv_get_allocated_file_size - =3D raw_get_allocated_file_size, + .bdrv_get_fs_allocated_size =3D raw_get_fs_allocated_size, =20 /* removable device support */ .bdrv_is_inserted =3D cdrom_is_inserted, @@ -2933,8 +2930,7 @@ static BlockDriver bdrv_host_cdrom =3D { .bdrv_truncate =3D raw_truncate, .bdrv_getlength =3D raw_getlength, .has_variable_length =3D true, - .bdrv_get_allocated_file_size - =3D raw_get_allocated_file_size, + .bdrv_get_fs_allocated_size =3D raw_get_fs_allocated_size, =20 /* removable device support */ .bdrv_is_inserted =3D cdrom_is_inserted, diff --git a/block/file-win32.c b/block/file-win32.c index 8f14f0bdcd..e246b8954b 100644 --- a/block/file-win32.c +++ b/block/file-win32.c @@ -524,7 +524,7 @@ static int64_t raw_getlength(BlockDriverState *bs) return l.QuadPart; } =20 -static int64_t raw_get_allocated_file_size(BlockDriverState *bs) +static int64_t raw_get_fs_allocated_size(BlockDriverState *bs) { typedef DWORD (WINAPI * get_compressed_t)(const char *filename, DWORD * high); @@ -604,8 +604,7 @@ BlockDriver bdrv_file =3D { =20 .bdrv_truncate =3D raw_truncate, .bdrv_getlength =3D raw_getlength, - .bdrv_get_allocated_file_size - =3D raw_get_allocated_file_size, + .bdrv_get_fs_allocated_size =3D raw_get_fs_allocated_size, =20 .create_opts =3D &raw_create_opts, }; @@ -773,8 +772,7 @@ static BlockDriver bdrv_host_device =3D { .bdrv_getlength =3D raw_getlength, .has_variable_length =3D true, =20 - .bdrv_get_allocated_file_size - =3D raw_get_allocated_file_size, + .bdrv_get_fs_allocated_size =3D raw_get_fs_allocated_size, }; =20 static void bdrv_file_init(void) diff --git a/block/gluster.c b/block/gluster.c index 7c76cd0988..4509602d83 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -1407,7 +1407,7 @@ static BlockDriver bdrv_gluster =3D { .bdrv_close =3D qemu_gluster_close, .bdrv_create =3D qemu_gluster_create, .bdrv_getlength =3D qemu_gluster_getlength, - .bdrv_get_allocated_file_size =3D qemu_gluster_allocated_file_size, + .bdrv_get_fs_allocated_size =3D qemu_gluster_allocated_file_size, .bdrv_truncate =3D qemu_gluster_truncate, .bdrv_co_readv =3D qemu_gluster_co_readv, .bdrv_co_writev =3D qemu_gluster_co_writev, @@ -1435,7 +1435,7 @@ static BlockDriver bdrv_gluster_tcp =3D { .bdrv_close =3D qemu_gluster_close, .bdrv_create =3D qemu_gluster_create, .bdrv_getlength =3D qemu_gluster_getlength, - .bdrv_get_allocated_file_size =3D qemu_gluster_allocated_file_size, + .bdrv_get_fs_allocated_size =3D qemu_gluster_allocated_file_size, .bdrv_truncate =3D qemu_gluster_truncate, .bdrv_co_readv =3D qemu_gluster_co_readv, .bdrv_co_writev =3D qemu_gluster_co_writev, @@ -1463,7 +1463,7 @@ static BlockDriver bdrv_gluster_unix =3D { .bdrv_close =3D qemu_gluster_close, .bdrv_create =3D qemu_gluster_create, .bdrv_getlength =3D qemu_gluster_getlength, - .bdrv_get_allocated_file_size =3D qemu_gluster_allocated_file_size, + .bdrv_get_fs_allocated_size =3D qemu_gluster_allocated_file_size, .bdrv_truncate =3D qemu_gluster_truncate, .bdrv_co_readv =3D qemu_gluster_co_readv, .bdrv_co_writev =3D qemu_gluster_co_writev, @@ -1497,7 +1497,7 @@ static BlockDriver bdrv_gluster_rdma =3D { .bdrv_close =3D qemu_gluster_close, .bdrv_create =3D qemu_gluster_create, .bdrv_getlength =3D qemu_gluster_getlength, - .bdrv_get_allocated_file_size =3D qemu_gluster_allocated_file_size, + .bdrv_get_fs_allocated_size =3D qemu_gluster_allocated_file_size, .bdrv_truncate =3D qemu_gluster_truncate, .bdrv_co_readv =3D qemu_gluster_co_readv, .bdrv_co_writev =3D qemu_gluster_co_writev, diff --git a/block/nfs.c b/block/nfs.c index 848b2c0bb0..0aa5288a07 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -719,7 +719,7 @@ static int nfs_has_zero_init(BlockDriverState *bs) =20 /* Called (via nfs_service) with QemuMutex held. */ static void -nfs_get_allocated_file_size_cb(int ret, struct nfs_context *nfs, void *dat= a, +nfs_get_fs_allocated_size_cb(int ret, struct nfs_context *nfs, void *data, void *private_data) { NFSRPC *task =3D private_data; @@ -734,7 +734,7 @@ nfs_get_allocated_file_size_cb(int ret, struct nfs_cont= ext *nfs, void *data, bdrv_wakeup(task->bs); } =20 -static int64_t nfs_get_allocated_file_size(BlockDriverState *bs) +static int64_t nfs_get_fs_allocated_size(BlockDriverState *bs) { NFSClient *client =3D bs->opaque; NFSRPC task =3D {0}; @@ -747,7 +747,7 @@ static int64_t nfs_get_allocated_file_size(BlockDriverS= tate *bs) =20 task.bs =3D bs; task.st =3D &st; - if (nfs_fstat_async(client->context, client->fh, nfs_get_allocated_fil= e_size_cb, + if (nfs_fstat_async(client->context, client->fh, nfs_get_fs_allocated_= size_cb, &task) !=3D 0) { return -ENOMEM; } @@ -880,7 +880,7 @@ static BlockDriver bdrv_nfs =3D { .create_opts =3D &nfs_create_opts, =20 .bdrv_has_zero_init =3D nfs_has_zero_init, - .bdrv_get_allocated_file_size =3D nfs_get_allocated_file_size, + .bdrv_get_fs_allocated_size =3D nfs_get_fs_allocated_size, .bdrv_truncate =3D nfs_file_truncate, =20 .bdrv_file_open =3D nfs_file_open, diff --git a/block/qapi.c b/block/qapi.c index d249d97142..6dc3575785 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -246,7 +246,7 @@ void bdrv_query_image_info(BlockDriverState *bs, info->filename =3D g_strdup(bs->filename); info->format =3D g_strdup(bdrv_get_format_name(bs)); info->virtual_size =3D size; - info->actual_size =3D bdrv_get_allocated_file_size(bs); + info->actual_size =3D bdrv_get_fs_allocated_size(bs); info->has_actual_size =3D info->actual_size >=3D 0; if (bdrv_is_encrypted(bs)) { info->encrypted =3D true; diff --git a/block/sheepdog.c b/block/sheepdog.c index a18315a1ca..d6195981d4 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -3003,7 +3003,7 @@ sd_co_get_block_status(BlockDriverState *bs, int64_t = sector_num, int nb_sectors, return ret; } =20 -static int64_t sd_get_allocated_file_size(BlockDriverState *bs) +static int64_t sd_get_fs_allocated_size(BlockDriverState *bs) { BDRVSheepdogState *s =3D bs->opaque; SheepdogInode *inode =3D &s->inode; @@ -3066,7 +3066,7 @@ static BlockDriver bdrv_sheepdog =3D { .bdrv_create =3D sd_create, .bdrv_has_zero_init =3D bdrv_has_zero_init_1, .bdrv_getlength =3D sd_getlength, - .bdrv_get_allocated_file_size =3D sd_get_allocated_file_size, + .bdrv_get_fs_allocated_size =3D sd_get_fs_allocated_size, .bdrv_truncate =3D sd_truncate, =20 .bdrv_co_readv =3D sd_co_readv, @@ -3102,7 +3102,7 @@ static BlockDriver bdrv_sheepdog_tcp =3D { .bdrv_create =3D sd_create, .bdrv_has_zero_init =3D bdrv_has_zero_init_1, .bdrv_getlength =3D sd_getlength, - .bdrv_get_allocated_file_size =3D sd_get_allocated_file_size, + .bdrv_get_fs_allocated_size =3D sd_get_fs_allocated_size, .bdrv_truncate =3D sd_truncate, =20 .bdrv_co_readv =3D sd_co_readv, @@ -3138,7 +3138,7 @@ static BlockDriver bdrv_sheepdog_unix =3D { .bdrv_create =3D sd_create, .bdrv_has_zero_init =3D bdrv_has_zero_init_1, .bdrv_getlength =3D sd_getlength, - .bdrv_get_allocated_file_size =3D sd_get_allocated_file_size, + .bdrv_get_fs_allocated_size =3D sd_get_fs_allocated_size, .bdrv_truncate =3D sd_truncate, =20 .bdrv_co_readv =3D sd_co_readv, diff --git a/block/vmdk.c b/block/vmdk.c index 55581b03fe..bfb53204c6 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -2134,14 +2134,14 @@ static coroutine_fn int vmdk_co_flush(BlockDriverSt= ate *bs) return ret; } =20 -static int64_t vmdk_get_allocated_file_size(BlockDriverState *bs) +static int64_t vmdk_get_fs_allocated_size(BlockDriverState *bs) { int i; int64_t ret =3D 0; int64_t r; BDRVVmdkState *s =3D bs->opaque; =20 - ret =3D bdrv_get_allocated_file_size(bs->file->bs); + ret =3D bdrv_get_fs_allocated_size(bs->file->bs); if (ret < 0) { return ret; } @@ -2149,7 +2149,7 @@ static int64_t vmdk_get_allocated_file_size(BlockDriv= erState *bs) if (s->extents[i].file =3D=3D bs->file) { continue; } - r =3D bdrv_get_allocated_file_size(s->extents[i].file->bs); + r =3D bdrv_get_fs_allocated_size(s->extents[i].file->bs); if (r < 0) { return r; } @@ -2363,7 +2363,7 @@ static BlockDriver bdrv_vmdk =3D { .bdrv_create =3D vmdk_create, .bdrv_co_flush_to_disk =3D vmdk_co_flush, .bdrv_co_get_block_status =3D vmdk_co_get_block_status, - .bdrv_get_allocated_file_size =3D vmdk_get_allocated_file_size, + .bdrv_get_fs_allocated_size =3D vmdk_get_fs_allocated_size, .bdrv_has_zero_init =3D vmdk_has_zero_init, .bdrv_get_specific_info =3D vmdk_get_specific_info, .bdrv_refresh_limits =3D vmdk_refresh_limits, diff --git a/include/block/block.h b/include/block/block.h index c36b9ccae4..11ec88d18d 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -303,7 +303,7 @@ void bdrv_refresh_filename(BlockDriverState *bs); int bdrv_truncate(BdrvChild *child, int64_t offset, Error **errp); int64_t bdrv_nb_sectors(BlockDriverState *bs); int64_t bdrv_getlength(BlockDriverState *bs); -int64_t bdrv_get_allocated_file_size(BlockDriverState *bs); +int64_t bdrv_get_fs_allocated_size(BlockDriverState *bs); int64_t bdrv_get_format_allocated_size(BlockDriverState *bs); void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr); void bdrv_refresh_limits(BlockDriverState *bs, Error **errp); diff --git a/include/block/block_int.h b/include/block/block_int.h index e562fa7a5a..ab58746148 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -207,7 +207,7 @@ struct BlockDriver { =20 int64_t (*bdrv_getlength)(BlockDriverState *bs); bool has_variable_length; - int64_t (*bdrv_get_allocated_file_size)(BlockDriverState *bs); + int64_t (*bdrv_get_fs_allocated_size)(BlockDriverState *bs); int64_t (*bdrv_get_format_allocated_size)(BlockDriverState *bs); =20 int coroutine_fn (*bdrv_co_pwritev_compressed)(BlockDriverState *bs, --=20 2.11.1