Received: from eggs.gnu.org ([2001:4830:134:3::10]:53663) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn1CR-0001OA-Mi for qemu-devel@nongnu.org; Thu, 22 Sep 2016 06:25:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bn1CQ-00026j-IE for qemu-devel@nongnu.org; Thu, 22 Sep 2016 06:25:51 -0400 Date: Thu, 22 Sep 2016 12:25:41 +0200 From: Kevin Wolf Message-ID: <20160922102541.GA4420@noname.redhat.com> References: <1474405737-2092-1-git-send-email-kwolf@redhat.com> <1474405737-2092-4-git-send-email-kwolf@redhat.com> <4ede9ba6-c6b7-e696-7981-8b9f65de41b5@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="LQksG6bCIzRHxTLp" Content-Disposition: inline In-Reply-To: <4ede9ba6-c6b7-e696-7981-8b9f65de41b5@redhat.com> Subject: Re: [Qemu-devel] [PATCH 3/7] block/qapi: Move 'aio' option to file driver List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-block@nongnu.org, mreitz@redhat.com, qemu-devel@nongnu.org --LQksG6bCIzRHxTLp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Am 21.09.2016 um 00:27 hat Eric Blake geschrieben: > On 09/20/2016 04:08 PM, Kevin Wolf wrote: > > The option whether or not to use a native AIO interface really isn't a > > generic option for all drivers, but only applies to the native file > > protocols. This patch moves the option in blockdev-add to the > > appropriate places (raw-posix and raw-win32). > >=20 > > We still have to keep the flag BDRV_O_NATIVE_AIO for compatibility > > because so far the AIO option was usually specified on the wrong layer > > (the top-level format driver, which didn't even look at it) and then > > inherited by the protocol driver (where it was actually used). We can't > > forbid this use except in new interfaces. > >=20 > > Signed-off-by: Kevin Wolf > > --- > > block/raw-posix.c | 45 ++++++++++++++++++++++++++++--------------= --- > > block/raw-win32.c | 50 ++++++++++++++++++++++++++++++++++++++++++= +++----- > > qapi/block-core.json | 6 +++--- > > tests/qemu-iotests/087 | 4 ++-- > > 4 files changed, 78 insertions(+), 27 deletions(-) > >=20 > > diff --git a/block/raw-posix.c b/block/raw-posix.c > > index 6ed7547..beb86a3 100644 > > --- a/block/raw-posix.c > > +++ b/block/raw-posix.c > > @@ -143,6 +143,7 @@ typedef struct BDRVRawState { > > bool has_discard:1; > > bool has_write_zeroes:1; > > bool discard_zeroes:1; > > + bool use_linux_aio:1; > > bool has_fallocate; > > bool needs_alignment; >=20 > Not this patch's concern, but why are some of our bools packed in a > bitfield and others used with a full byte? Does the performance vs. > size tradeoff even matter for any of the members concerned? Probably not. Also, we have 5 bytes of padding at the end of this struct, so not using a bitfield would make it exactly the same size. And if we care about the size, we are already wasting 4 bytes with the misaligned size_t buf_align. Anyway, I just did what most other fields are doing. > > } BDRVRawState; > > @@ -367,18 +368,6 @@ static void raw_parse_flags(int bdrv_flags, int *o= pen_flags) > > } > > } > > =20 > > -#ifdef CONFIG_LINUX_AIO > > -static bool raw_use_aio(int bdrv_flags) > > -{ > > - /* > > - * Currently Linux do AIO only for files opened with O_DIRECT > > - * specified so check NOCACHE flag too >=20 > Nice; we're getting rid of some awkward grammar. >=20 > > @@ -429,6 +424,19 @@ static int raw_open_common(BlockDriverState *bs, Q= Dict *options, > > goto fail; > > } > > =20 > > + aio =3D qemu_opt_get(opts, "aio"); > > + if (!aio) { > > + s->use_linux_aio =3D !!(bdrv_flags & BDRV_O_NATIVE_AIO); > > + } else if (!strcmp(aio, "native")) { > > + s->use_linux_aio =3D true; > > + } else if (!strcmp(aio, "threads")) { > > + s->use_linux_aio =3D false; > > + } else { > > + error_setg(errp, "invalid aio option"); > > + ret =3D -EINVAL; > > + goto fail; > > + } > > + >=20 > > +++ b/block/raw-win32.c >=20 > > =20 > > +static bool get_aio_option(QemuOpts *opts, int flags, Error **errp) > > +{ > > + const char *aio =3D qemu_opt_get(opts, "aio"); > > + if (!aio) { > > + return !!(flags & BDRV_O_NATIVE_AIO); > > + } else if (!strcmp(aio, "native")) { > > + return true; > > + } else if (!strcmp(aio, "threads")) { > > + return false; > > + } > > + > > + error_setg(errp, "invalid aio option"); > > + return false; > > +} >=20 > Is there somewhere common to share this, to avoid duplication? I don't know where I would put it. This is a driver-specific option, so it doesn't belong in the generic block layer. It's just that two drivers happen to provide the same option currently. If we add another backend to raw-posix, raw-win32 wouldn't get the new option, so maybe leaving them separate is the best anyway. I guess I could do something like this to make the "duplicated" code look somewhat smaller, or at least condensed into a single statement: BlockdevAioOptions aio =3D qapi_enum_parse(BlockdevAioOptions_lookup, qemu_opt_get(opts, "aio"), BLOCKDEV_AIO_OPTIONS__MAX, (flags & BDRV_O_NATIVE_AIO) ? BLOCKDEV_AIO_OPTIONS_NATIVE : BLOCKDEV_AIO_OPTIONS_THREADS); s->use_linux_aio =3D (aio =3D=3D BLOCKDEV_AIO_OPTIONS_NATIVE); Would you consider this an improvement? Kevin --LQksG6bCIzRHxTLp Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJX47GlAAoJEH8JsnLIjy/WfqsQAJlEEga0GIIdPoyqvsoY7FOe wZ2/R9rE5AlnlfARwwb5RNchTrNwl+ZuUVaGOT8Cn/2FEg5ilxaGrjV9ED+V0KfQ jKWsIqTNsG5ufgjI68kpT5E4yVfwhggKXq5G2/EG3RasZs5WhIBKiNuMJwewp9iA idCLukVi4fAyiauIbTm1hCsZn3jTEk4KkMpAw2bg3xlXFOgJZMQutHa3LNJp+iKY jzvtXSBzf+L7wbTlzuDVKLKKksM8koNcj38x2vt6uQANgh4N77heZ3ZCHpAoVKKU Uo9++0VzdiMeFuiuaT799U+2M2c2i+JTZ0F8tvYebL9oP7N+Bz8mRatsVVEQpDlF dSnNzkc8+R8qwKoias8VoJ7uaxYs1fcgMGyPyOCmV1Bb36nNusJ1sId3nFZ8sW6M eb0SHE2MWulfpU9jU64gkf0Bp4DZWbnLkl4vSEVd88bgBuAa6q5BaCco7A/Kuv5v cH/kES5XHyJLm4LR1rVXx1T5+5OwhU5o0Gj7JQfW0FdIBqHcZh/TxqFm5qZbXz0B /2CN1CbA1UzBbCajfLlb9wZ/kQVGgUJorwHdUBR9eIENfsNyunOmFASeo6k28XYf EcenT8Rg38Y8YF2DKKIFjmtT9ist9LH5lluM2N56hrtCQbE6HHHE4xHyfkeUbY4w K/dgXGwvBSFklWVDZKb7 =oRBc -----END PGP SIGNATURE----- --LQksG6bCIzRHxTLp--