Received: from eggs.gnu.org ([2001:4830:134:3::10]:39538) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmTVW-0004df-Ve for qemu-devel@nongnu.org; Tue, 20 Sep 2016 18:27:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bmTVU-0000wV-Q9 for qemu-devel@nongnu.org; Tue, 20 Sep 2016 18:27:17 -0400 References: <1474405737-2092-1-git-send-email-kwolf@redhat.com> <1474405737-2092-4-git-send-email-kwolf@redhat.com> From: Eric Blake Message-ID: <4ede9ba6-c6b7-e696-7981-8b9f65de41b5@redhat.com> Date: Tue, 20 Sep 2016 17:27:07 -0500 MIME-Version: 1.0 In-Reply-To: <1474405737-2092-4-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="0UAU97KDcU60xjI8dOiW2wA76JJsOgwdU" 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: Kevin Wolf , qemu-block@nongnu.org Cc: mreitz@redhat.com, qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --0UAU97KDcU60xjI8dOiW2wA76JJsOgwdU From: Eric Blake To: Kevin Wolf , qemu-block@nongnu.org Cc: mreitz@redhat.com, qemu-devel@nongnu.org Message-ID: <4ede9ba6-c6b7-e696-7981-8b9f65de41b5@redhat.com> Subject: Re: [PATCH 3/7] block/qapi: Move 'aio' option to file driver References: <1474405737-2092-1-git-send-email-kwolf@redhat.com> <1474405737-2092-4-git-send-email-kwolf@redhat.com> In-Reply-To: <1474405737-2092-4-git-send-email-kwolf@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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; 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? > } 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 Nice; we're getting rid of some awkward grammar. > @@ -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; > + } > + > +++ b/block/raw-win32.c > =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; > +} Is there somewhere common to share this, to avoid duplication? > +++ b/qapi/block-core.json > @@ -1724,11 +1724,13 @@ > # Driver specific block device options for the file backend. > # > # @filename: path to the image file > +# @aio: #optional AIO backend (default: threads) > # > # Since: 1.7 > ## > { 'struct': 'BlockdevOptionsFile', > - 'data': { 'filename': 'str' } } > + 'data': { 'filename': 'str', > + '*aio': 'BlockdevAioOptions' } } > =20 > +++ b/tests/qemu-iotests/087 > @@ -117,10 +117,10 @@ run_qemu < "options": { > "driver": "$IMGFMT", > "node-name": "disk", > - "aio": "native", > "file": { > "driver": "file", > - "filename": "$TEST_IMG" > + "filename": "$TEST_IMG", > + "aio": "native" Looks like a reasonable relocation. And more evidence that blockdev-add is not yet usable; hopefully we get there in 2.8. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --0UAU97KDcU60xjI8dOiW2wA76JJsOgwdU Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJX4be7AAoJEKeha0olJ0NqMF0H/i6l/eifMfzRBZG8FEp0ODrZ mqrk78wVOgP9lE4FjnIsFzQOo6FNS+qxw3uYJ8npRAZw13RjrIlzPlUbYQaGwGCn kNfLNcHeUo5+mCcWtUkmzAm4jfz2wjbuuuQLrv9SRUue+J3jp5fO6eSVoayCTe0h w6+zFSuXXi344OJlVELNZbWD/SM7m3OO+MBhO1CIeonSQKKfcLYvSYQURs3oh4w+ hX3r85Tmkfiua+uMYRoeoVAMIK/kQad8xBRDcslj/vj1VPti0f6tynKm2vWgIJT7 hv7SMA6edBJNCRwDYLk4HZoVQPfHkJczHym1bUch4w18/lyZqy8cVsEADbqvGww= =+edQ -----END PGP SIGNATURE----- --0UAU97KDcU60xjI8dOiW2wA76JJsOgwdU--