From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MldlZ-0004Av-IC for qemu-devel@nongnu.org; Thu, 10 Sep 2009 03:08:25 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MldlV-0004AI-5d for qemu-devel@nongnu.org; Thu, 10 Sep 2009 03:08:25 -0400 Received: from [199.232.76.173] (port=42179 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MldlV-0004AF-1x for qemu-devel@nongnu.org; Thu, 10 Sep 2009 03:08:21 -0400 Received: from mx20.gnu.org ([199.232.41.8]:6101) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MldlU-0003wB-Go for qemu-devel@nongnu.org; Thu, 10 Sep 2009 03:08:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MldlT-0003nF-Ot for qemu-devel@nongnu.org; Thu, 10 Sep 2009 03:08:20 -0400 Message-ID: <4AA8A59E.9090206@redhat.com> Date: Thu, 10 Sep 2009 09:07:10 +0200 From: Kevin Wolf MIME-Version: 1.0 References: <1252511618-19497-1-git-send-email-kwolf@redhat.com> <1252511618-19497-2-git-send-email-kwolf@redhat.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH v3 1/2] Add bdrv_aio_multiwrite List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Juan Quintela Cc: qemu-devel@nongnu.org Am 10.09.2009 01:08, schrieb Juan Quintela: > Kevin Wolf wrote: > > Hi again > > >> + QEMUIOVector *qiov = qemu_mallocz(sizeof(*qiov)); >> + qemu_iovec_init(qiov, >> + reqs[outidx].qiov->niov + reqs[i].qiov->niov + 1); >> + >> + // Add the first request to the merged one. If the requests are >> + // overlapping, drop the last sectors of the first request. >> + size = (reqs[i].sector - reqs[outidx].sector) << 9; >> + qemu_iovec_concat(qiov, reqs[outidx].qiov, size); >> + >> + // We might need to add some zeros between the two requests >> + if (reqs[i].sector > oldreq_last) { >> + size_t zero_bytes = (reqs[i].sector - oldreq_last) << 9; >> + uint8_t *buf = qemu_blockalign(bs, zero_bytes); >> + memset(buf, 0, zero_bytes); >> + qemu_iovec_add(qiov, buf, zero_bytes); >> + mcb->callbacks[i].free_buf = buf; >> + } >> + >> + // Add the second request >> + qemu_iovec_concat(qiov, reqs[i].qiov, reqs[i].qiov->size); >> + >> + reqs[outidx].nb_sectors += reqs[i].nb_sectors; >> + reqs[outidx].qiov = qiov; > > What frees reqs[outidx].qiov previous value, or new one for that matter? Your decision where to stop quoting the code is kind of funny. The very next line is: mcb->callbacks[i].free_qiov = reqs[outidx].qiov; This saves each newly allocated qiov. It is later freed in multiwrite_user_cb. To free the original value of qiov is the task of the caller. > I can't see where it is done. As far as I can see, we are losing both > the ones that we are overwritten and the ones for the request that got merged. Hope you see them now. :-) Kevin