From nobody Tue Apr 8 23:33:35 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=1598344801; cv=none; d=zohomail.com; s=zohoarc; b=XQNT4Cwe5VffdIJ50+HTQoYY/Tjk+Iss0a69PWYMeQLJwbo8wBYgnCiu2TC4jcVp9KSrWVHb1yJRmrZOcQxaZ0jnUUXNPPHDJpsXpxKf1oiMiFClZMhtM8EAOHE94xy8FkfDuP7FcQSZKJPWCr60xIiwfqPN3RnQGY4CUHQOro0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598344801; 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=FNYD49X3Ct2RUPxIuMOFDYlnr5roDCbIhLnCG0zpxHU=; b=ekEvEMU+Rgn6M+e0nihaD1lsqIwky2YYpuwaXczibV1OEmUP6mGz9yvQEr19HpLlp6jMMAxK8hUv36DGof8Y3OAuTZZYX9HvFikwWyAtu9LHm3VSElT3g3MW7DRZbAUxwqiA42J+SRPVxrV7j+qE0SLEhhglL0g5q/uvY1hZW+E= 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 1598344801211605.9218833103611; Tue, 25 Aug 2020 01:40:01 -0700 (PDT) Received: from localhost ([::1]:37628 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kAUUp-0006zK-Sw for importer@patchew.org; Tue, 25 Aug 2020 04:39:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59958) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kAUOd-0003H3-CP for qemu-devel@nongnu.org; Tue, 25 Aug 2020 04:33:35 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:52952 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 1kAUOZ-0000ZX-NR for qemu-devel@nongnu.org; Tue, 25 Aug 2020 04:33: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-157-qfHR5gBANeCpFWqH0CSfjQ-1; Tue, 25 Aug 2020 04:33:28 -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 B4EC710051C2; Tue, 25 Aug 2020 08:33:27 +0000 (UTC) Received: from localhost (ovpn-113-72.ams2.redhat.com [10.36.113.72]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 271FD5D9CA; Tue, 25 Aug 2020 08:33:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598344411; 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=FNYD49X3Ct2RUPxIuMOFDYlnr5roDCbIhLnCG0zpxHU=; b=iAtte9okEKJ8veojFSnk0xjJnsJtUhQSRWOj1J7dic7PXekvGd9cGhL0bwdCLNAh0lyfO5 mcsUA4+wBIlBT0O3aAGohnh1JPdZ+7k3Lvz9+QIsqFweNxVzaFuwLDnSp60VR1D9Z30jO8 i7hi92mX34O69wgw0ALbPVrGmEVsqo0= X-MC-Unique: qfHR5gBANeCpFWqH0CSfjQ-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PULL 06/34] qcow2: Add get_l2_entry() and set_l2_entry() Date: Tue, 25 Aug 2020 10:32:43 +0200 Message-Id: <20200825083311.1098442-7-mreitz@redhat.com> In-Reply-To: <20200825083311.1098442-1-mreitz@redhat.com> References: <20200825083311.1098442-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.001 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=207.211.31.81; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/25 01:36:47 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=-0.956, 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.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: Alberto Garcia The size of an L2 entry is 64 bits, but if we want to have subclusters we need extended L2 entries. This means that we have to access L2 tables and slices differently depending on whether an image has extended L2 entries or not. This patch replaces all l2_slice[] accesses with calls to get_l2_entry() and set_l2_entry(). Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Reviewed-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy Message-Id: <9586363531fec125ba1386e561762d3e4224e9fc.1594396418.git.berto@= igalia.com> Signed-off-by: Max Reitz --- block/qcow2.h | 12 ++++++++ block/qcow2-cluster.c | 63 ++++++++++++++++++++++-------------------- block/qcow2-refcount.c | 17 ++++++------ 3 files changed, 54 insertions(+), 38 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index 06475e0849..eecbadc4cb 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -510,6 +510,18 @@ typedef enum QCow2MetadataOverlap { =20 #define INV_OFFSET (-1ULL) =20 +static inline uint64_t get_l2_entry(BDRVQcow2State *s, uint64_t *l2_slice, + int idx) +{ + return be64_to_cpu(l2_slice[idx]); +} + +static inline void set_l2_entry(BDRVQcow2State *s, uint64_t *l2_slice, + int idx, uint64_t entry) +{ + l2_slice[idx] =3D cpu_to_be64(entry); +} + static inline bool has_data_file(BlockDriverState *bs) { BDRVQcow2State *s =3D bs->opaque; diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index b7b7b37062..5bd1e1feb8 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -383,12 +383,13 @@ fail: * cluster which may require a different handling) */ static int count_contiguous_clusters(BlockDriverState *bs, int nb_clusters, - int cluster_size, uint64_t *l2_slice, uint64_t stop_flags) + int cluster_size, uint64_t *l2_slice, int l2_index, uint64_t stop_= flags) { + BDRVQcow2State *s =3D bs->opaque; int i; QCow2ClusterType first_cluster_type; uint64_t mask =3D stop_flags | L2E_OFFSET_MASK | QCOW_OFLAG_COMPRESSED; - uint64_t first_entry =3D be64_to_cpu(l2_slice[0]); + uint64_t first_entry =3D get_l2_entry(s, l2_slice, l2_index); uint64_t offset =3D first_entry & mask; =20 first_cluster_type =3D qcow2_get_cluster_type(bs, first_entry); @@ -401,7 +402,7 @@ static int count_contiguous_clusters(BlockDriverState *= bs, int nb_clusters, first_cluster_type =3D=3D QCOW2_CLUSTER_ZERO_ALLOC); =20 for (i =3D 0; i < nb_clusters; i++) { - uint64_t l2_entry =3D be64_to_cpu(l2_slice[i]) & mask; + uint64_t l2_entry =3D get_l2_entry(s, l2_slice, l2_index + i) & ma= sk; if (offset + (uint64_t) i * cluster_size !=3D l2_entry) { break; } @@ -417,14 +418,16 @@ static int count_contiguous_clusters(BlockDriverState= *bs, int nb_clusters, static int count_contiguous_clusters_unallocated(BlockDriverState *bs, int nb_clusters, uint64_t *l2_slice, + int l2_index, QCow2ClusterType wanted_t= ype) { + BDRVQcow2State *s =3D bs->opaque; int i; =20 assert(wanted_type =3D=3D QCOW2_CLUSTER_ZERO_PLAIN || wanted_type =3D=3D QCOW2_CLUSTER_UNALLOCATED); for (i =3D 0; i < nb_clusters; i++) { - uint64_t entry =3D be64_to_cpu(l2_slice[i]); + uint64_t entry =3D get_l2_entry(s, l2_slice, l2_index + i); QCow2ClusterType type =3D qcow2_get_cluster_type(bs, entry); =20 if (type !=3D wanted_type) { @@ -575,7 +578,7 @@ int qcow2_get_host_offset(BlockDriverState *bs, uint64_= t offset, /* find the cluster offset for the given disk offset */ =20 l2_index =3D offset_to_l2_slice_index(s, offset); - l2_entry =3D be64_to_cpu(l2_slice[l2_index]); + l2_entry =3D get_l2_entry(s, l2_slice, l2_index); =20 nb_clusters =3D size_to_clusters(s, bytes_needed); /* bytes_needed <=3D *bytes + offset_in_cluster, both of which are uns= igned @@ -610,7 +613,7 @@ int qcow2_get_host_offset(BlockDriverState *bs, uint64_= t offset, case QCOW2_CLUSTER_UNALLOCATED: /* how many empty clusters ? */ c =3D count_contiguous_clusters_unallocated(bs, nb_clusters, - &l2_slice[l2_index], typ= e); + l2_slice, l2_index, type= ); break; case QCOW2_CLUSTER_ZERO_ALLOC: case QCOW2_CLUSTER_NORMAL: { @@ -618,7 +621,7 @@ int qcow2_get_host_offset(BlockDriverState *bs, uint64_= t offset, *host_offset =3D host_cluster_offset + offset_in_cluster; /* how many allocated clusters ? */ c =3D count_contiguous_clusters(bs, nb_clusters, s->cluster_size, - &l2_slice[l2_index], QCOW_OFLAG_ZERO= ); + l2_slice, l2_index, QCOW_OFLAG_ZERO); if (offset_into_cluster(s, host_cluster_offset)) { qcow2_signal_corruption(bs, true, -1, -1, "Cluster allocation offset %#" @@ -770,7 +773,7 @@ int qcow2_alloc_compressed_cluster_offset(BlockDriverSt= ate *bs, =20 /* Compression can't overwrite anything. Fail if the cluster was alrea= dy * allocated. */ - cluster_offset =3D be64_to_cpu(l2_slice[l2_index]); + cluster_offset =3D get_l2_entry(s, l2_slice, l2_index); if (cluster_offset & L2E_OFFSET_MASK) { qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); return -EIO; @@ -799,7 +802,7 @@ int qcow2_alloc_compressed_cluster_offset(BlockDriverSt= ate *bs, =20 BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE_COMPRESSED); qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice); - l2_slice[l2_index] =3D cpu_to_be64(cluster_offset); + set_l2_entry(s, l2_slice, l2_index, cluster_offset); qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); =20 *host_offset =3D cluster_offset & s->cluster_offset_mask; @@ -992,14 +995,14 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs,= QCowL2Meta *m) * cluster the second one has to do RMW (which is done above by * perform_cow()), update l2 table with its cluster pointer and fr= ee * old cluster. This is what this loop does */ - if (l2_slice[l2_index + i] !=3D 0) { - old_cluster[j++] =3D l2_slice[l2_index + i]; + if (get_l2_entry(s, l2_slice, l2_index + i) !=3D 0) { + old_cluster[j++] =3D get_l2_entry(s, l2_slice, l2_index + i); } =20 /* The offset must fit in the offset field of the L2 table entry */ assert((offset & L2E_OFFSET_MASK) =3D=3D offset); =20 - l2_slice[l2_index + i] =3D cpu_to_be64(offset | QCOW_OFLAG_COPIED); + set_l2_entry(s, l2_slice, l2_index + i, offset | QCOW_OFLAG_COPIED= ); } =20 =20 @@ -1013,8 +1016,7 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs,= QCowL2Meta *m) */ if (!m->keep_old_clusters && j !=3D 0) { for (i =3D 0; i < j; i++) { - qcow2_free_any_clusters(bs, be64_to_cpu(old_cluster[i]), 1, - QCOW2_DISCARD_NEVER); + qcow2_free_any_clusters(bs, old_cluster[i], 1, QCOW2_DISCARD_N= EVER); } } =20 @@ -1077,7 +1079,7 @@ static void calculate_l2_meta(BlockDriverState *bs, if (keep_old) { int i; for (i =3D 0; i < nb_clusters; i++) { - l2_entry =3D be64_to_cpu(l2_slice[l2_index + i]); + l2_entry =3D get_l2_entry(s, l2_slice, l2_index + i); if (qcow2_get_cluster_type(bs, l2_entry) !=3D QCOW2_CLUSTER_NO= RMAL) { break; } @@ -1088,7 +1090,7 @@ static void calculate_l2_meta(BlockDriverState *bs, } =20 /* Get the L2 entry of the first cluster */ - l2_entry =3D be64_to_cpu(l2_slice[l2_index]); + l2_entry =3D get_l2_entry(s, l2_slice, l2_index); type =3D qcow2_get_cluster_type(bs, l2_entry); =20 if (type =3D=3D QCOW2_CLUSTER_NORMAL && keep_old) { @@ -1098,7 +1100,7 @@ static void calculate_l2_meta(BlockDriverState *bs, } =20 /* Get the L2 entry of the last cluster */ - l2_entry =3D be64_to_cpu(l2_slice[l2_index + nb_clusters - 1]); + l2_entry =3D get_l2_entry(s, l2_slice, l2_index + nb_clusters - 1); type =3D qcow2_get_cluster_type(bs, l2_entry); =20 if (type =3D=3D QCOW2_CLUSTER_NORMAL && keep_old) { @@ -1171,12 +1173,12 @@ static int count_single_write_clusters(BlockDriverS= tate *bs, int nb_clusters, bool new_alloc) { BDRVQcow2State *s =3D bs->opaque; - uint64_t l2_entry =3D be64_to_cpu(l2_slice[l2_index]); + uint64_t l2_entry =3D get_l2_entry(s, l2_slice, l2_index); uint64_t expected_offset =3D l2_entry & L2E_OFFSET_MASK; int i; =20 for (i =3D 0; i < nb_clusters; i++) { - l2_entry =3D be64_to_cpu(l2_slice[l2_index + i]); + l2_entry =3D get_l2_entry(s, l2_slice, l2_index + i); if (cluster_needs_new_alloc(bs, l2_entry) !=3D new_alloc) { break; } @@ -1312,7 +1314,7 @@ static int handle_copied(BlockDriverState *bs, uint64= _t guest_offset, return ret; } =20 - l2_entry =3D be64_to_cpu(l2_slice[l2_index]); + l2_entry =3D get_l2_entry(s, l2_slice, l2_index); cluster_offset =3D l2_entry & L2E_OFFSET_MASK; =20 if (!cluster_needs_new_alloc(bs, l2_entry)) { @@ -1689,7 +1691,7 @@ static int discard_in_l2_slice(BlockDriverState *bs, = uint64_t offset, for (i =3D 0; i < nb_clusters; i++) { uint64_t old_l2_entry; =20 - old_l2_entry =3D be64_to_cpu(l2_slice[l2_index + i]); + old_l2_entry =3D get_l2_entry(s, l2_slice, l2_index + i); =20 /* * If full_discard is false, make sure that a discarded area reads= back @@ -1729,9 +1731,9 @@ static int discard_in_l2_slice(BlockDriverState *bs, = uint64_t offset, /* First remove L2 entries */ qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice); if (!full_discard && s->qcow_version >=3D 3) { - l2_slice[l2_index + i] =3D cpu_to_be64(QCOW_OFLAG_ZERO); + set_l2_entry(s, l2_slice, l2_index + i, QCOW_OFLAG_ZERO); } else { - l2_slice[l2_index + i] =3D cpu_to_be64(0); + set_l2_entry(s, l2_slice, l2_index + i, 0); } =20 /* Then decrease the refcount */ @@ -1811,7 +1813,7 @@ static int zero_in_l2_slice(BlockDriverState *bs, uin= t64_t offset, uint64_t old_offset; QCow2ClusterType cluster_type; =20 - old_offset =3D be64_to_cpu(l2_slice[l2_index + i]); + old_offset =3D get_l2_entry(s, l2_slice, l2_index + i); =20 /* * Minimize L2 changes if the cluster already reads back as @@ -1825,10 +1827,11 @@ static int zero_in_l2_slice(BlockDriverState *bs, u= int64_t offset, =20 qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice); if (cluster_type =3D=3D QCOW2_CLUSTER_COMPRESSED || unmap) { - l2_slice[l2_index + i] =3D cpu_to_be64(QCOW_OFLAG_ZERO); + set_l2_entry(s, l2_slice, l2_index + i, QCOW_OFLAG_ZERO); qcow2_free_any_clusters(bs, old_offset, 1, QCOW2_DISCARD_REQUE= ST); } else { - l2_slice[l2_index + i] |=3D cpu_to_be64(QCOW_OFLAG_ZERO); + uint64_t entry =3D get_l2_entry(s, l2_slice, l2_index + i); + set_l2_entry(s, l2_slice, l2_index + i, entry | QCOW_OFLAG_ZER= O); } } =20 @@ -1973,7 +1976,7 @@ static int expand_zero_clusters_in_l1(BlockDriverStat= e *bs, uint64_t *l1_table, } =20 for (j =3D 0; j < s->l2_slice_size; j++) { - uint64_t l2_entry =3D be64_to_cpu(l2_slice[j]); + uint64_t l2_entry =3D get_l2_entry(s, l2_slice, j); int64_t offset =3D l2_entry & L2E_OFFSET_MASK; QCow2ClusterType cluster_type =3D qcow2_get_cluster_type(bs, l2_entry); @@ -1987,7 +1990,7 @@ static int expand_zero_clusters_in_l1(BlockDriverStat= e *bs, uint64_t *l1_table, if (!bs->backing) { /* not backed; therefore we can simply deallocate = the * cluster */ - l2_slice[j] =3D 0; + set_l2_entry(s, l2_slice, j, 0); l2_dirty =3D true; continue; } @@ -2053,9 +2056,9 @@ static int expand_zero_clusters_in_l1(BlockDriverStat= e *bs, uint64_t *l1_table, } =20 if (l2_refcount =3D=3D 1) { - l2_slice[j] =3D cpu_to_be64(offset | QCOW_OFLAG_COPIED= ); + set_l2_entry(s, l2_slice, j, offset | QCOW_OFLAG_COPIE= D); } else { - l2_slice[j] =3D cpu_to_be64(offset); + set_l2_entry(s, l2_slice, j, offset); } l2_dirty =3D true; } diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 0457a6060d..04546838e8 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1310,7 +1310,7 @@ int qcow2_update_snapshot_refcount(BlockDriverState *= bs, uint64_t cluster_index; uint64_t offset; =20 - entry =3D be64_to_cpu(l2_slice[j]); + entry =3D get_l2_entry(s, l2_slice, j); old_entry =3D entry; entry &=3D ~QCOW_OFLAG_COPIED; offset =3D entry & L2E_OFFSET_MASK; @@ -1384,7 +1384,7 @@ int qcow2_update_snapshot_refcount(BlockDriverState *= bs, qcow2_cache_set_dependency(bs, s->l2_table_cac= he, s->refcount_block_c= ache); } - l2_slice[j] =3D cpu_to_be64(entry); + set_l2_entry(s, l2_slice, j, entry); qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice); } @@ -1617,7 +1617,7 @@ static int check_refcounts_l2(BlockDriverState *bs, B= drvCheckResult *res, =20 /* Do the actual checks */ for(i =3D 0; i < s->l2_size; i++) { - l2_entry =3D be64_to_cpu(l2_table[i]); + l2_entry =3D get_l2_entry(s, l2_table, i); =20 switch (qcow2_get_cluster_type(bs, l2_entry)) { case QCOW2_CLUSTER_COMPRESSED: @@ -1686,7 +1686,7 @@ static int check_refcounts_l2(BlockDriverState *bs, B= drvCheckResult *res, QCOW2_OL_INACTIVE_L2; =20 l2_entry =3D QCOW_OFLAG_ZERO; - l2_table[i] =3D cpu_to_be64(l2_entry); + set_l2_entry(s, l2_table, i, l2_entry); ret =3D qcow2_pre_write_overlap_check(bs, ign, l2e_offset, sizeof(uint64_t), false); if (ret < 0) { @@ -1914,7 +1914,7 @@ static int check_oflag_copied(BlockDriverState *bs, B= drvCheckResult *res, } =20 for (j =3D 0; j < s->l2_size; j++) { - uint64_t l2_entry =3D be64_to_cpu(l2_table[j]); + uint64_t l2_entry =3D get_l2_entry(s, l2_table, j); uint64_t data_offset =3D l2_entry & L2E_OFFSET_MASK; QCow2ClusterType cluster_type =3D qcow2_get_cluster_type(bs, l= 2_entry); =20 @@ -1937,9 +1937,10 @@ static int check_oflag_copied(BlockDriverState *bs, = BdrvCheckResult *res, "l2_entry=3D%" PRIx64 " refcount=3D%" PRIu64 "= \n", repair ? "Repairing" : "ERROR", l2_entry, refc= ount); if (repair) { - l2_table[j] =3D cpu_to_be64(refcount =3D=3D 1 - ? l2_entry | QCOW_OFLAG_COPIED - : l2_entry & ~QCOW_OFLAG_COPIED); + set_l2_entry(s, l2_table, j, + refcount =3D=3D 1 ? + l2_entry | QCOW_OFLAG_COPIED : + l2_entry & ~QCOW_OFLAG_COPIED); l2_dirty++; } } --=20 2.26.2