diff options
author | NeilBrown <neilb@suse.de> | 2010-06-01 05:37:25 -0400 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2010-07-25 22:52:26 -0400 |
commit | f4be6b43f1ac60dff00ef0923ee43b0e08872947 (patch) | |
tree | b4fbfed60c0614d97a91638483058a133ddfcbf4 | |
parent | c41d4ac40df0d01bf9c383ff28f194d1df2d4fd9 (diff) |
md/raid5: ensure we create a unique name for kmem_cache when mddev has no gendisk
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>
-rw-r--r-- | drivers/md/raid5.c | 12 | ||||
-rw-r--r-- | drivers/md/raid5.h | 2 |
2 files changed, 9 insertions, 5 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index bd4067a70834..6fa60e416a09 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -1337,10 +1337,14 @@ static int grow_stripes(raid5_conf_t *conf, int num) | |||
1337 | struct kmem_cache *sc; | 1337 | struct kmem_cache *sc; |
1338 | int devs = max(conf->raid_disks, conf->previous_raid_disks); | 1338 | int devs = max(conf->raid_disks, conf->previous_raid_disks); |
1339 | 1339 | ||
1340 | sprintf(conf->cache_name[0], | 1340 | if (conf->mddev->gendisk) |
1341 | "raid%d-%s", conf->level, mdname(conf->mddev)); | 1341 | sprintf(conf->cache_name[0], |
1342 | sprintf(conf->cache_name[1], | 1342 | "raid%d-%s", conf->level, mdname(conf->mddev)); |
1343 | "raid%d-%s-alt", conf->level, mdname(conf->mddev)); | 1343 | else |
1344 | sprintf(conf->cache_name[0], | ||
1345 | "raid%d-%p", conf->level, conf->mddev); | ||
1346 | sprintf(conf->cache_name[1], "%s-alt", conf->cache_name[0]); | ||
1347 | |||
1344 | conf->active_name = 0; | 1348 | conf->active_name = 0; |
1345 | sc = kmem_cache_create(conf->cache_name[conf->active_name], | 1349 | sc = kmem_cache_create(conf->cache_name[conf->active_name], |
1346 | sizeof(struct stripe_head)+(devs-1)*sizeof(struct r5dev), | 1350 | sizeof(struct stripe_head)+(devs-1)*sizeof(struct r5dev), |
diff --git a/drivers/md/raid5.h b/drivers/md/raid5.h index cbdbc77695b3..61b6b25dc5e7 100644 --- a/drivers/md/raid5.h +++ b/drivers/md/raid5.h | |||
@@ -388,7 +388,7 @@ struct raid5_private_data { | |||
388 | * two caches. | 388 | * two caches. |
389 | */ | 389 | */ |
390 | int active_name; | 390 | int active_name; |
391 | char cache_name[2][20]; | 391 | char cache_name[2][32]; |
392 | struct kmem_cache *slab_cache; /* for allocating stripes */ | 392 | struct kmem_cache *slab_cache; /* for allocating stripes */ |
393 | 393 | ||
394 | int seq_flush, seq_write; | 394 | int seq_flush, seq_write; |