Thread (11 messages) 11 messages, 4 authors, 2019-03-22
STALE2664d
Revisions (2)
  1. v1 current
  2. v2 [diff vs current]

[PATCH 1/2] block: bio: ensure newly added bio flags don't override BVEC_POOL_IDX

From: Johannes Thumshirn <hidden>
Date: 2019-03-21 12:30:53
Also in: linux-fsdevel
Subsystem: block layer, the rest · Maintainers: Jens Axboe, Linus Torvalds

With the introduction of BIO_ALLOCED we've used up all available bits in
bio::bi_flags.

Make sure no-one adds a new one and thus overrides the BVEC_POOL_IDX

Signed-off-by: Johannes Thumshirn <redacted>
---
 block/bio.c               |  8 ++++++++
 include/linux/blk_types.h | 31 +++++++++++++++++--------------
 2 files changed, 25 insertions(+), 14 deletions(-)
diff --git a/block/bio.c b/block/bio.c
index 4db1008309ed..8c689aed46a0 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -2126,12 +2126,20 @@ static void __init biovec_init_slabs(void)
 	}
 }
 
+static inline void bio_flag_buildtime_check(void)
+{
+	BUILD_BUG_ON(BIO_FLAG_LAST > BVEC_POOL_OFFSET);
+}
+
 static int __init init_bio(void)
 {
 	bio_slab_max = 2;
 	bio_slab_nr = 0;
 	bio_slabs = kcalloc(bio_slab_max, sizeof(struct bio_slab),
 			    GFP_KERNEL);
+
+	bio_flag_buildtime_check();
+
 	if (!bio_slabs)
 		panic("bio: can't allocate bios\n");
 
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index d66bf5f32610..0273bad71a96 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -215,20 +215,23 @@ struct bio {
 /*
  * bio flags
  */
-#define BIO_SEG_VALID	1	/* bi_phys_segments valid */
-#define BIO_CLONED	2	/* doesn't own data */
-#define BIO_BOUNCED	3	/* bio is a bounce bio */
-#define BIO_USER_MAPPED 4	/* contains user pages */
-#define BIO_NULL_MAPPED 5	/* contains invalid user pages */
-#define BIO_QUIET	6	/* Make BIO Quiet */
-#define BIO_CHAIN	7	/* chained bio, ->bi_remaining in effect */
-#define BIO_REFFED	8	/* bio has elevated ->bi_cnt */
-#define BIO_THROTTLED	9	/* This bio has already been subjected to
-				 * throttling rules. Don't do it again. */
-#define BIO_TRACE_COMPLETION 10	/* bio_endio() should trace the final completion
-				 * of this bio. */
-#define BIO_QUEUE_ENTERED 11	/* can use blk_queue_enter_live() */
-#define BIO_TRACKED 12		/* set if bio goes through the rq_qos path */
+enum {
+	BIO_SEG_VALID =	1,		/* bi_phys_segments valid */
+	BIO_CLONED = 2,			/* doesn't own data */
+	BIO_BOUNCED = 3,		/* bio is a bounce bio */
+	BIO_USER_MAPPED = 4,		/* contains user pages */
+	BIO_NULL_MAPPED = 5,		/* contains invalid user pages */
+	BIO_QUIET = 6,			/* Make BIO Quiet */
+	BIO_CHAIN = 7,			/* chained bio, ->bi_remaining in effect */
+	BIO_REFFED = 8,			/* bio has elevated ->bi_cnt */
+	BIO_THROTTLED =	9,		/* This bio has already been subjected to
+					 * throttling rules. Don't do it again. */
+	BIO_TRACE_COMPLETION = 10,	/* bio_endio() should trace the final completion
+					 * of this bio. */
+	BIO_QUEUE_ENTERED = 11,		/* can use blk_queue_enter_live() */
+	BIO_TRACKED = 12,		/* set if bio goes through the rq_qos path */
+	BIO_FLAG_LAST
+};
 
 /* See BVEC_POOL_OFFSET below before adding new flags */
 
-- 
2.16.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help