From nobody Thu Dec 18 17:56:32 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1594030597; cv=none; d=zohomail.com; s=zohoarc; b=RjOYd1EwDI1OppPlmW661UbeJzZ9n/KCqZwSmrtLp6wW4V8Iw74jFBVQAtwKIvlzLjcXdZnYsgwtP11wMRJdFiVUGMA7EDftWX3CniBuVVa6zQN4K21hh0qHfSbVPAjzZBSjrxotsRDBPu7/EVhcCI2hdf2HhhWpPwl+mA7L/XA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594030597; h=Content-Type: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=dBcMJ46Jn3ReNscVGlgV/9oO1tSfI2BymR9OJQzxv04=; b=knhObRR4r+AWCKen7p+D0c2zUjOKhdXmLniCdnatsdC3t6Ic+XFOA4IMGEGZ1eDBkeVntmncTpMvB+fjExE8p1crHRE3n6PJKmLfs6qRI6OOdQN987VVtBF47lKP2WsbzsNOKoqy+HEfLN9NhtZrfs0Xv975KMn30noM7hKONYM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594030597560586.2935342334171; Mon, 6 Jul 2020 03:16:37 -0700 (PDT) Received: from localhost ([::1]:33772 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jsOAu-00082C-7D for importer@patchew.org; Mon, 06 Jul 2020 06:16:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53950) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jsO0G-0004Cv-9C for qemu-devel@nongnu.org; Mon, 06 Jul 2020 06:05:36 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:22906 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jsO0D-0004BC-IT for qemu-devel@nongnu.org; Mon, 06 Jul 2020 06:05:34 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-182-Ikn9zxpsPau0sKu8jMvKwg-1; Mon, 06 Jul 2020 06:05:30 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 44EBFA0BD7; Mon, 6 Jul 2020 10:05:29 +0000 (UTC) Received: from localhost (ovpn-112-176.ams2.redhat.com [10.36.112.176]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E022A5DD61; Mon, 6 Jul 2020 10:05:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594029932; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dBcMJ46Jn3ReNscVGlgV/9oO1tSfI2BymR9OJQzxv04=; b=CQzgYuH7tM28x1WZN4tHRtlUD0PnkchBftuH4f3pdf20SS9ku5MLQnJA+RxRuCy9Eh9Fm1 2IdzbnKLtEq5IgGuxrCKWR4zd4j9L3dWWEmW7lwxiV9itkKUiIJOlLj5Xdjor+aWGJjHDK go/P0zYJrRqYoB7sDt3+zpoK/MyZZtk= X-MC-Unique: Ikn9zxpsPau0sKu8jMvKwg-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 23/31] block: inline bdrv_unallocated_blocks_are_zero() Date: Mon, 6 Jul 2020 12:04:24 +0200 Message-Id: <20200706100432.2301919-24-mreitz@redhat.com> In-Reply-To: <20200706100432.2301919-1-mreitz@redhat.com> References: <20200706100432.2301919-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=205.139.110.61; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/06 01:59:39 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy The function has only one user: bdrv_co_block_status(). Inline it to simplify reviewing of the following patches, which will finally drop unallocated_blocks_are_zero field too. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake Message-Id: <20200528094405.145708-3-vsementsov@virtuozzo.com> Signed-off-by: Max Reitz --- include/block/block.h | 1 - block.c | 15 --------------- block/io.c | 11 ++++++++--- 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/include/block/block.h b/include/block/block.h index a2414a58c5..e7934e07f2 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -489,7 +489,6 @@ int bdrv_pdiscard(BdrvChild *child, int64_t offset, int= 64_t bytes); int bdrv_co_pdiscard(BdrvChild *child, int64_t offset, int64_t bytes); int bdrv_has_zero_init_1(BlockDriverState *bs); int bdrv_has_zero_init(BlockDriverState *bs); -bool bdrv_unallocated_blocks_are_zero(BlockDriverState *bs); bool bdrv_can_write_zeroes_with_unmap(BlockDriverState *bs); int bdrv_block_status(BlockDriverState *bs, int64_t offset, int64_t bytes, int64_t *pnum, int64_t *map, diff --git a/block.c b/block.c index 144f52e413..62e40db2f1 100644 --- a/block.c +++ b/block.c @@ -5408,21 +5408,6 @@ int bdrv_has_zero_init(BlockDriverState *bs) return 0; } =20 -bool bdrv_unallocated_blocks_are_zero(BlockDriverState *bs) -{ - BlockDriverInfo bdi; - - if (bs->backing) { - return false; - } - - if (bdrv_get_info(bs, &bdi) =3D=3D 0) { - return bdi.unallocated_blocks_are_zero; - } - - return false; -} - bool bdrv_can_write_zeroes_with_unmap(BlockDriverState *bs) { if (!(bs->open_flags & BDRV_O_UNMAP)) { diff --git a/block/io.c b/block/io.c index df8f2a98d4..36d4d562a6 100644 --- a/block/io.c +++ b/block/io.c @@ -2407,15 +2407,20 @@ static int coroutine_fn bdrv_co_block_status(BlockD= riverState *bs, if (ret & (BDRV_BLOCK_DATA | BDRV_BLOCK_ZERO)) { ret |=3D BDRV_BLOCK_ALLOCATED; } else if (want_zero) { - if (bdrv_unallocated_blocks_are_zero(bs)) { - ret |=3D BDRV_BLOCK_ZERO; - } else if (bs->backing) { + if (bs->backing) { BlockDriverState *bs2 =3D bs->backing->bs; int64_t size2 =3D bdrv_getlength(bs2); =20 if (size2 >=3D 0 && offset >=3D size2) { ret |=3D BDRV_BLOCK_ZERO; } + } else { + BlockDriverInfo bdi; + int ret2 =3D bdrv_get_info(bs, &bdi); + + if (ret2 =3D=3D 0 && bdi.unallocated_blocks_are_zero) { + ret |=3D BDRV_BLOCK_ZERO; + } } } =20 --=20 2.26.2