Received: from eggs.gnu.org ([2001:4830:134:3::10]:42897) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2g4X-0005o8-DC for qemu-devel@nongnu.org; Thu, 03 Jul 2014 08:25:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X2g4Q-0001xl-58 for qemu-devel@nongnu.org; Thu, 03 Jul 2014 08:25:05 -0400 Received: from mail-we0-x22b.google.com ([2a00:1450:400c:c03::22b]:40508) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2g4P-0001xZ-Ui for qemu-devel@nongnu.org; Thu, 03 Jul 2014 08:24:58 -0400 Received: by mail-we0-f171.google.com with SMTP id q58so154721wes.16 for ; Thu, 03 Jul 2014 05:24:56 -0700 (PDT) Date: Thu, 3 Jul 2014 14:24:53 +0200 From: Stefan Hajnoczi Message-ID: <20140703122453.GB28032@stefanha-thinkpad.redhat.com> References: <1404303528-7115-1-git-send-email-ming.lei@canonical.com> <1404303528-7115-3-git-send-email-ming.lei@canonical.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="K8nIJk4ghYZn606h" Content-Disposition: inline In-Reply-To: <1404303528-7115-3-git-send-email-ming.lei@canonical.com> Subject: Re: [Qemu-devel] [PATCH v4 2/3] linux-aio: implement io plug, unplug and flush io queue List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ming Lei Cc: Kevin Wolf , Peter Maydell , Fam Zheng , "Michael S. Tsirkin" , qemu-devel@nongnu.org, Stefan Hajnoczi , Paolo Bonzini --K8nIJk4ghYZn606h Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jul 02, 2014 at 08:18:47PM +0800, Ming Lei wrote: > @@ -36,9 +38,19 @@ struct qemu_laiocb { > QLIST_ENTRY(qemu_laiocb) node; > }; > =20 > +struct laio_queue { This file doesn't follow QEMU coding style for structs but normally this should be: typedef struct { ... } LaioQueue; Up to you if you want to fix it. See ./HACKING and ./CODING_STYLE. Please always run patches throught scripts/checkpatch.pl before submitting them. > +static int ioq_submit(struct qemu_laio_state *s) > +{ > + int ret, i =3D 0; > + int len =3D s->io_q.idx; > + > + do { > + ret =3D io_submit(s->ctx, len, s->io_q.iocbs); > + } while (i++ < 3 && ret =3D=3D -EAGAIN); > + > + /* empty io queue */ > + s->io_q.idx =3D 0; > + > + if (ret >=3D 0) > + return 0; This leaks requests when ret < len. I think the loop below should be used in that case to fail unsubmitted requests with -EIO. Also, QEMU always uses {} even when there is only one statement in the if body and 4-space indentation. > + > + for (i =3D 0; i < len; i++) { > + struct qemu_laiocb *laiocb =3D > + container_of(s->io_q.iocbs[i], struct qemu_laiocb, iocb); > + > + laiocb->ret =3D ret; > + qemu_laio_process_completion(s, laiocb); > + } > + return ret; > +} > + > +static void ioq_enqueue(struct qemu_laio_state *s, struct iocb *iocb) > +{ > + unsigned int idx =3D s->io_q.idx; > + > + s->io_q.iocbs[idx++] =3D iocb; > + s->io_q.idx =3D idx; > + > + /* submit immediately if queue is full */ > + if (idx =3D=3D s->io_q.size) > + ioq_submit(s); Missing {} > +} > + > +void laio_io_plug(BlockDriverState *bs, void *aio_ctx) > +{ > + struct qemu_laio_state *s =3D aio_ctx; > + > + s->io_q.plugged++; > +} > + > +int laio_io_unplug(BlockDriverState *bs, void *aio_ctx, bool unplug) > +{ > + struct qemu_laio_state *s =3D aio_ctx; > + int ret =3D 0; > + > + if (unplug && --s->io_q.plugged > 0) > + return 0; Missing {} --K8nIJk4ghYZn606h Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJTtUuVAAoJEJykq7OBq3PI74cIAKnQbJoNnIgr2PIgDs0d0N0D ONNp0kAWV1kSZM7lwY2F7Qop4PKwDTXqshWnuvY1GxFoVs8NW85hckJGpwpJnAMh 57zFrTQQvzEcJ2L3rcF0RQBFdhahZfjJAXA4rLW0JRxIsKpF2kWjgbP9C7zdVOqw RUzdHtlBW9QU3DMO+/pmsfZ6kQyrkEmLITcY9qpsr8GdjNBj9pUdfSSw4tKzWnA0 4qSWI9AktrYU3SgttV2CIqltJCak0LOHuwgzhTs+7av4TS5HF31AwgsuVpTFUJHX LSfAJGXR+nkFMoAWVc0vbyravaxJnYxzWE4AosgVQ9cPi7mXAiqMWctS1EKK/KE= =eNzG -----END PGP SIGNATURE----- --K8nIJk4ghYZn606h--