]> Pileus Git - ~andy/linux/commitdiff
md/raid5: ensure we create a unique name for kmem_cache when mddev has no gendisk
authorNeilBrown <neilb@suse.de>
Tue, 1 Jun 2010 09:37:25 +0000 (19:37 +1000)
committerNeilBrown <neilb@suse.de>
Mon, 26 Jul 2010 02:52:26 +0000 (12:52 +1000)
We will shortly allow md devices with no gendisk (they are attached to
a dm-target instead).  That will cause mdname() to return 'mdX'.
There is one place where mdname really needs to be unique: when
creating the name for a slab cache.
So in that case, if there is no gendisk, you the address of the mddev
formatted in HEX to provide a unique name.

Signed-off-by: NeilBrown <neilb@suse.de>
drivers/md/raid5.c
drivers/md/raid5.h

index bd4067a70834a3b10a741e125b8ac1f106487831..6fa60e416a097394815704d2b68d8a79de003ba1 100644 (file)
@@ -1337,10 +1337,14 @@ static int grow_stripes(raid5_conf_t *conf, int num)
        struct kmem_cache *sc;
        int devs = max(conf->raid_disks, conf->previous_raid_disks);
 
-       sprintf(conf->cache_name[0],
-               "raid%d-%s", conf->level, mdname(conf->mddev));
-       sprintf(conf->cache_name[1],
-               "raid%d-%s-alt", conf->level, mdname(conf->mddev));
+       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),
index cbdbc77695b3eacc56401f6e974751b1ad5c5e48..61b6b25dc5e7c3f6abce768af06c385fb4e7b56e 100644 (file)
@@ -388,7 +388,7 @@ struct raid5_private_data {
         * two caches.
         */
        int                     active_name;
-       char                    cache_name[2][20];
+       char                    cache_name[2][32];
        struct kmem_cache               *slab_cache; /* for allocating stripes */
 
        int                     seq_flush, seq_write;