aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2021-03-09 09:25:47 -0700
committerJens Axboe <axboe@kernel.dk>2021-08-10 13:57:19 -0600
commit8cf954fd6f6f684a2b10680c3816c486c02b0375 (patch)
treeb1ec853682dd732d76d0207aeef7e0ea7038fbab
parent0d476bc7ae4a036f9ffc8270db2845a298583f40 (diff)
downloadlinux-block-io_uring-bio-cache.3.tar.gz
iomap: enable use of bio allocation cacheio_uring-bio-cache.3
If the kiocb passed in has a bio cache specified, then use that to allocate a (and free) new bio if possible. Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--fs/iomap/direct-io.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
index 9398b8c31323b3..ccef77fec4a073 100644
--- a/fs/iomap/direct-io.c
+++ b/fs/iomap/direct-io.c
@@ -154,7 +154,10 @@ static void iomap_dio_bio_end_io(struct bio *bio)
{
struct iomap_dio *dio = bio->bi_private;
bool should_dirty = (dio->flags & IOMAP_DIO_DIRTY);
+ struct bio_alloc_cache *cache = dio->iocb->ki_bio_cache;
+ if (!(dio->iocb->ki_flags & IOCB_ALLOC_CACHE))
+ cache = NULL;
if (bio->bi_status)
iomap_dio_set_error(dio, blk_status_to_errno(bio->bi_status));
@@ -177,7 +180,7 @@ static void iomap_dio_bio_end_io(struct bio *bio)
bio_check_pages_dirty(bio);
} else {
bio_release_pages(bio, false);
- bio_put(bio);
+ bio_cache_put(cache, bio);
}
}
@@ -305,7 +308,15 @@ iomap_dio_bio_actor(struct inode *inode, loff_t pos, loff_t length,
goto out;
}
- bio = bio_alloc(GFP_KERNEL, nr_pages);
+ bio = NULL;
+ if (dio->iocb->ki_flags & IOCB_ALLOC_CACHE) {
+ bio = bio_cache_get(dio->iocb->ki_bio_cache, GFP_KERNEL,
+ nr_pages, &fs_bio_set);
+ if (!bio)
+ dio->iocb->ki_flags &= ~IOCB_ALLOC_CACHE;
+ }
+ if (!bio)
+ bio = bio_alloc(GFP_KERNEL, nr_pages);
bio_set_dev(bio, iomap->bdev);
bio->bi_iter.bi_sector = iomap_sector(iomap, pos);
bio->bi_write_hint = dio->iocb->ki_hint;