All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Richard W.M. Jones" <rjones@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	"Shergill, Gurinder" <gurinder.shergill@hp.com>,
	"Vinod, Chegu" <chegu_vinod@hp.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 17/22] ssh: use BlockDriverState's AioContext
Date: Thu, 1 May 2014 16:03:13 +0100	[thread overview]
Message-ID: <20140501150313.GT1302@redhat.com> (raw)
In-Reply-To: <1398956086-20171-18-git-send-email-stefanha@redhat.com>

On Thu, May 01, 2014 at 04:54:41PM +0200, Stefan Hajnoczi wrote:
> Drop the assumption that we're using the main AioContext.  Use
> bdrv_get_aio_context() to register fd handlers in the right AioContext
> for this BlockDriverState.
> 
> The .bdrv_detach_aio_context() and .bdrv_attach_aio_context() interfaces
> are not needed since no fd handlers, timers, or BHs stay registered when
> requests have been drained.
> 
> For now this doesn't make much difference but will allow ssh to work in
> IOThread instances in the future.
> 
> Cc: Richard W.M. Jones <rjones@redhat.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  block/ssh.c | 36 +++++++++++++++++++-----------------
>  1 file changed, 19 insertions(+), 17 deletions(-)
> 
> diff --git a/block/ssh.c b/block/ssh.c
> index aa63c9d..3f4a9fb 100644
> --- a/block/ssh.c
> +++ b/block/ssh.c
> @@ -742,7 +742,7 @@ static void restart_coroutine(void *opaque)
>      qemu_coroutine_enter(co, NULL);
>  }
>  
> -static coroutine_fn void set_fd_handler(BDRVSSHState *s)
> +static coroutine_fn void set_fd_handler(BDRVSSHState *s, BlockDriverState *bs)
>  {
>      int r;
>      IOHandler *rd_handler = NULL, *wr_handler = NULL;
> @@ -760,24 +760,26 @@ static coroutine_fn void set_fd_handler(BDRVSSHState *s)
>      DPRINTF("s->sock=%d rd_handler=%p wr_handler=%p", s->sock,
>              rd_handler, wr_handler);
>  
> -    qemu_aio_set_fd_handler(s->sock, rd_handler, wr_handler, co);
> +    aio_set_fd_handler(bdrv_get_aio_context(bs), s->sock,
> +                       rd_handler, wr_handler, co);
>  }
>  
> -static coroutine_fn void clear_fd_handler(BDRVSSHState *s)
> +static coroutine_fn void clear_fd_handler(BDRVSSHState *s,
> +                                          BlockDriverState *bs)
>  {
>      DPRINTF("s->sock=%d", s->sock);
> -    qemu_aio_set_fd_handler(s->sock, NULL, NULL, NULL);
> +    aio_set_fd_handler(bdrv_get_aio_context(bs), s->sock, NULL, NULL, NULL);
>  }
>  
>  /* A non-blocking call returned EAGAIN, so yield, ensuring the
>   * handlers are set up so that we'll be rescheduled when there is an
>   * interesting event on the socket.
>   */
> -static coroutine_fn void co_yield(BDRVSSHState *s)
> +static coroutine_fn void co_yield(BDRVSSHState *s, BlockDriverState *bs)
>  {
> -    set_fd_handler(s);
> +    set_fd_handler(s, bs);
>      qemu_coroutine_yield();
> -    clear_fd_handler(s);
> +    clear_fd_handler(s, bs);
>  }
>  
>  /* SFTP has a function `libssh2_sftp_seek64' which seeks to a position
> @@ -807,7 +809,7 @@ static void ssh_seek(BDRVSSHState *s, int64_t offset, int flags)
>      }
>  }
>  
> -static coroutine_fn int ssh_read(BDRVSSHState *s,
> +static coroutine_fn int ssh_read(BDRVSSHState *s, BlockDriverState *bs,
>                                   int64_t offset, size_t size,
>                                   QEMUIOVector *qiov)
>  {
> @@ -840,7 +842,7 @@ static coroutine_fn int ssh_read(BDRVSSHState *s,
>          DPRINTF("sftp_read returned %zd", r);
>  
>          if (r == LIBSSH2_ERROR_EAGAIN || r == LIBSSH2_ERROR_TIMEOUT) {
> -            co_yield(s);
> +            co_yield(s, bs);
>              goto again;
>          }
>          if (r < 0) {
> @@ -875,14 +877,14 @@ static coroutine_fn int ssh_co_readv(BlockDriverState *bs,
>      int ret;
>  
>      qemu_co_mutex_lock(&s->lock);
> -    ret = ssh_read(s, sector_num * BDRV_SECTOR_SIZE,
> +    ret = ssh_read(s, bs, sector_num * BDRV_SECTOR_SIZE,
>                     nb_sectors * BDRV_SECTOR_SIZE, qiov);
>      qemu_co_mutex_unlock(&s->lock);
>  
>      return ret;
>  }
>  
> -static int ssh_write(BDRVSSHState *s,
> +static int ssh_write(BDRVSSHState *s, BlockDriverState *bs,
>                       int64_t offset, size_t size,
>                       QEMUIOVector *qiov)
>  {
> @@ -910,7 +912,7 @@ static int ssh_write(BDRVSSHState *s,
>          DPRINTF("sftp_write returned %zd", r);
>  
>          if (r == LIBSSH2_ERROR_EAGAIN || r == LIBSSH2_ERROR_TIMEOUT) {
> -            co_yield(s);
> +            co_yield(s, bs);
>              goto again;
>          }
>          if (r < 0) {
> @@ -929,7 +931,7 @@ static int ssh_write(BDRVSSHState *s,
>           */
>          if (r == 0) {
>              ssh_seek(s, offset + written, SSH_SEEK_WRITE|SSH_SEEK_FORCE);
> -            co_yield(s);
> +            co_yield(s, bs);
>              goto again;
>          }
>  
> @@ -957,7 +959,7 @@ static coroutine_fn int ssh_co_writev(BlockDriverState *bs,
>      int ret;
>  
>      qemu_co_mutex_lock(&s->lock);
> -    ret = ssh_write(s, sector_num * BDRV_SECTOR_SIZE,
> +    ret = ssh_write(s, bs, sector_num * BDRV_SECTOR_SIZE,
>                      nb_sectors * BDRV_SECTOR_SIZE, qiov);
>      qemu_co_mutex_unlock(&s->lock);
>  
> @@ -978,7 +980,7 @@ static void unsafe_flush_warning(BDRVSSHState *s, const char *what)
>  
>  #ifdef HAS_LIBSSH2_SFTP_FSYNC
>  
> -static coroutine_fn int ssh_flush(BDRVSSHState *s)
> +static coroutine_fn int ssh_flush(BDRVSSHState *s, BlockDriverState *bs)
>  {
>      int r;
>  
> @@ -986,7 +988,7 @@ static coroutine_fn int ssh_flush(BDRVSSHState *s)
>   again:
>      r = libssh2_sftp_fsync(s->sftp_handle);
>      if (r == LIBSSH2_ERROR_EAGAIN || r == LIBSSH2_ERROR_TIMEOUT) {
> -        co_yield(s);
> +        co_yield(s, bs);
>          goto again;
>      }
>      if (r == LIBSSH2_ERROR_SFTP_PROTOCOL &&
> @@ -1008,7 +1010,7 @@ static coroutine_fn int ssh_co_flush(BlockDriverState *bs)
>      int ret;
>  
>      qemu_co_mutex_lock(&s->lock);
> -    ret = ssh_flush(s);
> +    ret = ssh_flush(s, bs);
>      qemu_co_mutex_unlock(&s->lock);
>  
>      return ret;
> -- 
> 1.9.0

As this appears to simply be about adding a context pointer to several
calls, it seems to be a simple, mechanical change, so ACK.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW

  reply	other threads:[~2014-05-01 15:03 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-01 14:54 [Qemu-devel] [PATCH 00/22] dataplane: use QEMU block layer Stefan Hajnoczi
2014-05-01 14:54 ` [Qemu-devel] [PATCH 01/22] block: use BlockDriverState AioContext Stefan Hajnoczi
2014-05-01 14:54 ` [Qemu-devel] [PATCH 02/22] block: acquire AioContext in bdrv_close_all() Stefan Hajnoczi
2014-05-01 14:54 ` [Qemu-devel] [PATCH 03/22] block: add bdrv_set_aio_context() Stefan Hajnoczi
2014-05-01 14:54 ` [Qemu-devel] [PATCH 04/22] blkdebug: use BlockDriverState's AioContext Stefan Hajnoczi
2014-05-01 14:54 ` [Qemu-devel] [PATCH 05/22] blkverify: implement .bdrv_detach/attach_aio_context() Stefan Hajnoczi
2014-05-01 14:54 ` [Qemu-devel] [PATCH 06/22] curl: " Stefan Hajnoczi
2014-05-04 11:00   ` Fam Zheng
2014-05-05 11:52     ` Stefan Hajnoczi
2014-05-01 14:54 ` [Qemu-devel] [PATCH 07/22] gluster: use BlockDriverState's AioContext Stefan Hajnoczi
2014-05-05  8:39   ` Bharata B Rao
2014-05-01 14:54 ` [Qemu-devel] [PATCH 08/22] iscsi: implement .bdrv_detach/attach_aio_context() Stefan Hajnoczi
2014-05-01 22:39   ` Peter Lieven
2014-05-07 10:07     ` Stefan Hajnoczi
2014-05-07 10:29       ` Paolo Bonzini
2014-05-07 14:09         ` Peter Lieven
2014-05-08 11:33           ` Stefan Hajnoczi
2014-05-08 14:52             ` ronnie sahlberg
2014-05-08 15:45               ` Peter Lieven
2014-05-01 14:54 ` [Qemu-devel] [PATCH 09/22] nbd: " Stefan Hajnoczi
2014-05-02  7:40   ` Paolo Bonzini
2014-05-01 14:54 ` [Qemu-devel] [PATCH 10/22] nfs: " Stefan Hajnoczi
2014-05-01 14:54 ` [Qemu-devel] [PATCH 11/22] qed: use BlockDriverState's AioContext Stefan Hajnoczi
2014-05-01 14:54 ` [Qemu-devel] [PATCH 12/22] quorum: implement .bdrv_detach/attach_aio_context() Stefan Hajnoczi
2014-05-05 15:46   ` Benoît Canet
2014-05-01 14:54 ` [Qemu-devel] [PATCH 13/22] block/raw-posix: " Stefan Hajnoczi
2014-05-02  7:39   ` Paolo Bonzini
2014-05-02 11:45     ` Stefan Hajnoczi
2014-05-01 14:54 ` [Qemu-devel] [PATCH 14/22] block/linux-aio: fix memory and fd leak Stefan Hajnoczi
2014-05-01 14:54 ` [Qemu-devel] [PATCH 15/22] rbd: use BlockDriverState's AioContext Stefan Hajnoczi
2014-05-01 14:54 ` [Qemu-devel] [PATCH 16/22] sheepdog: implement .bdrv_detach/attach_aio_context() Stefan Hajnoczi
2014-05-05  8:10   ` Liu Yuan
2014-05-01 14:54 ` [Qemu-devel] [PATCH 17/22] ssh: use BlockDriverState's AioContext Stefan Hajnoczi
2014-05-01 15:03   ` Richard W.M. Jones [this message]
2014-05-01 15:13     ` Stefan Hajnoczi
2014-05-01 14:54 ` [Qemu-devel] [PATCH 18/22] vmdk: implement .bdrv_detach/attach_aio_context() Stefan Hajnoczi
2014-05-04  9:50   ` Fam Zheng
2014-05-04 10:17   ` Fam Zheng
2014-05-05 12:03     ` Stefan Hajnoczi
2014-05-01 14:54 ` [Qemu-devel] [PATCH 19/22] dataplane: use the QEMU block layer for I/O Stefan Hajnoczi
2014-05-04 11:51   ` Fam Zheng
2014-05-05 12:03     ` Stefan Hajnoczi
2014-05-01 14:54 ` [Qemu-devel] [PATCH 20/22] dataplane: delete IOQueue since it is no longer used Stefan Hajnoczi
2014-05-01 14:54 ` [Qemu-devel] [PATCH 21/22] dataplane: implement async flush Stefan Hajnoczi
2014-05-01 14:54 ` [Qemu-devel] [PATCH 22/22] raw-posix: drop raw_get_aio_fd() since it is no longer used Stefan Hajnoczi
2014-05-02  7:42 ` [Qemu-devel] [PATCH 00/22] dataplane: use QEMU block layer Paolo Bonzini
2014-05-02 11:59   ` Stefan Hajnoczi
2014-05-05  9:17 ` Christian Borntraeger
2014-05-05 12:05   ` Stefan Hajnoczi
2014-05-05 12:46     ` Christian Borntraeger
2014-05-06  8:39       ` Stefan Hajnoczi
2014-05-06 13:30       ` 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=20140501150313.GT1302@redhat.com \
    --to=rjones@redhat.com \
    --cc=chegu_vinod@hp.com \
    --cc=gurinder.shergill@hp.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@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 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.