linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@fb.com>
To: Johannes Thumshirn <jthumshirn@suse.de>
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>
Subject: Re: [PATCH 1/2] block: bio: ensure newly added bio flags don't override BVEC_POOL_IDX
Date: Thu, 21 Mar 2019 14:15:14 +0000	[thread overview]
Message-ID: <78cf685f-2bb4-c494-4677-afa513b47339@fb.com> (raw)
In-Reply-To: <20190321123045.32396-2-jthumshirn@suse.de>

On 3/21/19 6:30 AM, Johannes Thumshirn wrote:
> 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

Two minor things:

> 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();
> +

Just add the BUILD_BUG_ON() here, don't put it in a function.

> +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
> +};

Let's order this after the BIO_NO_PAGE_REF patch, so we can avoid
having to explicitly initialize the values.

You also haven't solved the issue of now having an extra bit, 2/2 uses
the last bit which the other patch already took...

-- 
Jens Axboe


  parent reply	other threads:[~2019-03-21 14:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-21 12:30 [PATCH 0/2] add flag for tracking bio allocation Johannes Thumshirn
2019-03-21 12:30 ` [PATCH 1/2] block: bio: ensure newly added bio flags don't override BVEC_POOL_IDX Johannes Thumshirn
2019-03-21 13:18   ` Hannes Reinecke
2019-03-21 13:22     ` Johannes Thumshirn
2019-03-21 14:15   ` Jens Axboe [this message]
2019-03-21 14:21     ` Jens Axboe
2019-03-21 14:23       ` Johannes Thumshirn
2019-03-21 14:25         ` Jens Axboe
2019-03-21 15:54           ` Hannes Reinecke
2019-03-22 10:24           ` Johannes Thumshirn
2019-03-21 12:30 ` [PATCH 2/2] bio: introduce BIO_ALLOCED flag and check it in bio_free Johannes Thumshirn

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=78cf685f-2bb4-c494-4677-afa513b47339@fb.com \
    --to=axboe@fb.com \
    --cc=bvanassche@acm.org \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=jack@suse.cz \
    --cc=jthumshirn@suse.de \
    --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).