Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * multipath.c : Multiple Devices driver for Linux | |
3 | * | |
4 | * Copyright (C) 1999, 2000, 2001 Ingo Molnar, Red Hat | |
5 | * | |
6 | * Copyright (C) 1996, 1997, 1998 Ingo Molnar, Miguel de Icaza, Gadi Oxman | |
7 | * | |
8 | * MULTIPATH management functions. | |
9 | * | |
10 | * derived from raid1.c. | |
11 | * | |
12 | * This program is free software; you can redistribute it and/or modify | |
13 | * it under the terms of the GNU General Public License as published by | |
14 | * the Free Software Foundation; either version 2, or (at your option) | |
15 | * any later version. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * (for example /usr/src/linux/COPYING); if not, write to the Free | |
19 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
20 | */ | |
21 | ||
bff61975 | 22 | #include <linux/blkdev.h> |
056075c7 | 23 | #include <linux/module.h> |
bff61975 | 24 | #include <linux/raid/md_u.h> |
bff61975 | 25 | #include <linux/seq_file.h> |
5a0e3ad6 | 26 | #include <linux/slab.h> |
43b2e5d8 | 27 | #include "md.h" |
ef740c37 | 28 | #include "multipath.h" |
1da177e4 LT |
29 | |
30 | #define MAX_WORK_PER_DISK 128 | |
31 | ||
32 | #define NR_RESERVED_BUFS 32 | |
33 | ||
69724e28 | 34 | static int multipath_map (struct mpconf *conf) |
1da177e4 LT |
35 | { |
36 | int i, disks = conf->raid_disks; | |
37 | ||
38 | /* | |
f72ffdd6 | 39 | * Later we do read balancing on the read side |
1da177e4 LT |
40 | * now we use the first available disk. |
41 | */ | |
42 | ||
43 | rcu_read_lock(); | |
44 | for (i = 0; i < disks; i++) { | |
3cb03002 | 45 | struct md_rdev *rdev = rcu_dereference(conf->multipaths[i].rdev); |
f5b67ae8 N |
46 | if (rdev && test_bit(In_sync, &rdev->flags) && |
47 | !test_bit(Faulty, &rdev->flags)) { | |
1da177e4 LT |
48 | atomic_inc(&rdev->nr_pending); |
49 | rcu_read_unlock(); | |
50 | return i; | |
51 | } | |
52 | } | |
53 | rcu_read_unlock(); | |
54 | ||
55 | printk(KERN_ERR "multipath_map(): no more operational IO paths?\n"); | |
56 | return (-1); | |
57 | } | |
58 | ||
59 | static void multipath_reschedule_retry (struct multipath_bh *mp_bh) | |
60 | { | |
61 | unsigned long flags; | |
fd01b88c | 62 | struct mddev *mddev = mp_bh->mddev; |
69724e28 | 63 | struct mpconf *conf = mddev->private; |
1da177e4 LT |
64 | |
65 | spin_lock_irqsave(&conf->device_lock, flags); | |
66 | list_add(&mp_bh->retry_list, &conf->retry_list); | |
67 | spin_unlock_irqrestore(&conf->device_lock, flags); | |
68 | md_wakeup_thread(mddev->thread); | |
69 | } | |
70 | ||
1da177e4 LT |
71 | /* |
72 | * multipath_end_bh_io() is called when we have finished servicing a multipathed | |
73 | * operation and are ready to return a success/failure code to the buffer | |
74 | * cache layer. | |
75 | */ | |
76 | static void multipath_end_bh_io (struct multipath_bh *mp_bh, int err) | |
77 | { | |
78 | struct bio *bio = mp_bh->master_bio; | |
69724e28 | 79 | struct mpconf *conf = mp_bh->mddev->private; |
1da177e4 | 80 | |
4246a0b6 CH |
81 | bio->bi_error = err; |
82 | bio_endio(bio); | |
1da177e4 LT |
83 | mempool_free(mp_bh, conf->pool); |
84 | } | |
85 | ||
4246a0b6 | 86 | static void multipath_end_request(struct bio *bio) |
1da177e4 | 87 | { |
7b92813c | 88 | struct multipath_bh *mp_bh = bio->bi_private; |
69724e28 | 89 | struct mpconf *conf = mp_bh->mddev->private; |
3cb03002 | 90 | struct md_rdev *rdev = conf->multipaths[mp_bh->path].rdev; |
1da177e4 | 91 | |
4246a0b6 | 92 | if (!bio->bi_error) |
1da177e4 | 93 | multipath_end_bh_io(mp_bh, 0); |
7b6d91da | 94 | else if (!(bio->bi_rw & REQ_RAHEAD)) { |
1da177e4 LT |
95 | /* |
96 | * oops, IO error: | |
97 | */ | |
98 | char b[BDEVNAME_SIZE]; | |
99 | md_error (mp_bh->mddev, rdev); | |
f72ffdd6 N |
100 | printk(KERN_ERR "multipath: %s: rescheduling sector %llu\n", |
101 | bdevname(rdev->bdev,b), | |
4f024f37 | 102 | (unsigned long long)bio->bi_iter.bi_sector); |
1da177e4 LT |
103 | multipath_reschedule_retry(mp_bh); |
104 | } else | |
4246a0b6 | 105 | multipath_end_bh_io(mp_bh, bio->bi_error); |
1da177e4 | 106 | rdev_dec_pending(rdev, conf->mddev); |
1da177e4 LT |
107 | } |
108 | ||
b4fdcb02 | 109 | static void multipath_make_request(struct mddev *mddev, struct bio * bio) |
1da177e4 | 110 | { |
69724e28 | 111 | struct mpconf *conf = mddev->private; |
1da177e4 LT |
112 | struct multipath_bh * mp_bh; |
113 | struct multipath_info *multipath; | |
114 | ||
e9c7469b TH |
115 | if (unlikely(bio->bi_rw & REQ_FLUSH)) { |
116 | md_flush_request(mddev, bio); | |
5a7bbad2 | 117 | return; |
e5dcdd80 N |
118 | } |
119 | ||
1da177e4 LT |
120 | mp_bh = mempool_alloc(conf->pool, GFP_NOIO); |
121 | ||
122 | mp_bh->master_bio = bio; | |
123 | mp_bh->mddev = mddev; | |
124 | ||
1da177e4 LT |
125 | mp_bh->path = multipath_map(conf); |
126 | if (mp_bh->path < 0) { | |
4246a0b6 | 127 | bio_io_error(bio); |
1da177e4 | 128 | mempool_free(mp_bh, conf->pool); |
5a7bbad2 | 129 | return; |
1da177e4 LT |
130 | } |
131 | multipath = conf->multipaths + mp_bh->path; | |
132 | ||
fafcde3a ML |
133 | bio_init(&mp_bh->bio); |
134 | __bio_clone_fast(&mp_bh->bio, bio); | |
135 | ||
4f024f37 | 136 | mp_bh->bio.bi_iter.bi_sector += multipath->rdev->data_offset; |
1da177e4 | 137 | mp_bh->bio.bi_bdev = multipath->rdev->bdev; |
7b6d91da | 138 | mp_bh->bio.bi_rw |= REQ_FAILFAST_TRANSPORT; |
1da177e4 LT |
139 | mp_bh->bio.bi_end_io = multipath_end_request; |
140 | mp_bh->bio.bi_private = mp_bh; | |
141 | generic_make_request(&mp_bh->bio); | |
5a7bbad2 | 142 | return; |
1da177e4 LT |
143 | } |
144 | ||
40cf2123 | 145 | static void multipath_status(struct seq_file *seq, struct mddev *mddev) |
1da177e4 | 146 | { |
69724e28 | 147 | struct mpconf *conf = mddev->private; |
1da177e4 | 148 | int i; |
f72ffdd6 | 149 | |
1da177e4 | 150 | seq_printf (seq, " [%d/%d] [", conf->raid_disks, |
92f861a7 | 151 | conf->raid_disks - mddev->degraded); |
40cf2123 N |
152 | rcu_read_lock(); |
153 | for (i = 0; i < conf->raid_disks; i++) { | |
154 | struct md_rdev *rdev = rcu_dereference(conf->multipaths[i].rdev); | |
155 | seq_printf (seq, "%s", rdev && test_bit(In_sync, &rdev->flags) ? "U" : "_"); | |
156 | } | |
157 | rcu_read_unlock(); | |
1da177e4 LT |
158 | seq_printf (seq, "]"); |
159 | } | |
160 | ||
5c675f83 | 161 | static int multipath_congested(struct mddev *mddev, int bits) |
0d129228 | 162 | { |
69724e28 | 163 | struct mpconf *conf = mddev->private; |
0d129228 N |
164 | int i, ret = 0; |
165 | ||
166 | rcu_read_lock(); | |
167 | for (i = 0; i < mddev->raid_disks ; i++) { | |
3cb03002 | 168 | struct md_rdev *rdev = rcu_dereference(conf->multipaths[i].rdev); |
0d129228 | 169 | if (rdev && !test_bit(Faulty, &rdev->flags)) { |
165125e1 | 170 | struct request_queue *q = bdev_get_queue(rdev->bdev); |
0d129228 N |
171 | |
172 | ret |= bdi_congested(&q->backing_dev_info, bits); | |
173 | /* Just like multipath_map, we just check the | |
174 | * first available device | |
175 | */ | |
176 | break; | |
177 | } | |
178 | } | |
179 | rcu_read_unlock(); | |
180 | return ret; | |
181 | } | |
1da177e4 LT |
182 | |
183 | /* | |
184 | * Careful, this can execute in IRQ contexts as well! | |
185 | */ | |
fd01b88c | 186 | static void multipath_error (struct mddev *mddev, struct md_rdev *rdev) |
1da177e4 | 187 | { |
69724e28 | 188 | struct mpconf *conf = mddev->private; |
6f8d0c77 | 189 | char b[BDEVNAME_SIZE]; |
1da177e4 | 190 | |
92f861a7 | 191 | if (conf->raid_disks - mddev->degraded <= 1) { |
1da177e4 LT |
192 | /* |
193 | * Uh oh, we can do nothing if this is our last path, but | |
194 | * first check if this is a queued request for a device | |
195 | * which has just failed. | |
196 | */ | |
f72ffdd6 | 197 | printk(KERN_ALERT |
6f8d0c77 | 198 | "multipath: only one IO path left and IO error.\n"); |
1da177e4 | 199 | /* leave it active... it's all we have */ |
6f8d0c77 N |
200 | return; |
201 | } | |
202 | /* | |
203 | * Mark disk as unusable | |
204 | */ | |
205 | if (test_and_clear_bit(In_sync, &rdev->flags)) { | |
206 | unsigned long flags; | |
207 | spin_lock_irqsave(&conf->device_lock, flags); | |
208 | mddev->degraded++; | |
209 | spin_unlock_irqrestore(&conf->device_lock, flags); | |
1da177e4 | 210 | } |
6f8d0c77 N |
211 | set_bit(Faulty, &rdev->flags); |
212 | set_bit(MD_CHANGE_DEVS, &mddev->flags); | |
213 | printk(KERN_ALERT "multipath: IO failure on %s," | |
214 | " disabling IO path.\n" | |
215 | "multipath: Operation continuing" | |
216 | " on %d IO paths.\n", | |
217 | bdevname(rdev->bdev, b), | |
218 | conf->raid_disks - mddev->degraded); | |
1da177e4 LT |
219 | } |
220 | ||
69724e28 | 221 | static void print_multipath_conf (struct mpconf *conf) |
1da177e4 LT |
222 | { |
223 | int i; | |
224 | struct multipath_info *tmp; | |
225 | ||
226 | printk("MULTIPATH conf printout:\n"); | |
227 | if (!conf) { | |
228 | printk("(conf==NULL)\n"); | |
229 | return; | |
230 | } | |
92f861a7 | 231 | printk(" --- wd:%d rd:%d\n", conf->raid_disks - conf->mddev->degraded, |
1da177e4 LT |
232 | conf->raid_disks); |
233 | ||
234 | for (i = 0; i < conf->raid_disks; i++) { | |
235 | char b[BDEVNAME_SIZE]; | |
236 | tmp = conf->multipaths + i; | |
237 | if (tmp->rdev) | |
238 | printk(" disk%d, o:%d, dev:%s\n", | |
b2d444d7 | 239 | i,!test_bit(Faulty, &tmp->rdev->flags), |
1da177e4 LT |
240 | bdevname(tmp->rdev->bdev,b)); |
241 | } | |
242 | } | |
243 | ||
fd01b88c | 244 | static int multipath_add_disk(struct mddev *mddev, struct md_rdev *rdev) |
1da177e4 | 245 | { |
69724e28 | 246 | struct mpconf *conf = mddev->private; |
352d768b | 247 | struct request_queue *q; |
199050ea | 248 | int err = -EEXIST; |
1da177e4 LT |
249 | int path; |
250 | struct multipath_info *p; | |
6c2fce2e NB |
251 | int first = 0; |
252 | int last = mddev->raid_disks - 1; | |
253 | ||
254 | if (rdev->raid_disk >= 0) | |
255 | first = last = rdev->raid_disk; | |
1da177e4 LT |
256 | |
257 | print_multipath_conf(conf); | |
258 | ||
6c2fce2e | 259 | for (path = first; path <= last; path++) |
1da177e4 | 260 | if ((p=conf->multipaths+path)->rdev == NULL) { |
352d768b | 261 | q = rdev->bdev->bd_disk->queue; |
8f6c2e4b MP |
262 | disk_stack_limits(mddev->gendisk, rdev->bdev, |
263 | rdev->data_offset << 9); | |
1da177e4 | 264 | |
1501efad DW |
265 | err = md_integrity_add_rdev(rdev, mddev); |
266 | if (err) | |
267 | break; | |
6f8d0c77 | 268 | spin_lock_irq(&conf->device_lock); |
750a8f3e | 269 | mddev->degraded--; |
1da177e4 | 270 | rdev->raid_disk = path; |
b2d444d7 | 271 | set_bit(In_sync, &rdev->flags); |
6f8d0c77 | 272 | spin_unlock_irq(&conf->device_lock); |
d6065f7b | 273 | rcu_assign_pointer(p->rdev, rdev); |
199050ea NB |
274 | err = 0; |
275 | break; | |
1da177e4 LT |
276 | } |
277 | ||
278 | print_multipath_conf(conf); | |
199050ea NB |
279 | |
280 | return err; | |
1da177e4 LT |
281 | } |
282 | ||
b8321b68 | 283 | static int multipath_remove_disk(struct mddev *mddev, struct md_rdev *rdev) |
1da177e4 | 284 | { |
69724e28 | 285 | struct mpconf *conf = mddev->private; |
1da177e4 | 286 | int err = 0; |
b8321b68 | 287 | int number = rdev->raid_disk; |
1da177e4 LT |
288 | struct multipath_info *p = conf->multipaths + number; |
289 | ||
290 | print_multipath_conf(conf); | |
291 | ||
b8321b68 | 292 | if (rdev == p->rdev) { |
b2d444d7 | 293 | if (test_bit(In_sync, &rdev->flags) || |
1da177e4 | 294 | atomic_read(&rdev->nr_pending)) { |
dfc70645 N |
295 | printk(KERN_ERR "hot-remove-disk, slot %d is identified" |
296 | " but is still operational!\n", number); | |
1da177e4 LT |
297 | err = -EBUSY; |
298 | goto abort; | |
299 | } | |
300 | p->rdev = NULL; | |
fbd568a3 | 301 | synchronize_rcu(); |
1da177e4 LT |
302 | if (atomic_read(&rdev->nr_pending)) { |
303 | /* lost the race, try later */ | |
304 | err = -EBUSY; | |
305 | p->rdev = rdev; | |
ac5e7113 | 306 | goto abort; |
1da177e4 | 307 | } |
a91a2785 | 308 | err = md_integrity_register(mddev); |
1da177e4 LT |
309 | } |
310 | abort: | |
311 | ||
312 | print_multipath_conf(conf); | |
313 | return err; | |
314 | } | |
315 | ||
1da177e4 LT |
316 | /* |
317 | * This is a kernel thread which: | |
318 | * | |
319 | * 1. Retries failed read operations on working multipaths. | |
320 | * 2. Updates the raid superblock when problems encounter. | |
321 | * 3. Performs writes following reads for array syncronising. | |
322 | */ | |
323 | ||
4ed8731d | 324 | static void multipathd(struct md_thread *thread) |
1da177e4 | 325 | { |
4ed8731d | 326 | struct mddev *mddev = thread->mddev; |
1da177e4 LT |
327 | struct multipath_bh *mp_bh; |
328 | struct bio *bio; | |
329 | unsigned long flags; | |
69724e28 | 330 | struct mpconf *conf = mddev->private; |
1da177e4 LT |
331 | struct list_head *head = &conf->retry_list; |
332 | ||
333 | md_check_recovery(mddev); | |
334 | for (;;) { | |
335 | char b[BDEVNAME_SIZE]; | |
336 | spin_lock_irqsave(&conf->device_lock, flags); | |
337 | if (list_empty(head)) | |
338 | break; | |
339 | mp_bh = list_entry(head->prev, struct multipath_bh, retry_list); | |
340 | list_del(head->prev); | |
341 | spin_unlock_irqrestore(&conf->device_lock, flags); | |
342 | ||
343 | bio = &mp_bh->bio; | |
4f024f37 | 344 | bio->bi_iter.bi_sector = mp_bh->master_bio->bi_iter.bi_sector; |
f72ffdd6 | 345 | |
1da177e4 LT |
346 | if ((mp_bh->path = multipath_map (conf))<0) { |
347 | printk(KERN_ALERT "multipath: %s: unrecoverable IO read" | |
348 | " error for block %llu\n", | |
349 | bdevname(bio->bi_bdev,b), | |
4f024f37 | 350 | (unsigned long long)bio->bi_iter.bi_sector); |
1da177e4 LT |
351 | multipath_end_bh_io(mp_bh, -EIO); |
352 | } else { | |
353 | printk(KERN_ERR "multipath: %s: redirecting sector %llu" | |
354 | " to another IO path\n", | |
355 | bdevname(bio->bi_bdev,b), | |
4f024f37 | 356 | (unsigned long long)bio->bi_iter.bi_sector); |
1da177e4 | 357 | *bio = *(mp_bh->master_bio); |
4f024f37 KO |
358 | bio->bi_iter.bi_sector += |
359 | conf->multipaths[mp_bh->path].rdev->data_offset; | |
1da177e4 | 360 | bio->bi_bdev = conf->multipaths[mp_bh->path].rdev->bdev; |
7b6d91da | 361 | bio->bi_rw |= REQ_FAILFAST_TRANSPORT; |
1da177e4 LT |
362 | bio->bi_end_io = multipath_end_request; |
363 | bio->bi_private = mp_bh; | |
364 | generic_make_request(bio); | |
365 | } | |
366 | } | |
367 | spin_unlock_irqrestore(&conf->device_lock, flags); | |
368 | } | |
369 | ||
fd01b88c | 370 | static sector_t multipath_size(struct mddev *mddev, sector_t sectors, int raid_disks) |
80c3a6ce DW |
371 | { |
372 | WARN_ONCE(sectors || raid_disks, | |
373 | "%s does not support generic reshape\n", __func__); | |
374 | ||
375 | return mddev->dev_sectors; | |
376 | } | |
377 | ||
fd01b88c | 378 | static int multipath_run (struct mddev *mddev) |
1da177e4 | 379 | { |
69724e28 | 380 | struct mpconf *conf; |
1da177e4 LT |
381 | int disk_idx; |
382 | struct multipath_info *disk; | |
3cb03002 | 383 | struct md_rdev *rdev; |
92f861a7 | 384 | int working_disks; |
1da177e4 | 385 | |
0894cc30 AN |
386 | if (md_check_no_bitmap(mddev)) |
387 | return -EINVAL; | |
388 | ||
1da177e4 LT |
389 | if (mddev->level != LEVEL_MULTIPATH) { |
390 | printk("multipath: %s: raid level not set to multipath IO (%d)\n", | |
391 | mdname(mddev), mddev->level); | |
392 | goto out; | |
393 | } | |
394 | /* | |
395 | * copy the already verified devices into our private MULTIPATH | |
396 | * bookkeeping area. [whatever we allocate in multipath_run(), | |
afa0f557 | 397 | * should be freed in multipath_free()] |
1da177e4 LT |
398 | */ |
399 | ||
69724e28 | 400 | conf = kzalloc(sizeof(struct mpconf), GFP_KERNEL); |
1da177e4 LT |
401 | mddev->private = conf; |
402 | if (!conf) { | |
f72ffdd6 | 403 | printk(KERN_ERR |
1da177e4 LT |
404 | "multipath: couldn't allocate memory for %s\n", |
405 | mdname(mddev)); | |
406 | goto out; | |
407 | } | |
1da177e4 | 408 | |
9ffae0cf | 409 | conf->multipaths = kzalloc(sizeof(struct multipath_info)*mddev->raid_disks, |
1da177e4 LT |
410 | GFP_KERNEL); |
411 | if (!conf->multipaths) { | |
f72ffdd6 | 412 | printk(KERN_ERR |
1da177e4 LT |
413 | "multipath: couldn't allocate memory for %s\n", |
414 | mdname(mddev)); | |
415 | goto out_free_conf; | |
416 | } | |
1da177e4 | 417 | |
92f861a7 | 418 | working_disks = 0; |
dafb20fa | 419 | rdev_for_each(rdev, mddev) { |
1da177e4 LT |
420 | disk_idx = rdev->raid_disk; |
421 | if (disk_idx < 0 || | |
422 | disk_idx >= mddev->raid_disks) | |
423 | continue; | |
424 | ||
425 | disk = conf->multipaths + disk_idx; | |
426 | disk->rdev = rdev; | |
8f6c2e4b MP |
427 | disk_stack_limits(mddev->gendisk, rdev->bdev, |
428 | rdev->data_offset << 9); | |
1da177e4 | 429 | |
b2d444d7 | 430 | if (!test_bit(Faulty, &rdev->flags)) |
92f861a7 | 431 | working_disks++; |
1da177e4 LT |
432 | } |
433 | ||
434 | conf->raid_disks = mddev->raid_disks; | |
1da177e4 LT |
435 | conf->mddev = mddev; |
436 | spin_lock_init(&conf->device_lock); | |
437 | INIT_LIST_HEAD(&conf->retry_list); | |
438 | ||
92f861a7 | 439 | if (!working_disks) { |
1da177e4 LT |
440 | printk(KERN_ERR "multipath: no operational IO paths for %s\n", |
441 | mdname(mddev)); | |
442 | goto out_free_conf; | |
443 | } | |
92f861a7 | 444 | mddev->degraded = conf->raid_disks - working_disks; |
1da177e4 | 445 | |
bbba809e | 446 | conf->pool = mempool_create_kmalloc_pool(NR_RESERVED_BUFS, |
26b6e051 | 447 | sizeof(struct multipath_bh)); |
1da177e4 | 448 | if (conf->pool == NULL) { |
f72ffdd6 | 449 | printk(KERN_ERR |
1da177e4 LT |
450 | "multipath: couldn't allocate memory for %s\n", |
451 | mdname(mddev)); | |
452 | goto out_free_conf; | |
453 | } | |
454 | ||
455 | { | |
0232605d N |
456 | mddev->thread = md_register_thread(multipathd, mddev, |
457 | "multipath"); | |
1da177e4 LT |
458 | if (!mddev->thread) { |
459 | printk(KERN_ERR "multipath: couldn't allocate thread" | |
460 | " for %s\n", mdname(mddev)); | |
461 | goto out_free_conf; | |
462 | } | |
463 | } | |
464 | ||
f72ffdd6 | 465 | printk(KERN_INFO |
1da177e4 | 466 | "multipath: array %s active with %d out of %d IO paths\n", |
92f861a7 N |
467 | mdname(mddev), conf->raid_disks - mddev->degraded, |
468 | mddev->raid_disks); | |
1da177e4 LT |
469 | /* |
470 | * Ok, everything is just fine now | |
471 | */ | |
1f403624 | 472 | md_set_array_sectors(mddev, multipath_size(mddev, 0, 0)); |
7a5febe9 | 473 | |
a91a2785 MP |
474 | if (md_integrity_register(mddev)) |
475 | goto out_free_conf; | |
476 | ||
1da177e4 LT |
477 | return 0; |
478 | ||
479 | out_free_conf: | |
644df1a8 | 480 | mempool_destroy(conf->pool); |
990a8baf | 481 | kfree(conf->multipaths); |
1da177e4 LT |
482 | kfree(conf); |
483 | mddev->private = NULL; | |
484 | out: | |
485 | return -EIO; | |
486 | } | |
487 | ||
afa0f557 | 488 | static void multipath_free(struct mddev *mddev, void *priv) |
1da177e4 | 489 | { |
afa0f557 | 490 | struct mpconf *conf = priv; |
1da177e4 | 491 | |
1da177e4 LT |
492 | mempool_destroy(conf->pool); |
493 | kfree(conf->multipaths); | |
494 | kfree(conf); | |
1da177e4 LT |
495 | } |
496 | ||
84fc4b56 | 497 | static struct md_personality multipath_personality = |
1da177e4 LT |
498 | { |
499 | .name = "multipath", | |
2604b703 | 500 | .level = LEVEL_MULTIPATH, |
1da177e4 LT |
501 | .owner = THIS_MODULE, |
502 | .make_request = multipath_make_request, | |
503 | .run = multipath_run, | |
afa0f557 | 504 | .free = multipath_free, |
1da177e4 LT |
505 | .status = multipath_status, |
506 | .error_handler = multipath_error, | |
507 | .hot_add_disk = multipath_add_disk, | |
508 | .hot_remove_disk= multipath_remove_disk, | |
80c3a6ce | 509 | .size = multipath_size, |
5c675f83 | 510 | .congested = multipath_congested, |
1da177e4 LT |
511 | }; |
512 | ||
513 | static int __init multipath_init (void) | |
514 | { | |
2604b703 | 515 | return register_md_personality (&multipath_personality); |
1da177e4 LT |
516 | } |
517 | ||
518 | static void __exit multipath_exit (void) | |
519 | { | |
2604b703 | 520 | unregister_md_personality (&multipath_personality); |
1da177e4 LT |
521 | } |
522 | ||
523 | module_init(multipath_init); | |
524 | module_exit(multipath_exit); | |
525 | MODULE_LICENSE("GPL"); | |
0efb9e61 | 526 | MODULE_DESCRIPTION("simple multi-path personality for MD"); |
1da177e4 | 527 | MODULE_ALIAS("md-personality-7"); /* MULTIPATH */ |
d9d166c2 | 528 | MODULE_ALIAS("md-multipath"); |
2604b703 | 529 | MODULE_ALIAS("md-level--4"); |