On Tue, Aug 10, 2021 at 6:40 AM Jens Axboe <axboe@xxxxxxxxx> wrote: > > If a kiocb is marked as being valid for bio caching, then use that to > allocate a (and free) new bio if possible. > > Signed-off-by: Jens Axboe <axboe@xxxxxxxxx> > --- > fs/block_dev.c | 30 ++++++++++++++++++++++++++---- > 1 file changed, 26 insertions(+), 4 deletions(-) > > diff --git a/fs/block_dev.c b/fs/block_dev.c > index 9ef4f1fc2cb0..36a3d53326c0 100644 > --- a/fs/block_dev.c > +++ b/fs/block_dev.c > @@ -327,6 +327,14 @@ static int blkdev_iopoll(struct kiocb *kiocb, bool wait) > return blk_poll(q, READ_ONCE(kiocb->ki_cookie), wait); > } > > +static void dio_bio_put(struct blkdev_dio *dio) > +{ > + if (!dio->is_sync && (dio->iocb->ki_flags & IOCB_ALLOC_CACHE)) > + bio_cache_put(&dio->bio); I think the second check (against IOCB_ALLOC_CACHE) is sufficient here.