From: Alexander Lyakas <alex.bolshoy@gmail.com>
To: NeilBrown <neilb@suse.de>
Cc: linux-raid <linux-raid@vger.kernel.org>,
vdavydov@parallels.com, cl@linux.com
Subject: Re: raid5.c::grow_stripes() kmem_cache_create() race
Date: Mon, 16 Jun 2014 20:25:08 +0300 [thread overview]
Message-ID: <CAGRgLy54f3f-3QLQy_kQ8xbA8mkcAe1OPrhUVtir8Sb_-DOtMQ@mail.gmail.com> (raw)
In-Reply-To: <20140612173744.03dd7a70@notabene.brown>
Hi Neil,
apparently this problem has been fixed only very recently, by commit:
421af24 slub: do not drop slab_mutex for sysfs_slab_add
So I guess you won't be interested in fixing it in older kernels. As
Vladimir suggested, raid5 can create unmergeable caches, by providing
a dummy ctor to kmem_cache_create(). But I guess, it's not what we
want, is it?
Thanks,
Alex.
On Thu, Jun 12, 2014 at 10:37 AM, NeilBrown <neilb@suse.de> wrote:
> On Wed, 11 Jun 2014 19:00:42 +0300 Alexander Lyakas <alex.bolshoy@gmail.com>
> wrote:
>
>> Hi Neil,
>> in your master branch, you have a code like:
>>
>> static int grow_stripes(struct r5conf *conf, int num)
>> {
>> struct kmem_cache *sc;
>> int devs = max(conf->raid_disks, conf->previous_raid_disks);
>> int hash;
>>
>> if (conf->mddev->gendisk)
>> sprintf(conf->cache_name[0],
>> "raid%d-%s", conf->level, mdname(conf->mddev));
>> else
>> sprintf(conf->cache_name[0],
>> "raid%d-%p", conf->level, conf->mddev);
>> sprintf(conf->cache_name[1], "%s-alt", conf->cache_name[0]);
>>
>> conf->active_name = 0;
>> sc = kmem_cache_create(conf->cache_name[conf->active_name],
>> sizeof(struct stripe_head)+(devs-1)*sizeof(struct r5dev),
>> 0, 0, NULL);
>>
>> In our case what happened was:
>> - we were assembling two MDs in parallel: md4 and md5
>> - each one tried to create its own kmem_cache: raid5-md4 and raid5-md5
>> (each one had valid conf->mmdev->gendisk)
>>
>> In our kernel SLUB is configured. So the code went to
>> slub.c::__kmem_cache_create(). It called sysfs_slab_add(), which
>> eventually tried to do:
>>
>> if (unmergeable) {
>> // not here
>> } else {
>> // we went here
>> name = create_unique_id(s);
>> }
>>
>> For both threads calling this, it created the same unique id:
>> "t-0001832". And then sysfs freaked out and complained[1]. So md5 was
>> unlucky and failed to initialize, and md4 got lucky and came up.
>> Later, we retried md5 assembly and it worked alright.
>>
>> In this case, both MDs have the same number of disks. That's why
>> kernel tried to have a single cache. Problem is that
>> __kmem_cache_create unlocks slab_mutex, so that's why the race becomes
>> possible.
>>
>> I realize that this is not MD-specific, but rather slab-specific
>> issue, but do you have any idea how to fix that?:(
>
> no, sorry.
>
> As the slub developers.
>
> NeilBrown
prev parent reply other threads:[~2014-06-16 17:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-11 16:00 raid5.c::grow_stripes() kmem_cache_create() race Alexander Lyakas
2014-06-12 7:37 ` NeilBrown
2014-06-16 17:25 ` Alexander Lyakas [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=CAGRgLy54f3f-3QLQy_kQ8xbA8mkcAe1OPrhUVtir8Sb_-DOtMQ@mail.gmail.com \
--to=alex.bolshoy@gmail.com \
--cc=cl@linux.com \
--cc=linux-raid@vger.kernel.org \
--cc=neilb@suse.de \
--cc=vdavydov@parallels.com \
/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).