Commit 62c10f9e authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] md: Change the way the name of an md device is printed in error messages.

From: NeilBrown <neilb@cse.unsw.edu.au>

Instead of using ("md%d", mdidx(mddev)), we now use ("%s", mdname(mddev))
where mdname is the disk_name field in the associated gendisk structure.
This allows future flexability in naming.
parent fe6498c9
This diff is collapsed.
...@@ -389,8 +389,8 @@ static int multipath_run (mddev_t *mddev) ...@@ -389,8 +389,8 @@ static int multipath_run (mddev_t *mddev)
struct list_head *tmp; struct list_head *tmp;
if (mddev->level != LEVEL_MULTIPATH) { if (mddev->level != LEVEL_MULTIPATH) {
printk("multipath: md%d: raid level not set to multipath IO (%d)\n", printk("multipath: %s: raid level not set to multipath IO (%d)\n",
mdidx(mddev), mddev->level); mdname(mddev), mddev->level);
goto out; goto out;
} }
/* /*
...@@ -403,8 +403,8 @@ static int multipath_run (mddev_t *mddev) ...@@ -403,8 +403,8 @@ static int multipath_run (mddev_t *mddev)
mddev->private = conf; mddev->private = conf;
if (!conf) { if (!conf) {
printk(KERN_ERR printk(KERN_ERR
"multipath: couldn't allocate memory for md%d\n", "multipath: couldn't allocate memory for %s\n",
mdidx(mddev)); mdname(mddev));
goto out; goto out;
} }
memset(conf, 0, sizeof(*conf)); memset(conf, 0, sizeof(*conf));
...@@ -413,8 +413,8 @@ static int multipath_run (mddev_t *mddev) ...@@ -413,8 +413,8 @@ static int multipath_run (mddev_t *mddev)
GFP_KERNEL); GFP_KERNEL);
if (!conf->multipaths) { if (!conf->multipaths) {
printk(KERN_ERR printk(KERN_ERR
"multipath: couldn't allocate memory for md%d\n", "multipath: couldn't allocate memory for %s\n",
mdidx(mddev)); mdname(mddev));
goto out_free_conf; goto out_free_conf;
} }
memset(conf->multipaths, 0, sizeof(struct multipath_info)*mddev->raid_disks); memset(conf->multipaths, 0, sizeof(struct multipath_info)*mddev->raid_disks);
...@@ -448,8 +448,8 @@ static int multipath_run (mddev_t *mddev) ...@@ -448,8 +448,8 @@ static int multipath_run (mddev_t *mddev)
conf->device_lock = SPIN_LOCK_UNLOCKED; conf->device_lock = SPIN_LOCK_UNLOCKED;
if (!conf->working_disks) { if (!conf->working_disks) {
printk(KERN_ERR "multipath: no operational IO paths for md%d\n", printk(KERN_ERR "multipath: no operational IO paths for %s\n",
mdidx(mddev)); mdname(mddev));
goto out_free_conf; goto out_free_conf;
} }
mddev->degraded = conf->raid_disks = conf->working_disks; mddev->degraded = conf->raid_disks = conf->working_disks;
...@@ -459,25 +459,23 @@ static int multipath_run (mddev_t *mddev) ...@@ -459,25 +459,23 @@ static int multipath_run (mddev_t *mddev)
NULL); NULL);
if (conf->pool == NULL) { if (conf->pool == NULL) {
printk(KERN_ERR printk(KERN_ERR
"multipath: couldn't allocate memory for md%d\n", "multipath: couldn't allocate memory for %s\n",
mdidx(mddev)); mdname(mddev));
goto out_free_conf; goto out_free_conf;
} }
{ {
const char * name = "md%d_multipath"; mddev->thread = md_register_thread(multipathd, mddev, "%s_multipath");
mddev->thread = md_register_thread(multipathd, mddev, name);
if (!mddev->thread) { if (!mddev->thread) {
printk(KERN_ERR "multipath: couldn't allocate thread" printk(KERN_ERR "multipath: couldn't allocate thread"
" for md%d\n", mdidx(mddev)); " for %s\n", mdname(mddev));
goto out_free_conf; goto out_free_conf;
} }
} }
printk(KERN_INFO printk(KERN_INFO
"multipath: array md%d active with %d out of %d IO paths\n", "multipath: array %s active with %d out of %d IO paths\n",
mdidx(mddev), conf->working_disks, mddev->raid_disks); mdname(mddev), conf->working_disks, mddev->raid_disks);
/* /*
* Ok, everything is just fine now * Ok, everything is just fine now
*/ */
......
...@@ -240,8 +240,8 @@ static int raid0_run (mddev_t *mddev) ...@@ -240,8 +240,8 @@ static int raid0_run (mddev_t *mddev)
mdk_rdev_t *rdev; mdk_rdev_t *rdev;
struct list_head *tmp; struct list_head *tmp;
printk("md%d: setting max_sectors to %d, segment boundary to %d\n", printk("%s: setting max_sectors to %d, segment boundary to %d\n",
mdidx(mddev), mdname(mddev),
mddev->chunk_size >> 9, mddev->chunk_size >> 9,
(mddev->chunk_size>>1)-1); (mddev->chunk_size>>1)-1);
blk_queue_max_sectors(mddev->queue, mddev->chunk_size >> 9); blk_queue_max_sectors(mddev->queue, mddev->chunk_size >> 9);
......
...@@ -1052,8 +1052,8 @@ static int run(mddev_t *mddev) ...@@ -1052,8 +1052,8 @@ static int run(mddev_t *mddev)
struct list_head *tmp; struct list_head *tmp;
if (mddev->level != 1) { if (mddev->level != 1) {
printk("raid1: md%d: raid level not set to mirroring (%d)\n", printk("raid1: %s: raid level not set to mirroring (%d)\n",
mdidx(mddev), mddev->level); mdname(mddev), mddev->level);
goto out; goto out;
} }
/* /*
...@@ -1064,16 +1064,16 @@ static int run(mddev_t *mddev) ...@@ -1064,16 +1064,16 @@ static int run(mddev_t *mddev)
conf = kmalloc(sizeof(conf_t), GFP_KERNEL); conf = kmalloc(sizeof(conf_t), GFP_KERNEL);
mddev->private = conf; mddev->private = conf;
if (!conf) { if (!conf) {
printk(KERN_ERR "raid1: couldn't allocate memory for md%d\n", printk(KERN_ERR "raid1: couldn't allocate memory for %s\n",
mdidx(mddev)); mdname(mddev));
goto out; goto out;
} }
memset(conf, 0, sizeof(*conf)); memset(conf, 0, sizeof(*conf));
conf->mirrors = kmalloc(sizeof(struct mirror_info)*mddev->raid_disks, conf->mirrors = kmalloc(sizeof(struct mirror_info)*mddev->raid_disks,
GFP_KERNEL); GFP_KERNEL);
if (!conf->mirrors) { if (!conf->mirrors) {
printk(KERN_ERR "raid1: couldn't allocate memory for md%d\n", printk(KERN_ERR "raid1: couldn't allocate memory for %s\n",
mdidx(mddev)); mdname(mddev));
goto out_free_conf; goto out_free_conf;
} }
memset(conf->mirrors, 0, sizeof(struct mirror_info)*mddev->raid_disks); memset(conf->mirrors, 0, sizeof(struct mirror_info)*mddev->raid_disks);
...@@ -1081,8 +1081,8 @@ static int run(mddev_t *mddev) ...@@ -1081,8 +1081,8 @@ static int run(mddev_t *mddev)
conf->r1bio_pool = mempool_create(NR_RAID1_BIOS, r1bio_pool_alloc, conf->r1bio_pool = mempool_create(NR_RAID1_BIOS, r1bio_pool_alloc,
r1bio_pool_free, mddev); r1bio_pool_free, mddev);
if (!conf->r1bio_pool) { if (!conf->r1bio_pool) {
printk(KERN_ERR "raid1: couldn't allocate memory for md%d\n", printk(KERN_ERR "raid1: couldn't allocate memory for %s\n",
mdidx(mddev)); mdname(mddev));
goto out_free_conf; goto out_free_conf;
} }
...@@ -1121,8 +1121,8 @@ static int run(mddev_t *mddev) ...@@ -1121,8 +1121,8 @@ static int run(mddev_t *mddev)
init_waitqueue_head(&conf->wait_resume); init_waitqueue_head(&conf->wait_resume);
if (!conf->working_disks) { if (!conf->working_disks) {
printk(KERN_ERR "raid1: no operational mirrors for md%d\n", printk(KERN_ERR "raid1: no operational mirrors for %s\n",
mdidx(mddev)); mdname(mddev));
goto out_free_conf; goto out_free_conf;
} }
...@@ -1150,17 +1150,17 @@ static int run(mddev_t *mddev) ...@@ -1150,17 +1150,17 @@ static int run(mddev_t *mddev)
{ {
mddev->thread = md_register_thread(raid1d, mddev, "md%d_raid1"); mddev->thread = md_register_thread(raid1d, mddev, "%s_raid1");
if (!mddev->thread) { if (!mddev->thread) {
printk(KERN_ERR printk(KERN_ERR
"raid1: couldn't allocate thread for md%d\n", "raid1: couldn't allocate thread for %s\n",
mdidx(mddev)); mdname(mddev));
goto out_free_conf; goto out_free_conf;
} }
} }
printk(KERN_INFO printk(KERN_INFO
"raid1: raid set md%d active with %d out of %d mirrors\n", "raid1: raid set %s active with %d out of %d mirrors\n",
mdidx(mddev), mddev->raid_disks - mddev->degraded, mdname(mddev), mddev->raid_disks - mddev->degraded,
mddev->raid_disks); mddev->raid_disks);
/* /*
* Ok, everything is just fine now * Ok, everything is just fine now
......
...@@ -1485,7 +1485,7 @@ static int run (mddev_t *mddev) ...@@ -1485,7 +1485,7 @@ static int run (mddev_t *mddev)
struct list_head *tmp; struct list_head *tmp;
if (mddev->level != 5 && mddev->level != 4) { if (mddev->level != 5 && mddev->level != 4) {
printk("raid5: md%d: raid level not set to 4/5 (%d)\n", mdidx(mddev), mddev->level); printk("raid5: %s: raid level not set to 4/5 (%d)\n", mdname(mddev), mddev->level);
return -EIO; return -EIO;
} }
...@@ -1511,7 +1511,7 @@ static int run (mddev_t *mddev) ...@@ -1511,7 +1511,7 @@ static int run (mddev_t *mddev)
mddev->queue->unplug_fn = raid5_unplug_device; mddev->queue->unplug_fn = raid5_unplug_device;
PRINTK("raid5: run(md%d) called.\n", mdidx(mddev)); PRINTK("raid5: run(%s) called.\n", mdname(mddev));
ITERATE_RDEV(mddev,rdev,tmp) { ITERATE_RDEV(mddev,rdev,tmp) {
raid_disk = rdev->raid_disk; raid_disk = rdev->raid_disk;
...@@ -1543,37 +1543,37 @@ static int run (mddev_t *mddev) ...@@ -1543,37 +1543,37 @@ static int run (mddev_t *mddev)
conf->max_nr_stripes = NR_STRIPES; conf->max_nr_stripes = NR_STRIPES;
if (!conf->chunk_size || conf->chunk_size % 4) { if (!conf->chunk_size || conf->chunk_size % 4) {
printk(KERN_ERR "raid5: invalid chunk size %d for md%d\n", printk(KERN_ERR "raid5: invalid chunk size %d for %s\n",
conf->chunk_size, mdidx(mddev)); conf->chunk_size, mdname(mddev));
goto abort; goto abort;
} }
if (conf->algorithm > ALGORITHM_RIGHT_SYMMETRIC) { if (conf->algorithm > ALGORITHM_RIGHT_SYMMETRIC) {
printk(KERN_ERR printk(KERN_ERR
"raid5: unsupported parity algorithm %d for md%d\n", "raid5: unsupported parity algorithm %d for %s\n",
conf->algorithm, mdidx(mddev)); conf->algorithm, mdname(mddev));
goto abort; goto abort;
} }
if (mddev->degraded > 1) { if (mddev->degraded > 1) {
printk(KERN_ERR "raid5: not enough operational devices for md%d" printk(KERN_ERR "raid5: not enough operational devices for %s"
" (%d/%d failed)\n", " (%d/%d failed)\n",
mdidx(mddev), conf->failed_disks, conf->raid_disks); mdname(mddev), conf->failed_disks, conf->raid_disks);
goto abort; goto abort;
} }
if (mddev->degraded == 1 && if (mddev->degraded == 1 &&
mddev->recovery_cp != MaxSector) { mddev->recovery_cp != MaxSector) {
printk(KERN_ERR printk(KERN_ERR
"raid5: cannot start dirty degraded array for md%d\n", "raid5: cannot start dirty degraded array for %s\n",
mdidx(mddev)); mdname(mddev));
goto abort; goto abort;
} }
{ {
mddev->thread = md_register_thread(raid5d, mddev, "md%d_raid5"); mddev->thread = md_register_thread(raid5d, mddev, "%s_raid5");
if (!mddev->thread) { if (!mddev->thread) {
printk(KERN_ERR printk(KERN_ERR
"raid5: couldn't allocate thread for md%d\n", "raid5: couldn't allocate thread for %s\n",
mdidx(mddev)); mdname(mddev));
goto abort; goto abort;
} }
} }
...@@ -1586,18 +1586,18 @@ memory = conf->max_nr_stripes * (sizeof(struct stripe_head) + ...@@ -1586,18 +1586,18 @@ memory = conf->max_nr_stripes * (sizeof(struct stripe_head) +
md_unregister_thread(mddev->thread); md_unregister_thread(mddev->thread);
goto abort; goto abort;
} else } else
printk(KERN_INFO "raid5: allocated %dkB for md%d\n", printk(KERN_INFO "raid5: allocated %dkB for %s\n",
memory, mdidx(mddev)); memory, mdname(mddev));
if (mddev->degraded == 0) if (mddev->degraded == 0)
printk("raid5: raid level %d set md%d active with %d out of %d" printk("raid5: raid level %d set %s active with %d out of %d"
" devices, algorithm %d\n", conf->level, mdidx(mddev), " devices, algorithm %d\n", conf->level, mdname(mddev),
mddev->raid_disks-mddev->degraded, mddev->raid_disks, mddev->raid_disks-mddev->degraded, mddev->raid_disks,
conf->algorithm); conf->algorithm);
else else
printk(KERN_ALERT "raid5: raid level %d set md%d active with %d" printk(KERN_ALERT "raid5: raid level %d set %s active with %d"
" out of %d devices, algorithm %d\n", conf->level, " out of %d devices, algorithm %d\n", conf->level,
mdidx(mddev), mddev->raid_disks - mddev->degraded, mdname(mddev), mddev->raid_disks - mddev->degraded,
mddev->raid_disks, conf->algorithm); mddev->raid_disks, conf->algorithm);
print_raid5_conf(conf); print_raid5_conf(conf);
...@@ -1624,7 +1624,7 @@ memory = conf->max_nr_stripes * (sizeof(struct stripe_head) + ...@@ -1624,7 +1624,7 @@ memory = conf->max_nr_stripes * (sizeof(struct stripe_head) +
kfree(conf); kfree(conf);
} }
mddev->private = NULL; mddev->private = NULL;
printk(KERN_ALERT "raid5: failed to run raid set md%d\n", mdidx(mddev)); printk(KERN_ALERT "raid5: failed to run raid set %s\n", mdname(mddev));
return -EIO; return -EIO;
} }
......
...@@ -1647,7 +1647,7 @@ static int run (mddev_t *mddev) ...@@ -1647,7 +1647,7 @@ static int run (mddev_t *mddev)
struct list_head *tmp; struct list_head *tmp;
if (mddev->level != 6) { if (mddev->level != 6) {
PRINTK("raid6: md%d: raid level not set to 6 (%d)\n", mdidx(mddev), mddev->level); PRINTK("raid6: %s: raid level not set to 6 (%d)\n", mdname(mddev), mddev->level);
return -EIO; return -EIO;
} }
...@@ -1673,7 +1673,7 @@ static int run (mddev_t *mddev) ...@@ -1673,7 +1673,7 @@ static int run (mddev_t *mddev)
mddev->queue->unplug_fn = raid6_unplug_device; mddev->queue->unplug_fn = raid6_unplug_device;
PRINTK("raid6: run(md%d) called.\n", mdidx(mddev)); PRINTK("raid6: run(%s) called.\n", mdname(mddev));
ITERATE_RDEV(mddev,rdev,tmp) { ITERATE_RDEV(mddev,rdev,tmp) {
raid_disk = rdev->raid_disk; raid_disk = rdev->raid_disk;
...@@ -1706,42 +1706,42 @@ static int run (mddev_t *mddev) ...@@ -1706,42 +1706,42 @@ static int run (mddev_t *mddev)
conf->max_nr_stripes = NR_STRIPES; conf->max_nr_stripes = NR_STRIPES;
if (conf->raid_disks < 4) { if (conf->raid_disks < 4) {
printk(KERN_ERR "raid6: not enough configured devices for md%d (%d, minimum 4)\n", printk(KERN_ERR "raid6: not enough configured devices for %s (%d, minimum 4)\n",
mdidx(mddev), conf->raid_disks); mdname(mddev), conf->raid_disks);
goto abort; goto abort;
} }
if (!conf->chunk_size || conf->chunk_size % 4) { if (!conf->chunk_size || conf->chunk_size % 4) {
printk(KERN_ERR "raid6: invalid chunk size %d for md%d\n", printk(KERN_ERR "raid6: invalid chunk size %d for %s\n",
conf->chunk_size, mdidx(mddev)); conf->chunk_size, mdname(mddev));
goto abort; goto abort;
} }
if (conf->algorithm > ALGORITHM_RIGHT_SYMMETRIC) { if (conf->algorithm > ALGORITHM_RIGHT_SYMMETRIC) {
printk(KERN_ERR printk(KERN_ERR
"raid6: unsupported parity algorithm %d for md%d\n", "raid6: unsupported parity algorithm %d for %s\n",
conf->algorithm, mdidx(mddev)); conf->algorithm, mdname(mddev));
goto abort; goto abort;
} }
if (mddev->degraded > 2) { if (mddev->degraded > 2) {
printk(KERN_ERR "raid6: not enough operational devices for md%d" printk(KERN_ERR "raid6: not enough operational devices for %s"
" (%d/%d failed)\n", " (%d/%d failed)\n",
mdidx(mddev), conf->failed_disks, conf->raid_disks); mdname(mddev), conf->failed_disks, conf->raid_disks);
goto abort; goto abort;
} }
#if 0 /* FIX: For now */ #if 0 /* FIX: For now */
if (mddev->degraded > 0 && if (mddev->degraded > 0 &&
mddev->recovery_cp != MaxSector) { mddev->recovery_cp != MaxSector) {
printk(KERN_ERR "raid6: cannot start dirty degraded array for md%d\n", mdidx(mddev)); printk(KERN_ERR "raid6: cannot start dirty degraded array for %s\n", mdname(mddev));
goto abort; goto abort;
} }
#endif #endif
{ {
mddev->thread = md_register_thread(raid6d, mddev, "md%d_raid6"); mddev->thread = md_register_thread(raid6d, mddev, "%s_raid6");
if (!mddev->thread) { if (!mddev->thread) {
printk(KERN_ERR printk(KERN_ERR
"raid6: couldn't allocate thread for md%d\n", "raid6: couldn't allocate thread for %s\n",
mdidx(mddev)); mdname(mddev));
goto abort; goto abort;
} }
} }
...@@ -1755,18 +1755,18 @@ static int run (mddev_t *mddev) ...@@ -1755,18 +1755,18 @@ static int run (mddev_t *mddev)
md_unregister_thread(mddev->thread); md_unregister_thread(mddev->thread);
goto abort; goto abort;
} else } else
printk(KERN_INFO "raid6: allocated %dkB for md%d\n", printk(KERN_INFO "raid6: allocated %dkB for %s\n",
memory, mdidx(mddev)); memory, mdname(mddev));
if (mddev->degraded == 0) if (mddev->degraded == 0)
printk(KERN_INFO "raid6: raid level %d set md%d active with %d out of %d" printk(KERN_INFO "raid6: raid level %d set %s active with %d out of %d"
" devices, algorithm %d\n", conf->level, mdidx(mddev), " devices, algorithm %d\n", conf->level, mdname(mddev),
mddev->raid_disks-mddev->degraded, mddev->raid_disks, mddev->raid_disks-mddev->degraded, mddev->raid_disks,
conf->algorithm); conf->algorithm);
else else
printk(KERN_ALERT "raid6: raid level %d set md%d active with %d" printk(KERN_ALERT "raid6: raid level %d set %s active with %d"
" out of %d devices, algorithm %d\n", conf->level, " out of %d devices, algorithm %d\n", conf->level,
mdidx(mddev), mddev->raid_disks - mddev->degraded, mdname(mddev), mddev->raid_disks - mddev->degraded,
mddev->raid_disks, conf->algorithm); mddev->raid_disks, conf->algorithm);
print_raid6_conf(conf); print_raid6_conf(conf);
...@@ -1793,7 +1793,7 @@ static int run (mddev_t *mddev) ...@@ -1793,7 +1793,7 @@ static int run (mddev_t *mddev)
kfree(conf); kfree(conf);
} }
mddev->private = NULL; mddev->private = NULL;
printk(KERN_ALERT "raid6: failed to run raid set md%d\n", mdidx(mddev)); printk(KERN_ALERT "raid6: failed to run raid set %s\n", mdname(mddev));
return -EIO; return -EIO;
} }
......
...@@ -281,6 +281,10 @@ static inline int mdidx (mddev_t * mddev) ...@@ -281,6 +281,10 @@ static inline int mdidx (mddev_t * mddev)
{ {
return mddev->__minor; return mddev->__minor;
} }
static inline char * mdname (mddev_t * mddev)
{
return mddev->gendisk ? mddev->gendisk->disk_name : "mdX";
}
extern mdk_rdev_t * find_rdev_nr(mddev_t *mddev, int nr); extern mdk_rdev_t * find_rdev_nr(mddev_t *mddev, int nr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment