All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josh Durgin <josh.durgin@inktank.com>
To: Sylvain Munaut <s.munaut@whatever-company.com>
Cc: ceph-devel@vger.kernel.org
Subject: Re: RBD Async request: When / How are the call back called ?
Date: Wed, 29 Aug 2012 09:48:06 -0700	[thread overview]
Message-ID: <503E47C6.2040200@inktank.com> (raw)
In-Reply-To: <CAF6-1L5JfGW-cw45gTbOX7+igu9WnG7=fp75aoTg1HL4AtsF-Q@mail.gmail.com>

On 08/29/2012 07:57 AM, Sylvain Munaut wrote:
> Hi,
>
>
> It might be obvious for people knowing the API but somehow I can't
> figure it out:
>
> How and when will the call back specified in a rbd_completion_t be called ?
>
> Imagine I do a rbd_aio_write and then do while (1); ... I don't see
> how the library could call my callback unless there is threads
> involved (and then my cb would be called in another thread context
> which is not great ...)

It's called from another thread. There are several threads for
messaging started when you connect with a rados_cluster_t. When a
request is complete, it's put into a queue inside librados, and a
'finisher' thread reads from the queue and calls callbacks as
appropriate.

In the case of rbd, a single rbd_aio_write may translate to many rados
requests, but when the last is complete, the callback you provided is
called by the librados finisher thread. At this point the data is on
disk on all replicas.

> (Of course the 'while (1)' here is just a stub, in reality it's a call
> to a library beyond my control)
>
>
> My problem here is that I need to integrate inside the main loop of
> another software and I can't block, but I still need to be able to
> 'notify' when the requests are over. I can ask the scheduler of that
> main loop to call me on some even on a file descriptor (but I don't
> see any fd here), or to call me periodically (but I don't see any call
> to test for completion without waiting for it).

The way this is done in the qemu block driver (since qemu I/O
must be completed from the original qemu thread context) is to have a
pipe that the qemu thread reads from. When an rbd I/O completes, the
callback (called by a librados thread) tells the qemu thread that it's
done via the pipe. Here's the original discussion about this:

http://lists.gnu.org/archive/html/qemu-devel/2010-10/msg00420.html

and the code:

http://git.qemu.org/?p=qemu.git;a=blob;f=block/rbd.c;h=5a0f79fc8f38e90c5c635a86b60db4c0f2f20c2f;hb=HEAD

> Cheers,
>
>       Sylvain


  parent reply	other threads:[~2012-08-29 16:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-29 14:57 RBD Async request: When / How are the call back called ? Sylvain Munaut
2012-08-29 16:47 ` Mike Ryan
2012-08-29 16:48 ` Josh Durgin [this message]
2012-08-30 12:16   ` Sylvain Munaut
2012-08-30 14:52     ` Mike Ryan
2012-08-30 15:39       ` Josh Durgin

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=503E47C6.2040200@inktank.com \
    --to=josh.durgin@inktank.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=s.munaut@whatever-company.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.