Thomas Gleixner | af1a889 | 2019-05-20 19:08:12 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 3 | * faulty.c : Multiple Devices driver for Linux |
| 4 | * |
| 5 | * Copyright (C) 2004 Neil Brown |
| 6 | * |
| 7 | * fautly-device-simulator personality for md |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | |
| 11 | /* |
| 12 | * The "faulty" personality causes some requests to fail. |
| 13 | * |
| 14 | * Possible failure modes are: |
| 15 | * reads fail "randomly" but succeed on retry |
| 16 | * writes fail "randomly" but succeed on retry |
| 17 | * reads for some address fail and then persist until a write |
| 18 | * reads for some address fail and then persist irrespective of write |
| 19 | * writes for some address fail and persist |
| 20 | * all writes fail |
| 21 | * |
| 22 | * Different modes can be active at a time, but only |
| 23 | * one can be set at array creation. Others can be added later. |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 24 | * A mode can be one-shot or recurrent with the recurrence being |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | * once in every N requests. |
| 26 | * The bottom 5 bits of the "layout" indicate the mode. The |
| 27 | * remainder indicate a period, or 0 for one-shot. |
| 28 | * |
| 29 | * There is an implementation limit on the number of concurrently |
| 30 | * persisting-faulty blocks. When a new fault is requested that would |
| 31 | * exceed the limit, it is ignored. |
| 32 | * All current faults can be clear using a layout of "0". |
| 33 | * |
| 34 | * Requests are always sent to the device. If they are to fail, |
| 35 | * we clone the bio and insert a new b_end_io into the chain. |
| 36 | */ |
| 37 | |
| 38 | #define WriteTransient 0 |
| 39 | #define ReadTransient 1 |
| 40 | #define WritePersistent 2 |
| 41 | #define ReadPersistent 3 |
| 42 | #define WriteAll 4 /* doesn't go to device */ |
| 43 | #define ReadFixable 5 |
| 44 | #define Modes 6 |
| 45 | |
| 46 | #define ClearErrors 31 |
| 47 | #define ClearFaults 30 |
| 48 | |
| 49 | #define AllPersist 100 /* internal use only */ |
| 50 | #define NoPersist 101 |
| 51 | |
| 52 | #define ModeMask 0x1f |
| 53 | #define ModeShift 5 |
| 54 | |
| 55 | #define MaxFault 50 |
NeilBrown | bff6197 | 2009-03-31 14:33:13 +1100 | [diff] [blame] | 56 | #include <linux/blkdev.h> |
Paul Gortmaker | 056075c | 2011-07-03 13:58:33 -0400 | [diff] [blame] | 57 | #include <linux/module.h> |
NeilBrown | bff6197 | 2009-03-31 14:33:13 +1100 | [diff] [blame] | 58 | #include <linux/raid/md_u.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 59 | #include <linux/slab.h> |
NeilBrown | 43b2e5d | 2009-03-31 14:33:13 +1100 | [diff] [blame] | 60 | #include "md.h" |
NeilBrown | bff6197 | 2009-03-31 14:33:13 +1100 | [diff] [blame] | 61 | #include <linux/seq_file.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | |
| 63 | |
Christoph Hellwig | 4246a0b | 2015-07-20 15:29:37 +0200 | [diff] [blame] | 64 | static void faulty_fail(struct bio *bio) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | { |
| 66 | struct bio *b = bio->bi_private; |
| 67 | |
Kent Overstreet | 4f024f3 | 2013-10-11 15:44:27 -0700 | [diff] [blame] | 68 | b->bi_iter.bi_size = bio->bi_iter.bi_size; |
| 69 | b->bi_iter.bi_sector = bio->bi_iter.bi_sector; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | |
NeilBrown | 6712ecf | 2007-09-27 12:47:43 +0200 | [diff] [blame] | 71 | bio_put(bio); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | |
NeilBrown | 6712ecf | 2007-09-27 12:47:43 +0200 | [diff] [blame] | 73 | bio_io_error(b); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | } |
| 75 | |
NeilBrown | 8f1ae43 | 2011-10-11 16:48:52 +1100 | [diff] [blame] | 76 | struct faulty_conf { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | int period[Modes]; |
| 78 | atomic_t counters[Modes]; |
| 79 | sector_t faults[MaxFault]; |
| 80 | int modes[MaxFault]; |
| 81 | int nfaults; |
NeilBrown | 3cb0300 | 2011-10-11 16:45:26 +1100 | [diff] [blame] | 82 | struct md_rdev *rdev; |
NeilBrown | 8f1ae43 | 2011-10-11 16:48:52 +1100 | [diff] [blame] | 83 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | |
NeilBrown | 8f1ae43 | 2011-10-11 16:48:52 +1100 | [diff] [blame] | 85 | static int check_mode(struct faulty_conf *conf, int mode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | { |
| 87 | if (conf->period[mode] == 0 && |
| 88 | atomic_read(&conf->counters[mode]) <= 0) |
| 89 | return 0; /* no failure, no decrement */ |
| 90 | |
| 91 | |
| 92 | if (atomic_dec_and_test(&conf->counters[mode])) { |
| 93 | if (conf->period[mode]) |
| 94 | atomic_set(&conf->counters[mode], conf->period[mode]); |
| 95 | return 1; |
| 96 | } |
| 97 | return 0; |
| 98 | } |
| 99 | |
NeilBrown | 8f1ae43 | 2011-10-11 16:48:52 +1100 | [diff] [blame] | 100 | static int check_sector(struct faulty_conf *conf, sector_t start, sector_t end, int dir) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | { |
| 102 | /* If we find a ReadFixable sector, we fix it ... */ |
| 103 | int i; |
| 104 | for (i=0; i<conf->nfaults; i++) |
| 105 | if (conf->faults[i] >= start && |
| 106 | conf->faults[i] < end) { |
| 107 | /* found it ... */ |
| 108 | switch (conf->modes[i] * 2 + dir) { |
| 109 | case WritePersistent*2+WRITE: return 1; |
| 110 | case ReadPersistent*2+READ: return 1; |
| 111 | case ReadFixable*2+READ: return 1; |
| 112 | case ReadFixable*2+WRITE: |
| 113 | conf->modes[i] = NoPersist; |
| 114 | return 0; |
| 115 | case AllPersist*2+READ: |
| 116 | case AllPersist*2+WRITE: return 1; |
| 117 | default: |
| 118 | return 0; |
| 119 | } |
| 120 | } |
| 121 | return 0; |
| 122 | } |
| 123 | |
NeilBrown | 8f1ae43 | 2011-10-11 16:48:52 +1100 | [diff] [blame] | 124 | static void add_sector(struct faulty_conf *conf, sector_t start, int mode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | { |
| 126 | int i; |
| 127 | int n = conf->nfaults; |
| 128 | for (i=0; i<conf->nfaults; i++) |
| 129 | if (conf->faults[i] == start) { |
| 130 | switch(mode) { |
| 131 | case NoPersist: conf->modes[i] = mode; return; |
| 132 | case WritePersistent: |
| 133 | if (conf->modes[i] == ReadPersistent || |
| 134 | conf->modes[i] == ReadFixable) |
| 135 | conf->modes[i] = AllPersist; |
| 136 | else |
| 137 | conf->modes[i] = WritePersistent; |
| 138 | return; |
| 139 | case ReadPersistent: |
| 140 | if (conf->modes[i] == WritePersistent) |
| 141 | conf->modes[i] = AllPersist; |
| 142 | else |
| 143 | conf->modes[i] = ReadPersistent; |
| 144 | return; |
| 145 | case ReadFixable: |
| 146 | if (conf->modes[i] == WritePersistent || |
| 147 | conf->modes[i] == ReadPersistent) |
| 148 | conf->modes[i] = AllPersist; |
| 149 | else |
| 150 | conf->modes[i] = ReadFixable; |
| 151 | return; |
| 152 | } |
| 153 | } else if (conf->modes[i] == NoPersist) |
| 154 | n = i; |
| 155 | |
| 156 | if (n >= MaxFault) |
| 157 | return; |
| 158 | conf->faults[n] = start; |
| 159 | conf->modes[n] = mode; |
| 160 | if (conf->nfaults == n) |
| 161 | conf->nfaults = n+1; |
| 162 | } |
| 163 | |
NeilBrown | cc27b0c | 2017-06-05 16:49:39 +1000 | [diff] [blame] | 164 | static bool faulty_make_request(struct mddev *mddev, struct bio *bio) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | { |
NeilBrown | 8f1ae43 | 2011-10-11 16:48:52 +1100 | [diff] [blame] | 166 | struct faulty_conf *conf = mddev->private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | int failit = 0; |
| 168 | |
NeilBrown | 802ba06 | 2006-12-13 00:34:13 -0800 | [diff] [blame] | 169 | if (bio_data_dir(bio) == WRITE) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | /* write request */ |
| 171 | if (atomic_read(&conf->counters[WriteAll])) { |
| 172 | /* special case - don't decrement, don't generic_make_request, |
| 173 | * just fail immediately |
| 174 | */ |
Christoph Hellwig | 4246a0b | 2015-07-20 15:29:37 +0200 | [diff] [blame] | 175 | bio_io_error(bio); |
NeilBrown | cc27b0c | 2017-06-05 16:49:39 +1000 | [diff] [blame] | 176 | return true; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | } |
| 178 | |
Kent Overstreet | 4f024f3 | 2013-10-11 15:44:27 -0700 | [diff] [blame] | 179 | if (check_sector(conf, bio->bi_iter.bi_sector, |
| 180 | bio_end_sector(bio), WRITE)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | failit = 1; |
| 182 | if (check_mode(conf, WritePersistent)) { |
Kent Overstreet | 4f024f3 | 2013-10-11 15:44:27 -0700 | [diff] [blame] | 183 | add_sector(conf, bio->bi_iter.bi_sector, |
| 184 | WritePersistent); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | failit = 1; |
| 186 | } |
| 187 | if (check_mode(conf, WriteTransient)) |
| 188 | failit = 1; |
| 189 | } else { |
| 190 | /* read request */ |
Kent Overstreet | 4f024f3 | 2013-10-11 15:44:27 -0700 | [diff] [blame] | 191 | if (check_sector(conf, bio->bi_iter.bi_sector, |
| 192 | bio_end_sector(bio), READ)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | failit = 1; |
| 194 | if (check_mode(conf, ReadTransient)) |
| 195 | failit = 1; |
| 196 | if (check_mode(conf, ReadPersistent)) { |
Kent Overstreet | 4f024f3 | 2013-10-11 15:44:27 -0700 | [diff] [blame] | 197 | add_sector(conf, bio->bi_iter.bi_sector, |
| 198 | ReadPersistent); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | failit = 1; |
| 200 | } |
| 201 | if (check_mode(conf, ReadFixable)) { |
Kent Overstreet | 4f024f3 | 2013-10-11 15:44:27 -0700 | [diff] [blame] | 202 | add_sector(conf, bio->bi_iter.bi_sector, |
| 203 | ReadFixable); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | failit = 1; |
| 205 | } |
| 206 | } |
| 207 | if (failit) { |
Kent Overstreet | afeee51 | 2018-05-20 18:25:52 -0400 | [diff] [blame] | 208 | struct bio *b = bio_clone_fast(bio, GFP_NOIO, &mddev->bio_set); |
Christoph Hellwig | 5a7bbad | 2011-09-12 12:12:01 +0200 | [diff] [blame] | 209 | |
Christoph Hellwig | 74d4699 | 2017-08-23 19:10:32 +0200 | [diff] [blame] | 210 | bio_set_dev(b, conf->rdev->bdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | b->bi_private = bio; |
| 212 | b->bi_end_io = faulty_fail; |
Christoph Hellwig | 5a7bbad | 2011-09-12 12:12:01 +0200 | [diff] [blame] | 213 | bio = b; |
| 214 | } else |
Christoph Hellwig | 74d4699 | 2017-08-23 19:10:32 +0200 | [diff] [blame] | 215 | bio_set_dev(bio, conf->rdev->bdev); |
Christoph Hellwig | 5a7bbad | 2011-09-12 12:12:01 +0200 | [diff] [blame] | 216 | |
| 217 | generic_make_request(bio); |
NeilBrown | cc27b0c | 2017-06-05 16:49:39 +1000 | [diff] [blame] | 218 | return true; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | } |
| 220 | |
Shaohua Li | 849674e | 2016-01-20 13:52:20 -0800 | [diff] [blame] | 221 | static void faulty_status(struct seq_file *seq, struct mddev *mddev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | { |
NeilBrown | 8f1ae43 | 2011-10-11 16:48:52 +1100 | [diff] [blame] | 223 | struct faulty_conf *conf = mddev->private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | int n; |
| 225 | |
| 226 | if ((n=atomic_read(&conf->counters[WriteTransient])) != 0) |
| 227 | seq_printf(seq, " WriteTransient=%d(%d)", |
| 228 | n, conf->period[WriteTransient]); |
| 229 | |
| 230 | if ((n=atomic_read(&conf->counters[ReadTransient])) != 0) |
| 231 | seq_printf(seq, " ReadTransient=%d(%d)", |
| 232 | n, conf->period[ReadTransient]); |
| 233 | |
| 234 | if ((n=atomic_read(&conf->counters[WritePersistent])) != 0) |
| 235 | seq_printf(seq, " WritePersistent=%d(%d)", |
| 236 | n, conf->period[WritePersistent]); |
| 237 | |
| 238 | if ((n=atomic_read(&conf->counters[ReadPersistent])) != 0) |
| 239 | seq_printf(seq, " ReadPersistent=%d(%d)", |
| 240 | n, conf->period[ReadPersistent]); |
| 241 | |
| 242 | |
| 243 | if ((n=atomic_read(&conf->counters[ReadFixable])) != 0) |
| 244 | seq_printf(seq, " ReadFixable=%d(%d)", |
| 245 | n, conf->period[ReadFixable]); |
| 246 | |
| 247 | if ((n=atomic_read(&conf->counters[WriteAll])) != 0) |
| 248 | seq_printf(seq, " WriteAll"); |
| 249 | |
| 250 | seq_printf(seq, " nfaults=%d", conf->nfaults); |
| 251 | } |
| 252 | |
| 253 | |
Shaohua Li | 849674e | 2016-01-20 13:52:20 -0800 | [diff] [blame] | 254 | static int faulty_reshape(struct mddev *mddev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | { |
NeilBrown | 597a711 | 2009-06-18 08:47:42 +1000 | [diff] [blame] | 256 | int mode = mddev->new_layout & ModeMask; |
| 257 | int count = mddev->new_layout >> ModeShift; |
NeilBrown | 8f1ae43 | 2011-10-11 16:48:52 +1100 | [diff] [blame] | 258 | struct faulty_conf *conf = mddev->private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | |
NeilBrown | 597a711 | 2009-06-18 08:47:42 +1000 | [diff] [blame] | 260 | if (mddev->new_layout < 0) |
| 261 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 262 | |
| 263 | /* new layout */ |
| 264 | if (mode == ClearFaults) |
| 265 | conf->nfaults = 0; |
| 266 | else if (mode == ClearErrors) { |
| 267 | int i; |
| 268 | for (i=0 ; i < Modes ; i++) { |
| 269 | conf->period[i] = 0; |
| 270 | atomic_set(&conf->counters[i], 0); |
| 271 | } |
| 272 | } else if (mode < Modes) { |
| 273 | conf->period[mode] = count; |
| 274 | if (!count) count++; |
| 275 | atomic_set(&conf->counters[mode], count); |
| 276 | } else |
| 277 | return -EINVAL; |
NeilBrown | 597a711 | 2009-06-18 08:47:42 +1000 | [diff] [blame] | 278 | mddev->new_layout = -1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | mddev->layout = -1; /* makes sure further changes come through */ |
| 280 | return 0; |
| 281 | } |
| 282 | |
NeilBrown | fd01b88 | 2011-10-11 16:47:53 +1100 | [diff] [blame] | 283 | static sector_t faulty_size(struct mddev *mddev, sector_t sectors, int raid_disks) |
Dan Williams | 80c3a6c | 2009-03-17 18:10:40 -0700 | [diff] [blame] | 284 | { |
| 285 | WARN_ONCE(raid_disks, |
| 286 | "%s does not support generic reshape\n", __func__); |
| 287 | |
| 288 | if (sectors == 0) |
| 289 | return mddev->dev_sectors; |
| 290 | |
| 291 | return sectors; |
| 292 | } |
| 293 | |
Shaohua Li | 849674e | 2016-01-20 13:52:20 -0800 | [diff] [blame] | 294 | static int faulty_run(struct mddev *mddev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | { |
NeilBrown | 3cb0300 | 2011-10-11 16:45:26 +1100 | [diff] [blame] | 296 | struct md_rdev *rdev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | int i; |
NeilBrown | 8f1ae43 | 2011-10-11 16:48:52 +1100 | [diff] [blame] | 298 | struct faulty_conf *conf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | |
Andre Noll | 0894cc3 | 2009-06-18 08:49:23 +1000 | [diff] [blame] | 300 | if (md_check_no_bitmap(mddev)) |
| 301 | return -EINVAL; |
| 302 | |
| 303 | conf = kmalloc(sizeof(*conf), GFP_KERNEL); |
Sven Wegener | 08ff39f | 2008-10-16 14:16:53 +1100 | [diff] [blame] | 304 | if (!conf) |
| 305 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | |
| 307 | for (i=0; i<Modes; i++) { |
| 308 | atomic_set(&conf->counters[i], 0); |
| 309 | conf->period[i] = 0; |
| 310 | } |
| 311 | conf->nfaults = 0; |
| 312 | |
Eric Sandeen | 0be1fec | 2012-10-22 10:44:55 +1100 | [diff] [blame] | 313 | rdev_for_each(rdev, mddev) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | conf->rdev = rdev; |
Eric Sandeen | 0be1fec | 2012-10-22 10:44:55 +1100 | [diff] [blame] | 315 | disk_stack_limits(mddev->gendisk, rdev->bdev, |
| 316 | rdev->data_offset << 9); |
| 317 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | |
Dan Williams | 1f40362 | 2009-03-31 14:59:03 +1100 | [diff] [blame] | 319 | md_set_array_sectors(mddev, faulty_size(mddev, 0, 0)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | mddev->private = conf; |
| 321 | |
Shaohua Li | 849674e | 2016-01-20 13:52:20 -0800 | [diff] [blame] | 322 | faulty_reshape(mddev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | |
| 324 | return 0; |
| 325 | } |
| 326 | |
NeilBrown | afa0f55 | 2014-12-15 12:56:58 +1100 | [diff] [blame] | 327 | static void faulty_free(struct mddev *mddev, void *priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | { |
NeilBrown | afa0f55 | 2014-12-15 12:56:58 +1100 | [diff] [blame] | 329 | struct faulty_conf *conf = priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | |
| 331 | kfree(conf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | } |
| 333 | |
NeilBrown | 84fc4b5 | 2011-10-11 16:49:58 +1100 | [diff] [blame] | 334 | static struct md_personality faulty_personality = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | { |
| 336 | .name = "faulty", |
NeilBrown | 2604b70 | 2006-01-06 00:20:36 -0800 | [diff] [blame] | 337 | .level = LEVEL_FAULTY, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | .owner = THIS_MODULE, |
Shaohua Li | 849674e | 2016-01-20 13:52:20 -0800 | [diff] [blame] | 339 | .make_request = faulty_make_request, |
| 340 | .run = faulty_run, |
NeilBrown | afa0f55 | 2014-12-15 12:56:58 +1100 | [diff] [blame] | 341 | .free = faulty_free, |
Shaohua Li | 849674e | 2016-01-20 13:52:20 -0800 | [diff] [blame] | 342 | .status = faulty_status, |
| 343 | .check_reshape = faulty_reshape, |
Dan Williams | 80c3a6c | 2009-03-17 18:10:40 -0700 | [diff] [blame] | 344 | .size = faulty_size, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | }; |
| 346 | |
| 347 | static int __init raid_init(void) |
| 348 | { |
NeilBrown | 2604b70 | 2006-01-06 00:20:36 -0800 | [diff] [blame] | 349 | return register_md_personality(&faulty_personality); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | } |
| 351 | |
| 352 | static void raid_exit(void) |
| 353 | { |
NeilBrown | 2604b70 | 2006-01-06 00:20:36 -0800 | [diff] [blame] | 354 | unregister_md_personality(&faulty_personality); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | } |
| 356 | |
| 357 | module_init(raid_init); |
| 358 | module_exit(raid_exit); |
| 359 | MODULE_LICENSE("GPL"); |
NeilBrown | 0efb9e6 | 2009-12-14 12:49:58 +1100 | [diff] [blame] | 360 | MODULE_DESCRIPTION("Fault injection personality for MD"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | MODULE_ALIAS("md-personality-10"); /* faulty */ |
NeilBrown | d9d166c | 2006-01-06 00:20:51 -0800 | [diff] [blame] | 362 | MODULE_ALIAS("md-faulty"); |
NeilBrown | 2604b70 | 2006-01-06 00:20:36 -0800 | [diff] [blame] | 363 | MODULE_ALIAS("md-level--5"); |