qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Liu Yuan <namei.unix@gmail.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Benoit Canet <benoit@irqsave.net>,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v3 1/2] block/quorum: add simple read pattern support
Date: Tue, 15 Jul 2014 06:14:32 -0600	[thread overview]
Message-ID: <53C51B28.4030303@redhat.com> (raw)
In-Reply-To: <1405406098-30981-2-git-send-email-namei.unix@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2582 bytes --]

On 07/15/2014 12:34 AM, Liu Yuan wrote:
> This patch adds single read pattern to quorum driver and quorum vote is default
> pattern.
> 
> For now we do a quorum vote on all the reads, it is designed for unreliable
> underlying storage such as non-redundant NFS to make sure data integrity at the
> cost of the read performance.
> 

>                              */
> +
> +#define READ_PATTERN_QUORUM 0 /* default */
> +#define READ_PATTERN_FIFO   1
> +    int read_pattern;      /* fifo: read a single child and try first one
> +                            *         first. If error, try next child in an
> +                            *         FIFO order specifed by command line.
> +                            *         Return error if no child read succeeds.
> +                            * quorum: read all the children and do a quorum
> +                            *         vote on reads.
> +                            */

Please swap the order of your two patches, or squash them back into one.
 If you define the qapi enum first, then you don't need to open-code
these #defines; instead, the qapi code will generate a typedef that puts
the C enum QuorumReadPattern into play, so that this declaration becomes
'QuorumReadPattern read_pattern;'...


> @@ -263,6 +292,21 @@ static void quorum_aio_cb(void *opaque, int ret)
>      BDRVQuorumState *s = acb->common.bs->opaque;
>      bool rewrite = false;
>  
> +    if (acb->is_read && s->read_pattern == READ_PATTERN_FIFO) {

...and code like this can compare against the constant
QUORUM_READ_PATTERN_FIFO (which will be generated for you from the .json
file)...


> +    read_pattern = qemu_opt_get(opts, QUORUM_OPT_READ_PATTERN);
> +    if (read_pattern) {
> +        if (strcmp(read_pattern, "fifo") == 0) {
> +            s->read_pattern = READ_PATTERN_FIFO;
> +        } else if (strcmp(read_pattern, "quorum") == 0) {
> +            s->read_pattern = READ_PATTERN_QUORUM;
> +        } else {
> +            error_setg(&local_err,
> +                       "Please set read-pattern as fifo or quorum\n");
> +            ret = -EINVAL;
> +            goto exit;
> +        }

...and instead of open-coding this, you should use parse_enum_option().
Also, by using the generated list here, if you later add a third read
pattern, then this parser code doesn't have to change, but already
automatically covers all valid options encoded in the qapi list.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2014-07-15 12:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-15  6:34 [Qemu-devel] [PATCH v3 0/2] add read-pattern for block qourum Liu Yuan
2014-07-15  6:34 ` [Qemu-devel] [PATCH v3 1/2] block/quorum: add simple read pattern support Liu Yuan
2014-07-15 12:14   ` Eric Blake [this message]
2014-07-16  5:30     ` Liu Yuan
2014-07-15  6:34 ` [Qemu-devel] [PATCH v3 2/2] qapi: add read-pattern support for quorum Liu Yuan
2014-07-15 12:22   ` Eric Blake
2014-07-16  2:22     ` Liu Yuan
2014-07-16  2:23       ` Liu Yuan

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=53C51B28.4030303@redhat.com \
    --to=eblake@redhat.com \
    --cc=benoit@irqsave.net \
    --cc=kwolf@redhat.com \
    --cc=namei.unix@gmail.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 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).