qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Wen Congyang <wency@cn.fujitsu.com>,
	qemu devel <qemu-devel@nongnu.org>, Kevin Wolf <kwolf@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>,
	Jiang Yunhong <yunhong.jiang@intel.com>,
	Dong Eddie <eddie.dong@intel.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	Gonglei <arei.gonglei@huawei.com>,
	Yang Hongyang <yanghy@cn.fujitsu.com>,
	zhanghailiang <zhang.zhanghailiang@huawei.com>
Subject: Re: [Qemu-devel] [RFC PATCH 06/14] NBD client: connect to nbd server later
Date: Wed, 25 Feb 2015 09:22:47 -0500	[thread overview]
Message-ID: <54EDDAB7.90404@redhat.com> (raw)
In-Reply-To: <54ED321D.2050607@cn.fujitsu.com>

On 2015-02-24 at 21:23, Wen Congyang wrote:
> On 02/24/2015 05:31 AM, Max Reitz wrote:
>> On 2015-02-11 at 22:07, Wen Congyang wrote:
>>> The secondary qemu starts later than the primary qemu, so we
>>> cannot connect to nbd server in bdrv_open().
>>>
>>> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
>>> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
>>> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
>>> ---
>>>    block/nbd.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++--------
>>>    1 file changed, 87 insertions(+), 13 deletions(-)
>>>
>>> diff --git a/block/nbd.c b/block/nbd.c
>>> index b05d1d0..19b9200 100644
>>> --- a/block/nbd.c
>>> +++ b/block/nbd.c
>>> @@ -44,6 +44,8 @@
>>>    typedef struct BDRVNBDState {
>>>        NbdClientSession client;
>>>        QemuOpts *socket_opts;
>>> +    char *export;
>>> +    bool connected;
>>>    } BDRVNBDState;
>>>      static int nbd_parse_uri(const char *filename, QDict *options)
>>> @@ -247,20 +249,10 @@ static int nbd_establish_connection(BlockDriverState *bs, Error **errp)
>>>        return sock;
>>>    }
>>>    -static int nbd_open(BlockDriverState *bs, QDict *options, int flags,
>>> -                    Error **errp)
>>> +static int nbd_connect_server(BlockDriverState *bs, Error **errp)
>>>    {
>>>        BDRVNBDState *s = bs->opaque;
>>> -    char *export = NULL;
>>>        int result, sock;
>>> -    Error *local_err = NULL;
>>> -
>>> -    /* Pop the config into our state object. Exit if invalid. */
>>> -    nbd_config(s, options, &export, &local_err);
>>> -    if (local_err) {
>>> -        error_propagate(errp, local_err);
>>> -        return -EINVAL;
>>> -    }
>>>          /* establish TCP connection, return error if it fails
>>>         * TODO: Configurable retry-until-timeout behaviour.
>>> @@ -271,16 +263,57 @@ static int nbd_open(BlockDriverState *bs, QDict *options, int flags,
>>>        }
>>>          /* NBD handshake */
>>> -    result = nbd_client_session_init(&s->client, bs, sock, export, errp);
>>> -    g_free(export);
>>> +    result = nbd_client_session_init(&s->client, bs, sock, s->export, errp);
>>> +    g_free(s->export);
>>> +    s->export = NULL;
>>> +    if (!result) {
>>> +        s->connected = true;
>>> +    }
>>> +
>>>        return result;
>>>    }
>>>    +static int nbd_open(BlockDriverState *bs, QDict *options, int flags,
>>> +                    Error **errp)
>>> +{
>>> +    BDRVNBDState *s = bs->opaque;
>>> +    Error *local_err = NULL;
>>> +
>>> +    /* Pop the config into our state object. Exit if invalid. */
>>> +    nbd_config(s, options, &s->export, &local_err);
>>> +    if (local_err) {
>>> +        error_propagate(errp, local_err);
>>> +        return -EINVAL;
>>> +    }
>>> +
>>> +    return nbd_connect_server(bs, errp);
>>> +}
>>> +
>>> +static int nbd_open_colo(BlockDriverState *bs, QDict *options, int flags,
>>> +                         Error **errp)
>>> +{
>>> +    BDRVNBDState *s = bs->opaque;
>>> +    Error *local_err = NULL;
>>> +
>>> +    /* Pop the config into our state object. Exit if invalid. */
>>> +    nbd_config(s, options, &s->export, &local_err);
>>> +    if (local_err) {
>>> +        error_propagate(errp, local_err);
>>> +        return -EINVAL;
>>> +    }
>>> +
>>> +    return 0;
>>> +}
>>> +
>>>    static int nbd_co_readv(BlockDriverState *bs, int64_t sector_num,
>>>                            int nb_sectors, QEMUIOVector *qiov)
>>>    {
>>>        BDRVNBDState *s = bs->opaque;
>>>    +    if (!s->connected) {
>>> +        return -EIO;
>>> +    }
>>> +
>>>        return nbd_client_session_co_readv(&s->client, sector_num,
>>>                                           nb_sectors, qiov);
>>>    }
>>> @@ -290,6 +323,10 @@ static int nbd_co_writev(BlockDriverState *bs, int64_t sector_num,
>>>    {
>>>        BDRVNBDState *s = bs->opaque;
>>>    +    if (!s->connected) {
>>> +        return 0;
>>> +    }
>> Would it break anything to return -EIO here as well? (And in all the following functions)
> 1. nbd_co_writev()
>     If one child returns error, quorum will report it. There may be many write requests before
>     we connect to nbd server, so there are too many qapi events...
> 2. nbd_co_flush()
>     If quorum only have two children, and nbd client is the last one, quorum_co_flush()
>     will return -EIO.
> 3. nbd_co_discard()
>     quorum doens't call bdrv_co_discard(), so it is OK to return -EIO here.
>
> So only nbd_co_discard() can return -EIO.

Hm, okay. How about adding an option to quorum for ignoring errors from 
a specific child? It's probably not possible to do something like 
"children.1.ignore-errors=true", but maybe you can just ignore errors in 
quorum from any but the first child if the read pattern is set to 
"first", that would make sense to me.

But if you don't want to do that, I guess just making NBD some kind of 
/dev/null before it's connected should be fine.

Max

>>> +
>>>        return nbd_client_session_co_writev(&s->client, sector_num,
>>>                                            nb_sectors, qiov);
>>>    }
>>> @@ -298,6 +335,10 @@ static int nbd_co_flush(BlockDriverState *bs)
>>>    {
>>>        BDRVNBDState *s = bs->opaque;
>>>    +    if (!s->connected) {
>>> +        return 0;
>>> +    }
>>> +
>>>        return nbd_client_session_co_flush(&s->client);
>>>    }
>>>    @@ -312,6 +353,10 @@ static int nbd_co_discard(BlockDriverState *bs, int64_t sector_num,
>>>    {
>>>        BDRVNBDState *s = bs->opaque;
>>>    +    if (!s->connected) {
>>> +        return 0;
>>> +    }
>>> +
>>>        return nbd_client_session_co_discard(&s->client, sector_num,
>>>                                             nb_sectors);
>>>    }
>>> @@ -322,6 +367,7 @@ static void nbd_close(BlockDriverState *bs)
>>>          qemu_opts_del(s->socket_opts);
>>>        nbd_client_session_close(&s->client);
>>> +    s->connected = false;
>>>    }
>>>    

  reply	other threads:[~2015-02-25 14:23 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-12  3:07 [Qemu-devel] [RFC PATCH 00/14] Block replication for continuous checkpoints Wen Congyang
2015-02-12  3:07 ` [Qemu-devel] [RFC PATCH 01/14] docs: block replication's description Wen Congyang
2015-02-12  7:21   ` Fam Zheng
2015-02-12  7:40     ` Wen Congyang
2015-02-12  8:44       ` Fam Zheng
2015-02-12  9:33         ` Wen Congyang
2015-02-12  9:44           ` Fam Zheng
2015-02-12 10:11             ` Wen Congyang
2015-02-12 10:26               ` famz
2015-02-13  5:09                 ` Wen Congyang
2015-02-13  7:01                   ` Fam Zheng
2015-02-13 20:29                     ` John Snow
2015-03-03  7:53                 ` Wen Congyang
2015-03-03  7:59                   ` Fam Zheng
2015-03-03 12:12                     ` Wen Congyang
2015-03-11  6:44                     ` Wen Congyang
2015-03-11  6:49                       ` Fam Zheng
2015-03-11  7:01                         ` Wen Congyang
2015-03-11  7:04                           ` Fam Zheng
2015-03-11  7:12                             ` Wen Congyang
2015-03-13  9:01                         ` Wen Congyang
2015-03-13  9:05                           ` Fam Zheng
2015-03-16  6:19                             ` Wen Congyang
2015-03-25 12:41                               ` Paolo Bonzini
2015-02-12  9:36         ` Hongyang Yang
2015-02-12  9:46           ` Fam Zheng
2015-02-24  7:50         ` Wen Congyang
2015-02-25  2:46           ` Fam Zheng
2015-02-25  8:36             ` Wen Congyang
2015-02-25  8:58               ` Fam Zheng
2015-02-25  9:58                 ` Wen Congyang
2015-02-26  6:38             ` Wen Congyang
2015-02-26  8:44               ` Fam Zheng
2015-02-26  9:07                 ` Wen Congyang
2015-02-26 10:02                   ` Fam Zheng
2015-02-27  2:27                     ` Wen Congyang
2015-02-27  2:32                       ` Fam Zheng
2015-02-25  8:11         ` Wen Congyang
2015-02-25  8:18           ` Fam Zheng
2015-02-25  9:10         ` Wen Congyang
2015-02-25  9:45           ` Fam Zheng
2015-03-04 16:35   ` Dr. David Alan Gilbert
2015-03-05  1:03     ` Wen Congyang
2015-03-05 19:04       ` Dr. David Alan Gilbert
2015-02-12  3:07 ` [Qemu-devel] [RFC PATCH 02/14] quorom: add a new read pattern Wen Congyang
2015-02-12  6:42   ` Gonglei
2015-02-23 20:36   ` Max Reitz
2015-02-23 21:56   ` Eric Blake
2015-02-12  3:07 ` [Qemu-devel] [RFC PATCH 03/14] quorum: ignore 0-length child Wen Congyang
2015-02-23 20:43   ` Max Reitz
2015-02-24  2:33     ` Wen Congyang
2015-03-18  5:29     ` Wen Congyang
2015-03-18 12:57       ` Max Reitz
2015-02-12  3:07 ` [Qemu-devel] [RFC PATCH 04/14] Add new block driver interfaces to control disk replication Wen Congyang
2015-02-23 20:57   ` Max Reitz
2015-02-23 21:58     ` Eric Blake
2015-02-12  3:07 ` [Qemu-devel] [RFC PATCH 05/14] quorom: implement block driver interfaces for block replication Wen Congyang
2015-02-23 21:22   ` Max Reitz
2015-02-12  3:07 ` [Qemu-devel] [RFC PATCH 06/14] NBD client: connect to nbd server later Wen Congyang
2015-02-23 21:31   ` Max Reitz
2015-02-25  2:23     ` Wen Congyang
2015-02-25 14:22       ` Max Reitz [this message]
2015-02-26 14:07         ` Paolo Bonzini
2015-02-12  3:07 ` [Qemu-devel] [RFC PATCH 07/14] NBD client: implement block driver interfaces for block replication Wen Congyang
2015-02-23 21:41   ` Max Reitz
2015-02-26 14:08     ` Paolo Bonzini
2015-02-12  3:07 ` [Qemu-devel] [RFC PATCH 08/14] block: add a new API to create a hidden BlockBackend Wen Congyang
2015-02-23 21:48   ` Max Reitz
2015-02-12  3:07 ` [Qemu-devel] [RFC PATCH 09/14] block: give backing image its own BlockBackend Wen Congyang
2015-02-23 21:53   ` Max Reitz
2015-02-12  3:07 ` [Qemu-devel] [RFC PATCH 10/14] allow the backing image access the origin BlockDriverState Wen Congyang
2015-02-23 22:01   ` Max Reitz
2015-02-12  3:07 ` [Qemu-devel] [RFC PATCH 11/14] allow writing to the backing file Wen Congyang
2015-02-23 22:03   ` Max Reitz
2015-02-26 14:15     ` Paolo Bonzini
2015-02-12  3:07 ` [Qemu-devel] [RFC PATCH 12/14] Add disk buffer for block replication Wen Congyang
2015-02-23 22:27   ` Max Reitz
2015-02-12  3:07 ` [Qemu-devel] [RFC PATCH 13/14] COW: move cow interfaces to a seperate file Wen Congyang
2015-02-12  3:07 ` [Qemu-devel] [RFC PATCH 14/14] COLO: implement a new block driver Wen Congyang
2015-02-23 22:35   ` Max Reitz
2015-02-18 16:26 ` [Qemu-devel] [RFC PATCH 00/14] Block replication for continuous checkpoints Paolo Bonzini

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=54EDDAB7.90404@redhat.com \
    --to=mreitz@redhat.com \
    --cc=arei.gonglei@huawei.com \
    --cc=dgilbert@redhat.com \
    --cc=eddie.dong@intel.com \
    --cc=kwolf@redhat.com \
    --cc=laijs@cn.fujitsu.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=wency@cn.fujitsu.com \
    --cc=yanghy@cn.fujitsu.com \
    --cc=yunhong.jiang@intel.com \
    --cc=zhang.zhanghailiang@huawei.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).