xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Lai Jiangshan <laijs@cn.fujitsu.com>
To: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>,
	FNST-Wen Congyang <wency@cn.fujitsu.com>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Jiang Yunhong <yunhong.jiang@intel.com>,
	Dong Eddie <eddie.dong@intel.com>,
	xen-devel@lists.xen.org, Shriram Rajagopalan <rshriram@cs.ubc.ca>,
	Roger Pau Monne <roger.pau@citrix.com>
Subject: Re: [PATCH RFC] remus: implement remus replicated checkpointing disk
Date: Mon, 10 Mar 2014 20:34:32 +0800	[thread overview]
Message-ID: <531DB158.6020102@cn.fujitsu.com> (raw)
In-Reply-To: <21277.41420.110875.680384@mariner.uk.xensource.com>

On 03/10/2014 07:28 PM, Ian Jackson wrote:
> Lai Jiangshan writes ("[PATCH RFC] remus: implement remus replicated checkpointing disk"):
>> This patch implements remus replicated checkpointing disk.
>> It includes two parts:
> ...
>> I request *comments* as many as possible.
> 
> Thanks for posting this so early.  It's very helpful to be able to
> review it before it's been polished.  Sorry it's taken a while to
> reply:
> 
>> diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
>> index a4ffdfd..858f5be 100644
>> --- a/tools/libxl/libxl_dom.c
>> +++ b/tools/libxl/libxl_dom.c
>> @@ -1251,9 +1251,14 @@ static int libxl__remus_domain_suspend_callback(void *data)
> 
> These parts seem reasonable.
> 
>> +    rc = libxl__remus_disks_commit(remus_state);
>> +    if (rc) {
>> +        LOG(ERROR, "Failed to commit disks state"
>> +            " Terminating Remus..");
> 
> Why do we log a message hear but not in the other
> libxl__remus_disks_foo failure cases ?
> 
>> diff --git a/tools/libxl/libxl_remus.c b/tools/libxl/libxl_remus.c
>> index cdc1c16..92eb36a 100644
>> --- a/tools/libxl/libxl_remus.c
>> +++ b/tools/libxl/libxl_remus.c
>> @@ -23,6 +23,7 @@ void libxl__remus_setup_initiate(libxl__egc *egc,
>>                                   libxl__domain_suspend_state *dss)
>>  {
>>      libxl__ev_time_init(&dss->remus_state->timeout);
>> +    libxl__remus_disks_setup(egc, dss);
> 
> I think this is going to have to be an asynchronous function (ie, use
> a callback style), as it's going to want to run scripts.  Likewise the
> teardown.
> 
>> +/*** drbd implementation ***/
>> +const int DRBD_SEND_CHECKPOINT = 20;
>> +const int DRBD_WAIT_CHECKPOINT_ACK = 30;
> 
> These should be "static" as well as "const".
> 
>> +typedef struct libxl__remus_drbd_disk
>> +{
> 
> Our coding style reserves "{" in the LH column for functions, so your
> struct definitions should have the "{" on the end of the previous
> line.  See libxl__device and libxl__ev_watch_slot for examples.
> 
>> +static int drbd_postsuspend(libxl__remus_disk *d)
>> +{
>> +    struct libxl__remus_drbd_disk *drbd = CONTAINER_OF(d, *drbd, remus_disk);
>> +
>> +    if (!drbd->ackwait) {
>> +        if (ioctl(drbd->ctl_fd, DRBD_SEND_CHECKPOINT, 0) <= 0)
>> +            drbd->ackwait = 1;
> 
> This seems to make some assumption about return values, or lack of
> errors, or something.  I would expect to see some error handling
> here.
> 
>> +static int drbd_commit(libxl__remus_disk *d)
>> +{
>> +    /* nothing to do, all work are done by DRBD's protocal-D. */
>> +    return 0;
>> +}
> 
> I'm not sure I understand how this can be true.  Can you point me at
> an explanation of the supposed semantics of the remus disk commit ?
> (Eg in a remus design document or even a paper.)  I suspect something
> ought to be done here.


in drbd-remus case, DRBD_SEND_CHECKPOINT(drbd_postsuspend()) will
do the committing works asynchronously. 

tools/python/xen/remus/device.py:
    def commit(self):
        if not self.is_drbd:
            msg = os.read(self.msgfd.fileno(), 4)
            if msg != 'done':
                print 'Unknown message: %s' % msg

> 
>> +static libxl__remus_disk *drbd_setup(libxl__gc *gc, libxl_device_disk *disk)
> ...
>> +    drbd->ctl_fd = open(GCSPRINTF("/dev/drbd/by-res/%s", disk->pdev_path), O_RDONLY);
> 
> This line could do with wrapping.  And your error handling is a bit
> nugatory, I think - surely something should be logged here ?
> 
>> +static const libxl__remus_disk_type drbd_disk_type = {
>> +  .postsuspend = drbd_postsuspend,
>> +  .preresume = drbd_preresume,
>> +  .commit = drbd_commit,
>> +  .setup = drbd_setup,
>> +  .teardown = drbd_teardown,
>> +};
> 
> I like this vtable approach.
> 
>> +int libxl__remus_disks_postsuspend(libxl__remus_state *state)
>> +{
>> +    int i;
>> +    int rc = 0;
>> +
>> +    for (i = 0; rc == 0 && i < state->nr_disks; i++)
>> +        rc = state->disks[i]->type->postsuspend(state->disks[i]);
>> +
>> +    return rc;
>> +}
> 
> I think the error handling in these functions isn't correct.
> 
> Also, there are several almost-identical functions.  Can you consider
> whether you can write a macro to define them, or perhaps use offsetof
> to write a generic version of the function, or something ?
> 
>> +#if 0
>> +/* TODO: implement disk setup/teardown script */
>> +static void disk_exec_timeout_cb(libxl__egc *egc, libxl__ev_time *ev,
>> +                                      const struct timeval *requested_abs)
> 
> This will probably be easier after the refactoring needed to tease out
> the common script invocation code for the network buffering.
> 
>> +int libxl__remus_disks_setup(libxl__egc *egc, libxl__domain_suspend_state *dss)
>> +{
>> +    libxl__remus_state *remus_state = dss->remus_state;
>> +    int i, j, nr_disks;
>> +    libxl_device_disk *disks;
>> +    libxl__remus_disk *remus_disk;
>> +    const libxl__remus_disk_type *type;
>> +
>> +    STATE_AO_GC(dss->ao);
>> +    disks = libxl_device_disk_list(CTX, dss->domid, &nr_disks);
> 
> disks doesn't come from the gc, so you need to free it.  You should
> initialise it to 0 (NULL), and use the "goto out" error handling
> style.
> 
>> +    remus_state->nr_disks = nr_disks;
>> +    GCNEW_ARRAY(remus_state->disks, nr_disks);
>> +
>> +    for (i = 0; i < nr_disks; i++) {
>> +        remus_disk = NULL;
>> +        for (j = 0; j < ARRAY_SIZE(remus_disk_types); j++) {
>> +            type = remus_disk_types[j];
>> +            remus_disk = type->setup(gc, &disks[i]);
>> +            if (!remus_disk)
>> +                break;
>> +
>> +            remus_state->disks[i] = remus_disk;
>> +            remus_disk->disk = &disks[i];
>> +            remus_disk->type = type;
>> +        }
> 
> I think this code is wrong.  It appears to call all of the setup
> functions, not just one, and overwrite remus_disk with their
> successive results.

If the user use remus disk replication, it is required that
all the disks should support remus disk replication.

So we call setup to all disk. If any disk doesn't support remus
or any disk fail to setup, this libxl__remus_disks_setup() should failed too.

tools/python/xen/remus/device.py:
    def __init__(self, disk):
        if disk.uname.startswith('tap:remus:') or disk.uname.startswith('tap:tapdisk:remus:'):
            ...
        elif disk.uname.startswith('drbd:'):
        else:
            raise ReplicatedDiskException('Disk is not replicated: %s' %
                                        str(disk))


> 
>> +        if (!remus_disk) {
>> +            remus_state->nr_disks = i;
> 
> You may find this easier to write with the "goto found" / "found:"
> search loop idiom.  See "childproc_checkall" in libxl_fork.c for an
> example.
> 
> Thanks,
> Ian.
> 

  reply	other threads:[~2014-03-10 12:34 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-02 11:04 [PATCH V8 0/8] Remus/Libxl: Network buffering support Yang Hongyang
2014-04-02 11:04 ` [PATCH V8 1/8] remus: add libnl3 dependency to autoconf scripts Yang Hongyang
2014-04-02 11:04 ` [PATCH V8 2/8] remus: introduce a function to check whether network buffering is enabled Yang Hongyang
2014-04-02 11:04 ` [PATCH V8 3/8] remus: Remus network buffering core and APIs to setup/teardown Yang Hongyang
2014-02-10  9:19   ` [PATCH 00/10 V7] Remus/Libxl: Network buffering support Lai Jiangshan
2014-02-10  9:19     ` [PATCH 01/10 V7] remus: add libnl3 dependency to autoconf scripts Lai Jiangshan
2014-02-10  9:19     ` [PATCH 02/10 V7] tools/libxl: update libxl_domain_remus_info Lai Jiangshan
2014-03-03 16:33       ` Ian Jackson
2014-02-10  9:19     ` [PATCH 03/10 V7] tools/libxl: introduce a new structure libxl__remus_state Lai Jiangshan
2014-03-03 16:38       ` Ian Jackson
2014-02-10  9:19     ` [PATCH 04/10 V7] remus: introduce a function to check whether network buffering is enabled Lai Jiangshan
2014-03-03 16:39       ` Ian Jackson
2014-02-10  9:19     ` [PATCH 05/10 V7] remus: Remus network buffering core and APIs to setup/teardown Lai Jiangshan
2014-03-03 17:44       ` Ian Jackson
2014-04-03 14:06         ` [PATCH 05/10 V7] remus: Remus network buffering core and APIs to setup/teardown [and 1 more messages] Ian Jackson
2014-02-10  9:19     ` [PATCH 06/10 V7] remus: implement the API to buffer/release packages Lai Jiangshan
2014-03-03 17:48       ` Ian Jackson
2014-02-10  9:19     ` [PATCH 07/10 V7] libxl: use the API to setup/teardown network buffering Lai Jiangshan
2014-03-03 17:51       ` Ian Jackson
2014-04-23 16:02         ` [PATCH 07/10 V7] libxl: use the API to setup/teardown network buffering [and 1 more messages] Ian Jackson
2014-04-23 16:55           ` Shriram Rajagopalan
2014-05-02 16:08             ` Ian Jackson
2014-05-02 21:59               ` Shriram Rajagopalan
2014-05-07  5:42               ` Hongyang Yang
2014-05-07 13:12                 ` Shriram Rajagopalan
2014-05-12 13:18                   ` Ian Jackson
2014-05-13  1:41                     ` Hongyang Yang
2014-02-10  9:19     ` [PATCH 08/10 V7] libxl: rename remus_failover_cb() to remus_replication_failure_cb() Lai Jiangshan
2014-03-03 17:52       ` Ian Jackson
2014-02-10  9:19     ` [PATCH 09/10 V7] libxl: control network buffering in remus callbacks Lai Jiangshan
2014-03-03 17:54       ` Ian Jackson
2014-02-10  9:19     ` [PATCH 10/10 V7] libxl: network buffering cmdline switch Lai Jiangshan
2014-03-03 17:58       ` Ian Jackson
2014-02-26  2:31     ` [PATCH 00/10 V7] Remus/Libxl: Network buffering support Lai Jiangshan
2014-02-26  2:53     ` [PATCH RFC] remus: implement remus replicated checkpointing disk Lai Jiangshan
2014-03-10 11:28       ` Ian Jackson
2014-03-10 12:34         ` Lai Jiangshan [this message]
2014-03-10 16:19           ` Ian Jackson
2014-03-11 18:10       ` Shriram Rajagopalan
2014-03-12  2:35         ` Lai Jiangshan
2014-03-12  6:23           ` Shriram Rajagopalan
2014-03-12 10:07           ` Ian Campbell
2014-03-12 11:57             ` Lai Jiangshan
2014-03-12 12:17               ` Ian Campbell
2014-03-12 12:28                 ` Lai Jiangshan
2014-03-12 10:06         ` Ian Campbell
2014-03-12 12:21           ` Lai Jiangshan
2014-04-02 11:04 ` [PATCH V8 4/8] remus: implement the API to buffer/release packages Yang Hongyang
2014-04-02 11:04 ` [PATCH V8 5/8] libxl: use the API to setup/teardown network buffering Yang Hongyang
2014-04-02 11:04 ` [PATCH V8 6/8] libxl: rename remus_failover_cb() to remus_replication_failure_cb() Yang Hongyang
2014-04-02 11:04 ` [PATCH V8 7/8] libxl: control network buffering in remus callbacks Yang Hongyang
2014-04-02 11:04 ` [PATCH V8 8/8] libxl: network buffering cmdline switch Yang Hongyang
2014-04-03 12:22   ` [PATCH 1/7] introduce a new function libxl__remus_netbuf_setup_done() Lai Jiangshan
2014-04-03 12:22     ` [PATCH 2/7] introduce a new function libxl__remus_netbuf_teardown_done() Lai Jiangshan
2014-04-03 12:22     ` [PATCH 3/7] introduce an API to async exec scripts Lai Jiangshan
2014-04-03 12:22     ` [PATCH 4/7] netbuffer: use async exec API to exec the netbuffer script Lai Jiangshan
2014-04-03 12:22     ` [PATCH 5/7] netbuf: move dev_id from remus_state to netbuf_state Lai Jiangshan
2014-04-03 12:22     ` [PATCH 6/7] remus: implement remus replicated checkpointing disk Lai Jiangshan
2014-04-03 16:41       ` Shriram Rajagopalan
2014-04-04  3:04         ` Lai Jiangshan
2014-04-03 12:22     ` [PATCH 7/7] drbd: implement " Lai Jiangshan
2014-04-03 16:07       ` Shriram Rajagopalan
2014-04-03 14:08     ` [PATCH 1/7] introduce a new function libxl__remus_netbuf_setup_done() Ian Jackson
2014-04-04  8:53       ` Hongyang Yang
  -- strict thread matches above, loose matches on Subject: below --
2014-04-15  5:38 [PATCH V9 00/12] Remus/Libxl: Network buffering support Yang Hongyang
2014-04-15  5:38 ` [PATCH V9 01/12] introduce an API to async exec scripts Yang Hongyang
2014-04-23 15:44   ` Ian Jackson
2014-04-15  5:38 ` [PATCH V9 02/12] libxl_device: use async exec script api Yang Hongyang
2014-04-23 15:48   ` Ian Jackson
2014-04-15  5:38 ` [PATCH V9 03/12] remus: add libnl3 dependency to autoconf scripts Yang Hongyang
2014-04-15  5:38 ` [PATCH V9 04/12] remus: introduce a function to check whether network buffering is enabled Yang Hongyang
2014-04-23 15:50   ` Ian Jackson
2014-04-23 15:51     ` Shriram Rajagopalan
2014-04-30 14:36       ` Ian Jackson
2014-04-15  5:38 ` [PATCH V9 05/12] remus: remus device core and APIs to setup/teardown Yang Hongyang
2014-04-15  5:38 ` [PATCH V9 06/12] remus: implement the API for checkpoint Yang Hongyang
2014-04-23 16:04   ` Ian Jackson
2014-05-14  1:46     ` Hongyang Yang
2014-04-15  5:38 ` [PATCH V9 07/12] remus: Remus network buffering core and APIs to setup/teardown Yang Hongyang
2014-04-15  5:38 ` [PATCH V9 08/12] remus: implement the API to buffer/release packages Yang Hongyang
2014-04-23 16:10   ` Ian Jackson
2014-04-23 17:04     ` Shriram Rajagopalan
2014-05-02 16:10       ` Ian Jackson
2014-04-15  5:38 ` [PATCH V9 09/12] libxl: use the API to setup/teardown network buffering Yang Hongyang
2014-04-23 16:12   ` Ian Jackson
2014-04-16  2:55 ` [PATCH 1/2] drbd: implement replicated checkpointing disk Lai Jiangshan
2014-04-16  2:56   ` [PATCH 2/2] remus: support disk replicated checkpointing Lai Jiangshan
2014-04-23  9:53 ` [PATCH V9 00/12] Remus/Libxl: Network buffering support Hongyang Yang
2014-04-23 15:51 ` Ian Jackson

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=531DB158.6020102@cn.fujitsu.com \
    --to=laijs@cn.fujitsu.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=eddie.dong@intel.com \
    --cc=ian.campbell@citrix.com \
    --cc=roger.pau@citrix.com \
    --cc=rshriram@cs.ubc.ca \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=wency@cn.fujitsu.com \
    --cc=xen-devel@lists.xen.org \
    --cc=yunhong.jiang@intel.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).