From: Stefan Hajnoczi <stefanha@gmail.com>
To: Bharata B Rao <bharata@linux.vnet.ibm.com>
Cc: kwolf@redhat.com, jcody@redhat.com, qemu-devel@nongnu.org,
stefanha@redhat.com
Subject: Re: [Qemu-devel] [RFC PATCH v1 1/3] gluster: Convert aio routines into coroutines
Date: Mon, 16 Dec 2013 17:33:48 +0100 [thread overview]
Message-ID: <20131216163348.GA23949@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <1386241288-18180-2-git-send-email-bharata@linux.vnet.ibm.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
next prev parent reply other threads:[~2013-12-16 16:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-05 11:01 [Qemu-devel] [RFC PATCH v1 0/3] gluster: conversion to coroutines and supporting write_zeroes Bharata B Rao
2013-12-05 11:01 ` [Qemu-devel] [RFC PATCH v1 1/3] gluster: Convert aio routines into coroutines Bharata B Rao
2013-12-16 16:33 ` Stefan Hajnoczi [this message]
2013-12-05 11:01 ` [Qemu-devel] [RFC PATCH v1 2/3] gluster: Implement .bdrv_co_write_zeroes for gluster Bharata B Rao
2013-12-05 11:01 ` [Qemu-devel] [RFC PATCH v1 3/3] gluster: Add support for creating zero-filled image Bharata B Rao
2013-12-16 16:39 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131216163348.GA23949@stefanha-thinkpad.redhat.com \
--to=stefanha@gmail.com \
--cc=bharata@linux.vnet.ibm.com \
--cc=jcody@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).