On Fri, Apr 24, 2020 at 06:23:48PM +0800, Ming Lei wrote: > +/* complete requests which just requires one flush command */ > +static void blk_complete_flush_requests(struct blk_flush_queue *fq, > + struct list_head *flush_list) > +{ > + struct block_device *bdev; > + struct request *rq; > + int error = -ENXIO; > + > + if (list_empty(flush_list)) > + return; > + > + rq = list_first_entry(flush_list, struct request, queuelist); > + > + /* Send flush via one active hctx so we can move on */ > + bdev = bdget_disk(rq->rq_disk, 0); > + if (bdev) { > + error = blkdev_issue_flush(bdev, GFP_KERNEL, NULL); > + bdput(bdev); > + } FYI, we don't really need the bdev to send a bio anymore, this could just do: bio = bio_alloc(GFP_KERNEL, 0); // XXX: shouldn't this be GFP_NOIO?? bio->bi_disk = rq->rq_disk; bio->bi_partno = 0; bio_associate_blkg(bio); // XXX: actually, shouldn't this come from rq? bio->bi_opf = REQ_OP_WRITE | REQ_PREFLUSH; error = submit_bio_wait(bio); bio_put(bio);