diff options
author | NeilBrown <neilb@suse.de> | 2006-01-06 03:20:36 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-06 11:34:06 -0500 |
commit | 2604b703b6b3db80e3c75ce472a54dfd0b7bf9f4 (patch) | |
tree | 8c0e985c455ff35af24fbe60d8a3f5a276034370 /include | |
parent | a24a8dd858e0ba50f06a9fd8f61fe8c4fe7a8d8e (diff) |
[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: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/raid/md.h | 4 | ||||
-rw-r--r-- | include/linux/raid/md_k.h | 63 |
2 files changed, 12 insertions, 55 deletions
diff --git a/include/linux/raid/md.h b/include/linux/raid/md.h index 13e7c4b62367..b6e0bcad84e1 100644 --- a/include/linux/raid/md.h +++ b/include/linux/raid/md.h | |||
@@ -71,8 +71,8 @@ | |||
71 | */ | 71 | */ |
72 | #define MD_PATCHLEVEL_VERSION 3 | 72 | #define MD_PATCHLEVEL_VERSION 3 |
73 | 73 | ||
74 | extern int register_md_personality (int p_num, mdk_personality_t *p); | 74 | extern int register_md_personality (struct mdk_personality *p); |
75 | extern int unregister_md_personality (int p_num); | 75 | extern int unregister_md_personality (struct mdk_personality *p); |
76 | extern mdk_thread_t * md_register_thread (void (*run) (mddev_t *mddev), | 76 | extern mdk_thread_t * md_register_thread (void (*run) (mddev_t *mddev), |
77 | mddev_t *mddev, const char *name); | 77 | mddev_t *mddev, const char *name); |
78 | extern void md_unregister_thread (mdk_thread_t *thread); | 78 | extern void md_unregister_thread (mdk_thread_t *thread); |
diff --git a/include/linux/raid/md_k.h b/include/linux/raid/md_k.h index 1dd587b5975a..e559fb701aa1 100644 --- a/include/linux/raid/md_k.h +++ b/include/linux/raid/md_k.h | |||
@@ -18,62 +18,19 @@ | |||
18 | /* and dm-bio-list.h is not under include/linux because.... ??? */ | 18 | /* and dm-bio-list.h is not under include/linux because.... ??? */ |
19 | #include "../../../drivers/md/dm-bio-list.h" | 19 | #include "../../../drivers/md/dm-bio-list.h" |
20 | 20 | ||
21 | #define MD_RESERVED 0UL | ||
22 | #define LINEAR 1UL | ||
23 | #define RAID0 2UL | ||
24 | #define RAID1 3UL | ||
25 | #define RAID5 4UL | ||
26 | #define TRANSLUCENT 5UL | ||
27 | #define HSM 6UL | ||
28 | #define MULTIPATH 7UL | ||
29 | #define RAID6 8UL | ||
30 | #define RAID10 9UL | ||
31 | #define FAULTY 10UL | ||
32 | #define MAX_PERSONALITY 11UL | ||
33 | |||
34 | #define LEVEL_MULTIPATH (-4) | 21 | #define LEVEL_MULTIPATH (-4) |
35 | #define LEVEL_LINEAR (-1) | 22 | #define LEVEL_LINEAR (-1) |
36 | #define LEVEL_FAULTY (-5) | 23 | #define LEVEL_FAULTY (-5) |
37 | 24 | ||
25 | /* we need a value for 'no level specified' and 0 | ||
26 | * means 'raid0', so we need something else. This is | ||
27 | * for internal use only | ||
28 | */ | ||
29 | #define LEVEL_NONE (-1000000) | ||
30 | |||
38 | #define MaxSector (~(sector_t)0) | 31 | #define MaxSector (~(sector_t)0) |
39 | #define MD_THREAD_NAME_MAX 14 | 32 | #define MD_THREAD_NAME_MAX 14 |
40 | 33 | ||
41 | static inline int pers_to_level (int pers) | ||
42 | { | ||
43 | switch (pers) { | ||
44 | case FAULTY: return LEVEL_FAULTY; | ||
45 | case MULTIPATH: return LEVEL_MULTIPATH; | ||
46 | case HSM: return -3; | ||
47 | case TRANSLUCENT: return -2; | ||
48 | case LINEAR: return LEVEL_LINEAR; | ||
49 | case RAID0: return 0; | ||
50 | case RAID1: return 1; | ||
51 | case RAID5: return 5; | ||
52 | case RAID6: return 6; | ||
53 | case RAID10: return 10; | ||
54 | } | ||
55 | BUG(); | ||
56 | return MD_RESERVED; | ||
57 | } | ||
58 | |||
59 | static inline int level_to_pers (int level) | ||
60 | { | ||
61 | switch (level) { | ||
62 | case LEVEL_FAULTY: return FAULTY; | ||
63 | case LEVEL_MULTIPATH: return MULTIPATH; | ||
64 | case -3: return HSM; | ||
65 | case -2: return TRANSLUCENT; | ||
66 | case LEVEL_LINEAR: return LINEAR; | ||
67 | case 0: return RAID0; | ||
68 | case 1: return RAID1; | ||
69 | case 4: | ||
70 | case 5: return RAID5; | ||
71 | case 6: return RAID6; | ||
72 | case 10: return RAID10; | ||
73 | } | ||
74 | return MD_RESERVED; | ||
75 | } | ||
76 | |||
77 | typedef struct mddev_s mddev_t; | 34 | typedef struct mddev_s mddev_t; |
78 | typedef struct mdk_rdev_s mdk_rdev_t; | 35 | typedef struct mdk_rdev_s mdk_rdev_t; |
79 | 36 | ||
@@ -140,12 +97,10 @@ struct mdk_rdev_s | |||
140 | */ | 97 | */ |
141 | }; | 98 | }; |
142 | 99 | ||
143 | typedef struct mdk_personality_s mdk_personality_t; | ||
144 | |||
145 | struct mddev_s | 100 | struct mddev_s |
146 | { | 101 | { |
147 | void *private; | 102 | void *private; |
148 | mdk_personality_t *pers; | 103 | struct mdk_personality *pers; |
149 | dev_t unit; | 104 | dev_t unit; |
150 | int md_minor; | 105 | int md_minor; |
151 | struct list_head disks; | 106 | struct list_head disks; |
@@ -266,9 +221,11 @@ static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sect | |||
266 | atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io); | 221 | atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io); |
267 | } | 222 | } |
268 | 223 | ||
269 | struct mdk_personality_s | 224 | struct mdk_personality |
270 | { | 225 | { |
271 | char *name; | 226 | char *name; |
227 | int level; | ||
228 | struct list_head list; | ||
272 | struct module *owner; | 229 | struct module *owner; |
273 | int (*make_request)(request_queue_t *q, struct bio *bio); | 230 | int (*make_request)(request_queue_t *q, struct bio *bio); |
274 | int (*run)(mddev_t *mddev); | 231 | int (*run)(mddev_t *mddev); |