From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34223) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vsb7O-0000vT-5o for qemu-devel@nongnu.org; Mon, 16 Dec 2013 11:34:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vsb7A-00010S-M5 for qemu-devel@nongnu.org; Mon, 16 Dec 2013 11:34:06 -0500 Received: from mail-ea0-x22d.google.com ([2a00:1450:4013:c01::22d]:64644) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vsb7A-00010F-Fe for qemu-devel@nongnu.org; Mon, 16 Dec 2013 11:33:52 -0500 Received: by mail-ea0-f173.google.com with SMTP id o10so2364922eaj.4 for ; Mon, 16 Dec 2013 08:33:51 -0800 (PST) Date: Mon, 16 Dec 2013 17:33:48 +0100 From: Stefan Hajnoczi Message-ID: <20131216163348.GA23949@stefanha-thinkpad.redhat.com> References: <1386241288-18180-1-git-send-email-bharata@linux.vnet.ibm.com> <1386241288-18180-2-git-send-email-bharata@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1386241288-18180-2-git-send-email-bharata@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [RFC PATCH v1 1/3] gluster: Convert aio routines into coroutines List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bharata B Rao Cc: kwolf@redhat.com, jcody@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com On Thu, Dec 05, 2013 at 04:31:26PM +0530, Bharata B Rao wrote: > -static void qemu_gluster_complete_aio(GlusterAIOCB *acb, BDRVGlusterState *s) > +static void qemu_gluster_complete_aio(void *opaque) > { > - int ret; > - bool *finished = acb->finished; > - BlockDriverCompletionFunc *cb = acb->common.cb; > - void *opaque = acb->common.opaque; > - > - if (!acb->ret || acb->ret == acb->size) { > - ret = 0; /* Success */ > - } else if (acb->ret < 0) { > - ret = acb->ret; /* Read/Write failed */ > - } else { > - ret = -EIO; /* Partial read/write - fail it */ > - } [...] > + if (acb->ret == acb->size) { > + acb->ret = 0; > + } else if (acb->ret > 0) { > + acb->ret = -EIO; /* Partial read/write - fail it */ > } This change is a little ugly since qemu_gluster_complete_aio() now modifies acb->ret in-place. I suggest moving the if statements down into gluster_finish_aiocb() where we first receive the request's return value. Then qemu_gluster_complete_aio() simply enters the coroutine and doesn't modify acb->ret. > static const AIOCBInfo gluster_aiocb_info = { > .aiocb_size = sizeof(GlusterAIOCB), > - .cancel = qemu_gluster_aio_cancel, > }; At this point using BlockDriverAIOCB and qemu_aio_get() becomes questionable. We no longer implement .cancel() because we don't need the aio interface. It would be cleaner to manage our own request struct and allocate using g_slice_new()/g_slice_free(). That way we don't "reuse" BlockDriverAIOCB without fully implementing the AIOCBInfo interface. Stefan