From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35202) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X71d8-0001cd-2U for qemu-devel@nongnu.org; Tue, 15 Jul 2014 08:14:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X71d1-0008M9-5E for qemu-devel@nongnu.org; Tue, 15 Jul 2014 08:14:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:24469) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X71d0-0008Lu-Sg for qemu-devel@nongnu.org; Tue, 15 Jul 2014 08:14:39 -0400 Message-ID: <53C51B28.4030303@redhat.com> Date: Tue, 15 Jul 2014 06:14:32 -0600 From: Eric Blake MIME-Version: 1.0 References: <1405406098-30981-1-git-send-email-namei.unix@gmail.com> <1405406098-30981-2-git-send-email-namei.unix@gmail.com> In-Reply-To: <1405406098-30981-2-git-send-email-namei.unix@gmail.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="rJSha65lVewssUXi2pOdj1VrAFc1PbbfB" Subject: Re: [Qemu-devel] [PATCH v3 1/2] block/quorum: add simple read pattern support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Liu Yuan , qemu-devel@nongnu.org Cc: Kevin Wolf , Benoit Canet , Stefan Hajnoczi This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --rJSha65lVewssUXi2pOdj1VrAFc1PbbfB Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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. >=20 > For now we do a quorum vote on all the reads, it is designed for unreli= able > underlying storage such as non-redundant NFS to make sure data integrit= y at the > cost of the read performance. >=20 > */ > + > +#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 l= ine. > + * Return error if no child read su= cceeds. > + * quorum: read all the children and do a q= uorum > + * 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 =3D acb->common.bs->opaque; > bool rewrite =3D false; > =20 > + if (acb->is_read && s->read_pattern =3D=3D READ_PATTERN_FIFO) { =2E..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 =3D qemu_opt_get(opts, QUORUM_OPT_READ_PATTERN); > + if (read_pattern) { > + if (strcmp(read_pattern, "fifo") =3D=3D 0) { > + s->read_pattern =3D READ_PATTERN_FIFO; > + } else if (strcmp(read_pattern, "quorum") =3D=3D 0) { > + s->read_pattern =3D READ_PATTERN_QUORUM; > + } else { > + error_setg(&local_err, > + "Please set read-pattern as fifo or quorum\n");= > + ret =3D -EINVAL; > + goto exit; > + } =2E..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. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --rJSha65lVewssUXi2pOdj1VrAFc1PbbfB Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJTxRsoAAoJEKeha0olJ0NqaysH/RvkNHfb39sSMzFPetKRIJs3 ++IE91RLiHP1cueaMiNJhJ5P0UFRlsl7LljzKnvKe1WwUu8vJs3G9mYqCAr9NnrZ 4s+O3l9zFBSPu7LU443bRW6TCOUz8DLoEvVhRhNzEQ41EwsBHk5tYyrM7qzSZzWA jnG8PxdSQaocGswChEOEowX8AfqlwmMIs/fnCyvRWqJiN3FhCpAIYI5rm2nZhWxp 81LeOl+iz3StSukWrG4fLXod2F4DX7ZNKmWrgThy5xZgBNgPXLFRT8UNmmZLPDhK kRan2FEHC1FUgqBaKASwGkGx+4MSHMiOWT2TlYr54ZAOFCZLbFhKrE12xtpJlpU= =zU0/ -----END PGP SIGNATURE----- --rJSha65lVewssUXi2pOdj1VrAFc1PbbfB--