linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Thumshirn <jthumshirn@suse.de>
To: Jens Axboe <axboe@fb.com>
Cc: Hannes Reinecke <hare@suse.de>,
	Bart Van Assche <bvanassche@acm.org>,
	Christoph Hellwig <hch@lst.de>, Jan Kara <jack@suse.cz>,
	Linux Block Layer Mailinglist <linux-block@vger.kernel.org>,
	Linux FSDEVEL Mailinglist <linux-fsdevel@vger.kernel.org>,
	Johannes Thumshirn <jthumshirn@suse.de>
Subject: [PATCH v2 2/3] block: bio: ensure newly added bio flags don't override BVEC_POOL_IDX
Date: Fri, 22 Mar 2019 14:13:45 +0100	[thread overview]
Message-ID: <20190322131346.20169-3-jthumshirn@suse.de> (raw)
In-Reply-To: <20190322131346.20169-1-jthumshirn@suse.de>

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 <jthumshirn@suse.de>
---
 block/bio.c               |  3 +++
 include/linux/blk_types.h | 25 ++++++++++++++-----------
 2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/block/bio.c b/block/bio.c
index a79b2bbcffd0..87a515e93bee 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -2198,6 +2198,9 @@ static int __init init_bio(void)
 	bio_slab_nr = 0;
 	bio_slabs = kcalloc(bio_slab_max, sizeof(struct bio_slab),
 			    GFP_KERNEL);
+
+	BUILD_BUG_ON(BIO_FLAG_LAST > BVEC_POOL_OFFSET);
+
 	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 472059e92071..1d28992a20f0 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -215,19 +215,22 @@ struct bio {
 /*
  * bio flags
  */
-#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
+enum {
+	BIO_CLONED,		/* doesn't own data */
+	BIO_BOUNCED,		/* bio is a bounce bio */
+	BIO_USER_MAPPED,	/* contains user pages */
+	BIO_NULL_MAPPED,	/* contains invalid user pages */
+	BIO_QUIET,		/* Make BIO Quiet */
+	BIO_CHAIN,		/* chained bio, ->bi_remaining in effect */
+	BIO_REFFED,		/* bio has elevated ->bi_cnt */
+	BIO_THROTTLED,		/* 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
+	BIO_TRACE_COMPLETION,	/* 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 */
+	BIO_QUEUE_ENTERED,	/* can use blk_queue_enter_live() */
+	BIO_TRACKED,		/* set if bio goes through the rq_qos path */
+	BIO_FLAG_LAST
+};
 
 /* See BVEC_POOL_OFFSET below before adding new flags */
 
-- 
2.16.4


  parent reply	other threads:[~2019-03-22 13:14 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-22 13:13 [PATCH v2 0/3] add flag for tracking bio allocation Johannes Thumshirn
2019-03-22 13:13 ` [PATCH v2 1/3] block: bio: kill BIO_SEG_VALID flag Johannes Thumshirn
2019-03-22 14:01   ` Christoph Hellwig
2019-03-25  8:02     ` Johannes Thumshirn
2019-03-22 14:06   ` Hannes Reinecke
2019-03-22 22:00   ` Jens Axboe
2019-03-23 19:31     ` Jens Axboe
2019-03-25 13:32       ` Johannes Thumshirn
2019-03-22 22:40   ` Ming Lei
2019-03-22 13:13 ` Johannes Thumshirn [this message]
2019-03-22 14:01   ` [PATCH v2 2/3] block: bio: ensure newly added bio flags don't override BVEC_POOL_IDX Christoph Hellwig
2019-03-22 14:07   ` Hannes Reinecke
2019-03-22 13:13 ` [PATCH v2 3/3] block: bio: introduce BIO_ALLOCED flag and check it in bio_free Johannes Thumshirn
2019-03-22 14:02   ` Christoph Hellwig
2019-03-22 14:05     ` Hannes Reinecke
2019-03-22 21:30       ` Keith Busch
2019-03-22 23:04         ` Ming Lei
2019-03-22 14:10   ` Hannes Reinecke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190322131346.20169-3-jthumshirn@suse.de \
    --to=jthumshirn@suse.de \
    --cc=axboe@fb.com \
    --cc=bvanassche@acm.org \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=jack@suse.cz \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).