From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47425) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2e9i-0005hQ-KG for qemu-devel@nongnu.org; Thu, 03 Jul 2014 06:22:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X2e9c-00052r-PU for qemu-devel@nongnu.org; Thu, 03 Jul 2014 06:22:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38583) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2e9c-00052Z-GE for qemu-devel@nongnu.org; Thu, 03 Jul 2014 06:22:12 -0400 Date: Thu, 3 Jul 2014 12:22:04 +0200 From: Kevin Wolf Message-ID: <20140703102204.GG4322@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> 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 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); > 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? > > > >> + if (unplug && --s->io_q.plugged > 0) > >> + return 0; > > > > Missing braces. > > > >> + > >> + if (s->io_q.idx > 0) { > >> + ret = ioq_submit(s); > >> + } > >> + > >> + return ret; > >> +} Kevin