summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2021-03-09 09:25:47 -0700
committerJens Axboe <axboe@kernel.dk>2021-08-09 15:14:16 -0600
commitadc1b5a5186b37c9876a5379e0ad7647c821a7c6 (patch)
treef71e0c66faa721780254784ba7c27569107ea18d
parentdb69e416ac26a7c89b00e5a9093f90d9b2e16fc9 (diff)
iomap: enable use of bio allocation cache
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@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 9398b8c31323..a762f20a3a24 100644
--- a/fs/iomap/direct-io.c
+++ b/fs/iomap/direct-io.c
@@ -154,6 +154,7 @@ 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);
+ bool cached = (dio->iocb->ki_flags & IOCB_ALLOC_CACHE);
if (bio->bi_status)
iomap_dio_set_error(dio, blk_status_to_errno(bio->bi_status));
@@ -177,7 +178,10 @@ static void iomap_dio_bio_end_io(struct bio *bio)
bio_check_pages_dirty(bio);
} else {
bio_release_pages(bio, false);
- bio_put(bio);
+ if (cached)
+ bio_cache_put(bio);
+ else
+ bio_put(bio);
}
}
@@ -305,7 +309,14 @@ 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(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;