Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'md-next-20231219' of https://git.kernel.org/pub/scm/linux/kernel/git/song/md into for-6.8/block

Pull MD updates from Song:

"1. Remove deprecated flavors, by Song Liu;
2. raid1 read error check support, by Li Nan;
3. Better handle events off-by-1 case, by Alex Lyakas."

* tag 'md-next-20231219' of https://git.kernel.org/pub/scm/linux/kernel/git/song/md:
md: Remove deprecated CONFIG_MD_FAULTY
md: Remove deprecated CONFIG_MD_MULTIPATH
md: Remove deprecated CONFIG_MD_LINEAR
md/raid1: support read error check
md: factor out a helper exceed_read_errors() to check read_errors
md: Whenassemble the array, consult the superblock of the freshest device
md/raid1: remove unnecessary null checking

+201 -1378
-34
drivers/md/Kconfig
··· 61 61 various kernel APIs and can only work with files on a file system not 62 62 actually sitting on the MD device. 63 63 64 - config MD_LINEAR 65 - tristate "Linear (append) mode (deprecated)" 66 - depends on BLK_DEV_MD 67 - help 68 - If you say Y here, then your multiple devices driver will be able to 69 - use the so-called linear mode, i.e. it will combine the hard disk 70 - partitions by simply appending one to the other. 71 - 72 - To compile this as a module, choose M here: the module 73 - will be called linear. 74 - 75 - If unsure, say Y. 76 - 77 64 config MD_RAID0 78 65 tristate "RAID-0 (striping) mode" 79 66 depends on BLK_DEV_MD ··· 158 171 will be called raid456. 159 172 160 173 If unsure, say Y. 161 - 162 - config MD_MULTIPATH 163 - tristate "Multipath I/O support (deprecated)" 164 - depends on BLK_DEV_MD 165 - help 166 - MD_MULTIPATH provides a simple multi-path personality for use 167 - the MD framework. It is not under active development. New 168 - projects should consider using DM_MULTIPATH which has more 169 - features and more testing. 170 - 171 - If unsure, say N. 172 - 173 - config MD_FAULTY 174 - tristate "Faulty test module for MD (deprecated)" 175 - depends on BLK_DEV_MD 176 - help 177 - The "faulty" module allows for a block device that occasionally returns 178 - read or write errors. It is useful for testing. 179 - 180 - In unsure, say N. 181 - 182 174 183 175 config MD_CLUSTER 184 176 tristate "Cluster Support for MD"
+2 -8
drivers/md/Makefile
··· 29 29 30 30 md-mod-y += md.o md-bitmap.o 31 31 raid456-y += raid5.o raid5-cache.o raid5-ppl.o 32 - linear-y += md-linear.o 33 - multipath-y += md-multipath.o 34 - faulty-y += md-faulty.o 35 32 36 33 # Note: link order is important. All raid personalities 37 - # and must come before md.o, as they each initialise 38 - # themselves, and md.o may use the personalities when it 34 + # and must come before md.o, as they each initialise 35 + # themselves, and md.o may use the personalities when it 39 36 # auto-initialised. 40 37 41 - obj-$(CONFIG_MD_LINEAR) += linear.o 42 38 obj-$(CONFIG_MD_RAID0) += raid0.o 43 39 obj-$(CONFIG_MD_RAID1) += raid1.o 44 40 obj-$(CONFIG_MD_RAID10) += raid10.o 45 41 obj-$(CONFIG_MD_RAID456) += raid456.o 46 - obj-$(CONFIG_MD_MULTIPATH) += multipath.o 47 - obj-$(CONFIG_MD_FAULTY) += faulty.o 48 42 obj-$(CONFIG_MD_CLUSTER) += md-cluster.o 49 43 obj-$(CONFIG_BCACHE) += bcache/ 50 44 obj-$(CONFIG_BLK_DEV_MD) += md-mod.o
+2 -6
drivers/md/md-autodetect.c
··· 49 49 * instead of just one. -- KTK 50 50 * 18May2000: Added support for persistent-superblock arrays: 51 51 * md=n,0,factor,fault,device-list uses RAID0 for device n 52 - * md=n,-1,factor,fault,device-list uses LINEAR for device n 53 52 * md=n,device-list reads a RAID superblock from the devices 54 53 * elements in device-list are read by name_to_kdev_t so can be 55 54 * a hex number or something like /dev/hda1 /dev/sdb ··· 87 88 md_setup_ents++; 88 89 switch (get_option(&str, &level)) { /* RAID level */ 89 90 case 2: /* could be 0 or -1.. */ 90 - if (level == 0 || level == LEVEL_LINEAR) { 91 + if (level == 0) { 91 92 if (get_option(&str, &factor) != 2 || /* Chunk Size */ 92 93 get_option(&str, &fault) != 2) { 93 94 printk(KERN_WARNING "md: Too few arguments supplied to md=.\n"); ··· 95 96 } 96 97 md_setup_args[ent].level = level; 97 98 md_setup_args[ent].chunk = 1 << (factor+12); 98 - if (level == LEVEL_LINEAR) 99 - pername = "linear"; 100 - else 101 - pername = "raid0"; 99 + pername = "raid0"; 102 100 break; 103 101 } 104 102 fallthrough;
-365
drivers/md/md-faulty.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-or-later 2 - /* 3 - * faulty.c : Multiple Devices driver for Linux 4 - * 5 - * Copyright (C) 2004 Neil Brown 6 - * 7 - * fautly-device-simulator personality for md 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. 24 - * A mode can be one-shot or recurrent with the recurrence being 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 56 - #include <linux/blkdev.h> 57 - #include <linux/module.h> 58 - #include <linux/raid/md_u.h> 59 - #include <linux/slab.h> 60 - #include "md.h" 61 - #include <linux/seq_file.h> 62 - 63 - 64 - static void faulty_fail(struct bio *bio) 65 - { 66 - struct bio *b = bio->bi_private; 67 - 68 - b->bi_iter.bi_size = bio->bi_iter.bi_size; 69 - b->bi_iter.bi_sector = bio->bi_iter.bi_sector; 70 - 71 - bio_put(bio); 72 - 73 - bio_io_error(b); 74 - } 75 - 76 - struct faulty_conf { 77 - int period[Modes]; 78 - atomic_t counters[Modes]; 79 - sector_t faults[MaxFault]; 80 - int modes[MaxFault]; 81 - int nfaults; 82 - struct md_rdev *rdev; 83 - }; 84 - 85 - static int check_mode(struct faulty_conf *conf, int mode) 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 - 100 - static int check_sector(struct faulty_conf *conf, sector_t start, sector_t end, int dir) 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 - 124 - static void add_sector(struct faulty_conf *conf, sector_t start, int mode) 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 - 164 - static bool faulty_make_request(struct mddev *mddev, struct bio *bio) 165 - { 166 - struct faulty_conf *conf = mddev->private; 167 - int failit = 0; 168 - 169 - if (bio_data_dir(bio) == WRITE) { 170 - /* write request */ 171 - if (atomic_read(&conf->counters[WriteAll])) { 172 - /* special case - don't decrement, don't submit_bio_noacct, 173 - * just fail immediately 174 - */ 175 - bio_io_error(bio); 176 - return true; 177 - } 178 - 179 - if (check_sector(conf, bio->bi_iter.bi_sector, 180 - bio_end_sector(bio), WRITE)) 181 - failit = 1; 182 - if (check_mode(conf, WritePersistent)) { 183 - add_sector(conf, bio->bi_iter.bi_sector, 184 - WritePersistent); 185 - failit = 1; 186 - } 187 - if (check_mode(conf, WriteTransient)) 188 - failit = 1; 189 - } else { 190 - /* read request */ 191 - if (check_sector(conf, bio->bi_iter.bi_sector, 192 - bio_end_sector(bio), READ)) 193 - failit = 1; 194 - if (check_mode(conf, ReadTransient)) 195 - failit = 1; 196 - if (check_mode(conf, ReadPersistent)) { 197 - add_sector(conf, bio->bi_iter.bi_sector, 198 - ReadPersistent); 199 - failit = 1; 200 - } 201 - if (check_mode(conf, ReadFixable)) { 202 - add_sector(conf, bio->bi_iter.bi_sector, 203 - ReadFixable); 204 - failit = 1; 205 - } 206 - } 207 - 208 - md_account_bio(mddev, &bio); 209 - if (failit) { 210 - struct bio *b = bio_alloc_clone(conf->rdev->bdev, bio, GFP_NOIO, 211 - &mddev->bio_set); 212 - 213 - b->bi_private = bio; 214 - b->bi_end_io = faulty_fail; 215 - bio = b; 216 - } else 217 - bio_set_dev(bio, conf->rdev->bdev); 218 - 219 - submit_bio_noacct(bio); 220 - return true; 221 - } 222 - 223 - static void faulty_status(struct seq_file *seq, struct mddev *mddev) 224 - { 225 - struct faulty_conf *conf = mddev->private; 226 - int n; 227 - 228 - if ((n=atomic_read(&conf->counters[WriteTransient])) != 0) 229 - seq_printf(seq, " WriteTransient=%d(%d)", 230 - n, conf->period[WriteTransient]); 231 - 232 - if ((n=atomic_read(&conf->counters[ReadTransient])) != 0) 233 - seq_printf(seq, " ReadTransient=%d(%d)", 234 - n, conf->period[ReadTransient]); 235 - 236 - if ((n=atomic_read(&conf->counters[WritePersistent])) != 0) 237 - seq_printf(seq, " WritePersistent=%d(%d)", 238 - n, conf->period[WritePersistent]); 239 - 240 - if ((n=atomic_read(&conf->counters[ReadPersistent])) != 0) 241 - seq_printf(seq, " ReadPersistent=%d(%d)", 242 - n, conf->period[ReadPersistent]); 243 - 244 - 245 - if ((n=atomic_read(&conf->counters[ReadFixable])) != 0) 246 - seq_printf(seq, " ReadFixable=%d(%d)", 247 - n, conf->period[ReadFixable]); 248 - 249 - if ((n=atomic_read(&conf->counters[WriteAll])) != 0) 250 - seq_printf(seq, " WriteAll"); 251 - 252 - seq_printf(seq, " nfaults=%d", conf->nfaults); 253 - } 254 - 255 - 256 - static int faulty_reshape(struct mddev *mddev) 257 - { 258 - int mode = mddev->new_layout & ModeMask; 259 - int count = mddev->new_layout >> ModeShift; 260 - struct faulty_conf *conf = mddev->private; 261 - 262 - if (mddev->new_layout < 0) 263 - return 0; 264 - 265 - /* new layout */ 266 - if (mode == ClearFaults) 267 - conf->nfaults = 0; 268 - else if (mode == ClearErrors) { 269 - int i; 270 - for (i=0 ; i < Modes ; i++) { 271 - conf->period[i] = 0; 272 - atomic_set(&conf->counters[i], 0); 273 - } 274 - } else if (mode < Modes) { 275 - conf->period[mode] = count; 276 - if (!count) count++; 277 - atomic_set(&conf->counters[mode], count); 278 - } else 279 - return -EINVAL; 280 - mddev->new_layout = -1; 281 - mddev->layout = -1; /* makes sure further changes come through */ 282 - return 0; 283 - } 284 - 285 - static sector_t faulty_size(struct mddev *mddev, sector_t sectors, int raid_disks) 286 - { 287 - WARN_ONCE(raid_disks, 288 - "%s does not support generic reshape\n", __func__); 289 - 290 - if (sectors == 0) 291 - return mddev->dev_sectors; 292 - 293 - return sectors; 294 - } 295 - 296 - static int faulty_run(struct mddev *mddev) 297 - { 298 - struct md_rdev *rdev; 299 - int i; 300 - struct faulty_conf *conf; 301 - 302 - if (md_check_no_bitmap(mddev)) 303 - return -EINVAL; 304 - 305 - conf = kmalloc(sizeof(*conf), GFP_KERNEL); 306 - if (!conf) 307 - return -ENOMEM; 308 - 309 - for (i=0; i<Modes; i++) { 310 - atomic_set(&conf->counters[i], 0); 311 - conf->period[i] = 0; 312 - } 313 - conf->nfaults = 0; 314 - 315 - rdev_for_each(rdev, mddev) { 316 - conf->rdev = rdev; 317 - disk_stack_limits(mddev->gendisk, rdev->bdev, 318 - rdev->data_offset << 9); 319 - } 320 - 321 - md_set_array_sectors(mddev, faulty_size(mddev, 0, 0)); 322 - mddev->private = conf; 323 - 324 - faulty_reshape(mddev); 325 - 326 - return 0; 327 - } 328 - 329 - static void faulty_free(struct mddev *mddev, void *priv) 330 - { 331 - struct faulty_conf *conf = priv; 332 - 333 - kfree(conf); 334 - } 335 - 336 - static struct md_personality faulty_personality = 337 - { 338 - .name = "faulty", 339 - .level = LEVEL_FAULTY, 340 - .owner = THIS_MODULE, 341 - .make_request = faulty_make_request, 342 - .run = faulty_run, 343 - .free = faulty_free, 344 - .status = faulty_status, 345 - .check_reshape = faulty_reshape, 346 - .size = faulty_size, 347 - }; 348 - 349 - static int __init raid_init(void) 350 - { 351 - return register_md_personality(&faulty_personality); 352 - } 353 - 354 - static void raid_exit(void) 355 - { 356 - unregister_md_personality(&faulty_personality); 357 - } 358 - 359 - module_init(raid_init); 360 - module_exit(raid_exit); 361 - MODULE_LICENSE("GPL"); 362 - MODULE_DESCRIPTION("Fault injection personality for MD (deprecated)"); 363 - MODULE_ALIAS("md-personality-10"); /* faulty */ 364 - MODULE_ALIAS("md-faulty"); 365 - MODULE_ALIAS("md-level--5");
-318
drivers/md/md-linear.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-or-later 2 - /* 3 - linear.c : Multiple Devices driver for Linux 4 - Copyright (C) 1994-96 Marc ZYNGIER 5 - <zyngier@ufr-info-p7.ibp.fr> or 6 - <maz@gloups.fdn.fr> 7 - 8 - Linear mode management functions. 9 - 10 - */ 11 - 12 - #include <linux/blkdev.h> 13 - #include <linux/raid/md_u.h> 14 - #include <linux/seq_file.h> 15 - #include <linux/module.h> 16 - #include <linux/slab.h> 17 - #include <trace/events/block.h> 18 - #include "md.h" 19 - #include "md-linear.h" 20 - 21 - /* 22 - * find which device holds a particular offset 23 - */ 24 - static inline struct dev_info *which_dev(struct mddev *mddev, sector_t sector) 25 - { 26 - int lo, mid, hi; 27 - struct linear_conf *conf; 28 - 29 - lo = 0; 30 - hi = mddev->raid_disks - 1; 31 - conf = mddev->private; 32 - 33 - /* 34 - * Binary Search 35 - */ 36 - 37 - while (hi > lo) { 38 - 39 - mid = (hi + lo) / 2; 40 - if (sector < conf->disks[mid].end_sector) 41 - hi = mid; 42 - else 43 - lo = mid + 1; 44 - } 45 - 46 - return conf->disks + lo; 47 - } 48 - 49 - static sector_t linear_size(struct mddev *mddev, sector_t sectors, int raid_disks) 50 - { 51 - struct linear_conf *conf; 52 - sector_t array_sectors; 53 - 54 - conf = mddev->private; 55 - WARN_ONCE(sectors || raid_disks, 56 - "%s does not support generic reshape\n", __func__); 57 - array_sectors = conf->array_sectors; 58 - 59 - return array_sectors; 60 - } 61 - 62 - static struct linear_conf *linear_conf(struct mddev *mddev, int raid_disks) 63 - { 64 - struct linear_conf *conf; 65 - struct md_rdev *rdev; 66 - int i, cnt; 67 - 68 - conf = kzalloc(struct_size(conf, disks, raid_disks), GFP_KERNEL); 69 - if (!conf) 70 - return NULL; 71 - 72 - /* 73 - * conf->raid_disks is copy of mddev->raid_disks. The reason to 74 - * keep a copy of mddev->raid_disks in struct linear_conf is, 75 - * mddev->raid_disks may not be consistent with pointers number of 76 - * conf->disks[] when it is updated in linear_add() and used to 77 - * iterate old conf->disks[] earray in linear_congested(). 78 - * Here conf->raid_disks is always consitent with number of 79 - * pointers in conf->disks[] array, and mddev->private is updated 80 - * with rcu_assign_pointer() in linear_addr(), such race can be 81 - * avoided. 82 - */ 83 - conf->raid_disks = raid_disks; 84 - 85 - cnt = 0; 86 - conf->array_sectors = 0; 87 - 88 - rdev_for_each(rdev, mddev) { 89 - int j = rdev->raid_disk; 90 - struct dev_info *disk = conf->disks + j; 91 - sector_t sectors; 92 - 93 - if (j < 0 || j >= raid_disks || disk->rdev) { 94 - pr_warn("md/linear:%s: disk numbering problem. Aborting!\n", 95 - mdname(mddev)); 96 - goto out; 97 - } 98 - 99 - disk->rdev = rdev; 100 - if (mddev->chunk_sectors) { 101 - sectors = rdev->sectors; 102 - sector_div(sectors, mddev->chunk_sectors); 103 - rdev->sectors = sectors * mddev->chunk_sectors; 104 - } 105 - 106 - disk_stack_limits(mddev->gendisk, rdev->bdev, 107 - rdev->data_offset << 9); 108 - 109 - conf->array_sectors += rdev->sectors; 110 - cnt++; 111 - } 112 - if (cnt != raid_disks) { 113 - pr_warn("md/linear:%s: not enough drives present. Aborting!\n", 114 - mdname(mddev)); 115 - goto out; 116 - } 117 - 118 - /* 119 - * Here we calculate the device offsets. 120 - */ 121 - conf->disks[0].end_sector = conf->disks[0].rdev->sectors; 122 - 123 - for (i = 1; i < raid_disks; i++) 124 - conf->disks[i].end_sector = 125 - conf->disks[i-1].end_sector + 126 - conf->disks[i].rdev->sectors; 127 - 128 - return conf; 129 - 130 - out: 131 - kfree(conf); 132 - return NULL; 133 - } 134 - 135 - static int linear_run (struct mddev *mddev) 136 - { 137 - struct linear_conf *conf; 138 - int ret; 139 - 140 - if (md_check_no_bitmap(mddev)) 141 - return -EINVAL; 142 - conf = linear_conf(mddev, mddev->raid_disks); 143 - 144 - if (!conf) 145 - return 1; 146 - mddev->private = conf; 147 - md_set_array_sectors(mddev, linear_size(mddev, 0, 0)); 148 - 149 - ret = md_integrity_register(mddev); 150 - if (ret) { 151 - kfree(conf); 152 - mddev->private = NULL; 153 - } 154 - return ret; 155 - } 156 - 157 - static int linear_add(struct mddev *mddev, struct md_rdev *rdev) 158 - { 159 - /* Adding a drive to a linear array allows the array to grow. 160 - * It is permitted if the new drive has a matching superblock 161 - * already on it, with raid_disk equal to raid_disks. 162 - * It is achieved by creating a new linear_private_data structure 163 - * and swapping it in in-place of the current one. 164 - * The current one is never freed until the array is stopped. 165 - * This avoids races. 166 - */ 167 - struct linear_conf *newconf, *oldconf; 168 - 169 - if (rdev->saved_raid_disk != mddev->raid_disks) 170 - return -EINVAL; 171 - 172 - rdev->raid_disk = rdev->saved_raid_disk; 173 - rdev->saved_raid_disk = -1; 174 - 175 - newconf = linear_conf(mddev,mddev->raid_disks+1); 176 - 177 - if (!newconf) 178 - return -ENOMEM; 179 - 180 - /* newconf->raid_disks already keeps a copy of * the increased 181 - * value of mddev->raid_disks, WARN_ONCE() is just used to make 182 - * sure of this. It is possible that oldconf is still referenced 183 - * in linear_congested(), therefore kfree_rcu() is used to free 184 - * oldconf until no one uses it anymore. 185 - */ 186 - oldconf = rcu_dereference_protected(mddev->private, 187 - lockdep_is_held(&mddev->reconfig_mutex)); 188 - mddev->raid_disks++; 189 - WARN_ONCE(mddev->raid_disks != newconf->raid_disks, 190 - "copied raid_disks doesn't match mddev->raid_disks"); 191 - rcu_assign_pointer(mddev->private, newconf); 192 - md_set_array_sectors(mddev, linear_size(mddev, 0, 0)); 193 - set_capacity_and_notify(mddev->gendisk, mddev->array_sectors); 194 - kfree_rcu(oldconf, rcu); 195 - return 0; 196 - } 197 - 198 - static void linear_free(struct mddev *mddev, void *priv) 199 - { 200 - struct linear_conf *conf = priv; 201 - 202 - kfree(conf); 203 - } 204 - 205 - static bool linear_make_request(struct mddev *mddev, struct bio *bio) 206 - { 207 - struct dev_info *tmp_dev; 208 - sector_t start_sector, end_sector, data_offset; 209 - sector_t bio_sector = bio->bi_iter.bi_sector; 210 - 211 - if (unlikely(bio->bi_opf & REQ_PREFLUSH) 212 - && md_flush_request(mddev, bio)) 213 - return true; 214 - 215 - tmp_dev = which_dev(mddev, bio_sector); 216 - start_sector = tmp_dev->end_sector - tmp_dev->rdev->sectors; 217 - end_sector = tmp_dev->end_sector; 218 - data_offset = tmp_dev->rdev->data_offset; 219 - 220 - if (unlikely(bio_sector >= end_sector || 221 - bio_sector < start_sector)) 222 - goto out_of_bounds; 223 - 224 - if (unlikely(is_rdev_broken(tmp_dev->rdev))) { 225 - md_error(mddev, tmp_dev->rdev); 226 - bio_io_error(bio); 227 - return true; 228 - } 229 - 230 - if (unlikely(bio_end_sector(bio) > end_sector)) { 231 - /* This bio crosses a device boundary, so we have to split it */ 232 - struct bio *split = bio_split(bio, end_sector - bio_sector, 233 - GFP_NOIO, &mddev->bio_set); 234 - bio_chain(split, bio); 235 - submit_bio_noacct(bio); 236 - bio = split; 237 - } 238 - 239 - md_account_bio(mddev, &bio); 240 - bio_set_dev(bio, tmp_dev->rdev->bdev); 241 - bio->bi_iter.bi_sector = bio->bi_iter.bi_sector - 242 - start_sector + data_offset; 243 - 244 - if (unlikely((bio_op(bio) == REQ_OP_DISCARD) && 245 - !bdev_max_discard_sectors(bio->bi_bdev))) { 246 - /* Just ignore it */ 247 - bio_endio(bio); 248 - } else { 249 - if (mddev->gendisk) 250 - trace_block_bio_remap(bio, disk_devt(mddev->gendisk), 251 - bio_sector); 252 - mddev_check_write_zeroes(mddev, bio); 253 - submit_bio_noacct(bio); 254 - } 255 - return true; 256 - 257 - out_of_bounds: 258 - pr_err("md/linear:%s: make_request: Sector %llu out of bounds on dev %pg: %llu sectors, offset %llu\n", 259 - mdname(mddev), 260 - (unsigned long long)bio->bi_iter.bi_sector, 261 - tmp_dev->rdev->bdev, 262 - (unsigned long long)tmp_dev->rdev->sectors, 263 - (unsigned long long)start_sector); 264 - bio_io_error(bio); 265 - return true; 266 - } 267 - 268 - static void linear_status (struct seq_file *seq, struct mddev *mddev) 269 - { 270 - seq_printf(seq, " %dk rounding", mddev->chunk_sectors / 2); 271 - } 272 - 273 - static void linear_error(struct mddev *mddev, struct md_rdev *rdev) 274 - { 275 - if (!test_and_set_bit(MD_BROKEN, &mddev->flags)) { 276 - char *md_name = mdname(mddev); 277 - 278 - pr_crit("md/linear%s: Disk failure on %pg detected, failing array.\n", 279 - md_name, rdev->bdev); 280 - } 281 - } 282 - 283 - static void linear_quiesce(struct mddev *mddev, int state) 284 - { 285 - } 286 - 287 - static struct md_personality linear_personality = 288 - { 289 - .name = "linear", 290 - .level = LEVEL_LINEAR, 291 - .owner = THIS_MODULE, 292 - .make_request = linear_make_request, 293 - .run = linear_run, 294 - .free = linear_free, 295 - .status = linear_status, 296 - .hot_add_disk = linear_add, 297 - .size = linear_size, 298 - .quiesce = linear_quiesce, 299 - .error_handler = linear_error, 300 - }; 301 - 302 - static int __init linear_init (void) 303 - { 304 - return register_md_personality (&linear_personality); 305 - } 306 - 307 - static void linear_exit (void) 308 - { 309 - unregister_md_personality (&linear_personality); 310 - } 311 - 312 - module_init(linear_init); 313 - module_exit(linear_exit); 314 - MODULE_LICENSE("GPL"); 315 - MODULE_DESCRIPTION("Linear device concatenation personality for MD (deprecated)"); 316 - MODULE_ALIAS("md-personality-1"); /* LINEAR - deprecated*/ 317 - MODULE_ALIAS("md-linear"); 318 - MODULE_ALIAS("md-level--1");
-463
drivers/md/md-multipath.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-or-later 2 - /* 3 - * multipath.c : Multiple Devices driver for Linux 4 - * 5 - * Copyright (C) 1999, 2000, 2001 Ingo Molnar, Red Hat 6 - * 7 - * Copyright (C) 1996, 1997, 1998 Ingo Molnar, Miguel de Icaza, Gadi Oxman 8 - * 9 - * MULTIPATH management functions. 10 - * 11 - * derived from raid1.c. 12 - */ 13 - 14 - #include <linux/blkdev.h> 15 - #include <linux/module.h> 16 - #include <linux/raid/md_u.h> 17 - #include <linux/seq_file.h> 18 - #include <linux/slab.h> 19 - #include "md.h" 20 - #include "md-multipath.h" 21 - 22 - #define MAX_WORK_PER_DISK 128 23 - 24 - #define NR_RESERVED_BUFS 32 25 - 26 - static int multipath_map (struct mpconf *conf) 27 - { 28 - int i, disks = conf->raid_disks; 29 - 30 - /* 31 - * Later we do read balancing on the read side 32 - * now we use the first available disk. 33 - */ 34 - 35 - for (i = 0; i < disks; i++) { 36 - struct md_rdev *rdev = conf->multipaths[i].rdev; 37 - 38 - if (rdev && test_bit(In_sync, &rdev->flags) && 39 - !test_bit(Faulty, &rdev->flags)) { 40 - atomic_inc(&rdev->nr_pending); 41 - return i; 42 - } 43 - } 44 - 45 - pr_crit_ratelimited("multipath_map(): no more operational IO paths?\n"); 46 - return (-1); 47 - } 48 - 49 - static void multipath_reschedule_retry (struct multipath_bh *mp_bh) 50 - { 51 - unsigned long flags; 52 - struct mddev *mddev = mp_bh->mddev; 53 - struct mpconf *conf = mddev->private; 54 - 55 - spin_lock_irqsave(&conf->device_lock, flags); 56 - list_add(&mp_bh->retry_list, &conf->retry_list); 57 - spin_unlock_irqrestore(&conf->device_lock, flags); 58 - md_wakeup_thread(mddev->thread); 59 - } 60 - 61 - /* 62 - * multipath_end_bh_io() is called when we have finished servicing a multipathed 63 - * operation and are ready to return a success/failure code to the buffer 64 - * cache layer. 65 - */ 66 - static void multipath_end_bh_io(struct multipath_bh *mp_bh, blk_status_t status) 67 - { 68 - struct bio *bio = mp_bh->master_bio; 69 - struct mpconf *conf = mp_bh->mddev->private; 70 - 71 - bio->bi_status = status; 72 - bio_endio(bio); 73 - mempool_free(mp_bh, &conf->pool); 74 - } 75 - 76 - static void multipath_end_request(struct bio *bio) 77 - { 78 - struct multipath_bh *mp_bh = bio->bi_private; 79 - struct mpconf *conf = mp_bh->mddev->private; 80 - struct md_rdev *rdev = conf->multipaths[mp_bh->path].rdev; 81 - 82 - if (!bio->bi_status) 83 - multipath_end_bh_io(mp_bh, 0); 84 - else if (!(bio->bi_opf & REQ_RAHEAD)) { 85 - /* 86 - * oops, IO error: 87 - */ 88 - md_error (mp_bh->mddev, rdev); 89 - pr_info("multipath: %pg: rescheduling sector %llu\n", 90 - rdev->bdev, 91 - (unsigned long long)bio->bi_iter.bi_sector); 92 - multipath_reschedule_retry(mp_bh); 93 - } else 94 - multipath_end_bh_io(mp_bh, bio->bi_status); 95 - rdev_dec_pending(rdev, conf->mddev); 96 - } 97 - 98 - static bool multipath_make_request(struct mddev *mddev, struct bio * bio) 99 - { 100 - struct mpconf *conf = mddev->private; 101 - struct multipath_bh * mp_bh; 102 - struct multipath_info *multipath; 103 - 104 - if (unlikely(bio->bi_opf & REQ_PREFLUSH) 105 - && md_flush_request(mddev, bio)) 106 - return true; 107 - 108 - md_account_bio(mddev, &bio); 109 - mp_bh = mempool_alloc(&conf->pool, GFP_NOIO); 110 - 111 - mp_bh->master_bio = bio; 112 - mp_bh->mddev = mddev; 113 - 114 - mp_bh->path = multipath_map(conf); 115 - if (mp_bh->path < 0) { 116 - bio_io_error(bio); 117 - mempool_free(mp_bh, &conf->pool); 118 - return true; 119 - } 120 - multipath = conf->multipaths + mp_bh->path; 121 - 122 - bio_init_clone(multipath->rdev->bdev, &mp_bh->bio, bio, GFP_NOIO); 123 - 124 - mp_bh->bio.bi_iter.bi_sector += multipath->rdev->data_offset; 125 - mp_bh->bio.bi_opf |= REQ_FAILFAST_TRANSPORT; 126 - mp_bh->bio.bi_end_io = multipath_end_request; 127 - mp_bh->bio.bi_private = mp_bh; 128 - mddev_check_write_zeroes(mddev, &mp_bh->bio); 129 - submit_bio_noacct(&mp_bh->bio); 130 - return true; 131 - } 132 - 133 - static void multipath_status(struct seq_file *seq, struct mddev *mddev) 134 - { 135 - struct mpconf *conf = mddev->private; 136 - int i; 137 - 138 - lockdep_assert_held(&mddev->lock); 139 - 140 - seq_printf (seq, " [%d/%d] [", conf->raid_disks, 141 - conf->raid_disks - mddev->degraded); 142 - for (i = 0; i < conf->raid_disks; i++) { 143 - struct md_rdev *rdev = READ_ONCE(conf->multipaths[i].rdev); 144 - 145 - seq_printf(seq, "%s", 146 - rdev && test_bit(In_sync, &rdev->flags) ? "U" : "_"); 147 - } 148 - seq_putc(seq, ']'); 149 - } 150 - 151 - /* 152 - * Careful, this can execute in IRQ contexts as well! 153 - */ 154 - static void multipath_error (struct mddev *mddev, struct md_rdev *rdev) 155 - { 156 - struct mpconf *conf = mddev->private; 157 - 158 - if (conf->raid_disks - mddev->degraded <= 1) { 159 - /* 160 - * Uh oh, we can do nothing if this is our last path, but 161 - * first check if this is a queued request for a device 162 - * which has just failed. 163 - */ 164 - pr_warn("multipath: only one IO path left and IO error.\n"); 165 - /* leave it active... it's all we have */ 166 - return; 167 - } 168 - /* 169 - * Mark disk as unusable 170 - */ 171 - if (test_and_clear_bit(In_sync, &rdev->flags)) { 172 - unsigned long flags; 173 - spin_lock_irqsave(&conf->device_lock, flags); 174 - mddev->degraded++; 175 - spin_unlock_irqrestore(&conf->device_lock, flags); 176 - } 177 - set_bit(Faulty, &rdev->flags); 178 - set_bit(MD_SB_CHANGE_DEVS, &mddev->sb_flags); 179 - pr_err("multipath: IO failure on %pg, disabling IO path.\n" 180 - "multipath: Operation continuing on %d IO paths.\n", 181 - rdev->bdev, 182 - conf->raid_disks - mddev->degraded); 183 - } 184 - 185 - static void print_multipath_conf(struct mpconf *conf) 186 - { 187 - int i; 188 - struct multipath_info *tmp; 189 - 190 - pr_debug("MULTIPATH conf printout:\n"); 191 - if (!conf) { 192 - pr_debug("(conf==NULL)\n"); 193 - return; 194 - } 195 - pr_debug(" --- wd:%d rd:%d\n", conf->raid_disks - conf->mddev->degraded, 196 - conf->raid_disks); 197 - 198 - lockdep_assert_held(&conf->mddev->reconfig_mutex); 199 - for (i = 0; i < conf->raid_disks; i++) { 200 - tmp = conf->multipaths + i; 201 - if (tmp->rdev) 202 - pr_debug(" disk%d, o:%d, dev:%pg\n", 203 - i,!test_bit(Faulty, &tmp->rdev->flags), 204 - tmp->rdev->bdev); 205 - } 206 - } 207 - 208 - static int multipath_add_disk(struct mddev *mddev, struct md_rdev *rdev) 209 - { 210 - struct mpconf *conf = mddev->private; 211 - int err = -EEXIST; 212 - int path; 213 - struct multipath_info *p; 214 - int first = 0; 215 - int last = mddev->raid_disks - 1; 216 - 217 - if (rdev->raid_disk >= 0) 218 - first = last = rdev->raid_disk; 219 - 220 - print_multipath_conf(conf); 221 - 222 - for (path = first; path <= last; path++) 223 - if ((p=conf->multipaths+path)->rdev == NULL) { 224 - disk_stack_limits(mddev->gendisk, rdev->bdev, 225 - rdev->data_offset << 9); 226 - 227 - err = md_integrity_add_rdev(rdev, mddev); 228 - if (err) 229 - break; 230 - spin_lock_irq(&conf->device_lock); 231 - mddev->degraded--; 232 - rdev->raid_disk = path; 233 - set_bit(In_sync, &rdev->flags); 234 - spin_unlock_irq(&conf->device_lock); 235 - WRITE_ONCE(p->rdev, rdev); 236 - err = 0; 237 - break; 238 - } 239 - 240 - print_multipath_conf(conf); 241 - 242 - return err; 243 - } 244 - 245 - static int multipath_remove_disk(struct mddev *mddev, struct md_rdev *rdev) 246 - { 247 - struct mpconf *conf = mddev->private; 248 - int err = 0; 249 - int number = rdev->raid_disk; 250 - struct multipath_info *p = conf->multipaths + number; 251 - 252 - print_multipath_conf(conf); 253 - 254 - if (rdev == p->rdev) { 255 - if (test_bit(In_sync, &rdev->flags) || 256 - atomic_read(&rdev->nr_pending)) { 257 - pr_warn("hot-remove-disk, slot %d is identified but is still operational!\n", number); 258 - err = -EBUSY; 259 - goto abort; 260 - } 261 - WRITE_ONCE(p->rdev, NULL); 262 - err = md_integrity_register(mddev); 263 - } 264 - abort: 265 - 266 - print_multipath_conf(conf); 267 - return err; 268 - } 269 - 270 - /* 271 - * This is a kernel thread which: 272 - * 273 - * 1. Retries failed read operations on working multipaths. 274 - * 2. Updates the raid superblock when problems encounter. 275 - * 3. Performs writes following reads for array syncronising. 276 - */ 277 - 278 - static void multipathd(struct md_thread *thread) 279 - { 280 - struct mddev *mddev = thread->mddev; 281 - struct multipath_bh *mp_bh; 282 - struct bio *bio; 283 - unsigned long flags; 284 - struct mpconf *conf = mddev->private; 285 - struct list_head *head = &conf->retry_list; 286 - 287 - md_check_recovery(mddev); 288 - for (;;) { 289 - spin_lock_irqsave(&conf->device_lock, flags); 290 - if (list_empty(head)) 291 - break; 292 - mp_bh = list_entry(head->prev, struct multipath_bh, retry_list); 293 - list_del(head->prev); 294 - spin_unlock_irqrestore(&conf->device_lock, flags); 295 - 296 - bio = &mp_bh->bio; 297 - bio->bi_iter.bi_sector = mp_bh->master_bio->bi_iter.bi_sector; 298 - 299 - if ((mp_bh->path = multipath_map (conf))<0) { 300 - pr_err("multipath: %pg: unrecoverable IO read error for block %llu\n", 301 - bio->bi_bdev, 302 - (unsigned long long)bio->bi_iter.bi_sector); 303 - multipath_end_bh_io(mp_bh, BLK_STS_IOERR); 304 - } else { 305 - pr_err("multipath: %pg: redirecting sector %llu to another IO path\n", 306 - bio->bi_bdev, 307 - (unsigned long long)bio->bi_iter.bi_sector); 308 - *bio = *(mp_bh->master_bio); 309 - bio->bi_iter.bi_sector += 310 - conf->multipaths[mp_bh->path].rdev->data_offset; 311 - bio_set_dev(bio, conf->multipaths[mp_bh->path].rdev->bdev); 312 - bio->bi_opf |= REQ_FAILFAST_TRANSPORT; 313 - bio->bi_end_io = multipath_end_request; 314 - bio->bi_private = mp_bh; 315 - submit_bio_noacct(bio); 316 - } 317 - } 318 - spin_unlock_irqrestore(&conf->device_lock, flags); 319 - } 320 - 321 - static sector_t multipath_size(struct mddev *mddev, sector_t sectors, int raid_disks) 322 - { 323 - WARN_ONCE(sectors || raid_disks, 324 - "%s does not support generic reshape\n", __func__); 325 - 326 - return mddev->dev_sectors; 327 - } 328 - 329 - static int multipath_run (struct mddev *mddev) 330 - { 331 - struct mpconf *conf; 332 - int disk_idx; 333 - struct multipath_info *disk; 334 - struct md_rdev *rdev; 335 - int working_disks; 336 - int ret; 337 - 338 - if (md_check_no_bitmap(mddev)) 339 - return -EINVAL; 340 - 341 - if (mddev->level != LEVEL_MULTIPATH) { 342 - pr_warn("multipath: %s: raid level not set to multipath IO (%d)\n", 343 - mdname(mddev), mddev->level); 344 - goto out; 345 - } 346 - /* 347 - * copy the already verified devices into our private MULTIPATH 348 - * bookkeeping area. [whatever we allocate in multipath_run(), 349 - * should be freed in multipath_free()] 350 - */ 351 - 352 - conf = kzalloc(sizeof(struct mpconf), GFP_KERNEL); 353 - mddev->private = conf; 354 - if (!conf) 355 - goto out; 356 - 357 - conf->multipaths = kcalloc(mddev->raid_disks, 358 - sizeof(struct multipath_info), 359 - GFP_KERNEL); 360 - if (!conf->multipaths) 361 - goto out_free_conf; 362 - 363 - working_disks = 0; 364 - rdev_for_each(rdev, mddev) { 365 - disk_idx = rdev->raid_disk; 366 - if (disk_idx < 0 || 367 - disk_idx >= mddev->raid_disks) 368 - continue; 369 - 370 - disk = conf->multipaths + disk_idx; 371 - disk->rdev = rdev; 372 - disk_stack_limits(mddev->gendisk, rdev->bdev, 373 - rdev->data_offset << 9); 374 - 375 - if (!test_bit(Faulty, &rdev->flags)) 376 - working_disks++; 377 - } 378 - 379 - conf->raid_disks = mddev->raid_disks; 380 - conf->mddev = mddev; 381 - spin_lock_init(&conf->device_lock); 382 - INIT_LIST_HEAD(&conf->retry_list); 383 - 384 - if (!working_disks) { 385 - pr_warn("multipath: no operational IO paths for %s\n", 386 - mdname(mddev)); 387 - goto out_free_conf; 388 - } 389 - mddev->degraded = conf->raid_disks - working_disks; 390 - 391 - ret = mempool_init_kmalloc_pool(&conf->pool, NR_RESERVED_BUFS, 392 - sizeof(struct multipath_bh)); 393 - if (ret) 394 - goto out_free_conf; 395 - 396 - rcu_assign_pointer(mddev->thread, 397 - md_register_thread(multipathd, mddev, "multipath")); 398 - if (!mddev->thread) 399 - goto out_free_conf; 400 - 401 - pr_info("multipath: array %s active with %d out of %d IO paths\n", 402 - mdname(mddev), conf->raid_disks - mddev->degraded, 403 - mddev->raid_disks); 404 - /* 405 - * Ok, everything is just fine now 406 - */ 407 - md_set_array_sectors(mddev, multipath_size(mddev, 0, 0)); 408 - 409 - if (md_integrity_register(mddev)) 410 - goto out_free_conf; 411 - 412 - return 0; 413 - 414 - out_free_conf: 415 - mempool_exit(&conf->pool); 416 - kfree(conf->multipaths); 417 - kfree(conf); 418 - mddev->private = NULL; 419 - out: 420 - return -EIO; 421 - } 422 - 423 - static void multipath_free(struct mddev *mddev, void *priv) 424 - { 425 - struct mpconf *conf = priv; 426 - 427 - mempool_exit(&conf->pool); 428 - kfree(conf->multipaths); 429 - kfree(conf); 430 - } 431 - 432 - static struct md_personality multipath_personality = 433 - { 434 - .name = "multipath", 435 - .level = LEVEL_MULTIPATH, 436 - .owner = THIS_MODULE, 437 - .make_request = multipath_make_request, 438 - .run = multipath_run, 439 - .free = multipath_free, 440 - .status = multipath_status, 441 - .error_handler = multipath_error, 442 - .hot_add_disk = multipath_add_disk, 443 - .hot_remove_disk= multipath_remove_disk, 444 - .size = multipath_size, 445 - }; 446 - 447 - static int __init multipath_init (void) 448 - { 449 - return register_md_personality (&multipath_personality); 450 - } 451 - 452 - static void __exit multipath_exit (void) 453 - { 454 - unregister_md_personality (&multipath_personality); 455 - } 456 - 457 - module_init(multipath_init); 458 - module_exit(multipath_exit); 459 - MODULE_LICENSE("GPL"); 460 - MODULE_DESCRIPTION("simple multi-path personality for MD (deprecated)"); 461 - MODULE_ALIAS("md-personality-7"); /* MULTIPATH */ 462 - MODULE_ALIAS("md-multipath"); 463 - MODULE_ALIAS("md-level--4");
+124 -115
drivers/md/md.c
··· 1206 1206 struct md_rdev *refdev, 1207 1207 int minor_version); 1208 1208 int (*validate_super)(struct mddev *mddev, 1209 + struct md_rdev *freshest, 1209 1210 struct md_rdev *rdev); 1210 1211 void (*sync_super)(struct mddev *mddev, 1211 1212 struct md_rdev *rdev); ··· 1287 1286 rdev->sb_size = MD_SB_BYTES; 1288 1287 rdev->badblocks.shift = -1; 1289 1288 1290 - if (sb->level == LEVEL_MULTIPATH) 1291 - rdev->desc_nr = -1; 1292 - else 1293 - rdev->desc_nr = sb->this_disk.number; 1289 + rdev->desc_nr = sb->this_disk.number; 1294 1290 1295 - /* not spare disk, or LEVEL_MULTIPATH */ 1296 - if (sb->level == LEVEL_MULTIPATH || 1297 - (rdev->desc_nr >= 0 && 1298 - rdev->desc_nr < MD_SB_DISKS && 1299 - sb->disks[rdev->desc_nr].state & 1300 - ((1<<MD_DISK_SYNC) | (1 << MD_DISK_ACTIVE)))) 1291 + /* not spare disk */ 1292 + if (rdev->desc_nr >= 0 && rdev->desc_nr < MD_SB_DISKS && 1293 + sb->disks[rdev->desc_nr].state & ((1<<MD_DISK_SYNC) | (1 << MD_DISK_ACTIVE))) 1301 1294 spare_disk = false; 1302 1295 1303 1296 if (!refdev) { ··· 1338 1343 1339 1344 /* 1340 1345 * validate_super for 0.90.0 1346 + * note: we are not using "freshest" for 0.9 superblock 1341 1347 */ 1342 - static int super_90_validate(struct mddev *mddev, struct md_rdev *rdev) 1348 + static int super_90_validate(struct mddev *mddev, struct md_rdev *freshest, struct md_rdev *rdev) 1343 1349 { 1344 1350 mdp_disk_t *desc; 1345 1351 mdp_super_t *sb = page_address(rdev->sb_page); ··· 1438 1442 return 0; 1439 1443 } 1440 1444 1441 - if (mddev->level != LEVEL_MULTIPATH) { 1442 - desc = sb->disks + rdev->desc_nr; 1445 + desc = sb->disks + rdev->desc_nr; 1443 1446 1444 - if (desc->state & (1<<MD_DISK_FAULTY)) 1445 - set_bit(Faulty, &rdev->flags); 1446 - else if (desc->state & (1<<MD_DISK_SYNC) /* && 1447 - desc->raid_disk < mddev->raid_disks */) { 1448 - set_bit(In_sync, &rdev->flags); 1449 - rdev->raid_disk = desc->raid_disk; 1450 - rdev->saved_raid_disk = desc->raid_disk; 1451 - } else if (desc->state & (1<<MD_DISK_ACTIVE)) { 1452 - /* active but not in sync implies recovery up to 1453 - * reshape position. We don't know exactly where 1454 - * that is, so set to zero for now */ 1455 - if (mddev->minor_version >= 91) { 1456 - rdev->recovery_offset = 0; 1457 - rdev->raid_disk = desc->raid_disk; 1458 - } 1459 - } 1460 - if (desc->state & (1<<MD_DISK_WRITEMOSTLY)) 1461 - set_bit(WriteMostly, &rdev->flags); 1462 - if (desc->state & (1<<MD_DISK_FAILFAST)) 1463 - set_bit(FailFast, &rdev->flags); 1464 - } else /* MULTIPATH are always insync */ 1447 + if (desc->state & (1<<MD_DISK_FAULTY)) 1448 + set_bit(Faulty, &rdev->flags); 1449 + else if (desc->state & (1<<MD_DISK_SYNC)) { 1465 1450 set_bit(In_sync, &rdev->flags); 1451 + rdev->raid_disk = desc->raid_disk; 1452 + rdev->saved_raid_disk = desc->raid_disk; 1453 + } else if (desc->state & (1<<MD_DISK_ACTIVE)) { 1454 + /* active but not in sync implies recovery up to 1455 + * reshape position. We don't know exactly where 1456 + * that is, so set to zero for now 1457 + */ 1458 + if (mddev->minor_version >= 91) { 1459 + rdev->recovery_offset = 0; 1460 + rdev->raid_disk = desc->raid_disk; 1461 + } 1462 + } 1463 + if (desc->state & (1<<MD_DISK_WRITEMOSTLY)) 1464 + set_bit(WriteMostly, &rdev->flags); 1465 + if (desc->state & (1<<MD_DISK_FAILFAST)) 1466 + set_bit(FailFast, &rdev->flags); 1466 1467 return 0; 1467 1468 } 1468 1469 ··· 1749 1756 && rdev->new_data_offset < sb_start + (rdev->sb_size/512)) 1750 1757 return -EINVAL; 1751 1758 1752 - if (sb->level == cpu_to_le32(LEVEL_MULTIPATH)) 1753 - rdev->desc_nr = -1; 1754 - else 1755 - rdev->desc_nr = le32_to_cpu(sb->dev_number); 1759 + rdev->desc_nr = le32_to_cpu(sb->dev_number); 1756 1760 1757 1761 if (!rdev->bb_page) { 1758 1762 rdev->bb_page = alloc_page(GFP_KERNEL); ··· 1802 1812 sb->level != 0) 1803 1813 return -EINVAL; 1804 1814 1805 - /* not spare disk, or LEVEL_MULTIPATH */ 1806 - if (sb->level == cpu_to_le32(LEVEL_MULTIPATH) || 1807 - (rdev->desc_nr >= 0 && 1808 - rdev->desc_nr < le32_to_cpu(sb->max_dev) && 1809 - (le16_to_cpu(sb->dev_roles[rdev->desc_nr]) < MD_DISK_ROLE_MAX || 1810 - le16_to_cpu(sb->dev_roles[rdev->desc_nr]) == MD_DISK_ROLE_JOURNAL))) 1815 + /* not spare disk */ 1816 + if (rdev->desc_nr >= 0 && rdev->desc_nr < le32_to_cpu(sb->max_dev) && 1817 + (le16_to_cpu(sb->dev_roles[rdev->desc_nr]) < MD_DISK_ROLE_MAX || 1818 + le16_to_cpu(sb->dev_roles[rdev->desc_nr]) == MD_DISK_ROLE_JOURNAL)) 1811 1819 spare_disk = false; 1812 1820 1813 1821 if (!refdev) { ··· 1844 1856 return ret; 1845 1857 } 1846 1858 1847 - static int super_1_validate(struct mddev *mddev, struct md_rdev *rdev) 1859 + static int super_1_validate(struct mddev *mddev, struct md_rdev *freshest, struct md_rdev *rdev) 1848 1860 { 1849 1861 struct mdp_superblock_1 *sb = page_address(rdev->sb_page); 1850 1862 __u64 ev1 = le64_to_cpu(sb->events); 1863 + int role; 1851 1864 1852 1865 rdev->raid_disk = -1; 1853 1866 clear_bit(Faulty, &rdev->flags); ··· 1941 1952 } 1942 1953 } else if (mddev->pers == NULL) { 1943 1954 /* Insist of good event counter while assembling, except for 1944 - * spares (which don't need an event count) */ 1945 - ++ev1; 1955 + * spares (which don't need an event count). 1956 + * Similar to mdadm, we allow event counter difference of 1 1957 + * from the freshest device. 1958 + */ 1946 1959 if (rdev->desc_nr >= 0 && 1947 1960 rdev->desc_nr < le32_to_cpu(sb->max_dev) && 1948 1961 (le16_to_cpu(sb->dev_roles[rdev->desc_nr]) < MD_DISK_ROLE_MAX || 1949 1962 le16_to_cpu(sb->dev_roles[rdev->desc_nr]) == MD_DISK_ROLE_JOURNAL)) 1950 - if (ev1 < mddev->events) 1963 + if (ev1 + 1 < mddev->events) 1951 1964 return -EINVAL; 1952 1965 } else if (mddev->bitmap) { 1953 1966 /* If adding to array with a bitmap, then we can accept an ··· 1964 1973 /* just a hot-add of a new device, leave raid_disk at -1 */ 1965 1974 return 0; 1966 1975 } 1967 - if (mddev->level != LEVEL_MULTIPATH) { 1968 - int role; 1969 - if (rdev->desc_nr < 0 || 1970 - rdev->desc_nr >= le32_to_cpu(sb->max_dev)) { 1971 - role = MD_DISK_ROLE_SPARE; 1972 - rdev->desc_nr = -1; 1973 - } else 1974 - role = le16_to_cpu(sb->dev_roles[rdev->desc_nr]); 1975 - switch(role) { 1976 - case MD_DISK_ROLE_SPARE: /* spare */ 1977 - break; 1978 - case MD_DISK_ROLE_FAULTY: /* faulty */ 1979 - set_bit(Faulty, &rdev->flags); 1980 - break; 1981 - case MD_DISK_ROLE_JOURNAL: /* journal device */ 1982 - if (!(le32_to_cpu(sb->feature_map) & MD_FEATURE_JOURNAL)) { 1983 - /* journal device without journal feature */ 1984 - pr_warn("md: journal device provided without journal feature, ignoring the device\n"); 1985 - return -EINVAL; 1986 - } 1987 - set_bit(Journal, &rdev->flags); 1988 - rdev->journal_tail = le64_to_cpu(sb->journal_tail); 1989 - rdev->raid_disk = 0; 1990 - break; 1991 - default: 1992 - rdev->saved_raid_disk = role; 1993 - if ((le32_to_cpu(sb->feature_map) & 1994 - MD_FEATURE_RECOVERY_OFFSET)) { 1995 - rdev->recovery_offset = le64_to_cpu(sb->recovery_offset); 1996 - if (!(le32_to_cpu(sb->feature_map) & 1997 - MD_FEATURE_RECOVERY_BITMAP)) 1998 - rdev->saved_raid_disk = -1; 1999 - } else { 2000 - /* 2001 - * If the array is FROZEN, then the device can't 2002 - * be in_sync with rest of array. 2003 - */ 2004 - if (!test_bit(MD_RECOVERY_FROZEN, 2005 - &mddev->recovery)) 2006 - set_bit(In_sync, &rdev->flags); 2007 - } 2008 - rdev->raid_disk = role; 2009 - break; 1976 + 1977 + if (rdev->desc_nr < 0 || 1978 + rdev->desc_nr >= le32_to_cpu(sb->max_dev)) { 1979 + role = MD_DISK_ROLE_SPARE; 1980 + rdev->desc_nr = -1; 1981 + } else if (mddev->pers == NULL && freshest && ev1 < mddev->events) { 1982 + /* 1983 + * If we are assembling, and our event counter is smaller than the 1984 + * highest event counter, we cannot trust our superblock about the role. 1985 + * It could happen that our rdev was marked as Faulty, and all other 1986 + * superblocks were updated with +1 event counter. 1987 + * Then, before the next superblock update, which typically happens when 1988 + * remove_and_add_spares() removes the device from the array, there was 1989 + * a crash or reboot. 1990 + * If we allow current rdev without consulting the freshest superblock, 1991 + * we could cause data corruption. 1992 + * Note that in this case our event counter is smaller by 1 than the 1993 + * highest, otherwise, this rdev would not be allowed into array; 1994 + * both kernel and mdadm allow event counter difference of 1. 1995 + */ 1996 + struct mdp_superblock_1 *freshest_sb = page_address(freshest->sb_page); 1997 + u32 freshest_max_dev = le32_to_cpu(freshest_sb->max_dev); 1998 + 1999 + if (rdev->desc_nr >= freshest_max_dev) { 2000 + /* this is unexpected, better not proceed */ 2001 + pr_warn("md: %s: rdev[%pg]: desc_nr(%d) >= freshest(%pg)->sb->max_dev(%u)\n", 2002 + mdname(mddev), rdev->bdev, rdev->desc_nr, 2003 + freshest->bdev, freshest_max_dev); 2004 + return -EUCLEAN; 2010 2005 } 2011 - if (sb->devflags & WriteMostly1) 2012 - set_bit(WriteMostly, &rdev->flags); 2013 - if (sb->devflags & FailFast1) 2014 - set_bit(FailFast, &rdev->flags); 2015 - if (le32_to_cpu(sb->feature_map) & MD_FEATURE_REPLACEMENT) 2016 - set_bit(Replacement, &rdev->flags); 2017 - } else /* MULTIPATH are always insync */ 2018 - set_bit(In_sync, &rdev->flags); 2006 + 2007 + role = le16_to_cpu(freshest_sb->dev_roles[rdev->desc_nr]); 2008 + pr_debug("md: %s: rdev[%pg]: role=%d(0x%x) according to freshest %pg\n", 2009 + mdname(mddev), rdev->bdev, role, role, freshest->bdev); 2010 + } else { 2011 + role = le16_to_cpu(sb->dev_roles[rdev->desc_nr]); 2012 + } 2013 + switch (role) { 2014 + case MD_DISK_ROLE_SPARE: /* spare */ 2015 + break; 2016 + case MD_DISK_ROLE_FAULTY: /* faulty */ 2017 + set_bit(Faulty, &rdev->flags); 2018 + break; 2019 + case MD_DISK_ROLE_JOURNAL: /* journal device */ 2020 + if (!(le32_to_cpu(sb->feature_map) & MD_FEATURE_JOURNAL)) { 2021 + /* journal device without journal feature */ 2022 + pr_warn("md: journal device provided without journal feature, ignoring the device\n"); 2023 + return -EINVAL; 2024 + } 2025 + set_bit(Journal, &rdev->flags); 2026 + rdev->journal_tail = le64_to_cpu(sb->journal_tail); 2027 + rdev->raid_disk = 0; 2028 + break; 2029 + default: 2030 + rdev->saved_raid_disk = role; 2031 + if ((le32_to_cpu(sb->feature_map) & 2032 + MD_FEATURE_RECOVERY_OFFSET)) { 2033 + rdev->recovery_offset = le64_to_cpu(sb->recovery_offset); 2034 + if (!(le32_to_cpu(sb->feature_map) & 2035 + MD_FEATURE_RECOVERY_BITMAP)) 2036 + rdev->saved_raid_disk = -1; 2037 + } else { 2038 + /* 2039 + * If the array is FROZEN, then the device can't 2040 + * be in_sync with rest of array. 2041 + */ 2042 + if (!test_bit(MD_RECOVERY_FROZEN, 2043 + &mddev->recovery)) 2044 + set_bit(In_sync, &rdev->flags); 2045 + } 2046 + rdev->raid_disk = role; 2047 + break; 2048 + } 2049 + if (sb->devflags & WriteMostly1) 2050 + set_bit(WriteMostly, &rdev->flags); 2051 + if (sb->devflags & FailFast1) 2052 + set_bit(FailFast, &rdev->flags); 2053 + if (le32_to_cpu(sb->feature_map) & MD_FEATURE_REPLACEMENT) 2054 + set_bit(Replacement, &rdev->flags); 2019 2055 2020 2056 return 0; 2021 2057 } ··· 2860 2842 } else 2861 2843 pr_debug("md: %pg (skipping faulty)\n", 2862 2844 rdev->bdev); 2863 - 2864 - if (mddev->level == LEVEL_MULTIPATH) 2865 - /* only need to write one superblock... */ 2866 - break; 2867 2845 } 2868 2846 if (md_super_wait(mddev) < 0) 2869 2847 goto rewrite; ··· 2901 2887 * and should be added immediately. 2902 2888 */ 2903 2889 super_types[mddev->major_version]. 2904 - validate_super(mddev, rdev); 2890 + validate_super(mddev, NULL/*freshest*/, rdev); 2905 2891 err = mddev->pers->hot_add_disk(mddev, rdev); 2906 2892 if (err) { 2907 2893 md_kick_rdev_from_array(rdev); ··· 3838 3824 } 3839 3825 3840 3826 super_types[mddev->major_version]. 3841 - validate_super(mddev, freshest); 3827 + validate_super(mddev, NULL/*freshest*/, freshest); 3842 3828 3843 3829 i = 0; 3844 3830 rdev_for_each_safe(rdev, tmp, mddev) { ··· 3853 3839 } 3854 3840 if (rdev != freshest) { 3855 3841 if (super_types[mddev->major_version]. 3856 - validate_super(mddev, rdev)) { 3842 + validate_super(mddev, freshest, rdev)) { 3857 3843 pr_warn("md: kicking non-fresh %pg from array!\n", 3858 3844 rdev->bdev); 3859 3845 md_kick_rdev_from_array(rdev); 3860 3846 continue; 3861 3847 } 3862 3848 } 3863 - if (mddev->level == LEVEL_MULTIPATH) { 3864 - rdev->desc_nr = i++; 3865 - rdev->raid_disk = rdev->desc_nr; 3866 - set_bit(In_sync, &rdev->flags); 3867 - } else if (rdev->raid_disk >= 3868 - (mddev->raid_disks - min(0, mddev->delta_disks)) && 3869 - !test_bit(Journal, &rdev->flags)) { 3849 + if (rdev->raid_disk >= (mddev->raid_disks - min(0, mddev->delta_disks)) && 3850 + !test_bit(Journal, &rdev->flags)) { 3870 3851 rdev->raid_disk = -1; 3871 3852 clear_bit(In_sync, &rdev->flags); 3872 3853 } ··· 6856 6847 rdev->saved_raid_disk = rdev->raid_disk; 6857 6848 } else 6858 6849 super_types[mddev->major_version]. 6859 - validate_super(mddev, rdev); 6850 + validate_super(mddev, NULL/*freshest*/, rdev); 6860 6851 if ((info->state & (1<<MD_DISK_SYNC)) && 6861 6852 rdev->raid_disk != info->raid_disk) { 6862 6853 /* This was a hot-add request, but events doesn't ··· 8099 8090 return; 8100 8091 mddev->pers->error_handler(mddev, rdev); 8101 8092 8102 - if (mddev->pers->level == 0 || mddev->pers->level == LEVEL_LINEAR) 8093 + if (mddev->pers->level == 0) 8103 8094 return; 8104 8095 8105 8096 if (mddev->degraded && !test_bit(MD_BROKEN, &mddev->flags))
+54
drivers/md/raid1-10.c
··· 173 173 else 174 174 md_bitmap_unplug(bitmap); 175 175 } 176 + 177 + /* 178 + * Used by fix_read_error() to decay the per rdev read_errors. 179 + * We halve the read error count for every hour that has elapsed 180 + * since the last recorded read error. 181 + */ 182 + static inline void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev) 183 + { 184 + long cur_time_mon; 185 + unsigned long hours_since_last; 186 + unsigned int read_errors = atomic_read(&rdev->read_errors); 187 + 188 + cur_time_mon = ktime_get_seconds(); 189 + 190 + if (rdev->last_read_error == 0) { 191 + /* first time we've seen a read error */ 192 + rdev->last_read_error = cur_time_mon; 193 + return; 194 + } 195 + 196 + hours_since_last = (long)(cur_time_mon - 197 + rdev->last_read_error) / 3600; 198 + 199 + rdev->last_read_error = cur_time_mon; 200 + 201 + /* 202 + * if hours_since_last is > the number of bits in read_errors 203 + * just set read errors to 0. We do this to avoid 204 + * overflowing the shift of read_errors by hours_since_last. 205 + */ 206 + if (hours_since_last >= 8 * sizeof(read_errors)) 207 + atomic_set(&rdev->read_errors, 0); 208 + else 209 + atomic_set(&rdev->read_errors, read_errors >> hours_since_last); 210 + } 211 + 212 + static inline bool exceed_read_errors(struct mddev *mddev, struct md_rdev *rdev) 213 + { 214 + int max_read_errors = atomic_read(&mddev->max_corr_read_errors); 215 + int read_errors; 216 + 217 + check_decay_read_errors(mddev, rdev); 218 + read_errors = atomic_inc_return(&rdev->read_errors); 219 + if (read_errors > max_read_errors) { 220 + pr_notice("md/"RAID_1_10_NAME":%s: %pg: Raid device exceeded read_error threshold [cur %d:max %d]\n", 221 + mdname(mddev), rdev->bdev, read_errors, max_read_errors); 222 + pr_notice("md/"RAID_1_10_NAME":%s: %pg: Failing raid device\n", 223 + mdname(mddev), rdev->bdev); 224 + md_error(mddev, rdev); 225 + return true; 226 + } 227 + 228 + return false; 229 + }
+13 -7
drivers/md/raid1.c
··· 49 49 #define raid1_log(md, fmt, args...) \ 50 50 do { if ((md)->queue) blk_add_trace_msg((md)->queue, "raid1 " fmt, ##args); } while (0) 51 51 52 + #define RAID_1_10_NAME "raid1" 52 53 #include "raid1-10.c" 53 54 54 55 #define START(node) ((node)->start) ··· 1125 1124 1126 1125 behind_bio = bio_alloc_bioset(NULL, vcnt, 0, GFP_NOIO, 1127 1126 &r1_bio->mddev->bio_set); 1128 - if (!behind_bio) 1129 - return; 1130 1127 1131 1128 /* discard op, we don't support writezero/writesame yet */ 1132 1129 if (!bio_has_data(bio)) { ··· 2256 2257 * 3. Performs writes following reads for array synchronising. 2257 2258 */ 2258 2259 2259 - static void fix_read_error(struct r1conf *conf, int read_disk, 2260 - sector_t sect, int sectors) 2260 + static void fix_read_error(struct r1conf *conf, struct r1bio *r1_bio) 2261 2261 { 2262 + sector_t sect = r1_bio->sector; 2263 + int sectors = r1_bio->sectors; 2264 + int read_disk = r1_bio->read_disk; 2262 2265 struct mddev *mddev = conf->mddev; 2266 + struct md_rdev *rdev = rcu_dereference(conf->mirrors[read_disk].rdev); 2267 + 2268 + if (exceed_read_errors(mddev, rdev)) { 2269 + r1_bio->bios[r1_bio->read_disk] = IO_BLOCKED; 2270 + return; 2271 + } 2272 + 2263 2273 while(sectors) { 2264 2274 int s = sectors; 2265 2275 int d = read_disk; 2266 2276 int success = 0; 2267 2277 int start; 2268 - struct md_rdev *rdev; 2269 2278 2270 2279 if (s > (PAGE_SIZE>>9)) 2271 2280 s = PAGE_SIZE >> 9; ··· 2514 2507 if (mddev->ro == 0 2515 2508 && !test_bit(FailFast, &rdev->flags)) { 2516 2509 freeze_array(conf, 1); 2517 - fix_read_error(conf, r1_bio->read_disk, 2518 - r1_bio->sector, r1_bio->sectors); 2510 + fix_read_error(conf, r1_bio); 2519 2511 unfreeze_array(conf); 2520 2512 } else if (mddev->ro == 0 && test_bit(FailFast, &rdev->flags)) { 2521 2513 md_error(mddev, rdev);
+3 -46
drivers/md/raid10.c
··· 19 19 #include <linux/raid/md_p.h> 20 20 #include <trace/events/block.h> 21 21 #include "md.h" 22 + 23 + #define RAID_1_10_NAME "raid10" 22 24 #include "raid10.h" 23 25 #include "raid0.h" 24 26 #include "md-bitmap.h" ··· 2594 2592 } 2595 2593 } 2596 2594 2597 - /* 2598 - * Used by fix_read_error() to decay the per rdev read_errors. 2599 - * We halve the read error count for every hour that has elapsed 2600 - * since the last recorded read error. 2601 - * 2602 - */ 2603 - static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev) 2604 - { 2605 - long cur_time_mon; 2606 - unsigned long hours_since_last; 2607 - unsigned int read_errors = atomic_read(&rdev->read_errors); 2608 - 2609 - cur_time_mon = ktime_get_seconds(); 2610 - 2611 - if (rdev->last_read_error == 0) { 2612 - /* first time we've seen a read error */ 2613 - rdev->last_read_error = cur_time_mon; 2614 - return; 2615 - } 2616 - 2617 - hours_since_last = (long)(cur_time_mon - 2618 - rdev->last_read_error) / 3600; 2619 - 2620 - rdev->last_read_error = cur_time_mon; 2621 - 2622 - /* 2623 - * if hours_since_last is > the number of bits in read_errors 2624 - * just set read errors to 0. We do this to avoid 2625 - * overflowing the shift of read_errors by hours_since_last. 2626 - */ 2627 - if (hours_since_last >= 8 * sizeof(read_errors)) 2628 - atomic_set(&rdev->read_errors, 0); 2629 - else 2630 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last); 2631 - } 2632 - 2633 2595 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector, 2634 2596 int sectors, struct page *page, enum req_op op) 2635 2597 { ··· 2631 2665 int sect = 0; /* Offset from r10_bio->sector */ 2632 2666 int sectors = r10_bio->sectors, slot = r10_bio->read_slot; 2633 2667 struct md_rdev *rdev; 2634 - int max_read_errors = atomic_read(&mddev->max_corr_read_errors); 2635 2668 int d = r10_bio->devs[slot].devnum; 2636 2669 2637 2670 /* still own a reference to this rdev, so it cannot ··· 2643 2678 more fix_read_error() attempts */ 2644 2679 return; 2645 2680 2646 - check_decay_read_errors(mddev, rdev); 2647 - atomic_inc(&rdev->read_errors); 2648 - if (atomic_read(&rdev->read_errors) > max_read_errors) { 2649 - pr_notice("md/raid10:%s: %pg: Raid device exceeded read_error threshold [cur %d:max %d]\n", 2650 - mdname(mddev), rdev->bdev, 2651 - atomic_read(&rdev->read_errors), max_read_errors); 2652 - pr_notice("md/raid10:%s: %pg: Failing raid device\n", 2653 - mdname(mddev), rdev->bdev); 2654 - md_error(mddev, rdev); 2681 + if (exceed_read_errors(mddev, rdev)) { 2655 2682 r10_bio->devs[slot].bio = IO_BLOCKED; 2656 2683 return; 2657 2684 }
+2 -6
include/uapi/linux/raid/md_p.h
··· 2 2 /* 3 3 md_p.h : physical layout of Linux RAID devices 4 4 Copyright (C) 1996-98 Ingo Molnar, Gadi Oxman 5 - 5 + 6 6 This program is free software; you can redistribute it and/or modify 7 7 it under the terms of the GNU General Public License as published by 8 8 the Free Software Foundation; either version 2, or (at your option) 9 9 any later version. 10 - 11 - You should have received a copy of the GNU General Public License 12 - (for example /usr/src/linux/COPYING); if not, write to the Free 13 - Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 14 10 */ 15 11 16 12 #ifndef _MD_P_H ··· 233 237 char set_name[32]; /* set and interpreted by user-space */ 234 238 235 239 __le64 ctime; /* lo 40 bits are seconds, top 24 are microseconds or 0*/ 236 - __le32 level; /* -4 (multipath), -1 (linear), 0,1,4,5 */ 240 + __le32 level; /* 0,1,4,5 */ 237 241 __le32 layout; /* only for raid5 and raid10 currently */ 238 242 __le64 size; /* used size of component devices, in 512byte sectors */ 239 243
+1 -10
include/uapi/linux/raid/md_u.h
··· 2 2 /* 3 3 md_u.h : user <=> kernel API between Linux raidtools and RAID drivers 4 4 Copyright (C) 1998 Ingo Molnar 5 - 5 + 6 6 This program is free software; you can redistribute it and/or modify 7 7 it under the terms of the GNU General Public License as published by 8 8 the Free Software Foundation; either version 2, or (at your option) 9 9 any later version. 10 - 11 - You should have received a copy of the GNU General Public License 12 - (for example /usr/src/linux/COPYING); if not, write to the Free 13 - Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 14 10 */ 15 11 16 12 #ifndef _UAPI_MD_U_H ··· 102 106 int chunk_size; /* 1 chunk size in bytes */ 103 107 104 108 } mdu_array_info_t; 105 - 106 - /* non-obvious values for 'level' */ 107 - #define LEVEL_MULTIPATH (-4) 108 - #define LEVEL_LINEAR (-1) 109 - #define LEVEL_FAULTY (-5) 110 109 111 110 /* we need a value for 'no level specified' and 0 112 111 * means 'raid0', so we need something else. This is