On 4/17/23 05:09, Christoph Hellwig wrote: > Use a switch statement to decide on the disposition of a flush request > instead of multiple if statements, out of which one does checks that are > more complex than required. Also warn on a malformed request early > on instead of doing a BUG_ON later. > > Signed-off-by: Christoph Hellwig <hch@xxxxxx> One nit below, but looks OK overall. Reviewed-by: Damien Le Moal <dlemoal@xxxxxxxxxx> > --- > block/blk-flush.c | 53 +++++++++++++++++++++++------------------------ > 1 file changed, 26 insertions(+), 27 deletions(-) > > diff --git a/block/blk-flush.c b/block/blk-flush.c > index 422a6d5446d1c5..9fcfee7394f27d 100644 > --- a/block/blk-flush.c > +++ b/block/blk-flush.c > @@ -402,6 +402,9 @@ void blk_insert_flush(struct request *rq) > struct blk_flush_queue *fq = blk_get_flush_queue(q, rq->mq_ctx); > struct blk_mq_hw_ctx *hctx = rq->mq_hctx; > > + /* FLUSH/FUA request must never be merged */ > + WARN_ON_ONCE(rq->bio != rq->biotail); This could be: if (WARN_ON_ONCE(rq->bio != rq->biotail)) { blk_mq_end_request(rq, BLK_STS_IOERR); return; } To avoid an oops on the malformed request later on ?