Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
NeilBrown | bff6197 | 2009-03-31 14:33:13 +1100 | [diff] [blame] | 21 | #include <linux/blkdev.h> |
NeilBrown | bff6197 | 2009-03-31 14:33:13 +1100 | [diff] [blame] | 22 | #include <linux/seq_file.h> |
NeilBrown | 43b2e5d | 2009-03-31 14:33:13 +1100 | [diff] [blame] | 23 | #include "md.h" |
Christoph Hellwig | ef740c3 | 2009-03-31 14:27:03 +1100 | [diff] [blame] | 24 | #include "raid0.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
Jens Axboe | 165125e | 2007-07-24 09:28:11 +0200 | [diff] [blame] | 26 | static void raid0_unplug(struct request_queue *q) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | { |
| 28 | mddev_t *mddev = q->queuedata; |
NeilBrown | 070ec55 | 2009-06-16 16:54:21 +1000 | [diff] [blame] | 29 | raid0_conf_t *conf = mddev->private; |
NeilBrown | b414579 | 2009-06-16 16:50:52 +1000 | [diff] [blame] | 30 | mdk_rdev_t **devlist = conf->devlist; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | int i; |
| 32 | |
| 33 | for (i=0; i<mddev->raid_disks; i++) { |
Jens Axboe | 165125e | 2007-07-24 09:28:11 +0200 | [diff] [blame] | 34 | struct request_queue *r_queue = bdev_get_queue(devlist[i]->bdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | |
Alan D. Brunelle | 2ad8b1e | 2007-11-07 14:26:56 -0500 | [diff] [blame] | 36 | blk_unplug(r_queue); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | } |
| 38 | } |
| 39 | |
NeilBrown | 26be34d | 2006-10-03 01:15:53 -0700 | [diff] [blame] | 40 | static int raid0_congested(void *data, int bits) |
| 41 | { |
| 42 | mddev_t *mddev = data; |
NeilBrown | 070ec55 | 2009-06-16 16:54:21 +1000 | [diff] [blame] | 43 | raid0_conf_t *conf = mddev->private; |
NeilBrown | b414579 | 2009-06-16 16:50:52 +1000 | [diff] [blame] | 44 | mdk_rdev_t **devlist = conf->devlist; |
NeilBrown | 26be34d | 2006-10-03 01:15:53 -0700 | [diff] [blame] | 45 | int i, ret = 0; |
| 46 | |
NeilBrown | 3fa841d | 2009-09-23 18:10:29 +1000 | [diff] [blame] | 47 | if (mddev_congested(mddev, bits)) |
| 48 | return 1; |
| 49 | |
NeilBrown | 26be34d | 2006-10-03 01:15:53 -0700 | [diff] [blame] | 50 | for (i = 0; i < mddev->raid_disks && !ret ; i++) { |
Jens Axboe | 165125e | 2007-07-24 09:28:11 +0200 | [diff] [blame] | 51 | struct request_queue *q = bdev_get_queue(devlist[i]->bdev); |
NeilBrown | 26be34d | 2006-10-03 01:15:53 -0700 | [diff] [blame] | 52 | |
| 53 | ret |= bdi_congested(&q->backing_dev_info, bits); |
| 54 | } |
| 55 | return ret; |
| 56 | } |
| 57 | |
raz ben yehuda | 4699419 | 2009-06-16 17:00:54 +1000 | [diff] [blame] | 58 | /* |
| 59 | * inform the user of the raid configuration |
| 60 | */ |
| 61 | static void dump_zones(mddev_t *mddev) |
| 62 | { |
| 63 | int j, k, h; |
| 64 | sector_t zone_size = 0; |
| 65 | sector_t zone_start = 0; |
| 66 | char b[BDEVNAME_SIZE]; |
| 67 | raid0_conf_t *conf = mddev->private; |
| 68 | printk(KERN_INFO "******* %s configuration *********\n", |
| 69 | mdname(mddev)); |
| 70 | h = 0; |
| 71 | for (j = 0; j < conf->nr_strip_zones; j++) { |
| 72 | printk(KERN_INFO "zone%d=[", j); |
| 73 | for (k = 0; k < conf->strip_zone[j].nb_dev; k++) |
| 74 | printk("%s/", |
| 75 | bdevname(conf->devlist[j*mddev->raid_disks |
| 76 | + k]->bdev, b)); |
| 77 | printk("]\n"); |
| 78 | |
| 79 | zone_size = conf->strip_zone[j].zone_end - zone_start; |
| 80 | printk(KERN_INFO " zone offset=%llukb " |
| 81 | "device offset=%llukb size=%llukb\n", |
| 82 | (unsigned long long)zone_start>>1, |
| 83 | (unsigned long long)conf->strip_zone[j].dev_start>>1, |
| 84 | (unsigned long long)zone_size>>1); |
| 85 | zone_start = conf->strip_zone[j].zone_end; |
| 86 | } |
| 87 | printk(KERN_INFO "**********************************\n\n"); |
| 88 | } |
| 89 | |
Andre Noll | ed7b003 | 2009-06-16 16:47:36 +1000 | [diff] [blame] | 90 | static int create_strip_zones(mddev_t *mddev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | { |
NeilBrown | a9f326e | 2009-09-23 18:06:41 +1000 | [diff] [blame] | 92 | int i, c, err; |
NeilBrown | 49f357a2 | 2009-06-16 16:50:35 +1000 | [diff] [blame] | 93 | sector_t curr_zone_end, sectors; |
NeilBrown | b414579 | 2009-06-16 16:50:52 +1000 | [diff] [blame] | 94 | mdk_rdev_t *smallest, *rdev1, *rdev2, *rdev, **dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | struct strip_zone *zone; |
| 96 | int cnt; |
| 97 | char b[BDEVNAME_SIZE]; |
Andre Noll | ed7b003 | 2009-06-16 16:47:36 +1000 | [diff] [blame] | 98 | raid0_conf_t *conf = kzalloc(sizeof(*conf), GFP_KERNEL); |
| 99 | |
| 100 | if (!conf) |
| 101 | return -ENOMEM; |
Cheng Renquan | 159ec1f | 2009-01-09 08:31:08 +1100 | [diff] [blame] | 102 | list_for_each_entry(rdev1, &mddev->disks, same_set) { |
Andre Noll | 0825b87a | 2009-01-09 08:31:07 +1100 | [diff] [blame] | 103 | printk(KERN_INFO "raid0: looking at %s\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | bdevname(rdev1->bdev,b)); |
| 105 | c = 0; |
NeilBrown | 13f2682 | 2009-06-18 08:48:55 +1000 | [diff] [blame] | 106 | |
| 107 | /* round size to chunk_size */ |
| 108 | sectors = rdev1->sectors; |
| 109 | sector_div(sectors, mddev->chunk_sectors); |
| 110 | rdev1->sectors = sectors * mddev->chunk_sectors; |
| 111 | |
Cheng Renquan | 159ec1f | 2009-01-09 08:31:08 +1100 | [diff] [blame] | 112 | list_for_each_entry(rdev2, &mddev->disks, same_set) { |
Andre Noll | 0825b87a | 2009-01-09 08:31:07 +1100 | [diff] [blame] | 113 | printk(KERN_INFO "raid0: comparing %s(%llu)", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | bdevname(rdev1->bdev,b), |
Andre Noll | dd8ac33 | 2009-03-31 14:33:13 +1100 | [diff] [blame] | 115 | (unsigned long long)rdev1->sectors); |
Andre Noll | 0825b87a | 2009-01-09 08:31:07 +1100 | [diff] [blame] | 116 | printk(KERN_INFO " with %s(%llu)\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | bdevname(rdev2->bdev,b), |
Andre Noll | dd8ac33 | 2009-03-31 14:33:13 +1100 | [diff] [blame] | 118 | (unsigned long long)rdev2->sectors); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | if (rdev2 == rdev1) { |
Andre Noll | 0825b87a | 2009-01-09 08:31:07 +1100 | [diff] [blame] | 120 | printk(KERN_INFO "raid0: END\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | break; |
| 122 | } |
Andre Noll | dd8ac33 | 2009-03-31 14:33:13 +1100 | [diff] [blame] | 123 | if (rdev2->sectors == rdev1->sectors) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | /* |
| 125 | * Not unique, don't count it as a new |
| 126 | * group |
| 127 | */ |
Andre Noll | 0825b87a | 2009-01-09 08:31:07 +1100 | [diff] [blame] | 128 | printk(KERN_INFO "raid0: EQUAL\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | c = 1; |
| 130 | break; |
| 131 | } |
Andre Noll | 0825b87a | 2009-01-09 08:31:07 +1100 | [diff] [blame] | 132 | printk(KERN_INFO "raid0: NOT EQUAL\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | } |
| 134 | if (!c) { |
Andre Noll | 0825b87a | 2009-01-09 08:31:07 +1100 | [diff] [blame] | 135 | printk(KERN_INFO "raid0: ==> UNIQUE\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | conf->nr_strip_zones++; |
Andre Noll | 0825b87a | 2009-01-09 08:31:07 +1100 | [diff] [blame] | 137 | printk(KERN_INFO "raid0: %d zones\n", |
| 138 | conf->nr_strip_zones); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | } |
| 140 | } |
Andre Noll | 0825b87a | 2009-01-09 08:31:07 +1100 | [diff] [blame] | 141 | printk(KERN_INFO "raid0: FINAL %d zones\n", conf->nr_strip_zones); |
Andre Noll | ed7b003 | 2009-06-16 16:47:36 +1000 | [diff] [blame] | 142 | err = -ENOMEM; |
NeilBrown | 9ffae0c | 2006-01-06 00:20:32 -0800 | [diff] [blame] | 143 | conf->strip_zone = kzalloc(sizeof(struct strip_zone)* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | conf->nr_strip_zones, GFP_KERNEL); |
| 145 | if (!conf->strip_zone) |
Andre Noll | ed7b003 | 2009-06-16 16:47:36 +1000 | [diff] [blame] | 146 | goto abort; |
NeilBrown | 9ffae0c | 2006-01-06 00:20:32 -0800 | [diff] [blame] | 147 | conf->devlist = kzalloc(sizeof(mdk_rdev_t*)* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | conf->nr_strip_zones*mddev->raid_disks, |
| 149 | GFP_KERNEL); |
| 150 | if (!conf->devlist) |
Andre Noll | ed7b003 | 2009-06-16 16:47:36 +1000 | [diff] [blame] | 151 | goto abort; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | /* The first zone must contain all devices, so here we check that |
| 154 | * there is a proper alignment of slots to devices and find them all |
| 155 | */ |
| 156 | zone = &conf->strip_zone[0]; |
| 157 | cnt = 0; |
| 158 | smallest = NULL; |
NeilBrown | b414579 | 2009-06-16 16:50:52 +1000 | [diff] [blame] | 159 | dev = conf->devlist; |
Andre Noll | ed7b003 | 2009-06-16 16:47:36 +1000 | [diff] [blame] | 160 | err = -EINVAL; |
Cheng Renquan | 159ec1f | 2009-01-09 08:31:08 +1100 | [diff] [blame] | 161 | list_for_each_entry(rdev1, &mddev->disks, same_set) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | int j = rdev1->raid_disk; |
| 163 | |
| 164 | if (j < 0 || j >= mddev->raid_disks) { |
Andre Noll | 0825b87a | 2009-01-09 08:31:07 +1100 | [diff] [blame] | 165 | printk(KERN_ERR "raid0: bad disk number %d - " |
| 166 | "aborting!\n", j); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | goto abort; |
| 168 | } |
NeilBrown | b414579 | 2009-06-16 16:50:52 +1000 | [diff] [blame] | 169 | if (dev[j]) { |
Andre Noll | 0825b87a | 2009-01-09 08:31:07 +1100 | [diff] [blame] | 170 | printk(KERN_ERR "raid0: multiple devices for %d - " |
| 171 | "aborting!\n", j); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | goto abort; |
| 173 | } |
NeilBrown | b414579 | 2009-06-16 16:50:52 +1000 | [diff] [blame] | 174 | dev[j] = rdev1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | |
Martin K. Petersen | 8f6c2e4 | 2009-07-01 11:13:45 +1000 | [diff] [blame] | 176 | disk_stack_limits(mddev->gendisk, rdev1->bdev, |
| 177 | rdev1->data_offset << 9); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | /* as we don't honour merge_bvec_fn, we must never risk |
NeilBrown | 627a2d3 | 2010-03-08 16:44:38 +1100 | [diff] [blame^] | 179 | * violating it, so limit ->max_segments to 1, lying within |
| 180 | * a single page. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | */ |
| 182 | |
NeilBrown | 627a2d3 | 2010-03-08 16:44:38 +1100 | [diff] [blame^] | 183 | if (rdev1->bdev->bd_disk->queue->merge_bvec_fn) { |
| 184 | blk_queue_max_segments(mddev->queue, 1); |
| 185 | blk_queue_segment_boundary(mddev->queue, |
| 186 | PAGE_CACHE_SIZE - 1); |
| 187 | } |
Andre Noll | dd8ac33 | 2009-03-31 14:33:13 +1100 | [diff] [blame] | 188 | if (!smallest || (rdev1->sectors < smallest->sectors)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | smallest = rdev1; |
| 190 | cnt++; |
| 191 | } |
| 192 | if (cnt != mddev->raid_disks) { |
Andre Noll | 0825b87a | 2009-01-09 08:31:07 +1100 | [diff] [blame] | 193 | printk(KERN_ERR "raid0: too few disks (%d of %d) - " |
| 194 | "aborting!\n", cnt, mddev->raid_disks); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | goto abort; |
| 196 | } |
| 197 | zone->nb_dev = cnt; |
NeilBrown | 49f357a2 | 2009-06-16 16:50:35 +1000 | [diff] [blame] | 198 | zone->zone_end = smallest->sectors * cnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | |
NeilBrown | 49f357a2 | 2009-06-16 16:50:35 +1000 | [diff] [blame] | 200 | curr_zone_end = zone->zone_end; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | |
| 202 | /* now do the other zones */ |
| 203 | for (i = 1; i < conf->nr_strip_zones; i++) |
| 204 | { |
NeilBrown | a9f326e | 2009-09-23 18:06:41 +1000 | [diff] [blame] | 205 | int j; |
| 206 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | zone = conf->strip_zone + i; |
NeilBrown | b414579 | 2009-06-16 16:50:52 +1000 | [diff] [blame] | 208 | dev = conf->devlist + i * mddev->raid_disks; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | |
Andre Noll | 0825b87a | 2009-01-09 08:31:07 +1100 | [diff] [blame] | 210 | printk(KERN_INFO "raid0: zone %d\n", i); |
NeilBrown | d27a43ab | 2009-06-16 16:46:46 +1000 | [diff] [blame] | 211 | zone->dev_start = smallest->sectors; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | smallest = NULL; |
| 213 | c = 0; |
| 214 | |
| 215 | for (j=0; j<cnt; j++) { |
NeilBrown | b414579 | 2009-06-16 16:50:52 +1000 | [diff] [blame] | 216 | rdev = conf->devlist[j]; |
Andre Noll | 0825b87a | 2009-01-09 08:31:07 +1100 | [diff] [blame] | 217 | printk(KERN_INFO "raid0: checking %s ...", |
| 218 | bdevname(rdev->bdev, b)); |
NeilBrown | d27a43ab | 2009-06-16 16:46:46 +1000 | [diff] [blame] | 219 | if (rdev->sectors <= zone->dev_start) { |
Andre Noll | 0825b87a | 2009-01-09 08:31:07 +1100 | [diff] [blame] | 220 | printk(KERN_INFO " nope.\n"); |
Andre Noll | dd8ac33 | 2009-03-31 14:33:13 +1100 | [diff] [blame] | 221 | continue; |
| 222 | } |
| 223 | printk(KERN_INFO " contained as device %d\n", c); |
NeilBrown | b414579 | 2009-06-16 16:50:52 +1000 | [diff] [blame] | 224 | dev[c] = rdev; |
Andre Noll | dd8ac33 | 2009-03-31 14:33:13 +1100 | [diff] [blame] | 225 | c++; |
| 226 | if (!smallest || rdev->sectors < smallest->sectors) { |
| 227 | smallest = rdev; |
| 228 | printk(KERN_INFO " (%llu) is smallest!.\n", |
| 229 | (unsigned long long)rdev->sectors); |
| 230 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | } |
| 232 | |
| 233 | zone->nb_dev = c; |
NeilBrown | 49f357a2 | 2009-06-16 16:50:35 +1000 | [diff] [blame] | 234 | sectors = (smallest->sectors - zone->dev_start) * c; |
Andre Noll | 83838ed | 2009-01-09 08:31:07 +1100 | [diff] [blame] | 235 | printk(KERN_INFO "raid0: zone->nb_dev: %d, sectors: %llu\n", |
NeilBrown | 49f357a2 | 2009-06-16 16:50:35 +1000 | [diff] [blame] | 236 | zone->nb_dev, (unsigned long long)sectors); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | |
NeilBrown | 49f357a2 | 2009-06-16 16:50:35 +1000 | [diff] [blame] | 238 | curr_zone_end += sectors; |
NeilBrown | d27a43ab | 2009-06-16 16:46:46 +1000 | [diff] [blame] | 239 | zone->zone_end = curr_zone_end; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | |
Andre Noll | 6b8796c | 2009-01-09 08:31:07 +1100 | [diff] [blame] | 241 | printk(KERN_INFO "raid0: current zone start: %llu\n", |
NeilBrown | d27a43ab | 2009-06-16 16:46:46 +1000 | [diff] [blame] | 242 | (unsigned long long)smallest->sectors); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | mddev->queue->unplug_fn = raid0_unplug; |
NeilBrown | 26be34d | 2006-10-03 01:15:53 -0700 | [diff] [blame] | 245 | mddev->queue->backing_dev_info.congested_fn = raid0_congested; |
| 246 | mddev->queue->backing_dev_info.congested_data = mddev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | |
raz ben yehuda | 92e59b6 | 2009-06-16 17:00:57 +1000 | [diff] [blame] | 248 | /* |
| 249 | * now since we have the hard sector sizes, we can make sure |
| 250 | * chunk size is a multiple of that sector size |
| 251 | */ |
Andre Noll | 9d8f036 | 2009-06-18 08:45:01 +1000 | [diff] [blame] | 252 | if ((mddev->chunk_sectors << 9) % queue_logical_block_size(mddev->queue)) { |
raz ben yehuda | 92e59b6 | 2009-06-16 17:00:57 +1000 | [diff] [blame] | 253 | printk(KERN_ERR "%s chunk_size of %d not valid\n", |
| 254 | mdname(mddev), |
Andre Noll | 9d8f036 | 2009-06-18 08:45:01 +1000 | [diff] [blame] | 255 | mddev->chunk_sectors << 9); |
raz ben yehuda | 92e59b6 | 2009-06-16 17:00:57 +1000 | [diff] [blame] | 256 | goto abort; |
| 257 | } |
Martin K. Petersen | 8f6c2e4 | 2009-07-01 11:13:45 +1000 | [diff] [blame] | 258 | |
| 259 | blk_queue_io_min(mddev->queue, mddev->chunk_sectors << 9); |
| 260 | blk_queue_io_opt(mddev->queue, |
| 261 | (mddev->chunk_sectors << 9) * mddev->raid_disks); |
| 262 | |
Andre Noll | 0825b87a | 2009-01-09 08:31:07 +1100 | [diff] [blame] | 263 | printk(KERN_INFO "raid0: done.\n"); |
Andre Noll | ed7b003 | 2009-06-16 16:47:36 +1000 | [diff] [blame] | 264 | mddev->private = conf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | return 0; |
Andre Noll | 5568a60 | 2009-06-16 16:47:21 +1000 | [diff] [blame] | 266 | abort: |
Andre Noll | ed7b003 | 2009-06-16 16:47:36 +1000 | [diff] [blame] | 267 | kfree(conf->strip_zone); |
| 268 | kfree(conf->devlist); |
| 269 | kfree(conf); |
| 270 | mddev->private = NULL; |
| 271 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | /** |
| 275 | * raid0_mergeable_bvec -- tell bio layer if a two requests can be merged |
| 276 | * @q: request queue |
Alasdair G Kergon | cc371e6 | 2008-07-03 09:53:43 +0200 | [diff] [blame] | 277 | * @bvm: properties of new bio |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | * @biovec: the request that could be merged to it. |
| 279 | * |
| 280 | * Return amount of bytes we can accept at this offset |
| 281 | */ |
Alasdair G Kergon | cc371e6 | 2008-07-03 09:53:43 +0200 | [diff] [blame] | 282 | static int raid0_mergeable_bvec(struct request_queue *q, |
| 283 | struct bvec_merge_data *bvm, |
| 284 | struct bio_vec *biovec) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | { |
| 286 | mddev_t *mddev = q->queuedata; |
Alasdair G Kergon | cc371e6 | 2008-07-03 09:53:43 +0200 | [diff] [blame] | 287 | sector_t sector = bvm->bi_sector + get_start_sect(bvm->bi_bdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | int max; |
Andre Noll | 9d8f036 | 2009-06-18 08:45:01 +1000 | [diff] [blame] | 289 | unsigned int chunk_sectors = mddev->chunk_sectors; |
Alasdair G Kergon | cc371e6 | 2008-07-03 09:53:43 +0200 | [diff] [blame] | 290 | unsigned int bio_sectors = bvm->bi_size >> 9; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | |
NeilBrown | d6e412e | 2009-06-18 08:47:00 +1000 | [diff] [blame] | 292 | if (is_power_of_2(chunk_sectors)) |
raz ben yehuda | fbb704e | 2009-06-16 17:02:05 +1000 | [diff] [blame] | 293 | max = (chunk_sectors - ((sector & (chunk_sectors-1)) |
| 294 | + bio_sectors)) << 9; |
| 295 | else |
| 296 | max = (chunk_sectors - (sector_div(sector, chunk_sectors) |
| 297 | + bio_sectors)) << 9; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | if (max < 0) max = 0; /* bio_add cannot handle a negative return */ |
| 299 | if (max <= biovec->bv_len && bio_sectors == 0) |
| 300 | return biovec->bv_len; |
| 301 | else |
| 302 | return max; |
| 303 | } |
| 304 | |
Dan Williams | 80c3a6c | 2009-03-17 18:10:40 -0700 | [diff] [blame] | 305 | static sector_t raid0_size(mddev_t *mddev, sector_t sectors, int raid_disks) |
| 306 | { |
| 307 | sector_t array_sectors = 0; |
| 308 | mdk_rdev_t *rdev; |
| 309 | |
| 310 | WARN_ONCE(sectors || raid_disks, |
| 311 | "%s does not support generic reshape\n", __func__); |
| 312 | |
| 313 | list_for_each_entry(rdev, &mddev->disks, same_set) |
| 314 | array_sectors += rdev->sectors; |
| 315 | |
| 316 | return array_sectors; |
| 317 | } |
| 318 | |
Andre Noll | 8f79cfc | 2009-06-16 16:47:10 +1000 | [diff] [blame] | 319 | static int raid0_run(mddev_t *mddev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | { |
Andre Noll | 5568a60 | 2009-06-16 16:47:21 +1000 | [diff] [blame] | 321 | int ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | |
Andre Noll | 9d8f036 | 2009-06-18 08:45:01 +1000 | [diff] [blame] | 323 | if (mddev->chunk_sectors == 0) { |
raz ben yehuda | fbb704e | 2009-06-16 17:02:05 +1000 | [diff] [blame] | 324 | printk(KERN_ERR "md/raid0: chunk size must be set.\n"); |
NeilBrown | 2604b70 | 2006-01-06 00:20:36 -0800 | [diff] [blame] | 325 | return -EINVAL; |
| 326 | } |
Andre Noll | 0894cc3 | 2009-06-18 08:49:23 +1000 | [diff] [blame] | 327 | if (md_check_no_bitmap(mddev)) |
| 328 | return -EINVAL; |
Martin K. Petersen | 086fa5f | 2010-02-26 00:20:38 -0500 | [diff] [blame] | 329 | blk_queue_max_hw_sectors(mddev->queue, mddev->chunk_sectors); |
Neil Brown | e7e72bf | 2008-05-14 16:05:54 -0700 | [diff] [blame] | 330 | mddev->queue->queue_lock = &mddev->queue->__queue_lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | |
Andre Noll | 5568a60 | 2009-06-16 16:47:21 +1000 | [diff] [blame] | 332 | ret = create_strip_zones(mddev); |
| 333 | if (ret < 0) |
Andre Noll | ed7b003 | 2009-06-16 16:47:36 +1000 | [diff] [blame] | 334 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | |
| 336 | /* calculate array device size */ |
Dan Williams | 1f40362 | 2009-03-31 14:59:03 +1100 | [diff] [blame] | 337 | md_set_array_sectors(mddev, raid0_size(mddev, 0, 0)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | |
Andre Noll | ccacc7d | 2009-01-09 08:31:08 +1100 | [diff] [blame] | 339 | printk(KERN_INFO "raid0 : md_size is %llu sectors.\n", |
| 340 | (unsigned long long)mddev->array_sectors); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | /* calculate the max read-ahead size. |
| 342 | * For read-ahead of large files to be effective, we need to |
| 343 | * readahead at least twice a whole stripe. i.e. number of devices |
| 344 | * multiplied by chunk size times 2. |
| 345 | * If an individual device has an ra_pages greater than the |
| 346 | * chunk size, then we will not drive that device as hard as it |
| 347 | * wants. We consider this a configuration error: a larger |
| 348 | * chunksize should be used in that case. |
| 349 | */ |
| 350 | { |
Andre Noll | 9d8f036 | 2009-06-18 08:45:01 +1000 | [diff] [blame] | 351 | int stripe = mddev->raid_disks * |
| 352 | (mddev->chunk_sectors << 9) / PAGE_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | if (mddev->queue->backing_dev_info.ra_pages < 2* stripe) |
| 354 | mddev->queue->backing_dev_info.ra_pages = 2* stripe; |
| 355 | } |
| 356 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | blk_queue_merge_bvec(mddev->queue, raid0_mergeable_bvec); |
raz ben yehuda | 4699419 | 2009-06-16 17:00:54 +1000 | [diff] [blame] | 358 | dump_zones(mddev); |
Andre Noll | ac5e711 | 2009-08-03 10:59:47 +1000 | [diff] [blame] | 359 | md_integrity_register(mddev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | } |
| 362 | |
Andre Noll | fb5ab4b | 2009-06-16 16:48:19 +1000 | [diff] [blame] | 363 | static int raid0_stop(mddev_t *mddev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 364 | { |
NeilBrown | 070ec55 | 2009-06-16 16:54:21 +1000 | [diff] [blame] | 365 | raid0_conf_t *conf = mddev->private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | |
| 367 | blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/ |
Jesper Juhl | 990a8ba | 2005-06-21 17:17:30 -0700 | [diff] [blame] | 368 | kfree(conf->strip_zone); |
Andre Noll | fb5ab4b | 2009-06-16 16:48:19 +1000 | [diff] [blame] | 369 | kfree(conf->devlist); |
Jesper Juhl | 990a8ba | 2005-06-21 17:17:30 -0700 | [diff] [blame] | 370 | kfree(conf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | mddev->private = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 372 | return 0; |
| 373 | } |
| 374 | |
NeilBrown | 49f357a2 | 2009-06-16 16:50:35 +1000 | [diff] [blame] | 375 | /* Find the zone which holds a particular offset |
| 376 | * Update *sectorp to be an offset in that zone |
| 377 | */ |
Andre Noll | dc58266 | 2009-06-16 16:18:43 +1000 | [diff] [blame] | 378 | static struct strip_zone *find_zone(struct raid0_private_data *conf, |
NeilBrown | 49f357a2 | 2009-06-16 16:50:35 +1000 | [diff] [blame] | 379 | sector_t *sectorp) |
Andre Noll | dc58266 | 2009-06-16 16:18:43 +1000 | [diff] [blame] | 380 | { |
| 381 | int i; |
| 382 | struct strip_zone *z = conf->strip_zone; |
NeilBrown | 49f357a2 | 2009-06-16 16:50:35 +1000 | [diff] [blame] | 383 | sector_t sector = *sectorp; |
Andre Noll | dc58266 | 2009-06-16 16:18:43 +1000 | [diff] [blame] | 384 | |
| 385 | for (i = 0; i < conf->nr_strip_zones; i++) |
NeilBrown | 49f357a2 | 2009-06-16 16:50:35 +1000 | [diff] [blame] | 386 | if (sector < z[i].zone_end) { |
| 387 | if (i) |
| 388 | *sectorp = sector - z[i-1].zone_end; |
Andre Noll | dc58266 | 2009-06-16 16:18:43 +1000 | [diff] [blame] | 389 | return z + i; |
NeilBrown | 49f357a2 | 2009-06-16 16:50:35 +1000 | [diff] [blame] | 390 | } |
Andre Noll | dc58266 | 2009-06-16 16:18:43 +1000 | [diff] [blame] | 391 | BUG(); |
| 392 | } |
| 393 | |
raz ben yehuda | fbb704e | 2009-06-16 17:02:05 +1000 | [diff] [blame] | 394 | /* |
| 395 | * remaps the bio to the target device. we separate two flows. |
| 396 | * power 2 flow and a general flow for the sake of perfromance |
| 397 | */ |
| 398 | static mdk_rdev_t *map_sector(mddev_t *mddev, struct strip_zone *zone, |
| 399 | sector_t sector, sector_t *sector_offset) |
| 400 | { |
| 401 | unsigned int sect_in_chunk; |
| 402 | sector_t chunk; |
| 403 | raid0_conf_t *conf = mddev->private; |
Andre Noll | 9d8f036 | 2009-06-18 08:45:01 +1000 | [diff] [blame] | 404 | unsigned int chunk_sects = mddev->chunk_sectors; |
raz ben yehuda | fbb704e | 2009-06-16 17:02:05 +1000 | [diff] [blame] | 405 | |
NeilBrown | d6e412e | 2009-06-18 08:47:00 +1000 | [diff] [blame] | 406 | if (is_power_of_2(chunk_sects)) { |
raz ben yehuda | fbb704e | 2009-06-16 17:02:05 +1000 | [diff] [blame] | 407 | int chunksect_bits = ffz(~chunk_sects); |
| 408 | /* find the sector offset inside the chunk */ |
| 409 | sect_in_chunk = sector & (chunk_sects - 1); |
| 410 | sector >>= chunksect_bits; |
| 411 | /* chunk in zone */ |
| 412 | chunk = *sector_offset; |
| 413 | /* quotient is the chunk in real device*/ |
| 414 | sector_div(chunk, zone->nb_dev << chunksect_bits); |
| 415 | } else{ |
| 416 | sect_in_chunk = sector_div(sector, chunk_sects); |
| 417 | chunk = *sector_offset; |
| 418 | sector_div(chunk, chunk_sects * zone->nb_dev); |
| 419 | } |
| 420 | /* |
| 421 | * position the bio over the real device |
| 422 | * real sector = chunk in device + starting of zone |
| 423 | * + the position in the chunk |
| 424 | */ |
| 425 | *sector_offset = (chunk * chunk_sects) + sect_in_chunk; |
| 426 | return conf->devlist[(zone - conf->strip_zone)*mddev->raid_disks |
| 427 | + sector_div(sector, zone->nb_dev)]; |
| 428 | } |
| 429 | |
| 430 | /* |
| 431 | * Is io distribute over 1 or more chunks ? |
| 432 | */ |
| 433 | static inline int is_io_in_chunk_boundary(mddev_t *mddev, |
| 434 | unsigned int chunk_sects, struct bio *bio) |
| 435 | { |
NeilBrown | d6e412e | 2009-06-18 08:47:00 +1000 | [diff] [blame] | 436 | if (likely(is_power_of_2(chunk_sects))) { |
raz ben yehuda | fbb704e | 2009-06-16 17:02:05 +1000 | [diff] [blame] | 437 | return chunk_sects >= ((bio->bi_sector & (chunk_sects-1)) |
| 438 | + (bio->bi_size >> 9)); |
| 439 | } else{ |
| 440 | sector_t sector = bio->bi_sector; |
| 441 | return chunk_sects >= (sector_div(sector, chunk_sects) |
| 442 | + (bio->bi_size >> 9)); |
| 443 | } |
| 444 | } |
| 445 | |
| 446 | static int raid0_make_request(struct request_queue *q, struct bio *bio) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 447 | { |
| 448 | mddev_t *mddev = q->queuedata; |
raz ben yehuda | fbb704e | 2009-06-16 17:02:05 +1000 | [diff] [blame] | 449 | unsigned int chunk_sects; |
| 450 | sector_t sector_offset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | struct strip_zone *zone; |
| 452 | mdk_rdev_t *tmp_dev; |
Jens Axboe | a362357 | 2005-11-01 09:26:16 +0100 | [diff] [blame] | 453 | const int rw = bio_data_dir(bio); |
Tejun Heo | c995905 | 2008-08-25 19:47:21 +0900 | [diff] [blame] | 454 | int cpu; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | |
Jens Axboe | 1f98a13 | 2009-09-11 14:32:04 +0200 | [diff] [blame] | 456 | if (unlikely(bio_rw_flagged(bio, BIO_RW_BARRIER))) { |
NeilBrown | a2826aa | 2009-12-14 12:49:49 +1100 | [diff] [blame] | 457 | md_barrier_request(mddev, bio); |
NeilBrown | e5dcdd8 | 2005-09-09 16:23:41 -0700 | [diff] [blame] | 458 | return 0; |
| 459 | } |
| 460 | |
Tejun Heo | 074a7ac | 2008-08-25 19:56:14 +0900 | [diff] [blame] | 461 | cpu = part_stat_lock(); |
| 462 | part_stat_inc(cpu, &mddev->gendisk->part0, ios[rw]); |
| 463 | part_stat_add(cpu, &mddev->gendisk->part0, sectors[rw], |
| 464 | bio_sectors(bio)); |
| 465 | part_stat_unlock(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | |
Andre Noll | 9d8f036 | 2009-06-18 08:45:01 +1000 | [diff] [blame] | 467 | chunk_sects = mddev->chunk_sectors; |
raz ben yehuda | fbb704e | 2009-06-16 17:02:05 +1000 | [diff] [blame] | 468 | if (unlikely(!is_io_in_chunk_boundary(mddev, chunk_sects, bio))) { |
| 469 | sector_t sector = bio->bi_sector; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 470 | struct bio_pair *bp; |
| 471 | /* Sanity check -- queue functions should prevent this happening */ |
| 472 | if (bio->bi_vcnt != 1 || |
| 473 | bio->bi_idx != 0) |
| 474 | goto bad_map; |
| 475 | /* This is a one page bio that upper layers |
| 476 | * refuse to split for us, so we need to split it. |
| 477 | */ |
NeilBrown | d6e412e | 2009-06-18 08:47:00 +1000 | [diff] [blame] | 478 | if (likely(is_power_of_2(chunk_sects))) |
raz ben yehuda | fbb704e | 2009-06-16 17:02:05 +1000 | [diff] [blame] | 479 | bp = bio_split(bio, chunk_sects - (sector & |
| 480 | (chunk_sects-1))); |
| 481 | else |
| 482 | bp = bio_split(bio, chunk_sects - |
| 483 | sector_div(sector, chunk_sects)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 484 | if (raid0_make_request(q, &bp->bio1)) |
| 485 | generic_make_request(&bp->bio1); |
| 486 | if (raid0_make_request(q, &bp->bio2)) |
| 487 | generic_make_request(&bp->bio2); |
| 488 | |
| 489 | bio_pair_release(bp); |
| 490 | return 0; |
| 491 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | |
raz ben yehuda | fbb704e | 2009-06-16 17:02:05 +1000 | [diff] [blame] | 493 | sector_offset = bio->bi_sector; |
| 494 | zone = find_zone(mddev->private, §or_offset); |
| 495 | tmp_dev = map_sector(mddev, zone, bio->bi_sector, |
| 496 | §or_offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 497 | bio->bi_bdev = tmp_dev->bdev; |
raz ben yehuda | fbb704e | 2009-06-16 17:02:05 +1000 | [diff] [blame] | 498 | bio->bi_sector = sector_offset + zone->dev_start + |
| 499 | tmp_dev->data_offset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | /* |
| 501 | * Let the main block layer submit the IO and resolve recursion: |
| 502 | */ |
| 503 | return 1; |
| 504 | |
| 505 | bad_map: |
| 506 | printk("raid0_make_request bug: can't convert block across chunks" |
Andre Noll | a471200 | 2009-01-09 08:31:06 +1100 | [diff] [blame] | 507 | " or bigger than %dk %llu %d\n", chunk_sects / 2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | (unsigned long long)bio->bi_sector, bio->bi_size >> 10); |
| 509 | |
NeilBrown | 6712ecf | 2007-09-27 12:47:43 +0200 | [diff] [blame] | 510 | bio_io_error(bio); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | return 0; |
| 512 | } |
NeilBrown | 8299d7f | 2007-10-16 23:30:53 -0700 | [diff] [blame] | 513 | |
raz ben yehuda | 1b96142 | 2009-06-16 16:57:40 +1000 | [diff] [blame] | 514 | static void raid0_status(struct seq_file *seq, mddev_t *mddev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 515 | { |
| 516 | #undef MD_DEBUG |
| 517 | #ifdef MD_DEBUG |
| 518 | int j, k, h; |
| 519 | char b[BDEVNAME_SIZE]; |
NeilBrown | 070ec55 | 2009-06-16 16:54:21 +1000 | [diff] [blame] | 520 | raid0_conf_t *conf = mddev->private; |
NeilBrown | 8299d7f | 2007-10-16 23:30:53 -0700 | [diff] [blame] | 521 | |
raz ben yehuda | 1b96142 | 2009-06-16 16:57:40 +1000 | [diff] [blame] | 522 | sector_t zone_size; |
| 523 | sector_t zone_start = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 524 | h = 0; |
raz ben yehuda | 1b96142 | 2009-06-16 16:57:40 +1000 | [diff] [blame] | 525 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | for (j = 0; j < conf->nr_strip_zones; j++) { |
| 527 | seq_printf(seq, " z%d", j); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 528 | seq_printf(seq, "=["); |
| 529 | for (k = 0; k < conf->strip_zone[j].nb_dev; k++) |
NeilBrown | 8299d7f | 2007-10-16 23:30:53 -0700 | [diff] [blame] | 530 | seq_printf(seq, "%s/", bdevname( |
raz ben yehuda | 1b96142 | 2009-06-16 16:57:40 +1000 | [diff] [blame] | 531 | conf->devlist[j*mddev->raid_disks + k] |
| 532 | ->bdev, b)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 533 | |
raz ben yehuda | 1b96142 | 2009-06-16 16:57:40 +1000 | [diff] [blame] | 534 | zone_size = conf->strip_zone[j].zone_end - zone_start; |
| 535 | seq_printf(seq, "] ze=%lld ds=%lld s=%lld\n", |
| 536 | (unsigned long long)zone_start>>1, |
| 537 | (unsigned long long)conf->strip_zone[j].dev_start>>1, |
| 538 | (unsigned long long)zone_size>>1); |
| 539 | zone_start = conf->strip_zone[j].zone_end; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | } |
| 541 | #endif |
Andre Noll | 9d8f036 | 2009-06-18 08:45:01 +1000 | [diff] [blame] | 542 | seq_printf(seq, " %dk chunks", mddev->chunk_sectors / 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 | return; |
| 544 | } |
| 545 | |
NeilBrown | 2604b70 | 2006-01-06 00:20:36 -0800 | [diff] [blame] | 546 | static struct mdk_personality raid0_personality= |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 547 | { |
| 548 | .name = "raid0", |
NeilBrown | 2604b70 | 2006-01-06 00:20:36 -0800 | [diff] [blame] | 549 | .level = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 550 | .owner = THIS_MODULE, |
| 551 | .make_request = raid0_make_request, |
| 552 | .run = raid0_run, |
| 553 | .stop = raid0_stop, |
| 554 | .status = raid0_status, |
Dan Williams | 80c3a6c | 2009-03-17 18:10:40 -0700 | [diff] [blame] | 555 | .size = raid0_size, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 556 | }; |
| 557 | |
| 558 | static int __init raid0_init (void) |
| 559 | { |
NeilBrown | 2604b70 | 2006-01-06 00:20:36 -0800 | [diff] [blame] | 560 | return register_md_personality (&raid0_personality); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 561 | } |
| 562 | |
| 563 | static void raid0_exit (void) |
| 564 | { |
NeilBrown | 2604b70 | 2006-01-06 00:20:36 -0800 | [diff] [blame] | 565 | unregister_md_personality (&raid0_personality); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 566 | } |
| 567 | |
| 568 | module_init(raid0_init); |
| 569 | module_exit(raid0_exit); |
| 570 | MODULE_LICENSE("GPL"); |
NeilBrown | 0efb9e6 | 2009-12-14 12:49:58 +1100 | [diff] [blame] | 571 | MODULE_DESCRIPTION("RAID0 (striping) personality for MD"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 572 | MODULE_ALIAS("md-personality-2"); /* RAID0 */ |
NeilBrown | d9d166c | 2006-01-06 00:20:51 -0800 | [diff] [blame] | 573 | MODULE_ALIAS("md-raid0"); |
NeilBrown | 2604b70 | 2006-01-06 00:20:36 -0800 | [diff] [blame] | 574 | MODULE_ALIAS("md-level-0"); |