summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-03-21 17:59:13 -0400
committerKent Overstreet <kent.overstreet@gmail.com>2022-03-21 18:21:31 -0400
commit205d75307a7c71f3807c8aa74405cd7267a40e4b (patch)
tree543393e689a19e40c8bfb02bc528a0358d54988b /include/linux
parentb2a9318aa86edfe267805890c5ff1511caa59e70 (diff)
Better bio_alloc_bioset()
bio_alloc_bioset() now uses mempools, so we don't segfault on memory allocation failure. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/bio.h19
-rw-r--r--include/linux/blk_types.h2
2 files changed, 8 insertions, 13 deletions
diff --git a/include/linux/bio.h b/include/linux/bio.h
index cdbbcb39..f6f5300e 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -212,23 +212,19 @@ static inline struct bio *bio_next_split(struct bio *bio, int sectors,
struct bio_set {
unsigned int front_pad;
+ unsigned int back_pad;
+ mempool_t bio_pool;
+ mempool_t bvec_pool;
};
-static inline void bioset_exit(struct bio_set *bs) {}
static inline void bioset_free(struct bio_set *bs)
{
kfree(bs);
}
-static inline int bioset_init(struct bio_set *bs,
- unsigned pool_size,
- unsigned front_pad,
- int flags)
-{
- bs->front_pad = front_pad;
- return 0;
-}
+void bioset_exit(struct bio_set *);
+int bioset_init(struct bio_set *, unsigned, unsigned, int);
extern struct bio_set *bioset_create(unsigned int, unsigned int);
extern struct bio_set *bioset_create_nobvec(unsigned int, unsigned int);
@@ -246,10 +242,7 @@ extern void __bio_clone_fast(struct bio *, struct bio *);
extern struct bio *bio_clone_fast(struct bio *, gfp_t, struct bio_set *);
extern struct bio *bio_clone_bioset(struct bio *, gfp_t, struct bio_set *bs);
-static inline struct bio *bio_kmalloc(gfp_t gfp_mask, unsigned int nr_iovecs)
-{
- return bio_alloc_bioset(gfp_mask, nr_iovecs, NULL);
-}
+struct bio *bio_kmalloc(gfp_t, unsigned int);
static inline struct bio *bio_clone_kmalloc(struct bio *bio, gfp_t gfp_mask)
{
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index be736c8c..2d137e50 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -65,6 +65,8 @@ typedef u8 __bitwise blk_status_t;
#define BLK_STS_AGAIN ((__force blk_status_t)12)
+#define BIO_INLINE_VECS 4
+
/*
* main unit of I/O for the block layer and lower layers (ie drivers and
* stacking drivers)