From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NXCjO-0006Qm-3a for qemu-devel@nongnu.org; Tue, 19 Jan 2010 06:58:46 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NXCjJ-0006QK-IZ for qemu-devel@nongnu.org; Tue, 19 Jan 2010 06:58:45 -0500 Received: from [199.232.76.173] (port=33400 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NXCjJ-0006QH-CE for qemu-devel@nongnu.org; Tue, 19 Jan 2010 06:58:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52490) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NXCjI-0008M1-Uw for qemu-devel@nongnu.org; Tue, 19 Jan 2010 06:58:41 -0500 Message-ID: <4B559E2F.9000309@redhat.com> Date: Tue, 19 Jan 2010 12:57:35 +0100 From: Kevin Wolf MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 04/10] qcow2: Return 0/-errno in qcow2_alloc_cluster_offset References: <1263816696-24122-1-git-send-email-kwolf@redhat.com> <1263816696-24122-5-git-send-email-kwolf@redhat.com> <20100119113547.GA14641@lst.de> In-Reply-To: <20100119113547.GA14641@lst.de> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Christoph Hellwig Cc: qemu-devel@nongnu.org Am 19.01.2010 12:35, schrieb Christoph Hellwig: >> @@ -715,6 +721,7 @@ uint64_t qcow2_alloc_cluster_offset(BlockDriverState *bs, >> >> cluster_offset &= ~QCOW_OFLAG_COPIED; >> m->nb_clusters = 0; >> + m->depends_on = NULL; > > What does this have to do with the rest? It's needed to be able to distinguish between the case where the clusters are already allocated (0/NULL) and the case where the request depends on another one (0/non-NULL). This check previously used the return value (cluster_offset for success, 0 for failure) and I didn't want to overload m->cluster_offset with such a meaning. This is the change in the caller: /* Need to wait for another request? If so, we are done for now. */ - if (!acb->cluster_offset && acb->l2meta.depends_on != NULL) { + if (acb->l2meta.nb_clusters == 0 && acb->l2meta.depends_on != NULL) { The alternative would have been to keep using the return value and hijack some errno value. This would possibly conflict with real read/write errors though, so I decided to leave the return value alone. Kevin