From: cgxu519 <cgxu519@gmx.com>
To: axboe@kernel.dk
Cc: linux-block@vger.kernel.org
Subject: Re: [PATCH 1/2] block: increase bio_slab_nr only for necessary case
Date: Wed, 20 Mar 2019 10:56:50 +0800 [thread overview]
Message-ID: <672a4135-9d68-e6c9-f9b6-c759018c3d65@gmx.com> (raw)
In-Reply-To: <20190308101540.24337-1-cgxu519@gmx.com>
On 3/8/19 6:15 PM, Chengguang Xu wrote:
> When fail to create new cache in bio_find_or_create_slab(),
> we should not increase bio_slab_nr because it will cause
> referring uninitilized data in subsequent search.
>
> Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
> ---
> block/bio.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/block/bio.c b/block/bio.c
> index 4db1008309ed..8081906f5d01 100644
> --- a/block/bio.c
> +++ b/block/bio.c
> @@ -109,7 +109,7 @@ static struct kmem_cache *bio_find_or_create_slab(unsigned int extra_size)
> bio_slabs = new_bio_slabs;
> }
> if (entry == -1)
> - entry = bio_slab_nr++;
> + entry = bio_slab_nr;
>
> bslab = &bio_slabs[entry];
>
> @@ -122,6 +122,10 @@ static struct kmem_cache *bio_find_or_create_slab(unsigned int extra_size)
> bslab->slab = slab;
> bslab->slab_ref = 1;
> bslab->slab_size = sz;
> +
> + if (entry == bio_slab_nr)
> + bio_slab_nr++;
> +
> out_unlock:
> mutex_unlock(&bio_slab_lock);
> return slab;
Any suggestion?
Thanks.
prev parent reply other threads:[~2019-03-20 2:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-08 10:15 [PATCH 1/2] block: increase bio_slab_nr only for necessary case Chengguang Xu
2019-03-08 10:15 ` [PATCH 2/2] block: code cleanup for bio_find_or_create_slab() Chengguang Xu
2019-03-20 2:56 ` cgxu519 [this message]
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=672a4135-9d68-e6c9-f9b6-c759018c3d65@gmx.com \
--to=cgxu519@gmx.com \
--cc=axboe@kernel.dk \
--cc=linux-block@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.