From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49129) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2eHy-00014O-8I for qemu-devel@nongnu.org; Thu, 03 Jul 2014 06:30:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X2eHs-0007mT-Fo for qemu-devel@nongnu.org; Thu, 03 Jul 2014 06:30:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:31163) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2eHs-0007mP-3x for qemu-devel@nongnu.org; Thu, 03 Jul 2014 06:30:44 -0400 Date: Thu, 3 Jul 2014 12:30:12 +0200 From: Kevin Wolf Message-ID: <20140703103012.GH4322@noname.redhat.com> References: <1404303528-7115-1-git-send-email-ming.lei@canonical.com> <1404303528-7115-3-git-send-email-ming.lei@canonical.com> <20140703094009.GC4322@noname.redhat.com> <20140703102204.GG4322@noname.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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: Peter Maydell , Fam Zheng , "Michael S. Tsirkin" , qemu-devel , Stefan Hajnoczi , Paolo Bonzini Am 03.07.2014 um 12:24 hat Ming Lei geschrieben: > On Thu, Jul 3, 2014 at 6:22 PM, Kevin Wolf wrote: > > Am 03.07.2014 um 11:51 hat Ming Lei geschrieben: > >> Hi Kevin, > >> > >> On Thu, Jul 3, 2014 at 5:40 PM, Kevin Wolf wrote: > >> > Am 02.07.2014 um 14:18 hat Ming Lei geschrieben: > >> >> This patch implements .bdrv_io_plug, .bdrv_io_unplug and > >> >> .bdrv_flush_io_queue callbacks for linux-aio Block Drivers, > >> >> so that submitting I/O as a batch can be supported on linux-aio. > >> >> > >> >> Signed-off-by: Ming Lei > >> > > >> > Just a couple of minor comments, see inline. > >> > >> Thanks for your review. > >> > >> >> +void laio_io_plug(BlockDriverState *bs, void *aio_ctx) > >> >> +{ > >> >> + struct qemu_laio_state *s = aio_ctx; > >> >> + > >> >> + s->io_q.plugged++; > >> >> +} > >> >> + > >> >> +int laio_io_unplug(BlockDriverState *bs, void *aio_ctx, bool unplug) > >> >> +{ > >> >> + struct qemu_laio_state *s = aio_ctx; > >> >> + int ret = 0; > >> >> + > >> > > >> > How about an assert(s->io_q.plugged > 0); here? > >> > >> how about just adding a warning because flush io queue uses > >> the function too? > > > > Good point, this is what the assertion should look like then: > > > > assert(s->io_q.plugged > 0 || !unplug); > > OK, will do it. > > >> Also that is why 'plugged' is defined as signed. > > > > I don't understand. The flush function leaves s->io_q.plugged alone > > (otherwise it would be buggy), so how can it ever become negative? And > > if you say that a negative value is valid, what would it even mean? > > I mean it is easy to detect bug with negative value, :-) Ah, I see. That makes some sense then. :-) Kevin