From: Paolo Bonzini <pbonzini@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
"Shergill, Gurinder" <gurinder.shergill@hp.com>,
"Vinod, Chegu" <chegu_vinod@hp.com>
Subject: Re: [Qemu-devel] [PATCH 09/22] nbd: implement .bdrv_detach/attach_aio_context()
Date: Fri, 02 May 2014 09:40:24 +0200 [thread overview]
Message-ID: <53634BE8.6010007@redhat.com> (raw)
In-Reply-To: <1398956086-20171-10-git-send-email-stefanha@redhat.com>
Il 01/05/2014 16:54, Stefan Hajnoczi ha scritto:
> Drop the assumption that we're using the main AioContext. Convert
> qemu_aio_set_fd_handler() calls to aio_set_fd_handler().
>
> The .bdrv_detach/attach_aio_context() interfaces also need to be
> implemented to move the socket fd handler from the old to the new
> AioContext.
>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
> block/nbd-client.c | 24 ++++++++++++---
> block/nbd-client.h | 4 +++
> block/nbd.c | 87 +++++++++++++++++++++++++++++++++---------------------
> 3 files changed, 78 insertions(+), 37 deletions(-)
>
> diff --git a/block/nbd-client.c b/block/nbd-client.c
> index 7d698cb..6e1c97c 100644
> --- a/block/nbd-client.c
> +++ b/block/nbd-client.c
> @@ -49,7 +49,7 @@ static void nbd_teardown_connection(NbdClientSession *client)
> shutdown(client->sock, 2);
> nbd_recv_coroutines_enter_all(client);
>
> - qemu_aio_set_fd_handler(client->sock, NULL, NULL, NULL);
> + nbd_client_session_detach_aio_context(client);
> closesocket(client->sock);
> client->sock = -1;
> }
> @@ -103,11 +103,14 @@ static int nbd_co_send_request(NbdClientSession *s,
> struct nbd_request *request,
> QEMUIOVector *qiov, int offset)
> {
> + AioContext *aio_context;
> int rc, ret;
>
> qemu_co_mutex_lock(&s->send_mutex);
> s->send_coroutine = qemu_coroutine_self();
> - qemu_aio_set_fd_handler(s->sock, nbd_reply_ready, nbd_restart_write, s);
> + aio_context = bdrv_get_aio_context(s->bs);
> + aio_set_fd_handler(aio_context, s->sock,
> + nbd_reply_ready, nbd_restart_write, s);
> if (qiov) {
> if (!s->is_unix) {
> socket_set_cork(s->sock, 1);
> @@ -126,7 +129,7 @@ static int nbd_co_send_request(NbdClientSession *s,
> } else {
> rc = nbd_send_request(s->sock, request);
> }
> - qemu_aio_set_fd_handler(s->sock, nbd_reply_ready, NULL, s);
> + aio_set_fd_handler(aio_context, s->sock, nbd_reply_ready, NULL, s);
> s->send_coroutine = NULL;
> qemu_co_mutex_unlock(&s->send_mutex);
> return rc;
> @@ -335,6 +338,19 @@ int nbd_client_session_co_discard(NbdClientSession *client, int64_t sector_num,
>
> }
>
> +void nbd_client_session_detach_aio_context(NbdClientSession *client)
> +{
> + aio_set_fd_handler(bdrv_get_aio_context(client->bs), client->sock,
> + NULL, NULL, NULL);
> +}
> +
> +void nbd_client_session_attach_aio_context(NbdClientSession *client,
> + AioContext *new_context)
> +{
> + aio_set_fd_handler(new_context, client->sock,
> + nbd_reply_ready, NULL, client);
> +}
> +
> void nbd_client_session_close(NbdClientSession *client)
> {
> struct nbd_request request = {
> @@ -381,7 +397,7 @@ int nbd_client_session_init(NbdClientSession *client, BlockDriverState *bs,
> /* Now that we're connected, set the socket to be non-blocking and
> * kick the reply mechanism. */
> qemu_set_nonblock(sock);
> - qemu_aio_set_fd_handler(sock, nbd_reply_ready, NULL, client);
> + nbd_client_session_attach_aio_context(client, bdrv_get_aio_context(bs));
>
> logout("Established connection with NBD server\n");
> return 0;
> diff --git a/block/nbd-client.h b/block/nbd-client.h
> index f2a6337..cd478f3 100644
> --- a/block/nbd-client.h
> +++ b/block/nbd-client.h
> @@ -47,4 +47,8 @@ int nbd_client_session_co_writev(NbdClientSession *client, int64_t sector_num,
> int nbd_client_session_co_readv(NbdClientSession *client, int64_t sector_num,
> int nb_sectors, QEMUIOVector *qiov);
>
> +void nbd_client_session_detach_aio_context(NbdClientSession *client);
> +void nbd_client_session_attach_aio_context(NbdClientSession *client,
> + AioContext *new_context);
> +
> #endif /* NBD_CLIENT_H */
> diff --git a/block/nbd.c b/block/nbd.c
> index 613f258..4eda095 100644
> --- a/block/nbd.c
> +++ b/block/nbd.c
> @@ -323,46 +323,67 @@ static int64_t nbd_getlength(BlockDriverState *bs)
> return s->client.size;
> }
>
> +static void nbd_detach_aio_context(BlockDriverState *bs)
> +{
> + BDRVNBDState *s = bs->opaque;
> +
> + nbd_client_session_detach_aio_context(&s->client);
> +}
> +
> +static void nbd_attach_aio_context(BlockDriverState *bs,
> + AioContext *new_context)
> +{
> + BDRVNBDState *s = bs->opaque;
> +
> + nbd_client_session_attach_aio_context(&s->client, new_context);
> +}
> +
> static BlockDriver bdrv_nbd = {
> - .format_name = "nbd",
> - .protocol_name = "nbd",
> - .instance_size = sizeof(BDRVNBDState),
> - .bdrv_parse_filename = nbd_parse_filename,
> - .bdrv_file_open = nbd_open,
> - .bdrv_co_readv = nbd_co_readv,
> - .bdrv_co_writev = nbd_co_writev,
> - .bdrv_close = nbd_close,
> - .bdrv_co_flush_to_os = nbd_co_flush,
> - .bdrv_co_discard = nbd_co_discard,
> - .bdrv_getlength = nbd_getlength,
> + .format_name = "nbd",
> + .protocol_name = "nbd",
> + .instance_size = sizeof(BDRVNBDState),
> + .bdrv_parse_filename = nbd_parse_filename,
> + .bdrv_file_open = nbd_open,
> + .bdrv_co_readv = nbd_co_readv,
> + .bdrv_co_writev = nbd_co_writev,
> + .bdrv_close = nbd_close,
> + .bdrv_co_flush_to_os = nbd_co_flush,
> + .bdrv_co_discard = nbd_co_discard,
> + .bdrv_getlength = nbd_getlength,
> + .bdrv_detach_aio_context = nbd_detach_aio_context,
> + .bdrv_attach_aio_context = nbd_attach_aio_context,
> };
>
> static BlockDriver bdrv_nbd_tcp = {
> - .format_name = "nbd",
> - .protocol_name = "nbd+tcp",
> - .instance_size = sizeof(BDRVNBDState),
> - .bdrv_parse_filename = nbd_parse_filename,
> - .bdrv_file_open = nbd_open,
> - .bdrv_co_readv = nbd_co_readv,
> - .bdrv_co_writev = nbd_co_writev,
> - .bdrv_close = nbd_close,
> - .bdrv_co_flush_to_os = nbd_co_flush,
> - .bdrv_co_discard = nbd_co_discard,
> - .bdrv_getlength = nbd_getlength,
> + .format_name = "nbd",
> + .protocol_name = "nbd+tcp",
> + .instance_size = sizeof(BDRVNBDState),
> + .bdrv_parse_filename = nbd_parse_filename,
> + .bdrv_file_open = nbd_open,
> + .bdrv_co_readv = nbd_co_readv,
> + .bdrv_co_writev = nbd_co_writev,
> + .bdrv_close = nbd_close,
> + .bdrv_co_flush_to_os = nbd_co_flush,
> + .bdrv_co_discard = nbd_co_discard,
> + .bdrv_getlength = nbd_getlength,
> + .bdrv_detach_aio_context = nbd_detach_aio_context,
> + .bdrv_attach_aio_context = nbd_attach_aio_context,
> };
>
> static BlockDriver bdrv_nbd_unix = {
> - .format_name = "nbd",
> - .protocol_name = "nbd+unix",
> - .instance_size = sizeof(BDRVNBDState),
> - .bdrv_parse_filename = nbd_parse_filename,
> - .bdrv_file_open = nbd_open,
> - .bdrv_co_readv = nbd_co_readv,
> - .bdrv_co_writev = nbd_co_writev,
> - .bdrv_close = nbd_close,
> - .bdrv_co_flush_to_os = nbd_co_flush,
> - .bdrv_co_discard = nbd_co_discard,
> - .bdrv_getlength = nbd_getlength,
> + .format_name = "nbd",
> + .protocol_name = "nbd+unix",
> + .instance_size = sizeof(BDRVNBDState),
> + .bdrv_parse_filename = nbd_parse_filename,
> + .bdrv_file_open = nbd_open,
> + .bdrv_co_readv = nbd_co_readv,
> + .bdrv_co_writev = nbd_co_writev,
> + .bdrv_close = nbd_close,
> + .bdrv_co_flush_to_os = nbd_co_flush,
> + .bdrv_co_discard = nbd_co_discard,
> + .bdrv_getlength = nbd_getlength,
> + .bdrv_detach_aio_context = nbd_detach_aio_context,
> + .bdrv_attach_aio_context = nbd_attach_aio_context,
> };
>
> static void bdrv_nbd_init(void)
>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
next prev parent reply other threads:[~2014-05-02 7:40 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 [this message]
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
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=53634BE8.6010007@redhat.com \
--to=pbonzini@redhat.com \
--cc=chegu_vinod@hp.com \
--cc=gurinder.shergill@hp.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 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.