Re: [PATCH v2] block: Limit number of items taken from the I/O scheduler in one go

From: Christoph Hellwig
Date: Fri Apr 24 2020 - 02:42:13 EST


On Fri, Apr 24, 2020 at 08:15:29AM +0200, Christoph Hellwig wrote:
> This is a weird loop. I'd split the code betweem the again label and
> the run_again check here into a __blk_mq_sched_dispatch_requests
> helper, and then you can do:
>
> if (__blk_mq_sched_dispatch_requests()) {
> if (__blk_mq_sched_dispatch_requests())
> blk_mq_run_hw_queue(hctx, true);
> }
>
> here. Preferably with ha good comment explaining the logic.

Also I wonder if inverting the return values in the lower level function
would make things a little more readable - a true return suggests
everything worked fine. Alternative 0 for sucess and -EAGAIN for needs
a retry also would be pretty self-documenting.