From patchwork Thu Feb 27 18:34:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 11409489 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A365C92A for ; Thu, 27 Feb 2020 18:35:43 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2F186246B4 for ; Thu, 27 Feb 2020 18:35:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="Fmwd+Wze" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2F186246B4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=igalia.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:36482 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7O0b-0004Ny-01 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 27 Feb 2020 13:35:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36234) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7Nzo-0003DH-8z for qemu-devel@nongnu.org; Thu, 27 Feb 2020 13:34:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7Nzm-0000gn-6z for qemu-devel@nongnu.org; Thu, 27 Feb 2020 13:34:51 -0500 Received: from fanzine.igalia.com ([178.60.130.6]:33974) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j7Nzl-0000MM-Oq; Thu, 27 Feb 2020 13:34:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:Cc:To:From; bh=aLV4Gc+Hy8ZDXp+dVGut38PRbNYaDayZT3HzNdMMlxU=; b=Fmwd+WzeslbG0gBAtUTH2dCyefcWjSNVVAzVi3+a27qlHWyT+T5iYaUA9U1ZOXOZcZ6COSHRTxF4kQPx9w0FlIpWIsZagCi4jCR72hLLnX/bg05zSrOHNlhtERMUXEyIOqAxYG9OveaIcERC2qZs5c05ypHey2Le11YiMHj0aW05BNYXVgpI7G8zfLlLQmbuD/tulYr0LjlGIqhzbiHBmTc4DotCPJz1+H2rB7qVg6Ht8B5eIEn/5Vu0ofwh4hr2FJk0oW5iDzqIZeIeLM3AOehJn6e8iwLyxt2WCstb/davTsxv35xXSuJWvDwLAm9alryRtuCjzm1DQ3gOPkh4mQ==; Received: from [192.168.12.213] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1j7NzT-0000H0-Ap; Thu, 27 Feb 2020 19:34:31 +0100 Received: from berto by perseus.local with local (Exim 4.92) (envelope-from ) id 1j7NzS-0000VS-Na; Thu, 27 Feb 2020 19:34:30 +0100 From: Alberto Garcia To: qemu-devel@nongnu.org Subject: [PATCH 0/2] Convert qcow2_get_cluster_offset() into qcow2_get_host_offset() Date: Thu, 27 Feb 2020 19:34:24 +0100 Message-Id: X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 178.60.130.6 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 , Alberto Garcia , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Hi, this is something I did while working on the subcluster series but it's independent from it so I thought to send it already. In short: qcow2_get_cluster_offset() returns a host cluster offset but none of the callers actually wants the offset of the cluster, they want the host offset into the cluster. There's a pre-existing exception with compressed clusters. In this case the returned value was overloaded to contain a cluster offset or a compressed cluster descriptor, depending on the cluster type. This is kind of ugly, and we could make it more explicit using a union or something like that but I don't think it's worth the effort here, so I just documented it. Berto Alberto Garcia (2): qcow2: Make Qcow2AioTask store the full host offset qcow2: Convert qcow2_get_cluster_offset() into qcow2_get_host_offset() block/qcow2.h | 4 +-- block/qcow2-cluster.c | 38 ++++++++++++---------- block/qcow2.c | 74 ++++++++++++++++++------------------------- 3 files changed, 55 insertions(+), 61 deletions(-)