Received: from eggs.gnu.org ([2001:4830:134:3::10]:57354) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WtzjX-0004xg-Vo for qemu-devel@nongnu.org; Mon, 09 Jun 2014 09:35:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WtzjO-0008RU-VO for qemu-devel@nongnu.org; Mon, 09 Jun 2014 09:35:31 -0400 Received: from mail-we0-x236.google.com ([2a00:1450:400c:c03::236]:52084) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WtzjO-0008R6-P5 for qemu-devel@nongnu.org; Mon, 09 Jun 2014 09:35:22 -0400 Received: by mail-we0-f182.google.com with SMTP id q59so642600wes.13 for ; Mon, 09 Jun 2014 06:35:21 -0700 (PDT) Date: Mon, 9 Jun 2014 15:35:18 +0200 From: Stefan Hajnoczi Message-ID: <20140609133518.GG19546@stefanha-thinkpad.redhat.com> References: <1401561792-13410-1-git-send-email-mreitz@redhat.com> <1401561792-13410-4-git-send-email-mreitz@redhat.com> <20140604123748.GD11073@stefanha-thinkpad.redhat.com> <5390B486.6060800@redhat.com> <53917173.6060107@redhat.com> <5393679E.9080900@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="OFj+1YLvsEfSXdCH" Content-Disposition: inline In-Reply-To: <5393679E.9080900@redhat.com> Subject: Re: [Qemu-devel] [RFC 3/5] nbd: Use aio_set_fd_handler2() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: Kevin Wolf , Paolo Bonzini , Fam Zheng , qemu-devel@nongnu.org, Stefan Hajnoczi --OFj+1YLvsEfSXdCH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Jun 07, 2014 at 09:27:26PM +0200, Max Reitz wrote: > On 06.06.2014 09:44, Paolo Bonzini wrote: > >Il 05/06/2014 20:18, Max Reitz ha scritto: > >>> > >>>Why is this design cleaner? Because NBD code doesn't have to worry > >>>about fd handlers. It uses straightforward coroutine send/recv for > >>>socket I/O inside nbd_read_req() and nbd_write_resp(). It's easy to > >>>see > >>>that only one coroutine receives from the socket and that only one > >>>coroutine writes to the socket. > >> > >>Yes, this sounds better. I'll take a look into it and see how far I can > >>get. > > > >But it doesn't solve any problem, and requires rethinking the > >aio_set_fd_handler API. >=20 > It might clean things up. :-) >=20 > On the other hand, you are right, it's probably too complicated right now. >=20 > >I suggest you just refactor all calls to qemu_set_fd_handler2 into a > >function like > > > > qemu_set_fd_handler2(fd, NULL, > > nbd_can_read(client) ? nbd_read : NULL, > > client->send_coroutine ? > > nbd_restart_write : NULL, > > opaque); > > > >and call this function every time the result of nbd_can_read() changes. > >Then you can switch to aio_set_fd_handler easily. >=20 > Seems good, I'll do that. Sounds fine to me. Restructuring NBD can be done later, if desirable. Stefan --OFj+1YLvsEfSXdCH Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJTlbgWAAoJEJykq7OBq3PIOB4IALMwJU2JMYq02BmBbqv9FNrh WCeVSatPGi4EuQqgBmB3s08kcxVA3l4bfPT2XZlhDQmR6HfSQp40UXIJn7Li4bkl 5Eh3ADzvqh/5I3z1Zr+WNsMByubsrl6TSO/LNwFvps78/zu8FOcknMzWZFocLniV dDn96zMht9sS9WUPGjaOyrN9VtzxWSSg2uHql4lvicklCCBSoBqFcfG3ZpqL0lyU RtFipj+eDzp4rHRYzz41KOonzRH6hj9Awap26ASPMAfQNYv73JRe78yjgMRHsMgt wyz6JghvRslbqS56q5PqYDB01JtXo+r+OJENtHLQPHf3Lv0C0/S5l0IOPSlP8DI= =uLlb -----END PGP SIGNATURE----- --OFj+1YLvsEfSXdCH--