forked from Minki/linux
md: simplify md_setup_drive
Move the loop over the possible arrays into the caller to remove a level of indentation for the whole function. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: NeilBrown <neilb@suse.de> Acked-by: Song Liu <song@kernel.org> Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
1a6a050620
commit
d1100488c3
@ -27,7 +27,7 @@ static int __initdata raid_noautodetect=1;
|
||||
#endif
|
||||
static int __initdata raid_autopart;
|
||||
|
||||
static struct {
|
||||
static struct md_setup_args {
|
||||
int minor;
|
||||
int partitioned;
|
||||
int level;
|
||||
@ -126,22 +126,20 @@ static inline int create_dev(char *name, dev_t dev)
|
||||
return ksys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
|
||||
}
|
||||
|
||||
static void __init md_setup_drive(void)
|
||||
static void __init md_setup_drive(struct md_setup_args *args)
|
||||
{
|
||||
int minor, i, ent, partitioned;
|
||||
int minor, i, partitioned;
|
||||
dev_t dev;
|
||||
dev_t devices[MD_SB_DISKS+1];
|
||||
|
||||
for (ent = 0; ent < md_setup_ents ; ent++) {
|
||||
int fd;
|
||||
int err = 0;
|
||||
char *devname;
|
||||
mdu_disk_info_t dinfo;
|
||||
char name[16];
|
||||
|
||||
minor = md_setup_args[ent].minor;
|
||||
partitioned = md_setup_args[ent].partitioned;
|
||||
devname = md_setup_args[ent].device_names;
|
||||
minor = args->minor;
|
||||
partitioned = args->partitioned;
|
||||
devname = args->device_names;
|
||||
|
||||
sprintf(name, "/dev/md%s%d", partitioned?"_d":"", minor);
|
||||
if (partitioned)
|
||||
@ -162,8 +160,7 @@ static void __init md_setup_drive(void)
|
||||
if (strncmp(devname, "/dev/", 5) == 0)
|
||||
devname += 5;
|
||||
snprintf(comp_name, 63, "/dev/%s", devname);
|
||||
if (vfs_stat(comp_name, &stat) == 0 &&
|
||||
S_ISBLK(stat.mode))
|
||||
if (vfs_stat(comp_name, &stat) == 0 && S_ISBLK(stat.mode))
|
||||
dev = new_decode_dev(stat.rdev);
|
||||
if (!dev) {
|
||||
printk(KERN_WARNING "md: Unknown device name: %s\n", devname);
|
||||
@ -171,36 +168,35 @@ static void __init md_setup_drive(void)
|
||||
}
|
||||
|
||||
devices[i] = dev;
|
||||
|
||||
devname = p;
|
||||
}
|
||||
devices[i] = 0;
|
||||
|
||||
if (!i)
|
||||
continue;
|
||||
return;
|
||||
|
||||
printk(KERN_INFO "md: Loading md%s%d: %s\n",
|
||||
partitioned ? "_d" : "", minor,
|
||||
md_setup_args[ent].device_names);
|
||||
args->device_names);
|
||||
|
||||
fd = ksys_open(name, 0, 0);
|
||||
if (fd < 0) {
|
||||
printk(KERN_ERR "md: open failed - cannot start "
|
||||
"array %s\n", name);
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
if (ksys_ioctl(fd, SET_ARRAY_INFO, 0) == -EBUSY) {
|
||||
printk(KERN_WARNING
|
||||
"md: Ignoring md=%d, already autodetected. (Use raid=noautodetect)\n",
|
||||
minor);
|
||||
ksys_close(fd);
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
if (md_setup_args[ent].level != LEVEL_NONE) {
|
||||
if (args->level != LEVEL_NONE) {
|
||||
/* non-persistent */
|
||||
mdu_array_info_t ainfo;
|
||||
ainfo.level = md_setup_args[ent].level;
|
||||
ainfo.level = args->level;
|
||||
ainfo.size = 0;
|
||||
ainfo.nr_disks =0;
|
||||
ainfo.raid_disks =0;
|
||||
@ -211,7 +207,7 @@ static void __init md_setup_drive(void)
|
||||
|
||||
ainfo.state = (1 << MD_SB_CLEAN);
|
||||
ainfo.layout = 0;
|
||||
ainfo.chunk_size = md_setup_args[ent].chunk;
|
||||
ainfo.chunk_size = args->chunk;
|
||||
err = ksys_ioctl(fd, SET_ARRAY_INFO, (long)&ainfo);
|
||||
for (i = 0; !err && i <= MD_SB_DISKS; i++) {
|
||||
dev = devices[i];
|
||||
@ -242,7 +238,6 @@ static void __init md_setup_drive(void)
|
||||
printk(KERN_WARNING "md: starting md%d failed\n", minor);
|
||||
ksys_close(fd);
|
||||
}
|
||||
}
|
||||
|
||||
static int __init raid_setup(char *str)
|
||||
{
|
||||
@ -289,11 +284,15 @@ static void __init autodetect_raid(void)
|
||||
|
||||
void __init md_run_setup(void)
|
||||
{
|
||||
int ent;
|
||||
|
||||
create_dev("/dev/md0", MKDEV(MD_MAJOR, 0));
|
||||
|
||||
if (raid_noautodetect)
|
||||
printk(KERN_INFO "md: Skipping autodetection of RAID arrays. (raid=autodetect will force)\n");
|
||||
else
|
||||
autodetect_raid();
|
||||
md_setup_drive();
|
||||
|
||||
for (ent = 0; ent < md_setup_ents; ent++)
|
||||
md_setup_drive(&md_setup_args[ent]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user