blob: fd65d8806c0f98cd8489acd93ac22c9c4a796a63 [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;
Andre Nolla4712002009-01-09 08:31:06 +1100390 unsigned int sect_in_chunk, chunksect_bits, chunk_sects;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391 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;
Andre Nolle0f06862009-01-09 08:31:06 +1100395 sector_t sector, 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
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410 chunk_sects = mddev->chunk_size >> 9;
Andre Noll1b7fdf82009-01-09 08:31:06 +1100411 chunksect_bits = ffz(~chunk_sects);
Andre Nolle0f06862009-01-09 08:31:06 +1100412 sector = bio->bi_sector;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413
414 if (unlikely(chunk_sects < (bio->bi_sector & (chunk_sects - 1)) + (bio->bi_size >> 9))) {
415 struct bio_pair *bp;
416 /* Sanity check -- queue functions should prevent this happening */
417 if (bio->bi_vcnt != 1 ||
418 bio->bi_idx != 0)
419 goto bad_map;
420 /* This is a one page bio that upper layers
421 * refuse to split for us, so we need to split it.
422 */
Denis ChengRq6feef532008-10-09 08:57:05 +0200423 bp = bio_split(bio, chunk_sects - (bio->bi_sector & (chunk_sects - 1)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424 if (raid0_make_request(q, &bp->bio1))
425 generic_make_request(&bp->bio1);
426 if (raid0_make_request(q, &bp->bio2))
427 generic_make_request(&bp->bio2);
428
429 bio_pair_release(bp);
430 return 0;
431 }
432
433
434 {
Andre Nolle0f06862009-01-09 08:31:06 +1100435 sector_t x = sector >> (conf->preshift + 1);
Neil Brown1eb29122005-07-15 03:56:27 -0700436 sector_div(x, (u32)conf->hash_spacing);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437 zone = conf->hash_table[x];
438 }
439
Andre Nolle0f06862009-01-09 08:31:06 +1100440 while (sector / 2 >= (zone->zone_offset + zone->size))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441 zone++;
442
Andre Nolla4712002009-01-09 08:31:06 +1100443 sect_in_chunk = bio->bi_sector & (chunk_sects - 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444
445
446 {
Andre Nolle0f06862009-01-09 08:31:06 +1100447 sector_t x = (sector - zone->zone_offset * 2) >> chunksect_bits;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448
449 sector_div(x, zone->nb_dev);
450 chunk = x;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451
Andre Nolle0f06862009-01-09 08:31:06 +1100452 x = sector >> chunksect_bits;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453 tmp_dev = zone->dev[sector_div(x, zone->nb_dev)];
454 }
Andre Noll1b7fdf82009-01-09 08:31:06 +1100455 rsect = (((chunk << (chunksect_bits - 1)) + zone->dev_offset)<<1)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456 + sect_in_chunk;
457
458 bio->bi_bdev = tmp_dev->bdev;
459 bio->bi_sector = rsect + tmp_dev->data_offset;
460
461 /*
462 * Let the main block layer submit the IO and resolve recursion:
463 */
464 return 1;
465
466bad_map:
467 printk("raid0_make_request bug: can't convert block across chunks"
Andre Nolla4712002009-01-09 08:31:06 +1100468 " or bigger than %dk %llu %d\n", chunk_sects / 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 (unsigned long long)bio->bi_sector, bio->bi_size >> 10);
470
NeilBrown6712ecf2007-09-27 12:47:43 +0200471 bio_io_error(bio);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 return 0;
473}
NeilBrown8299d7f2007-10-16 23:30:53 -0700474
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475static void raid0_status (struct seq_file *seq, mddev_t *mddev)
476{
477#undef MD_DEBUG
478#ifdef MD_DEBUG
479 int j, k, h;
480 char b[BDEVNAME_SIZE];
481 raid0_conf_t *conf = mddev_to_conf(mddev);
NeilBrown8299d7f2007-10-16 23:30:53 -0700482
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483 h = 0;
484 for (j = 0; j < conf->nr_strip_zones; j++) {
485 seq_printf(seq, " z%d", j);
486 if (conf->hash_table[h] == conf->strip_zone+j)
NeilBrown8299d7f2007-10-16 23:30:53 -0700487 seq_printf(seq, "(h%d)", h++);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488 seq_printf(seq, "=[");
489 for (k = 0; k < conf->strip_zone[j].nb_dev; k++)
NeilBrown8299d7f2007-10-16 23:30:53 -0700490 seq_printf(seq, "%s/", bdevname(
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491 conf->strip_zone[j].dev[k]->bdev,b));
492
NeilBrown8299d7f2007-10-16 23:30:53 -0700493 seq_printf(seq, "] zo=%d do=%d s=%d\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494 conf->strip_zone[j].zone_offset,
495 conf->strip_zone[j].dev_offset,
496 conf->strip_zone[j].size);
497 }
498#endif
499 seq_printf(seq, " %dk chunks", mddev->chunk_size/1024);
500 return;
501}
502
NeilBrown2604b702006-01-06 00:20:36 -0800503static struct mdk_personality raid0_personality=
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504{
505 .name = "raid0",
NeilBrown2604b702006-01-06 00:20:36 -0800506 .level = 0,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507 .owner = THIS_MODULE,
508 .make_request = raid0_make_request,
509 .run = raid0_run,
510 .stop = raid0_stop,
511 .status = raid0_status,
512};
513
514static int __init raid0_init (void)
515{
NeilBrown2604b702006-01-06 00:20:36 -0800516 return register_md_personality (&raid0_personality);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700517}
518
519static void raid0_exit (void)
520{
NeilBrown2604b702006-01-06 00:20:36 -0800521 unregister_md_personality (&raid0_personality);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522}
523
524module_init(raid0_init);
525module_exit(raid0_exit);
526MODULE_LICENSE("GPL");
527MODULE_ALIAS("md-personality-2"); /* RAID0 */
NeilBrownd9d166c2006-01-06 00:20:51 -0800528MODULE_ALIAS("md-raid0");
NeilBrown2604b702006-01-06 00:20:36 -0800529MODULE_ALIAS("md-level-0");