Commit 2604b703 authored by NeilBrown's avatar NeilBrown Committed by Linus Torvalds

[PATCH] md: remove personality numbering from md

md supports multiple different RAID level, each being implemented by a
'personality' (which is often in a separate module).

These personalities have fairly artificial 'numbers'.  The numbers
are use to:
 1- provide an index into an array where the various personalities
    are recorded
 2- identify the module (via an alias) which implements are particular
    personality.

Neither of these uses really justify the existence of personality numbers.
The array can be replaced by a linked list which is searched (array lookup
only happens very rarely).  Module identification can be done using an alias
based on level rather than 'personality' number.

The current 'raid5' modules support two level (4 and 5) but only one
personality.  This slight awkwardness (which was handled in the mapping from
level to personality) can be better handled by allowing raid5 to register 2
personalities.

With this change in place, the core md module does not need to have an
exhaustive list of all possible personalities, so other personalities can be
added independently.

This patch also moves the check for chunksize being non-zero into the ->run
routines for the personalities that need it, rather than having it in core-md.
 This has a side effect of allowing 'faulty' and 'linear' not to have a
chunk-size set.
Signed-off-by: default avatarNeil Brown <neilb@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent a24a8dd8
...@@ -316,9 +316,10 @@ static int stop(mddev_t *mddev) ...@@ -316,9 +316,10 @@ static int stop(mddev_t *mddev)
return 0; return 0;
} }
static mdk_personality_t faulty_personality = static struct mdk_personality faulty_personality =
{ {
.name = "faulty", .name = "faulty",
.level = LEVEL_FAULTY,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.make_request = make_request, .make_request = make_request,
.run = run, .run = run,
...@@ -329,15 +330,16 @@ static mdk_personality_t faulty_personality = ...@@ -329,15 +330,16 @@ static mdk_personality_t faulty_personality =
static int __init raid_init(void) static int __init raid_init(void)
{ {
return register_md_personality(FAULTY, &faulty_personality); return register_md_personality(&faulty_personality);
} }
static void raid_exit(void) static void raid_exit(void)
{ {
unregister_md_personality(FAULTY); unregister_md_personality(&faulty_personality);
} }
module_init(raid_init); module_init(raid_init);
module_exit(raid_exit); module_exit(raid_exit);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS("md-personality-10"); /* faulty */ MODULE_ALIAS("md-personality-10"); /* faulty */
MODULE_ALIAS("md-level--5");
...@@ -351,9 +351,10 @@ static void linear_status (struct seq_file *seq, mddev_t *mddev) ...@@ -351,9 +351,10 @@ static void linear_status (struct seq_file *seq, mddev_t *mddev)
} }
static mdk_personality_t linear_personality= static struct mdk_personality linear_personality =
{ {
.name = "linear", .name = "linear",
.level = LEVEL_LINEAR,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.make_request = linear_make_request, .make_request = linear_make_request,
.run = linear_run, .run = linear_run,
...@@ -363,16 +364,17 @@ static mdk_personality_t linear_personality= ...@@ -363,16 +364,17 @@ static mdk_personality_t linear_personality=
static int __init linear_init (void) static int __init linear_init (void)
{ {
return register_md_personality (LINEAR, &linear_personality); return register_md_personality (&linear_personality);
} }
static void linear_exit (void) static void linear_exit (void)
{ {
unregister_md_personality (LINEAR); unregister_md_personality (&linear_personality);
} }
module_init(linear_init); module_init(linear_init);
module_exit(linear_exit); module_exit(linear_exit);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS("md-personality-1"); /* LINEAR */ MODULE_ALIAS("md-personality-1"); /* LINEAR - degrecated*/
MODULE_ALIAS("md-level--1");
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
static void autostart_arrays (int part); static void autostart_arrays (int part);
#endif #endif
static mdk_personality_t *pers[MAX_PERSONALITY]; static LIST_HEAD(pers_list);
static DEFINE_SPINLOCK(pers_lock); static DEFINE_SPINLOCK(pers_lock);
/* /*
...@@ -303,6 +303,15 @@ static mdk_rdev_t * find_rdev(mddev_t * mddev, dev_t dev) ...@@ -303,6 +303,15 @@ static mdk_rdev_t * find_rdev(mddev_t * mddev, dev_t dev)
return NULL; return NULL;
} }
static struct mdk_personality *find_pers(int level)
{
struct mdk_personality *pers;
list_for_each_entry(pers, &pers_list, list)
if (pers->level == level)
return pers;
return NULL;
}
static inline sector_t calc_dev_sboffset(struct block_device *bdev) static inline sector_t calc_dev_sboffset(struct block_device *bdev)
{ {
sector_t size = bdev->bd_inode->i_size >> BLOCK_SIZE_BITS; sector_t size = bdev->bd_inode->i_size >> BLOCK_SIZE_BITS;
...@@ -1744,7 +1753,7 @@ static void analyze_sbs(mddev_t * mddev) ...@@ -1744,7 +1753,7 @@ static void analyze_sbs(mddev_t * mddev)
static ssize_t static ssize_t
level_show(mddev_t *mddev, char *page) level_show(mddev_t *mddev, char *page)
{ {
mdk_personality_t *p = mddev->pers; struct mdk_personality *p = mddev->pers;
if (p == NULL && mddev->raid_disks == 0) if (p == NULL && mddev->raid_disks == 0)
return 0; return 0;
if (mddev->level >= 0) if (mddev->level >= 0)
...@@ -1960,11 +1969,12 @@ static int start_dirty_degraded; ...@@ -1960,11 +1969,12 @@ static int start_dirty_degraded;
static int do_md_run(mddev_t * mddev) static int do_md_run(mddev_t * mddev)
{ {
int pnum, err; int err;
int chunk_size; int chunk_size;
struct list_head *tmp; struct list_head *tmp;
mdk_rdev_t *rdev; mdk_rdev_t *rdev;
struct gendisk *disk; struct gendisk *disk;
struct mdk_personality *pers;
char b[BDEVNAME_SIZE]; char b[BDEVNAME_SIZE];
if (list_empty(&mddev->disks)) if (list_empty(&mddev->disks))
...@@ -1981,20 +1991,8 @@ static int do_md_run(mddev_t * mddev) ...@@ -1981,20 +1991,8 @@ static int do_md_run(mddev_t * mddev)
analyze_sbs(mddev); analyze_sbs(mddev);
chunk_size = mddev->chunk_size; chunk_size = mddev->chunk_size;
pnum = level_to_pers(mddev->level);
if ((pnum != MULTIPATH) && (pnum != RAID1)) { if (chunk_size) {
if (!chunk_size) {
/*
* 'default chunksize' in the old md code used to
* be PAGE_SIZE, baaad.
* we abort here to be on the safe side. We don't
* want to continue the bad practice.
*/
printk(KERN_ERR
"no chunksize specified, see 'man raidtab'\n");
return -EINVAL;
}
if (chunk_size > MAX_CHUNK_SIZE) { if (chunk_size > MAX_CHUNK_SIZE) {
printk(KERN_ERR "too big chunk_size: %d > %d\n", printk(KERN_ERR "too big chunk_size: %d > %d\n",
chunk_size, MAX_CHUNK_SIZE); chunk_size, MAX_CHUNK_SIZE);
...@@ -2030,10 +2028,7 @@ static int do_md_run(mddev_t * mddev) ...@@ -2030,10 +2028,7 @@ static int do_md_run(mddev_t * mddev)
} }
#ifdef CONFIG_KMOD #ifdef CONFIG_KMOD
if (!pers[pnum]) request_module("md-level-%d", mddev->level);
{
request_module("md-personality-%d", pnum);
}
#endif #endif
/* /*
...@@ -2055,14 +2050,14 @@ static int do_md_run(mddev_t * mddev) ...@@ -2055,14 +2050,14 @@ static int do_md_run(mddev_t * mddev)
return -ENOMEM; return -ENOMEM;
spin_lock(&pers_lock); spin_lock(&pers_lock);
if (!pers[pnum] || !try_module_get(pers[pnum]->owner)) { pers = find_pers(mddev->level);
if (!pers || !try_module_get(pers->owner)) {
spin_unlock(&pers_lock); spin_unlock(&pers_lock);
printk(KERN_WARNING "md: personality %d is not loaded!\n", printk(KERN_WARNING "md: personality for level %d is not loaded!\n",
pnum); mddev->level);
return -EINVAL; return -EINVAL;
} }
mddev->pers = pers;
mddev->pers = pers[pnum];
spin_unlock(&pers_lock); spin_unlock(&pers_lock);
mddev->recovery = 0; mddev->recovery = 0;
...@@ -3701,15 +3696,14 @@ static int md_seq_show(struct seq_file *seq, void *v) ...@@ -3701,15 +3696,14 @@ static int md_seq_show(struct seq_file *seq, void *v)
struct list_head *tmp2; struct list_head *tmp2;
mdk_rdev_t *rdev; mdk_rdev_t *rdev;
struct mdstat_info *mi = seq->private; struct mdstat_info *mi = seq->private;
int i;
struct bitmap *bitmap; struct bitmap *bitmap;
if (v == (void*)1) { if (v == (void*)1) {
struct mdk_personality *pers;
seq_printf(seq, "Personalities : "); seq_printf(seq, "Personalities : ");
spin_lock(&pers_lock); spin_lock(&pers_lock);
for (i = 0; i < MAX_PERSONALITY; i++) list_for_each_entry(pers, &pers_list, list)
if (pers[i]) seq_printf(seq, "[%s] ", pers->name);
seq_printf(seq, "[%s] ", pers[i]->name);
spin_unlock(&pers_lock); spin_unlock(&pers_lock);
seq_printf(seq, "\n"); seq_printf(seq, "\n");
...@@ -3870,35 +3864,20 @@ static struct file_operations md_seq_fops = { ...@@ -3870,35 +3864,20 @@ static struct file_operations md_seq_fops = {
.poll = mdstat_poll, .poll = mdstat_poll,
}; };
int register_md_personality(int pnum, mdk_personality_t *p) int register_md_personality(struct mdk_personality *p)
{ {
if (pnum >= MAX_PERSONALITY) {
printk(KERN_ERR
"md: tried to install personality %s as nr %d, but max is %lu\n",
p->name, pnum, MAX_PERSONALITY-1);
return -EINVAL;
}
spin_lock(&pers_lock); spin_lock(&pers_lock);
if (pers[pnum]) { list_add_tail(&p->list, &pers_list);
spin_unlock(&pers_lock); printk(KERN_INFO "md: %s personality registered for level %d\n", p->name, p->level);
return -EBUSY;
}
pers[pnum] = p;
printk(KERN_INFO "md: %s personality registered as nr %d\n", p->name, pnum);
spin_unlock(&pers_lock); spin_unlock(&pers_lock);
return 0; return 0;
} }
int unregister_md_personality(int pnum) int unregister_md_personality(struct mdk_personality *p)
{ {
if (pnum >= MAX_PERSONALITY) printk(KERN_INFO "md: %s personality unregistered\n", p->name);
return -EINVAL;
printk(KERN_INFO "md: %s personality unregistered\n", pers[pnum]->name);
spin_lock(&pers_lock); spin_lock(&pers_lock);
pers[pnum] = NULL; list_del_init(&p->list);
spin_unlock(&pers_lock); spin_unlock(&pers_lock);
return 0; return 0;
} }
......
...@@ -35,9 +35,6 @@ ...@@ -35,9 +35,6 @@
#define NR_RESERVED_BUFS 32 #define NR_RESERVED_BUFS 32
static mdk_personality_t multipath_personality;
static void *mp_pool_alloc(gfp_t gfp_flags, void *data) static void *mp_pool_alloc(gfp_t gfp_flags, void *data)
{ {
struct multipath_bh *mpb; struct multipath_bh *mpb;
...@@ -553,9 +550,10 @@ static int multipath_stop (mddev_t *mddev) ...@@ -553,9 +550,10 @@ static int multipath_stop (mddev_t *mddev)
return 0; return 0;
} }
static mdk_personality_t multipath_personality= static struct mdk_personality multipath_personality =
{ {
.name = "multipath", .name = "multipath",
.level = LEVEL_MULTIPATH,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.make_request = multipath_make_request, .make_request = multipath_make_request,
.run = multipath_run, .run = multipath_run,
...@@ -568,15 +566,16 @@ static mdk_personality_t multipath_personality= ...@@ -568,15 +566,16 @@ static mdk_personality_t multipath_personality=
static int __init multipath_init (void) static int __init multipath_init (void)
{ {
return register_md_personality (MULTIPATH, &multipath_personality); return register_md_personality (&multipath_personality);
} }
static void __exit multipath_exit (void) static void __exit multipath_exit (void)
{ {
unregister_md_personality (MULTIPATH); unregister_md_personality (&multipath_personality);
} }
module_init(multipath_init); module_init(multipath_init);
module_exit(multipath_exit); module_exit(multipath_exit);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS("md-personality-7"); /* MULTIPATH */ MODULE_ALIAS("md-personality-7"); /* MULTIPATH */
MODULE_ALIAS("md-level--4");
...@@ -275,7 +275,11 @@ static int raid0_run (mddev_t *mddev) ...@@ -275,7 +275,11 @@ static int raid0_run (mddev_t *mddev)
mdk_rdev_t *rdev; mdk_rdev_t *rdev;
struct list_head *tmp; struct list_head *tmp;
printk("%s: setting max_sectors to %d, segment boundary to %d\n", if (mddev->chunk_size == 0) {
printk(KERN_ERR "md/raid0: non-zero chunk size required.\n");
return -EINVAL;
}
printk(KERN_INFO "%s: setting max_sectors to %d, segment boundary to %d\n",
mdname(mddev), mdname(mddev),
mddev->chunk_size >> 9, mddev->chunk_size >> 9,
(mddev->chunk_size>>1)-1); (mddev->chunk_size>>1)-1);
...@@ -507,9 +511,10 @@ static void raid0_status (struct seq_file *seq, mddev_t *mddev) ...@@ -507,9 +511,10 @@ static void raid0_status (struct seq_file *seq, mddev_t *mddev)
return; return;
} }
static mdk_personality_t raid0_personality= static struct mdk_personality raid0_personality=
{ {
.name = "raid0", .name = "raid0",
.level = 0,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.make_request = raid0_make_request, .make_request = raid0_make_request,
.run = raid0_run, .run = raid0_run,
...@@ -519,15 +524,16 @@ static mdk_personality_t raid0_personality= ...@@ -519,15 +524,16 @@ static mdk_personality_t raid0_personality=
static int __init raid0_init (void) static int __init raid0_init (void)
{ {
return register_md_personality (RAID0, &raid0_personality); return register_md_personality (&raid0_personality);
} }
static void raid0_exit (void) static void raid0_exit (void)
{ {
unregister_md_personality (RAID0); unregister_md_personality (&raid0_personality);
} }
module_init(raid0_init); module_init(raid0_init);
module_exit(raid0_exit); module_exit(raid0_exit);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS("md-personality-2"); /* RAID0 */ MODULE_ALIAS("md-personality-2"); /* RAID0 */
MODULE_ALIAS("md-level-0");
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
*/ */
#define NR_RAID1_BIOS 256 #define NR_RAID1_BIOS 256
static mdk_personality_t raid1_personality;
static void unplug_slaves(mddev_t *mddev); static void unplug_slaves(mddev_t *mddev);
...@@ -2036,9 +2035,10 @@ static void raid1_quiesce(mddev_t *mddev, int state) ...@@ -2036,9 +2035,10 @@ static void raid1_quiesce(mddev_t *mddev, int state)
} }
static mdk_personality_t raid1_personality = static struct mdk_personality raid1_personality =
{ {
.name = "raid1", .name = "raid1",
.level = 1,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.make_request = make_request, .make_request = make_request,
.run = run, .run = run,
...@@ -2056,15 +2056,16 @@ static mdk_personality_t raid1_personality = ...@@ -2056,15 +2056,16 @@ static mdk_personality_t raid1_personality =
static int __init raid_init(void) static int __init raid_init(void)
{ {
return register_md_personality(RAID1, &raid1_personality); return register_md_personality(&raid1_personality);
} }
static void raid_exit(void) static void raid_exit(void)
{ {
unregister_md_personality(RAID1); unregister_md_personality(&raid1_personality);
} }
module_init(raid_init); module_init(raid_init);
module_exit(raid_exit); module_exit(raid_exit);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS("md-personality-3"); /* RAID1 */ MODULE_ALIAS("md-personality-3"); /* RAID1 */
MODULE_ALIAS("md-level-1");
...@@ -1883,11 +1883,11 @@ static int run(mddev_t *mddev) ...@@ -1883,11 +1883,11 @@ static int run(mddev_t *mddev)
int nc, fc; int nc, fc;
sector_t stride, size; sector_t stride, size;
if (mddev->level != 10) { if (mddev->chunk_size == 0) {
printk(KERN_ERR "raid10: %s: raid level not set correctly... (%d)\n", printk(KERN_ERR "md/raid10: non-zero chunk size required.\n");
mdname(mddev), mddev->level); return -EINVAL;
goto out;
} }
nc = mddev->layout & 255; nc = mddev->layout & 255;
fc = (mddev->layout >> 8) & 255; fc = (mddev->layout >> 8) & 255;
if ((nc*fc) <2 || (nc*fc) > mddev->raid_disks || if ((nc*fc) <2 || (nc*fc) > mddev->raid_disks ||
...@@ -2072,9 +2072,10 @@ static void raid10_quiesce(mddev_t *mddev, int state) ...@@ -2072,9 +2072,10 @@ static void raid10_quiesce(mddev_t *mddev, int state)
} }
} }
static mdk_personality_t raid10_personality = static struct mdk_personality raid10_personality =
{ {
.name = "raid10", .name = "raid10",
.level = 10,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.make_request = make_request, .make_request = make_request,
.run = run, .run = run,
...@@ -2090,15 +2091,16 @@ static mdk_personality_t raid10_personality = ...@@ -2090,15 +2091,16 @@ static mdk_personality_t raid10_personality =
static int __init raid_init(void) static int __init raid_init(void)
{ {
return register_md_personality(RAID10, &raid10_personality); return register_md_personality(&raid10_personality);
} }
static void raid_exit(void) static void raid_exit(void)
{ {
unregister_md_personality(RAID10); unregister_md_personality(&raid10_personality);
} }
module_init(raid_init); module_init(raid_init);
module_exit(raid_exit); module_exit(raid_exit);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS("md-personality-9"); /* RAID10 */ MODULE_ALIAS("md-personality-9"); /* RAID10 */
MODULE_ALIAS("md-level-10");
...@@ -2187,9 +2187,10 @@ static void raid5_quiesce(mddev_t *mddev, int state) ...@@ -2187,9 +2187,10 @@ static void raid5_quiesce(mddev_t *mddev, int state)
} }
} }
static mdk_personality_t raid5_personality= static struct mdk_personality raid5_personality =
{ {
.name = "raid5", .name = "raid5",
.level = 5,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.make_request = make_request, .make_request = make_request,
.run = run, .run = run,
...@@ -2204,17 +2205,40 @@ static mdk_personality_t raid5_personality= ...@@ -2204,17 +2205,40 @@ static mdk_personality_t raid5_personality=
.quiesce = raid5_quiesce, .quiesce = raid5_quiesce,
}; };
static int __init raid5_init (void) static struct mdk_personality raid4_personality =
{ {
return register_md_personality (RAID5, &raid5_personality); .name = "raid4",
.level = 4,
.owner = THIS_MODULE,
.make_request = make_request,
.run = run,
.stop = stop,
.status = status,
.error_handler = error,
.hot_add_disk = raid5_add_disk,
.hot_remove_disk= raid5_remove_disk,
.spare_active = raid5_spare_active,
.sync_request = sync_request,
.resize = raid5_resize,
.quiesce = raid5_quiesce,
};
static int __init raid5_init(void)
{
register_md_personality(&raid5_personality);
register_md_personality(&raid4_personality);
return 0;
} }
static void raid5_exit (void) static void raid5_exit(void)
{ {
unregister_md_personality (RAID5); unregister_md_personality(&raid5_personality);
unregister_md_personality(&raid4_personality);
} }
module_init(raid5_init); module_init(raid5_init);
module_exit(raid5_exit); module_exit(raid5_exit);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS("md-personality-4"); /* RAID5 */ MODULE_ALIAS("md-personality-4"); /* RAID5 */
MODULE_ALIAS("md-level-5");
MODULE_ALIAS("md-level-4");
...@@ -2304,9 +2304,10 @@ static void raid6_quiesce(mddev_t *mddev, int state) ...@@ -2304,9 +2304,10 @@ static void raid6_quiesce(mddev_t *mddev, int state)
} }
} }
static mdk_personality_t raid6_personality= static struct mdk_personality raid6_personality =
{ {
.name = "raid6", .name = "raid6",
.level = 6,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.make_request = make_request, .make_request = make_request,
.run = run, .run = run,
...@@ -2321,7 +2322,7 @@ static mdk_personality_t raid6_personality= ...@@ -2321,7 +2322,7 @@ static mdk_personality_t raid6_personality=
.quiesce = raid6_quiesce, .quiesce = raid6_quiesce,
}; };
static int __init raid6_init (void) static int __init raid6_init(void)
{ {
int e; int e;
...@@ -2329,15 +2330,16 @@ static int __init raid6_init (void) ...@@ -2329,15 +2330,16 @@ static int __init raid6_init (void)
if ( e ) if ( e )
return e; return e;
return register_md_personality (RAID6, &raid6_personality); return register_md_personality(&raid6_personality);
} }
static void raid6_exit (void) static void raid6_exit (void)
{ {
unregister_md_personality (RAID6); unregister_md_personality(&raid6_personality);
} }
module_init(raid6_init); module_init(raid6_init);
module_exit(raid6_exit); module_exit(raid6_exit);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS("md-personality-8"); /* RAID6 */ MODULE_ALIAS("md-personality-8"); /* RAID6 */
MODULE_ALIAS("md-level-6");
...@@ -71,8 +71,8 @@ ...@@ -71,8 +71,8 @@
*/ */
#define MD_PATCHLEVEL_VERSION 3 #define MD_PATCHLEVEL_VERSION 3
extern int register_md_personality (int p_num, mdk_personality_t *p); extern int register_md_personality (struct mdk_personality *p);
extern int unregister_md_personality (int p_num); extern int unregister_md_personality (struct mdk_personality *p);
extern mdk_thread_t * md_register_thread (void (*run) (mddev_t *mddev), extern mdk_thread_t * md_register_thread (void (*run) (mddev_t *mddev),
mddev_t *mddev, const char *name); mddev_t *mddev, const char *name);
extern void md_unregister_thread (mdk_thread_t *thread); extern void md_unregister_thread (mdk_thread_t *thread);
......
...@@ -18,62 +18,19 @@ ...@@ -18,62 +18,19 @@
/* and dm-bio-list.h is not under include/linux because.... ??? */ /* and dm-bio-list.h is not under include/linux because.... ??? */
#include "../../../drivers/md/dm-bio-list.h" #include "../../../drivers/md/dm-bio-list.h"
#define MD_RESERVED 0UL
#define LINEAR 1UL
#define RAID0 2UL
#define RAID1 3UL
#define RAID5 4UL
#define TRANSLUCENT 5UL
#define HSM 6UL
#define MULTIPATH 7UL
#define RAID6 8UL
#define RAID10 9UL
#define FAULTY 10UL
#define MAX_PERSONALITY 11UL
#define LEVEL_MULTIPATH (-4) #define LEVEL_MULTIPATH (-4)
#define LEVEL_LINEAR (-1) #define LEVEL_LINEAR (-1)
#define LEVEL_FAULTY (-5) #define LEVEL_FAULTY (-5)
/* we need a value for 'no level specified' and 0
* means 'raid0', so we need something else. This is
* for internal use only
*/
#define LEVEL_NONE (-1000000)
#define MaxSector (~(sector_t)0) #define MaxSector (~(sector_t)0)
#define MD_THREAD_NAME_MAX 14 #define MD_THREAD_NAME_MAX 14
static inline int pers_to_level (int pers)
{
switch (pers) {
case FAULTY: return LEVEL_FAULTY;
case MULTIPATH: return LEVEL_MULTIPATH;
case HSM: return -3;
case TRANSLUCENT: return -2;
case LINEAR: return LEVEL_LINEAR;
case RAID0: return 0;
case RAID1: return 1;
case RAID5: return 5;
case RAID6: return 6;
case RAID10: return 10;
}
BUG();
return MD_RESERVED;
}
static inline int level_to_pers (int level)
{
switch (level) {
case LEVEL_FAULTY: return FAULTY;
case LEVEL_MULTIPATH: return MULTIPATH;
case -3: return HSM;
case -2: return TRANSLUCENT;
case LEVEL_LINEAR: return LINEAR;
case 0: return RAID0;
case 1: return RAID1;
case 4:
case 5: return RAID5;
case 6: return RAID6;
case 10: return RAID10;
}
return MD_RESERVED;
}
typedef struct mddev_s mddev_t; typedef struct mddev_s mddev_t;
typedef struct mdk_rdev_s mdk_rdev_t; typedef struct mdk_rdev_s mdk_rdev_t;
...@@ -140,12 +97,10 @@ struct mdk_rdev_s ...@@ -140,12 +97,10 @@ struct mdk_rdev_s
*/ */
}; };
typedef struct mdk_personality_s mdk_personality_t;
struct mddev_s struct mddev_s
{ {
void *private; void *private;
mdk_personality_t *pers; struct mdk_personality *pers;
dev_t unit; dev_t unit;
int md_minor; int md_minor;
struct list_head disks; struct list_head disks;
...@@ -266,9 +221,11 @@ static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sect ...@@ -266,9 +221,11 @@ static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sect
atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io); atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
} }
struct mdk_personality_s struct mdk_personality
{ {
char *name; char *name;
int level;
struct list_head list;
struct module *owner; struct module *owner;
int (*make_request)(request_queue_t *q, struct bio *bio); int (*make_request)(request_queue_t *q, struct bio *bio);
int (*run)(mddev_t *mddev); int (*run)(mddev_t *mddev);
......
...@@ -17,7 +17,7 @@ static int __initdata raid_noautodetect, raid_autopart; ...@@ -17,7 +17,7 @@ static int __initdata raid_noautodetect, raid_autopart;
static struct { static struct {
int minor; int minor;
int partitioned; int partitioned;
int pers; int level;
int chunk; int chunk;
char *device_names; char *device_names;
} md_setup_args[MAX_MD_DEVS] __initdata; } md_setup_args[MAX_MD_DEVS] __initdata;
...@@ -47,7 +47,7 @@ extern int mdp_major; ...@@ -47,7 +47,7 @@ extern int mdp_major;
*/ */
static int __init md_setup(char *str) static int __init md_setup(char *str)
{ {
int minor, level, factor, fault, pers, partitioned = 0; int minor, level, factor, fault, partitioned = 0;
char *pername = ""; char *pername = "";
char *str1; char *str1;
int ent; int ent;
...@@ -78,7 +78,7 @@ static int __init md_setup(char *str) ...@@ -78,7 +78,7 @@ static int __init md_setup(char *str)
} }
if (ent >= md_setup_ents) if (ent >= md_setup_ents)
md_setup_ents++; md_setup_ents++;
switch (get_option(&str, &level)) { /* RAID Personality */ switch (get_option(&str, &level)) { /* RAID level */
case 2: /* could be 0 or -1.. */ case 2: /* could be 0 or -1.. */
if (level == 0 || level == LEVEL_LINEAR) { if (level == 0 || level == LEVEL_LINEAR) {
if (get_option(&str, &factor) != 2 || /* Chunk Size */ if (get_option(&str, &factor) != 2 || /* Chunk Size */
...@@ -86,16 +86,12 @@ static int __init md_setup(char *str) ...@@ -86,16 +86,12 @@ static int __init md_setup(char *str)
printk(KERN_WARNING "md: Too few arguments supplied to md=.\n"); printk(KERN_WARNING "md: Too few arguments supplied to md=.\n");
return 0; return 0;
} }
md_setup_args[ent].pers = level; md_setup_args[ent].level = level;
md_setup_args[ent].chunk = 1 << (factor+12); md_setup_args[ent].chunk = 1 << (factor+12);
if (level == LEVEL_LINEAR) { if (level == LEVEL_LINEAR)
pers = LINEAR;
pername = "linear"; pername = "linear";
} else { else
pers = RAID0;
pername = "raid0"; pername = "raid0";
}
md_setup_args[ent].pers = pers;
break; break;
} }
/* FALL THROUGH */ /* FALL THROUGH */
...@@ -103,7 +99,7 @@ static int __init md_setup(char *str) ...@@ -103,7 +99,7 @@ static int __init md_setup(char *str)
str = str1; str = str1;
/* FALL THROUGH */ /* FALL THROUGH */
case 0: case 0:
md_setup_args[ent].pers = 0; md_setup_args[ent].level = LEVEL_NONE;
pername="super-block"; pername="super-block";
} }
...@@ -190,10 +186,10 @@ static void __init md_setup_drive(void) ...@@ -190,10 +186,10 @@ static void __init md_setup_drive(void)
continue; continue;
} }
if (md_setup_args[ent].pers) { if (md_setup_args[ent].level != LEVEL_NONE) {
/* non-persistent */ /* non-persistent */
mdu_array_info_t ainfo; mdu_array_info_t ainfo;
ainfo.level = pers_to_level(md_setup_args[ent].pers); ainfo.level = md_setup_args[ent].level;
ainfo.size = 0; ainfo.size = 0;
ainfo.nr_disks =0; ainfo.nr_disks =0;
ainfo.raid_disks =0; ainfo.raid_disks =0;
......
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