On Sat, Apr 25, 2020 at 11:44:05AM +0800, Ming Lei wrote: > > 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?? > > Error handling. bio_alloc does not fail for allocations that can sleep. > > > 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); > > Yeah, that is another way, however I prefer to blkdev_issue_flush > because it takes less code and we do have the API of blkdev_issue_flush. It is about the same amount of code, and as commented above I think the current code uses the wrong blkg assignment.