Am 03.07.2014 um 11:51 hat Ming Lei geschrieben: > Hi Kevin, > > On Thu, Jul 3, 2014 at 5:40 PM, Kevin Wolf <kw...@redhat.com> 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 <ming....@canonical.com> > > > > 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