blob: 8ac6488ad0dc6c1a86463c4e732c1205a6cbb9a3 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 raid0.c : Multiple Devices driver for Linux
3 Copyright (C) 1994-96 Marc ZYNGIER
4 <zyngier@ufr-info-p7.ibp.fr> or
5 <maz@gloups.fdn.fr>
6 Copyright (C) 1999, 2000 Ingo Molnar, Red Hat
7
8
9 RAID-0 management functions.
10
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2, or (at your option)
14 any later version.
15
16 You should have received a copy of the GNU General Public License
17 (for example /usr/src/linux/COPYING); if not, write to the Free
18 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/
20
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <linux/raid/raid0.h>
22
Jens Axboe165125e2007-07-24 09:28:11 +020023static void raid0_unplug(struct request_queue *q)
Linus Torvalds1da177e2005-04-16 15:20:36 -070024{
25 mddev_t *mddev = q->queuedata;
26 raid0_conf_t *conf = mddev_to_conf(mddev);
27 mdk_rdev_t **devlist = conf->strip_zone[0].dev;
28 int i;
29
30 for (i=0; i<mddev->raid_disks; i++) {
Jens Axboe165125e2007-07-24 09:28:11 +020031 struct request_queue *r_queue = bdev_get_queue(devlist[i]->bdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
Alan D. Brunelle2ad8b1e2007-11-07 14:26:56 -050033 blk_unplug(r_queue);
Linus Torvalds1da177e2005-04-16 15:20:36 -070034 }
35}
36
NeilBrown26be34d2006-10-03 01:15:53 -070037static int raid0_congested(void *data, int bits)
38{
39 mddev_t *mddev = data;
40 raid0_conf_t *conf = mddev_to_conf(mddev);
41 mdk_rdev_t **devlist = conf->strip_zone[0].dev;
42 int i, ret = 0;
43
44 for (i = 0; i < mddev->raid_disks && !ret ; i++) {
Jens Axboe165125e2007-07-24 09:28:11 +020045 struct request_queue *q = bdev_get_queue(devlist[i]->bdev);
NeilBrown26be34d2006-10-03 01:15:53 -070046
47 ret |= bdi_congested(&q->backing_dev_info, bits);
48 }
49 return ret;
50}
51
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
53static int create_strip_zones (mddev_t *mddev)
54{
55 int i, c, j;
56 sector_t current_offset, curr_zone_offset;
57 sector_t min_spacing;
58 raid0_conf_t *conf = mddev_to_conf(mddev);
59 mdk_rdev_t *smallest, *rdev1, *rdev2, *rdev;
60 struct list_head *tmp1, *tmp2;
61 struct strip_zone *zone;
62 int cnt;
63 char b[BDEVNAME_SIZE];
64
65 /*
66 * The number of 'same size groups'
67 */
68 conf->nr_strip_zones = 0;
69
NeilBrownd089c6a2008-02-06 01:39:59 -080070 rdev_for_each(rdev1, tmp1, mddev) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070071 printk("raid0: looking at %s\n",
72 bdevname(rdev1->bdev,b));
73 c = 0;
NeilBrownd089c6a2008-02-06 01:39:59 -080074 rdev_for_each(rdev2, tmp2, mddev) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070075 printk("raid0: comparing %s(%llu)",
76 bdevname(rdev1->bdev,b),
77 (unsigned long long)rdev1->size);
78 printk(" with %s(%llu)\n",
79 bdevname(rdev2->bdev,b),
80 (unsigned long long)rdev2->size);
81 if (rdev2 == rdev1) {
82 printk("raid0: END\n");
83 break;
84 }
85 if (rdev2->size == rdev1->size)
86 {
87 /*
88 * Not unique, don't count it as a new
89 * group
90 */
91 printk("raid0: EQUAL\n");
92 c = 1;
93 break;
94 }
95 printk("raid0: NOT EQUAL\n");
96 }
97 if (!c) {
98 printk("raid0: ==> UNIQUE\n");
99 conf->nr_strip_zones++;
100 printk("raid0: %d zones\n", conf->nr_strip_zones);
101 }
102 }
103 printk("raid0: FINAL %d zones\n", conf->nr_strip_zones);
104
NeilBrown9ffae0c2006-01-06 00:20:32 -0800105 conf->strip_zone = kzalloc(sizeof(struct strip_zone)*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106 conf->nr_strip_zones, GFP_KERNEL);
107 if (!conf->strip_zone)
108 return 1;
NeilBrown9ffae0c2006-01-06 00:20:32 -0800109 conf->devlist = kzalloc(sizeof(mdk_rdev_t*)*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 conf->nr_strip_zones*mddev->raid_disks,
111 GFP_KERNEL);
112 if (!conf->devlist)
113 return 1;
114
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 /* The first zone must contain all devices, so here we check that
116 * there is a proper alignment of slots to devices and find them all
117 */
118 zone = &conf->strip_zone[0];
119 cnt = 0;
120 smallest = NULL;
121 zone->dev = conf->devlist;
NeilBrownd089c6a2008-02-06 01:39:59 -0800122 rdev_for_each(rdev1, tmp1, mddev) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 int j = rdev1->raid_disk;
124
125 if (j < 0 || j >= mddev->raid_disks) {
126 printk("raid0: bad disk number %d - aborting!\n", j);
127 goto abort;
128 }
129 if (zone->dev[j]) {
130 printk("raid0: multiple devices for %d - aborting!\n",
131 j);
132 goto abort;
133 }
134 zone->dev[j] = rdev1;
135
136 blk_queue_stack_limits(mddev->queue,
137 rdev1->bdev->bd_disk->queue);
138 /* as we don't honour merge_bvec_fn, we must never risk
139 * violating it, so limit ->max_sector to one PAGE, as
140 * a one page request is never in violation.
141 */
142
143 if (rdev1->bdev->bd_disk->queue->merge_bvec_fn &&
144 mddev->queue->max_sectors > (PAGE_SIZE>>9))
145 blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9);
146
147 if (!smallest || (rdev1->size <smallest->size))
148 smallest = rdev1;
149 cnt++;
150 }
151 if (cnt != mddev->raid_disks) {
152 printk("raid0: too few disks (%d of %d) - aborting!\n",
153 cnt, mddev->raid_disks);
154 goto abort;
155 }
156 zone->nb_dev = cnt;
157 zone->size = smallest->size * cnt;
158 zone->zone_offset = 0;
159
160 current_offset = smallest->size;
161 curr_zone_offset = zone->size;
162
163 /* now do the other zones */
164 for (i = 1; i < conf->nr_strip_zones; i++)
165 {
166 zone = conf->strip_zone + i;
167 zone->dev = conf->strip_zone[i-1].dev + mddev->raid_disks;
168
169 printk("raid0: zone %d\n", i);
170 zone->dev_offset = current_offset;
171 smallest = NULL;
172 c = 0;
173
174 for (j=0; j<cnt; j++) {
175 char b[BDEVNAME_SIZE];
176 rdev = conf->strip_zone[0].dev[j];
177 printk("raid0: checking %s ...", bdevname(rdev->bdev,b));
178 if (rdev->size > current_offset)
179 {
180 printk(" contained as device %d\n", c);
181 zone->dev[c] = rdev;
182 c++;
183 if (!smallest || (rdev->size <smallest->size)) {
184 smallest = rdev;
185 printk(" (%llu) is smallest!.\n",
186 (unsigned long long)rdev->size);
187 }
188 } else
189 printk(" nope.\n");
190 }
191
192 zone->nb_dev = c;
193 zone->size = (smallest->size - current_offset) * c;
194 printk("raid0: zone->nb_dev: %d, size: %llu\n",
195 zone->nb_dev, (unsigned long long)zone->size);
196
197 zone->zone_offset = curr_zone_offset;
198 curr_zone_offset += zone->size;
199
200 current_offset = smallest->size;
201 printk("raid0: current zone offset: %llu\n",
202 (unsigned long long)current_offset);
203 }
204
205 /* Now find appropriate hash spacing.
206 * We want a number which causes most hash entries to cover
207 * at most two strips, but the hash table must be at most
208 * 1 PAGE. We choose the smallest strip, or contiguous collection
209 * of strips, that has big enough size. We never consider the last
210 * strip though as it's size has no bearing on the efficacy of the hash
211 * table.
212 */
213 conf->hash_spacing = curr_zone_offset;
214 min_spacing = curr_zone_offset;
215 sector_div(min_spacing, PAGE_SIZE/sizeof(struct strip_zone*));
216 for (i=0; i < conf->nr_strip_zones-1; i++) {
217 sector_t sz = 0;
218 for (j=i; j<conf->nr_strip_zones-1 &&
219 sz < min_spacing ; j++)
220 sz += conf->strip_zone[j].size;
221 if (sz >= min_spacing && sz < conf->hash_spacing)
222 conf->hash_spacing = sz;
223 }
224
225 mddev->queue->unplug_fn = raid0_unplug;
226
NeilBrown26be34d2006-10-03 01:15:53 -0700227 mddev->queue->backing_dev_info.congested_fn = raid0_congested;
228 mddev->queue->backing_dev_info.congested_data = mddev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229
230 printk("raid0: done.\n");
231 return 0;
232 abort:
233 return 1;
234}
235
236/**
237 * raid0_mergeable_bvec -- tell bio layer if a two requests can be merged
238 * @q: request queue
Alasdair G Kergoncc371e62008-07-03 09:53:43 +0200239 * @bvm: properties of new bio
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 * @biovec: the request that could be merged to it.
241 *
242 * Return amount of bytes we can accept at this offset
243 */
Alasdair G Kergoncc371e62008-07-03 09:53:43 +0200244static int raid0_mergeable_bvec(struct request_queue *q,
245 struct bvec_merge_data *bvm,
246 struct bio_vec *biovec)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247{
248 mddev_t *mddev = q->queuedata;
Alasdair G Kergoncc371e62008-07-03 09:53:43 +0200249 sector_t sector = bvm->bi_sector + get_start_sect(bvm->bi_bdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 int max;
251 unsigned int chunk_sectors = mddev->chunk_size >> 9;
Alasdair G Kergoncc371e62008-07-03 09:53:43 +0200252 unsigned int bio_sectors = bvm->bi_size >> 9;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253
254 max = (chunk_sectors - ((sector & (chunk_sectors - 1)) + bio_sectors)) << 9;
255 if (max < 0) max = 0; /* bio_add cannot handle a negative return */
256 if (max <= biovec->bv_len && bio_sectors == 0)
257 return biovec->bv_len;
258 else
259 return max;
260}
261
262static int raid0_run (mddev_t *mddev)
263{
264 unsigned cur=0, i=0, nb_zone;
265 s64 size;
266 raid0_conf_t *conf;
267 mdk_rdev_t *rdev;
268 struct list_head *tmp;
269
NeilBrown2604b702006-01-06 00:20:36 -0800270 if (mddev->chunk_size == 0) {
271 printk(KERN_ERR "md/raid0: non-zero chunk size required.\n");
272 return -EINVAL;
273 }
274 printk(KERN_INFO "%s: setting max_sectors to %d, segment boundary to %d\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275 mdname(mddev),
276 mddev->chunk_size >> 9,
277 (mddev->chunk_size>>1)-1);
278 blk_queue_max_sectors(mddev->queue, mddev->chunk_size >> 9);
279 blk_queue_segment_boundary(mddev->queue, (mddev->chunk_size>>1) - 1);
Neil Browne7e72bf2008-05-14 16:05:54 -0700280 mddev->queue->queue_lock = &mddev->queue->__queue_lock;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281
282 conf = kmalloc(sizeof (raid0_conf_t), GFP_KERNEL);
283 if (!conf)
284 goto out;
285 mddev->private = (void *)conf;
286
287 conf->strip_zone = NULL;
288 conf->devlist = NULL;
289 if (create_strip_zones (mddev))
290 goto out_free_conf;
291
292 /* calculate array device size */
Andre Nollf233ea52008-07-21 17:05:22 +1000293 mddev->array_sectors = 0;
NeilBrownd089c6a2008-02-06 01:39:59 -0800294 rdev_for_each(rdev, tmp, mddev)
Andre Nollf233ea52008-07-21 17:05:22 +1000295 mddev->array_sectors += rdev->size * 2;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296
297 printk("raid0 : md_size is %llu blocks.\n",
Andre Nollf233ea52008-07-21 17:05:22 +1000298 (unsigned long long)mddev->array_sectors / 2);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299 printk("raid0 : conf->hash_spacing is %llu blocks.\n",
300 (unsigned long long)conf->hash_spacing);
301 {
Andre Nollf233ea52008-07-21 17:05:22 +1000302 sector_t s = mddev->array_sectors / 2;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303 sector_t space = conf->hash_spacing;
304 int round;
305 conf->preshift = 0;
Neil Brown1eb29122005-07-15 03:56:27 -0700306 if (sizeof(sector_t) > sizeof(u32)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307 /*shift down space and s so that sector_div will work */
Neil Brown1eb29122005-07-15 03:56:27 -0700308 while (space > (sector_t) (~(u32)0)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 s >>= 1;
310 space >>= 1;
311 s += 1; /* force round-up */
312 conf->preshift++;
313 }
314 }
Neil Brown1eb29122005-07-15 03:56:27 -0700315 round = sector_div(s, (u32)space) ? 1 : 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316 nb_zone = s + round;
317 }
318 printk("raid0 : nb_zone is %d.\n", nb_zone);
319
320 printk("raid0 : Allocating %Zd bytes for hash.\n",
321 nb_zone*sizeof(struct strip_zone*));
322 conf->hash_table = kmalloc (sizeof (struct strip_zone *)*nb_zone, GFP_KERNEL);
323 if (!conf->hash_table)
324 goto out_free_conf;
325 size = conf->strip_zone[cur].size;
326
NeilBrown5c4c3332006-05-22 22:35:26 -0700327 conf->hash_table[0] = conf->strip_zone + cur;
328 for (i=1; i< nb_zone; i++) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329 while (size <= conf->hash_spacing) {
330 cur++;
331 size += conf->strip_zone[cur].size;
332 }
333 size -= conf->hash_spacing;
NeilBrown5c4c3332006-05-22 22:35:26 -0700334 conf->hash_table[i] = conf->strip_zone + cur;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335 }
336 if (conf->preshift) {
337 conf->hash_spacing >>= conf->preshift;
338 /* round hash_spacing up so when we divide by it, we
339 * err on the side of too-low, which is safest
340 */
341 conf->hash_spacing++;
342 }
343
344 /* calculate the max read-ahead size.
345 * For read-ahead of large files to be effective, we need to
346 * readahead at least twice a whole stripe. i.e. number of devices
347 * multiplied by chunk size times 2.
348 * If an individual device has an ra_pages greater than the
349 * chunk size, then we will not drive that device as hard as it
350 * wants. We consider this a configuration error: a larger
351 * chunksize should be used in that case.
352 */
353 {
NeilBrown2d1f3b52006-01-06 00:20:31 -0800354 int stripe = mddev->raid_disks * mddev->chunk_size / PAGE_SIZE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355 if (mddev->queue->backing_dev_info.ra_pages < 2* stripe)
356 mddev->queue->backing_dev_info.ra_pages = 2* stripe;
357 }
358
359
360 blk_queue_merge_bvec(mddev->queue, raid0_mergeable_bvec);
361 return 0;
362
363out_free_conf:
Jesper Juhl990a8ba2005-06-21 17:17:30 -0700364 kfree(conf->strip_zone);
365 kfree(conf->devlist);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366 kfree(conf);
367 mddev->private = NULL;
368out:
NeilBrown29fc7e32006-02-03 03:03:41 -0800369 return -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370}
371
372static int raid0_stop (mddev_t *mddev)
373{
374 raid0_conf_t *conf = mddev_to_conf(mddev);
375
376 blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
Jesper Juhl990a8ba2005-06-21 17:17:30 -0700377 kfree(conf->hash_table);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378 conf->hash_table = NULL;
Jesper Juhl990a8ba2005-06-21 17:17:30 -0700379 kfree(conf->strip_zone);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380 conf->strip_zone = NULL;
Jesper Juhl990a8ba2005-06-21 17:17:30 -0700381 kfree(conf);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382 mddev->private = NULL;
383
384 return 0;
385}
386
Jens Axboe165125e2007-07-24 09:28:11 +0200387static int raid0_make_request (struct request_queue *q, struct bio *bio)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388{
389 mddev_t *mddev = q->queuedata;
390 unsigned int sect_in_chunk, chunksize_bits, chunk_size, chunk_sects;
391 raid0_conf_t *conf = mddev_to_conf(mddev);
392 struct strip_zone *zone;
393 mdk_rdev_t *tmp_dev;
NeilBrown787f17f2007-05-23 13:58:09 -0700394 sector_t chunk;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395 sector_t block, rsect;
Jens Axboea3623572005-11-01 09:26:16 +0100396 const int rw = bio_data_dir(bio);
Tejun Heoc9959052008-08-25 19:47:21 +0900397 int cpu;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398
NeilBrowne5dcdd82005-09-09 16:23:41 -0700399 if (unlikely(bio_barrier(bio))) {
NeilBrown6712ecf2007-09-27 12:47:43 +0200400 bio_endio(bio, -EOPNOTSUPP);
NeilBrowne5dcdd82005-09-09 16:23:41 -0700401 return 0;
402 }
403
Tejun Heo074a7ac2008-08-25 19:56:14 +0900404 cpu = part_stat_lock();
405 part_stat_inc(cpu, &mddev->gendisk->part0, ios[rw]);
406 part_stat_add(cpu, &mddev->gendisk->part0, sectors[rw],
407 bio_sectors(bio));
408 part_stat_unlock();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409
410 chunk_size = mddev->chunk_size >> 10;
411 chunk_sects = mddev->chunk_size >> 9;
412 chunksize_bits = ffz(~chunk_size);
413 block = bio->bi_sector >> 1;
414
415
416 if (unlikely(chunk_sects < (bio->bi_sector & (chunk_sects - 1)) + (bio->bi_size >> 9))) {
417 struct bio_pair *bp;
418 /* Sanity check -- queue functions should prevent this happening */
419 if (bio->bi_vcnt != 1 ||
420 bio->bi_idx != 0)
421 goto bad_map;
422 /* This is a one page bio that upper layers
423 * refuse to split for us, so we need to split it.
424 */
Denis ChengRq6feef532008-10-09 08:57:05 +0200425 bp = bio_split(bio, chunk_sects - (bio->bi_sector & (chunk_sects - 1)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426 if (raid0_make_request(q, &bp->bio1))
427 generic_make_request(&bp->bio1);
428 if (raid0_make_request(q, &bp->bio2))
429 generic_make_request(&bp->bio2);
430
431 bio_pair_release(bp);
432 return 0;
433 }
434
435
436 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437 sector_t x = block >> conf->preshift;
Neil Brown1eb29122005-07-15 03:56:27 -0700438 sector_div(x, (u32)conf->hash_spacing);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439 zone = conf->hash_table[x];
440 }
441
442 while (block >= (zone->zone_offset + zone->size))
443 zone++;
444
445 sect_in_chunk = bio->bi_sector & ((chunk_size<<1) -1);
446
447
448 {
449 sector_t x = (block - zone->zone_offset) >> chunksize_bits;
450
451 sector_div(x, zone->nb_dev);
452 chunk = x;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453
454 x = block >> chunksize_bits;
455 tmp_dev = zone->dev[sector_div(x, zone->nb_dev)];
456 }
457 rsect = (((chunk << chunksize_bits) + zone->dev_offset)<<1)
458 + sect_in_chunk;
459
460 bio->bi_bdev = tmp_dev->bdev;
461 bio->bi_sector = rsect + tmp_dev->data_offset;
462
463 /*
464 * Let the main block layer submit the IO and resolve recursion:
465 */
466 return 1;
467
468bad_map:
469 printk("raid0_make_request bug: can't convert block across chunks"
470 " or bigger than %dk %llu %d\n", chunk_size,
471 (unsigned long long)bio->bi_sector, bio->bi_size >> 10);
472
NeilBrown6712ecf2007-09-27 12:47:43 +0200473 bio_io_error(bio);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 return 0;
475}
NeilBrown8299d7f2007-10-16 23:30:53 -0700476
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477static void raid0_status (struct seq_file *seq, mddev_t *mddev)
478{
479#undef MD_DEBUG
480#ifdef MD_DEBUG
481 int j, k, h;
482 char b[BDEVNAME_SIZE];
483 raid0_conf_t *conf = mddev_to_conf(mddev);
NeilBrown8299d7f2007-10-16 23:30:53 -0700484
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485 h = 0;
486 for (j = 0; j < conf->nr_strip_zones; j++) {
487 seq_printf(seq, " z%d", j);
488 if (conf->hash_table[h] == conf->strip_zone+j)
NeilBrown8299d7f2007-10-16 23:30:53 -0700489 seq_printf(seq, "(h%d)", h++);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490 seq_printf(seq, "=[");
491 for (k = 0; k < conf->strip_zone[j].nb_dev; k++)
NeilBrown8299d7f2007-10-16 23:30:53 -0700492 seq_printf(seq, "%s/", bdevname(
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493 conf->strip_zone[j].dev[k]->bdev,b));
494
NeilBrown8299d7f2007-10-16 23:30:53 -0700495 seq_printf(seq, "] zo=%d do=%d s=%d\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496 conf->strip_zone[j].zone_offset,
497 conf->strip_zone[j].dev_offset,
498 conf->strip_zone[j].size);
499 }
500#endif
501 seq_printf(seq, " %dk chunks", mddev->chunk_size/1024);
502 return;
503}
504
NeilBrown2604b702006-01-06 00:20:36 -0800505static struct mdk_personality raid0_personality=
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506{
507 .name = "raid0",
NeilBrown2604b702006-01-06 00:20:36 -0800508 .level = 0,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509 .owner = THIS_MODULE,
510 .make_request = raid0_make_request,
511 .run = raid0_run,
512 .stop = raid0_stop,
513 .status = raid0_status,
514};
515
516static int __init raid0_init (void)
517{
NeilBrown2604b702006-01-06 00:20:36 -0800518 return register_md_personality (&raid0_personality);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519}
520
521static void raid0_exit (void)
522{
NeilBrown2604b702006-01-06 00:20:36 -0800523 unregister_md_personality (&raid0_personality);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524}
525
526module_init(raid0_init);
527module_exit(raid0_exit);
528MODULE_LICENSE("GPL");
529MODULE_ALIAS("md-personality-2"); /* RAID0 */
NeilBrownd9d166c2006-01-06 00:20:51 -0800530MODULE_ALIAS("md-raid0");
NeilBrown2604b702006-01-06 00:20:36 -0800531MODULE_ALIAS("md-level-0");