Re: [PATCH v2 3/4] blk-flush: kill the flush state machine

From: Christoph Hellwig
Date: Mon Jul 31 2023 - 02:19:46 EST


On Tue, Jul 25, 2023 at 09:01:01PM +0800, chengming.zhou@xxxxxxxxx wrote:
> From: Chengming Zhou <zhouchengming@xxxxxxxxxxxxx>
>
> Since now we put preflush and postflush requests in separate queues,
> we don't need the flush sequence to record anymore.
>
> REQ_FSEQ_PREFLUSH: blk_enqueue_preflush()
> REQ_FSEQ_POSTFLUSH: blk_enqueue_postflush()
> REQ_FSEQ_DONE: blk_end_flush()
>
> In blk_flush_complete(), we have two list to handle: preflush_running
> and postflush_running. We just blk_end_flush() directly for postflush
> requests, but need to move preflush requests to requeue_list to
> dispatch.
>
> This patch just kill the flush state machine and directly call these
> functions, in preparation for the next patch.

> +static void blk_enqueue_postflush(struct request *rq, struct blk_flush_queue *fq)

Please avoid the overly long here. Maybe just rename enqueue to queue
here and for the preflush version as we don't really use enqueue in
the flush code anyway.

> +{
> + unsigned int nr_requeue = 0;
> + struct list_head *preflush_running;
> + struct list_head *postflush_running;
> + struct request *rq, *n;
> +
> + preflush_running = &fq->preflush_queue[fq->flush_running_idx];
> + postflush_running = &fq->postflush_queue[fq->flush_running_idx];

I'd initialize these ad declaration time:

struct list_head *preflush_running =
&fq->preflush_queue[fq->flush_running_idx];
struct list_head *postflush_running =
&fq->postflush_queue[fq->flush_running_idx];
unsigned int nr_requeue = 0;
struct request *rq, *n;

> +
> + list_for_each_entry_safe(rq, n, postflush_running, queuelist) {
> + blk_end_flush(rq, fq, error);
> }

No need for the braces.