dm-raid.c 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294
  1. /*
  2. * Copyright (C) 2010-2011 Neil Brown
  3. * Copyright (C) 2010-2011 Red Hat, Inc. All rights reserved.
  4. *
  5. * This file is released under the GPL.
  6. */
  7. #include <linux/slab.h>
  8. #include <linux/module.h>
  9. #include "md.h"
  10. #include "raid1.h"
  11. #include "raid5.h"
  12. #include "bitmap.h"
  13. #include <linux/device-mapper.h>
  14. #define DM_MSG_PREFIX "raid"
  15. /*
  16. * The following flags are used by dm-raid.c to set up the array state.
  17. * They must be cleared before md_run is called.
  18. */
  19. #define FirstUse 10 /* rdev flag */
  20. struct raid_dev {
  21. /*
  22. * Two DM devices, one to hold metadata and one to hold the
  23. * actual data/parity. The reason for this is to not confuse
  24. * ti->len and give more flexibility in altering size and
  25. * characteristics.
  26. *
  27. * While it is possible for this device to be associated
  28. * with a different physical device than the data_dev, it
  29. * is intended for it to be the same.
  30. * |--------- Physical Device ---------|
  31. * |- meta_dev -|------ data_dev ------|
  32. */
  33. struct dm_dev *meta_dev;
  34. struct dm_dev *data_dev;
  35. struct md_rdev rdev;
  36. };
  37. /*
  38. * Flags for rs->print_flags field.
  39. */
  40. #define DMPF_SYNC 0x1
  41. #define DMPF_NOSYNC 0x2
  42. #define DMPF_REBUILD 0x4
  43. #define DMPF_DAEMON_SLEEP 0x8
  44. #define DMPF_MIN_RECOVERY_RATE 0x10
  45. #define DMPF_MAX_RECOVERY_RATE 0x20
  46. #define DMPF_MAX_WRITE_BEHIND 0x40
  47. #define DMPF_STRIPE_CACHE 0x80
  48. #define DMPF_REGION_SIZE 0X100
  49. struct raid_set {
  50. struct dm_target *ti;
  51. uint32_t bitmap_loaded;
  52. uint32_t print_flags;
  53. struct mddev md;
  54. struct raid_type *raid_type;
  55. struct dm_target_callbacks callbacks;
  56. struct raid_dev dev[0];
  57. };
  58. /* Supported raid types and properties. */
  59. static struct raid_type {
  60. const char *name; /* RAID algorithm. */
  61. const char *descr; /* Descriptor text for logging. */
  62. const unsigned parity_devs; /* # of parity devices. */
  63. const unsigned minimal_devs; /* minimal # of devices in set. */
  64. const unsigned level; /* RAID level. */
  65. const unsigned algorithm; /* RAID algorithm. */
  66. } raid_types[] = {
  67. {"raid1", "RAID1 (mirroring)", 0, 2, 1, 0 /* NONE */},
  68. {"raid4", "RAID4 (dedicated parity disk)", 1, 2, 5, ALGORITHM_PARITY_0},
  69. {"raid5_la", "RAID5 (left asymmetric)", 1, 2, 5, ALGORITHM_LEFT_ASYMMETRIC},
  70. {"raid5_ra", "RAID5 (right asymmetric)", 1, 2, 5, ALGORITHM_RIGHT_ASYMMETRIC},
  71. {"raid5_ls", "RAID5 (left symmetric)", 1, 2, 5, ALGORITHM_LEFT_SYMMETRIC},
  72. {"raid5_rs", "RAID5 (right symmetric)", 1, 2, 5, ALGORITHM_RIGHT_SYMMETRIC},
  73. {"raid6_zr", "RAID6 (zero restart)", 2, 4, 6, ALGORITHM_ROTATING_ZERO_RESTART},
  74. {"raid6_nr", "RAID6 (N restart)", 2, 4, 6, ALGORITHM_ROTATING_N_RESTART},
  75. {"raid6_nc", "RAID6 (N continue)", 2, 4, 6, ALGORITHM_ROTATING_N_CONTINUE}
  76. };
  77. static struct raid_type *get_raid_type(char *name)
  78. {
  79. int i;
  80. for (i = 0; i < ARRAY_SIZE(raid_types); i++)
  81. if (!strcmp(raid_types[i].name, name))
  82. return &raid_types[i];
  83. return NULL;
  84. }
  85. static struct raid_set *context_alloc(struct dm_target *ti, struct raid_type *raid_type, unsigned raid_devs)
  86. {
  87. unsigned i;
  88. struct raid_set *rs;
  89. sector_t sectors_per_dev;
  90. if (raid_devs <= raid_type->parity_devs) {
  91. ti->error = "Insufficient number of devices";
  92. return ERR_PTR(-EINVAL);
  93. }
  94. sectors_per_dev = ti->len;
  95. if ((raid_type->level > 1) &&
  96. sector_div(sectors_per_dev, (raid_devs - raid_type->parity_devs))) {
  97. ti->error = "Target length not divisible by number of data devices";
  98. return ERR_PTR(-EINVAL);
  99. }
  100. rs = kzalloc(sizeof(*rs) + raid_devs * sizeof(rs->dev[0]), GFP_KERNEL);
  101. if (!rs) {
  102. ti->error = "Cannot allocate raid context";
  103. return ERR_PTR(-ENOMEM);
  104. }
  105. mddev_init(&rs->md);
  106. rs->ti = ti;
  107. rs->raid_type = raid_type;
  108. rs->md.raid_disks = raid_devs;
  109. rs->md.level = raid_type->level;
  110. rs->md.new_level = rs->md.level;
  111. rs->md.dev_sectors = sectors_per_dev;
  112. rs->md.layout = raid_type->algorithm;
  113. rs->md.new_layout = rs->md.layout;
  114. rs->md.delta_disks = 0;
  115. rs->md.recovery_cp = 0;
  116. for (i = 0; i < raid_devs; i++)
  117. md_rdev_init(&rs->dev[i].rdev);
  118. /*
  119. * Remaining items to be initialized by further RAID params:
  120. * rs->md.persistent
  121. * rs->md.external
  122. * rs->md.chunk_sectors
  123. * rs->md.new_chunk_sectors
  124. */
  125. return rs;
  126. }
  127. static void context_free(struct raid_set *rs)
  128. {
  129. int i;
  130. for (i = 0; i < rs->md.raid_disks; i++) {
  131. if (rs->dev[i].meta_dev)
  132. dm_put_device(rs->ti, rs->dev[i].meta_dev);
  133. md_rdev_clear(&rs->dev[i].rdev);
  134. if (rs->dev[i].data_dev)
  135. dm_put_device(rs->ti, rs->dev[i].data_dev);
  136. }
  137. kfree(rs);
  138. }
  139. /*
  140. * For every device we have two words
  141. * <meta_dev>: meta device name or '-' if missing
  142. * <data_dev>: data device name or '-' if missing
  143. *
  144. * The following are permitted:
  145. * - -
  146. * - <data_dev>
  147. * <meta_dev> <data_dev>
  148. *
  149. * The following is not allowed:
  150. * <meta_dev> -
  151. *
  152. * This code parses those words. If there is a failure,
  153. * the caller must use context_free to unwind the operations.
  154. */
  155. static int dev_parms(struct raid_set *rs, char **argv)
  156. {
  157. int i;
  158. int rebuild = 0;
  159. int metadata_available = 0;
  160. int ret = 0;
  161. for (i = 0; i < rs->md.raid_disks; i++, argv += 2) {
  162. rs->dev[i].rdev.raid_disk = i;
  163. rs->dev[i].meta_dev = NULL;
  164. rs->dev[i].data_dev = NULL;
  165. /*
  166. * There are no offsets, since there is a separate device
  167. * for data and metadata.
  168. */
  169. rs->dev[i].rdev.data_offset = 0;
  170. rs->dev[i].rdev.mddev = &rs->md;
  171. if (strcmp(argv[0], "-")) {
  172. ret = dm_get_device(rs->ti, argv[0],
  173. dm_table_get_mode(rs->ti->table),
  174. &rs->dev[i].meta_dev);
  175. rs->ti->error = "RAID metadata device lookup failure";
  176. if (ret)
  177. return ret;
  178. rs->dev[i].rdev.sb_page = alloc_page(GFP_KERNEL);
  179. if (!rs->dev[i].rdev.sb_page)
  180. return -ENOMEM;
  181. }
  182. if (!strcmp(argv[1], "-")) {
  183. if (!test_bit(In_sync, &rs->dev[i].rdev.flags) &&
  184. (!rs->dev[i].rdev.recovery_offset)) {
  185. rs->ti->error = "Drive designated for rebuild not specified";
  186. return -EINVAL;
  187. }
  188. rs->ti->error = "No data device supplied with metadata device";
  189. if (rs->dev[i].meta_dev)
  190. return -EINVAL;
  191. continue;
  192. }
  193. ret = dm_get_device(rs->ti, argv[1],
  194. dm_table_get_mode(rs->ti->table),
  195. &rs->dev[i].data_dev);
  196. if (ret) {
  197. rs->ti->error = "RAID device lookup failure";
  198. return ret;
  199. }
  200. if (rs->dev[i].meta_dev) {
  201. metadata_available = 1;
  202. rs->dev[i].rdev.meta_bdev = rs->dev[i].meta_dev->bdev;
  203. }
  204. rs->dev[i].rdev.bdev = rs->dev[i].data_dev->bdev;
  205. list_add(&rs->dev[i].rdev.same_set, &rs->md.disks);
  206. if (!test_bit(In_sync, &rs->dev[i].rdev.flags))
  207. rebuild++;
  208. }
  209. if (metadata_available) {
  210. rs->md.external = 0;
  211. rs->md.persistent = 1;
  212. rs->md.major_version = 2;
  213. } else if (rebuild && !rs->md.recovery_cp) {
  214. /*
  215. * Without metadata, we will not be able to tell if the array
  216. * is in-sync or not - we must assume it is not. Therefore,
  217. * it is impossible to rebuild a drive.
  218. *
  219. * Even if there is metadata, the on-disk information may
  220. * indicate that the array is not in-sync and it will then
  221. * fail at that time.
  222. *
  223. * User could specify 'nosync' option if desperate.
  224. */
  225. DMERR("Unable to rebuild drive while array is not in-sync");
  226. rs->ti->error = "RAID device lookup failure";
  227. return -EINVAL;
  228. }
  229. return 0;
  230. }
  231. /*
  232. * validate_region_size
  233. * @rs
  234. * @region_size: region size in sectors. If 0, pick a size (4MiB default).
  235. *
  236. * Set rs->md.bitmap_info.chunksize (which really refers to 'region size').
  237. * Ensure that (ti->len/region_size < 2^21) - required by MD bitmap.
  238. *
  239. * Returns: 0 on success, -EINVAL on failure.
  240. */
  241. static int validate_region_size(struct raid_set *rs, unsigned long region_size)
  242. {
  243. unsigned long min_region_size = rs->ti->len / (1 << 21);
  244. if (!region_size) {
  245. /*
  246. * Choose a reasonable default. All figures in sectors.
  247. */
  248. if (min_region_size > (1 << 13)) {
  249. DMINFO("Choosing default region size of %lu sectors",
  250. region_size);
  251. region_size = min_region_size;
  252. } else {
  253. DMINFO("Choosing default region size of 4MiB");
  254. region_size = 1 << 13; /* sectors */
  255. }
  256. } else {
  257. /*
  258. * Validate user-supplied value.
  259. */
  260. if (region_size > rs->ti->len) {
  261. rs->ti->error = "Supplied region size is too large";
  262. return -EINVAL;
  263. }
  264. if (region_size < min_region_size) {
  265. DMERR("Supplied region_size (%lu sectors) below minimum (%lu)",
  266. region_size, min_region_size);
  267. rs->ti->error = "Supplied region size is too small";
  268. return -EINVAL;
  269. }
  270. if (!is_power_of_2(region_size)) {
  271. rs->ti->error = "Region size is not a power of 2";
  272. return -EINVAL;
  273. }
  274. if (region_size < rs->md.chunk_sectors) {
  275. rs->ti->error = "Region size is smaller than the chunk size";
  276. return -EINVAL;
  277. }
  278. }
  279. /*
  280. * Convert sectors to bytes.
  281. */
  282. rs->md.bitmap_info.chunksize = (region_size << 9);
  283. return 0;
  284. }
  285. /*
  286. * Possible arguments are...
  287. * <chunk_size> [optional_args]
  288. *
  289. * Argument definitions
  290. * <chunk_size> The number of sectors per disk that
  291. * will form the "stripe"
  292. * [[no]sync] Force or prevent recovery of the
  293. * entire array
  294. * [rebuild <idx>] Rebuild the drive indicated by the index
  295. * [daemon_sleep <ms>] Time between bitmap daemon work to
  296. * clear bits
  297. * [min_recovery_rate <kB/sec/disk>] Throttle RAID initialization
  298. * [max_recovery_rate <kB/sec/disk>] Throttle RAID initialization
  299. * [write_mostly <idx>] Indicate a write mostly drive via index
  300. * [max_write_behind <sectors>] See '-write-behind=' (man mdadm)
  301. * [stripe_cache <sectors>] Stripe cache size for higher RAIDs
  302. * [region_size <sectors>] Defines granularity of bitmap
  303. */
  304. static int parse_raid_params(struct raid_set *rs, char **argv,
  305. unsigned num_raid_params)
  306. {
  307. unsigned i, rebuild_cnt = 0;
  308. unsigned long value, region_size = 0;
  309. char *key;
  310. /*
  311. * First, parse the in-order required arguments
  312. * "chunk_size" is the only argument of this type.
  313. */
  314. if ((strict_strtoul(argv[0], 10, &value) < 0)) {
  315. rs->ti->error = "Bad chunk size";
  316. return -EINVAL;
  317. } else if (rs->raid_type->level == 1) {
  318. if (value)
  319. DMERR("Ignoring chunk size parameter for RAID 1");
  320. value = 0;
  321. } else if (!is_power_of_2(value)) {
  322. rs->ti->error = "Chunk size must be a power of 2";
  323. return -EINVAL;
  324. } else if (value < 8) {
  325. rs->ti->error = "Chunk size value is too small";
  326. return -EINVAL;
  327. }
  328. rs->md.new_chunk_sectors = rs->md.chunk_sectors = value;
  329. argv++;
  330. num_raid_params--;
  331. /*
  332. * We set each individual device as In_sync with a completed
  333. * 'recovery_offset'. If there has been a device failure or
  334. * replacement then one of the following cases applies:
  335. *
  336. * 1) User specifies 'rebuild'.
  337. * - Device is reset when param is read.
  338. * 2) A new device is supplied.
  339. * - No matching superblock found, resets device.
  340. * 3) Device failure was transient and returns on reload.
  341. * - Failure noticed, resets device for bitmap replay.
  342. * 4) Device hadn't completed recovery after previous failure.
  343. * - Superblock is read and overrides recovery_offset.
  344. *
  345. * What is found in the superblocks of the devices is always
  346. * authoritative, unless 'rebuild' or '[no]sync' was specified.
  347. */
  348. for (i = 0; i < rs->md.raid_disks; i++) {
  349. set_bit(In_sync, &rs->dev[i].rdev.flags);
  350. rs->dev[i].rdev.recovery_offset = MaxSector;
  351. }
  352. /*
  353. * Second, parse the unordered optional arguments
  354. */
  355. for (i = 0; i < num_raid_params; i++) {
  356. if (!strcasecmp(argv[i], "nosync")) {
  357. rs->md.recovery_cp = MaxSector;
  358. rs->print_flags |= DMPF_NOSYNC;
  359. continue;
  360. }
  361. if (!strcasecmp(argv[i], "sync")) {
  362. rs->md.recovery_cp = 0;
  363. rs->print_flags |= DMPF_SYNC;
  364. continue;
  365. }
  366. /* The rest of the optional arguments come in key/value pairs */
  367. if ((i + 1) >= num_raid_params) {
  368. rs->ti->error = "Wrong number of raid parameters given";
  369. return -EINVAL;
  370. }
  371. key = argv[i++];
  372. if (strict_strtoul(argv[i], 10, &value) < 0) {
  373. rs->ti->error = "Bad numerical argument given in raid params";
  374. return -EINVAL;
  375. }
  376. if (!strcasecmp(key, "rebuild")) {
  377. rebuild_cnt++;
  378. if (((rs->raid_type->level != 1) &&
  379. (rebuild_cnt > rs->raid_type->parity_devs)) ||
  380. ((rs->raid_type->level == 1) &&
  381. (rebuild_cnt > (rs->md.raid_disks - 1)))) {
  382. rs->ti->error = "Too many rebuild devices specified for given RAID type";
  383. return -EINVAL;
  384. }
  385. if (value > rs->md.raid_disks) {
  386. rs->ti->error = "Invalid rebuild index given";
  387. return -EINVAL;
  388. }
  389. clear_bit(In_sync, &rs->dev[value].rdev.flags);
  390. rs->dev[value].rdev.recovery_offset = 0;
  391. rs->print_flags |= DMPF_REBUILD;
  392. } else if (!strcasecmp(key, "write_mostly")) {
  393. if (rs->raid_type->level != 1) {
  394. rs->ti->error = "write_mostly option is only valid for RAID1";
  395. return -EINVAL;
  396. }
  397. if (value >= rs->md.raid_disks) {
  398. rs->ti->error = "Invalid write_mostly drive index given";
  399. return -EINVAL;
  400. }
  401. set_bit(WriteMostly, &rs->dev[value].rdev.flags);
  402. } else if (!strcasecmp(key, "max_write_behind")) {
  403. if (rs->raid_type->level != 1) {
  404. rs->ti->error = "max_write_behind option is only valid for RAID1";
  405. return -EINVAL;
  406. }
  407. rs->print_flags |= DMPF_MAX_WRITE_BEHIND;
  408. /*
  409. * In device-mapper, we specify things in sectors, but
  410. * MD records this value in kB
  411. */
  412. value /= 2;
  413. if (value > COUNTER_MAX) {
  414. rs->ti->error = "Max write-behind limit out of range";
  415. return -EINVAL;
  416. }
  417. rs->md.bitmap_info.max_write_behind = value;
  418. } else if (!strcasecmp(key, "daemon_sleep")) {
  419. rs->print_flags |= DMPF_DAEMON_SLEEP;
  420. if (!value || (value > MAX_SCHEDULE_TIMEOUT)) {
  421. rs->ti->error = "daemon sleep period out of range";
  422. return -EINVAL;
  423. }
  424. rs->md.bitmap_info.daemon_sleep = value;
  425. } else if (!strcasecmp(key, "stripe_cache")) {
  426. rs->print_flags |= DMPF_STRIPE_CACHE;
  427. /*
  428. * In device-mapper, we specify things in sectors, but
  429. * MD records this value in kB
  430. */
  431. value /= 2;
  432. if (rs->raid_type->level < 5) {
  433. rs->ti->error = "Inappropriate argument: stripe_cache";
  434. return -EINVAL;
  435. }
  436. if (raid5_set_cache_size(&rs->md, (int)value)) {
  437. rs->ti->error = "Bad stripe_cache size";
  438. return -EINVAL;
  439. }
  440. } else if (!strcasecmp(key, "min_recovery_rate")) {
  441. rs->print_flags |= DMPF_MIN_RECOVERY_RATE;
  442. if (value > INT_MAX) {
  443. rs->ti->error = "min_recovery_rate out of range";
  444. return -EINVAL;
  445. }
  446. rs->md.sync_speed_min = (int)value;
  447. } else if (!strcasecmp(key, "max_recovery_rate")) {
  448. rs->print_flags |= DMPF_MAX_RECOVERY_RATE;
  449. if (value > INT_MAX) {
  450. rs->ti->error = "max_recovery_rate out of range";
  451. return -EINVAL;
  452. }
  453. rs->md.sync_speed_max = (int)value;
  454. } else if (!strcasecmp(key, "region_size")) {
  455. rs->print_flags |= DMPF_REGION_SIZE;
  456. region_size = value;
  457. } else {
  458. DMERR("Unable to parse RAID parameter: %s", key);
  459. rs->ti->error = "Unable to parse RAID parameters";
  460. return -EINVAL;
  461. }
  462. }
  463. if (validate_region_size(rs, region_size))
  464. return -EINVAL;
  465. if (rs->md.chunk_sectors)
  466. rs->ti->split_io = rs->md.chunk_sectors;
  467. else
  468. rs->ti->split_io = region_size;
  469. if (rs->md.chunk_sectors)
  470. rs->ti->split_io = rs->md.chunk_sectors;
  471. else
  472. rs->ti->split_io = region_size;
  473. /* Assume there are no metadata devices until the drives are parsed */
  474. rs->md.persistent = 0;
  475. rs->md.external = 1;
  476. return 0;
  477. }
  478. static void do_table_event(struct work_struct *ws)
  479. {
  480. struct raid_set *rs = container_of(ws, struct raid_set, md.event_work);
  481. dm_table_event(rs->ti->table);
  482. }
  483. static int raid_is_congested(struct dm_target_callbacks *cb, int bits)
  484. {
  485. struct raid_set *rs = container_of(cb, struct raid_set, callbacks);
  486. if (rs->raid_type->level == 1)
  487. return md_raid1_congested(&rs->md, bits);
  488. return md_raid5_congested(&rs->md, bits);
  489. }
  490. /*
  491. * This structure is never routinely used by userspace, unlike md superblocks.
  492. * Devices with this superblock should only ever be accessed via device-mapper.
  493. */
  494. #define DM_RAID_MAGIC 0x64526D44
  495. struct dm_raid_superblock {
  496. __le32 magic; /* "DmRd" */
  497. __le32 features; /* Used to indicate possible future changes */
  498. __le32 num_devices; /* Number of devices in this array. (Max 64) */
  499. __le32 array_position; /* The position of this drive in the array */
  500. __le64 events; /* Incremented by md when superblock updated */
  501. __le64 failed_devices; /* Bit field of devices to indicate failures */
  502. /*
  503. * This offset tracks the progress of the repair or replacement of
  504. * an individual drive.
  505. */
  506. __le64 disk_recovery_offset;
  507. /*
  508. * This offset tracks the progress of the initial array
  509. * synchronisation/parity calculation.
  510. */
  511. __le64 array_resync_offset;
  512. /*
  513. * RAID characteristics
  514. */
  515. __le32 level;
  516. __le32 layout;
  517. __le32 stripe_sectors;
  518. __u8 pad[452]; /* Round struct to 512 bytes. */
  519. /* Always set to 0 when writing. */
  520. } __packed;
  521. static int read_disk_sb(struct md_rdev *rdev, int size)
  522. {
  523. BUG_ON(!rdev->sb_page);
  524. if (rdev->sb_loaded)
  525. return 0;
  526. if (!sync_page_io(rdev, 0, size, rdev->sb_page, READ, 1)) {
  527. DMERR("Failed to read superblock of device at position %d",
  528. rdev->raid_disk);
  529. set_bit(Faulty, &rdev->flags);
  530. return -EINVAL;
  531. }
  532. rdev->sb_loaded = 1;
  533. return 0;
  534. }
  535. static void super_sync(struct mddev *mddev, struct md_rdev *rdev)
  536. {
  537. struct md_rdev *r;
  538. uint64_t failed_devices;
  539. struct dm_raid_superblock *sb;
  540. sb = page_address(rdev->sb_page);
  541. failed_devices = le64_to_cpu(sb->failed_devices);
  542. rdev_for_each(r, mddev)
  543. if ((r->raid_disk >= 0) && test_bit(Faulty, &r->flags))
  544. failed_devices |= (1ULL << r->raid_disk);
  545. memset(sb, 0, sizeof(*sb));
  546. sb->magic = cpu_to_le32(DM_RAID_MAGIC);
  547. sb->features = cpu_to_le32(0); /* No features yet */
  548. sb->num_devices = cpu_to_le32(mddev->raid_disks);
  549. sb->array_position = cpu_to_le32(rdev->raid_disk);
  550. sb->events = cpu_to_le64(mddev->events);
  551. sb->failed_devices = cpu_to_le64(failed_devices);
  552. sb->disk_recovery_offset = cpu_to_le64(rdev->recovery_offset);
  553. sb->array_resync_offset = cpu_to_le64(mddev->recovery_cp);
  554. sb->level = cpu_to_le32(mddev->level);
  555. sb->layout = cpu_to_le32(mddev->layout);
  556. sb->stripe_sectors = cpu_to_le32(mddev->chunk_sectors);
  557. }
  558. /*
  559. * super_load
  560. *
  561. * This function creates a superblock if one is not found on the device
  562. * and will decide which superblock to use if there's a choice.
  563. *
  564. * Return: 1 if use rdev, 0 if use refdev, -Exxx otherwise
  565. */
  566. static int super_load(struct md_rdev *rdev, struct md_rdev *refdev)
  567. {
  568. int ret;
  569. struct dm_raid_superblock *sb;
  570. struct dm_raid_superblock *refsb;
  571. uint64_t events_sb, events_refsb;
  572. rdev->sb_start = 0;
  573. rdev->sb_size = sizeof(*sb);
  574. ret = read_disk_sb(rdev, rdev->sb_size);
  575. if (ret)
  576. return ret;
  577. sb = page_address(rdev->sb_page);
  578. /*
  579. * Two cases that we want to write new superblocks and rebuild:
  580. * 1) New device (no matching magic number)
  581. * 2) Device specified for rebuild (!In_sync w/ offset == 0)
  582. */
  583. if ((sb->magic != cpu_to_le32(DM_RAID_MAGIC)) ||
  584. (!test_bit(In_sync, &rdev->flags) && !rdev->recovery_offset)) {
  585. super_sync(rdev->mddev, rdev);
  586. set_bit(FirstUse, &rdev->flags);
  587. /* Force writing of superblocks to disk */
  588. set_bit(MD_CHANGE_DEVS, &rdev->mddev->flags);
  589. /* Any superblock is better than none, choose that if given */
  590. return refdev ? 0 : 1;
  591. }
  592. if (!refdev)
  593. return 1;
  594. events_sb = le64_to_cpu(sb->events);
  595. refsb = page_address(refdev->sb_page);
  596. events_refsb = le64_to_cpu(refsb->events);
  597. return (events_sb > events_refsb) ? 1 : 0;
  598. }
  599. static int super_init_validation(struct mddev *mddev, struct md_rdev *rdev)
  600. {
  601. int role;
  602. struct raid_set *rs = container_of(mddev, struct raid_set, md);
  603. uint64_t events_sb;
  604. uint64_t failed_devices;
  605. struct dm_raid_superblock *sb;
  606. uint32_t new_devs = 0;
  607. uint32_t rebuilds = 0;
  608. struct md_rdev *r;
  609. struct dm_raid_superblock *sb2;
  610. sb = page_address(rdev->sb_page);
  611. events_sb = le64_to_cpu(sb->events);
  612. failed_devices = le64_to_cpu(sb->failed_devices);
  613. /*
  614. * Initialise to 1 if this is a new superblock.
  615. */
  616. mddev->events = events_sb ? : 1;
  617. /*
  618. * Reshaping is not currently allowed
  619. */
  620. if ((le32_to_cpu(sb->level) != mddev->level) ||
  621. (le32_to_cpu(sb->layout) != mddev->layout) ||
  622. (le32_to_cpu(sb->stripe_sectors) != mddev->chunk_sectors)) {
  623. DMERR("Reshaping arrays not yet supported.");
  624. return -EINVAL;
  625. }
  626. /* We can only change the number of devices in RAID1 right now */
  627. if ((rs->raid_type->level != 1) &&
  628. (le32_to_cpu(sb->num_devices) != mddev->raid_disks)) {
  629. DMERR("Reshaping arrays not yet supported.");
  630. return -EINVAL;
  631. }
  632. if (!(rs->print_flags & (DMPF_SYNC | DMPF_NOSYNC)))
  633. mddev->recovery_cp = le64_to_cpu(sb->array_resync_offset);
  634. /*
  635. * During load, we set FirstUse if a new superblock was written.
  636. * There are two reasons we might not have a superblock:
  637. * 1) The array is brand new - in which case, all of the
  638. * devices must have their In_sync bit set. Also,
  639. * recovery_cp must be 0, unless forced.
  640. * 2) This is a new device being added to an old array
  641. * and the new device needs to be rebuilt - in which
  642. * case the In_sync bit will /not/ be set and
  643. * recovery_cp must be MaxSector.
  644. */
  645. rdev_for_each(r, mddev) {
  646. if (!test_bit(In_sync, &r->flags)) {
  647. DMINFO("Device %d specified for rebuild: "
  648. "Clearing superblock", r->raid_disk);
  649. rebuilds++;
  650. } else if (test_bit(FirstUse, &r->flags))
  651. new_devs++;
  652. }
  653. if (!rebuilds) {
  654. if (new_devs == mddev->raid_disks) {
  655. DMINFO("Superblocks created for new array");
  656. set_bit(MD_ARRAY_FIRST_USE, &mddev->flags);
  657. } else if (new_devs) {
  658. DMERR("New device injected "
  659. "into existing array without 'rebuild' "
  660. "parameter specified");
  661. return -EINVAL;
  662. }
  663. } else if (new_devs) {
  664. DMERR("'rebuild' devices cannot be "
  665. "injected into an array with other first-time devices");
  666. return -EINVAL;
  667. } else if (mddev->recovery_cp != MaxSector) {
  668. DMERR("'rebuild' specified while array is not in-sync");
  669. return -EINVAL;
  670. }
  671. /*
  672. * Now we set the Faulty bit for those devices that are
  673. * recorded in the superblock as failed.
  674. */
  675. rdev_for_each(r, mddev) {
  676. if (!r->sb_page)
  677. continue;
  678. sb2 = page_address(r->sb_page);
  679. sb2->failed_devices = 0;
  680. /*
  681. * Check for any device re-ordering.
  682. */
  683. if (!test_bit(FirstUse, &r->flags) && (r->raid_disk >= 0)) {
  684. role = le32_to_cpu(sb2->array_position);
  685. if (role != r->raid_disk) {
  686. if (rs->raid_type->level != 1) {
  687. rs->ti->error = "Cannot change device "
  688. "positions in RAID array";
  689. return -EINVAL;
  690. }
  691. DMINFO("RAID1 device #%d now at position #%d",
  692. role, r->raid_disk);
  693. }
  694. /*
  695. * Partial recovery is performed on
  696. * returning failed devices.
  697. */
  698. if (failed_devices & (1 << role))
  699. set_bit(Faulty, &r->flags);
  700. }
  701. }
  702. return 0;
  703. }
  704. static int super_validate(struct mddev *mddev, struct md_rdev *rdev)
  705. {
  706. struct dm_raid_superblock *sb = page_address(rdev->sb_page);
  707. /*
  708. * If mddev->events is not set, we know we have not yet initialized
  709. * the array.
  710. */
  711. if (!mddev->events && super_init_validation(mddev, rdev))
  712. return -EINVAL;
  713. mddev->bitmap_info.offset = 4096 >> 9; /* Enable bitmap creation */
  714. rdev->mddev->bitmap_info.default_offset = 4096 >> 9;
  715. if (!test_bit(FirstUse, &rdev->flags)) {
  716. rdev->recovery_offset = le64_to_cpu(sb->disk_recovery_offset);
  717. if (rdev->recovery_offset != MaxSector)
  718. clear_bit(In_sync, &rdev->flags);
  719. }
  720. /*
  721. * If a device comes back, set it as not In_sync and no longer faulty.
  722. */
  723. if (test_bit(Faulty, &rdev->flags)) {
  724. clear_bit(Faulty, &rdev->flags);
  725. clear_bit(In_sync, &rdev->flags);
  726. rdev->saved_raid_disk = rdev->raid_disk;
  727. rdev->recovery_offset = 0;
  728. }
  729. clear_bit(FirstUse, &rdev->flags);
  730. return 0;
  731. }
  732. /*
  733. * Analyse superblocks and select the freshest.
  734. */
  735. static int analyse_superblocks(struct dm_target *ti, struct raid_set *rs)
  736. {
  737. int ret;
  738. unsigned redundancy = 0;
  739. struct raid_dev *dev;
  740. struct md_rdev *rdev, *tmp, *freshest;
  741. struct mddev *mddev = &rs->md;
  742. switch (rs->raid_type->level) {
  743. case 1:
  744. redundancy = rs->md.raid_disks - 1;
  745. break;
  746. case 4:
  747. case 5:
  748. case 6:
  749. redundancy = rs->raid_type->parity_devs;
  750. break;
  751. default:
  752. ti->error = "Unknown RAID type";
  753. return -EINVAL;
  754. }
  755. freshest = NULL;
  756. rdev_for_each_safe(rdev, tmp, mddev) {
  757. if (!rdev->meta_bdev)
  758. continue;
  759. ret = super_load(rdev, freshest);
  760. switch (ret) {
  761. case 1:
  762. freshest = rdev;
  763. break;
  764. case 0:
  765. break;
  766. default:
  767. dev = container_of(rdev, struct raid_dev, rdev);
  768. if (redundancy--) {
  769. if (dev->meta_dev)
  770. dm_put_device(ti, dev->meta_dev);
  771. dev->meta_dev = NULL;
  772. rdev->meta_bdev = NULL;
  773. if (rdev->sb_page)
  774. put_page(rdev->sb_page);
  775. rdev->sb_page = NULL;
  776. rdev->sb_loaded = 0;
  777. /*
  778. * We might be able to salvage the data device
  779. * even though the meta device has failed. For
  780. * now, we behave as though '- -' had been
  781. * set for this device in the table.
  782. */
  783. if (dev->data_dev)
  784. dm_put_device(ti, dev->data_dev);
  785. dev->data_dev = NULL;
  786. rdev->bdev = NULL;
  787. list_del(&rdev->same_set);
  788. continue;
  789. }
  790. ti->error = "Failed to load superblock";
  791. return ret;
  792. }
  793. }
  794. if (!freshest)
  795. return 0;
  796. /*
  797. * Validation of the freshest device provides the source of
  798. * validation for the remaining devices.
  799. */
  800. ti->error = "Unable to assemble array: Invalid superblocks";
  801. if (super_validate(mddev, freshest))
  802. return -EINVAL;
  803. rdev_for_each(rdev, mddev)
  804. if ((rdev != freshest) && super_validate(mddev, rdev))
  805. return -EINVAL;
  806. return 0;
  807. }
  808. /*
  809. * Construct a RAID4/5/6 mapping:
  810. * Args:
  811. * <raid_type> <#raid_params> <raid_params> \
  812. * <#raid_devs> { <meta_dev1> <dev1> .. <meta_devN> <devN> }
  813. *
  814. * <raid_params> varies by <raid_type>. See 'parse_raid_params' for
  815. * details on possible <raid_params>.
  816. */
  817. static int raid_ctr(struct dm_target *ti, unsigned argc, char **argv)
  818. {
  819. int ret;
  820. struct raid_type *rt;
  821. unsigned long num_raid_params, num_raid_devs;
  822. struct raid_set *rs = NULL;
  823. /* Must have at least <raid_type> <#raid_params> */
  824. if (argc < 2) {
  825. ti->error = "Too few arguments";
  826. return -EINVAL;
  827. }
  828. /* raid type */
  829. rt = get_raid_type(argv[0]);
  830. if (!rt) {
  831. ti->error = "Unrecognised raid_type";
  832. return -EINVAL;
  833. }
  834. argc--;
  835. argv++;
  836. /* number of RAID parameters */
  837. if (strict_strtoul(argv[0], 10, &num_raid_params) < 0) {
  838. ti->error = "Cannot understand number of RAID parameters";
  839. return -EINVAL;
  840. }
  841. argc--;
  842. argv++;
  843. /* Skip over RAID params for now and find out # of devices */
  844. if (num_raid_params + 1 > argc) {
  845. ti->error = "Arguments do not agree with counts given";
  846. return -EINVAL;
  847. }
  848. if ((strict_strtoul(argv[num_raid_params], 10, &num_raid_devs) < 0) ||
  849. (num_raid_devs >= INT_MAX)) {
  850. ti->error = "Cannot understand number of raid devices";
  851. return -EINVAL;
  852. }
  853. rs = context_alloc(ti, rt, (unsigned)num_raid_devs);
  854. if (IS_ERR(rs))
  855. return PTR_ERR(rs);
  856. ret = parse_raid_params(rs, argv, (unsigned)num_raid_params);
  857. if (ret)
  858. goto bad;
  859. ret = -EINVAL;
  860. argc -= num_raid_params + 1; /* +1: we already have num_raid_devs */
  861. argv += num_raid_params + 1;
  862. if (argc != (num_raid_devs * 2)) {
  863. ti->error = "Supplied RAID devices does not match the count given";
  864. goto bad;
  865. }
  866. ret = dev_parms(rs, argv);
  867. if (ret)
  868. goto bad;
  869. rs->md.sync_super = super_sync;
  870. ret = analyse_superblocks(ti, rs);
  871. if (ret)
  872. goto bad;
  873. INIT_WORK(&rs->md.event_work, do_table_event);
  874. ti->private = rs;
  875. ti->num_flush_requests = 1;
  876. mutex_lock(&rs->md.reconfig_mutex);
  877. ret = md_run(&rs->md);
  878. rs->md.in_sync = 0; /* Assume already marked dirty */
  879. mutex_unlock(&rs->md.reconfig_mutex);
  880. if (ret) {
  881. ti->error = "Fail to run raid array";
  882. goto bad;
  883. }
  884. rs->callbacks.congested_fn = raid_is_congested;
  885. dm_table_add_target_callbacks(ti->table, &rs->callbacks);
  886. mddev_suspend(&rs->md);
  887. return 0;
  888. bad:
  889. context_free(rs);
  890. return ret;
  891. }
  892. static void raid_dtr(struct dm_target *ti)
  893. {
  894. struct raid_set *rs = ti->private;
  895. list_del_init(&rs->callbacks.list);
  896. md_stop(&rs->md);
  897. context_free(rs);
  898. }
  899. static int raid_map(struct dm_target *ti, struct bio *bio, union map_info *map_context)
  900. {
  901. struct raid_set *rs = ti->private;
  902. struct mddev *mddev = &rs->md;
  903. mddev->pers->make_request(mddev, bio);
  904. return DM_MAPIO_SUBMITTED;
  905. }
  906. static int raid_status(struct dm_target *ti, status_type_t type,
  907. char *result, unsigned maxlen)
  908. {
  909. struct raid_set *rs = ti->private;
  910. unsigned raid_param_cnt = 1; /* at least 1 for chunksize */
  911. unsigned sz = 0;
  912. int i, array_in_sync = 0;
  913. sector_t sync;
  914. switch (type) {
  915. case STATUSTYPE_INFO:
  916. DMEMIT("%s %d ", rs->raid_type->name, rs->md.raid_disks);
  917. if (test_bit(MD_RECOVERY_RUNNING, &rs->md.recovery))
  918. sync = rs->md.curr_resync_completed;
  919. else
  920. sync = rs->md.recovery_cp;
  921. if (sync >= rs->md.resync_max_sectors) {
  922. array_in_sync = 1;
  923. sync = rs->md.resync_max_sectors;
  924. } else {
  925. /*
  926. * The array may be doing an initial sync, or it may
  927. * be rebuilding individual components. If all the
  928. * devices are In_sync, then it is the array that is
  929. * being initialized.
  930. */
  931. for (i = 0; i < rs->md.raid_disks; i++)
  932. if (!test_bit(In_sync, &rs->dev[i].rdev.flags))
  933. array_in_sync = 1;
  934. }
  935. /*
  936. * Status characters:
  937. * 'D' = Dead/Failed device
  938. * 'a' = Alive but not in-sync
  939. * 'A' = Alive and in-sync
  940. */
  941. for (i = 0; i < rs->md.raid_disks; i++) {
  942. if (test_bit(Faulty, &rs->dev[i].rdev.flags))
  943. DMEMIT("D");
  944. else if (!array_in_sync ||
  945. !test_bit(In_sync, &rs->dev[i].rdev.flags))
  946. DMEMIT("a");
  947. else
  948. DMEMIT("A");
  949. }
  950. /*
  951. * In-sync ratio:
  952. * The in-sync ratio shows the progress of:
  953. * - Initializing the array
  954. * - Rebuilding a subset of devices of the array
  955. * The user can distinguish between the two by referring
  956. * to the status characters.
  957. */
  958. DMEMIT(" %llu/%llu",
  959. (unsigned long long) sync,
  960. (unsigned long long) rs->md.resync_max_sectors);
  961. break;
  962. case STATUSTYPE_TABLE:
  963. /* The string you would use to construct this array */
  964. for (i = 0; i < rs->md.raid_disks; i++) {
  965. if ((rs->print_flags & DMPF_REBUILD) &&
  966. rs->dev[i].data_dev &&
  967. !test_bit(In_sync, &rs->dev[i].rdev.flags))
  968. raid_param_cnt += 2; /* for rebuilds */
  969. if (rs->dev[i].data_dev &&
  970. test_bit(WriteMostly, &rs->dev[i].rdev.flags))
  971. raid_param_cnt += 2;
  972. }
  973. raid_param_cnt += (hweight32(rs->print_flags & ~DMPF_REBUILD) * 2);
  974. if (rs->print_flags & (DMPF_SYNC | DMPF_NOSYNC))
  975. raid_param_cnt--;
  976. DMEMIT("%s %u %u", rs->raid_type->name,
  977. raid_param_cnt, rs->md.chunk_sectors);
  978. if ((rs->print_flags & DMPF_SYNC) &&
  979. (rs->md.recovery_cp == MaxSector))
  980. DMEMIT(" sync");
  981. if (rs->print_flags & DMPF_NOSYNC)
  982. DMEMIT(" nosync");
  983. for (i = 0; i < rs->md.raid_disks; i++)
  984. if ((rs->print_flags & DMPF_REBUILD) &&
  985. rs->dev[i].data_dev &&
  986. !test_bit(In_sync, &rs->dev[i].rdev.flags))
  987. DMEMIT(" rebuild %u", i);
  988. if (rs->print_flags & DMPF_DAEMON_SLEEP)
  989. DMEMIT(" daemon_sleep %lu",
  990. rs->md.bitmap_info.daemon_sleep);
  991. if (rs->print_flags & DMPF_MIN_RECOVERY_RATE)
  992. DMEMIT(" min_recovery_rate %d", rs->md.sync_speed_min);
  993. if (rs->print_flags & DMPF_MAX_RECOVERY_RATE)
  994. DMEMIT(" max_recovery_rate %d", rs->md.sync_speed_max);
  995. for (i = 0; i < rs->md.raid_disks; i++)
  996. if (rs->dev[i].data_dev &&
  997. test_bit(WriteMostly, &rs->dev[i].rdev.flags))
  998. DMEMIT(" write_mostly %u", i);
  999. if (rs->print_flags & DMPF_MAX_WRITE_BEHIND)
  1000. DMEMIT(" max_write_behind %lu",
  1001. rs->md.bitmap_info.max_write_behind);
  1002. if (rs->print_flags & DMPF_STRIPE_CACHE) {
  1003. struct r5conf *conf = rs->md.private;
  1004. /* convert from kiB to sectors */
  1005. DMEMIT(" stripe_cache %d",
  1006. conf ? conf->max_nr_stripes * 2 : 0);
  1007. }
  1008. if (rs->print_flags & DMPF_REGION_SIZE)
  1009. DMEMIT(" region_size %lu",
  1010. rs->md.bitmap_info.chunksize >> 9);
  1011. DMEMIT(" %d", rs->md.raid_disks);
  1012. for (i = 0; i < rs->md.raid_disks; i++) {
  1013. if (rs->dev[i].meta_dev)
  1014. DMEMIT(" %s", rs->dev[i].meta_dev->name);
  1015. else
  1016. DMEMIT(" -");
  1017. if (rs->dev[i].data_dev)
  1018. DMEMIT(" %s", rs->dev[i].data_dev->name);
  1019. else
  1020. DMEMIT(" -");
  1021. }
  1022. }
  1023. return 0;
  1024. }
  1025. static int raid_iterate_devices(struct dm_target *ti, iterate_devices_callout_fn fn, void *data)
  1026. {
  1027. struct raid_set *rs = ti->private;
  1028. unsigned i;
  1029. int ret = 0;
  1030. for (i = 0; !ret && i < rs->md.raid_disks; i++)
  1031. if (rs->dev[i].data_dev)
  1032. ret = fn(ti,
  1033. rs->dev[i].data_dev,
  1034. 0, /* No offset on data devs */
  1035. rs->md.dev_sectors,
  1036. data);
  1037. return ret;
  1038. }
  1039. static void raid_io_hints(struct dm_target *ti, struct queue_limits *limits)
  1040. {
  1041. struct raid_set *rs = ti->private;
  1042. unsigned chunk_size = rs->md.chunk_sectors << 9;
  1043. struct r5conf *conf = rs->md.private;
  1044. blk_limits_io_min(limits, chunk_size);
  1045. blk_limits_io_opt(limits, chunk_size * (conf->raid_disks - conf->max_degraded));
  1046. }
  1047. static void raid_presuspend(struct dm_target *ti)
  1048. {
  1049. struct raid_set *rs = ti->private;
  1050. md_stop_writes(&rs->md);
  1051. }
  1052. static void raid_postsuspend(struct dm_target *ti)
  1053. {
  1054. struct raid_set *rs = ti->private;
  1055. mddev_suspend(&rs->md);
  1056. }
  1057. static void raid_resume(struct dm_target *ti)
  1058. {
  1059. struct raid_set *rs = ti->private;
  1060. if (!rs->bitmap_loaded) {
  1061. bitmap_load(&rs->md);
  1062. rs->bitmap_loaded = 1;
  1063. }
  1064. clear_bit(MD_RECOVERY_FROZEN, &rs->md.recovery);
  1065. mddev_resume(&rs->md);
  1066. }
  1067. static struct target_type raid_target = {
  1068. .name = "raid",
  1069. .version = {1, 2, 0},
  1070. .module = THIS_MODULE,
  1071. .ctr = raid_ctr,
  1072. .dtr = raid_dtr,
  1073. .map = raid_map,
  1074. .status = raid_status,
  1075. .iterate_devices = raid_iterate_devices,
  1076. .io_hints = raid_io_hints,
  1077. .presuspend = raid_presuspend,
  1078. .postsuspend = raid_postsuspend,
  1079. .resume = raid_resume,
  1080. };
  1081. static int __init dm_raid_init(void)
  1082. {
  1083. return dm_register_target(&raid_target);
  1084. }
  1085. static void __exit dm_raid_exit(void)
  1086. {
  1087. dm_unregister_target(&raid_target);
  1088. }
  1089. module_init(dm_raid_init);
  1090. module_exit(dm_raid_exit);
  1091. MODULE_DESCRIPTION(DM_NAME " raid4/5/6 target");
  1092. MODULE_ALIAS("dm-raid4");
  1093. MODULE_ALIAS("dm-raid5");
  1094. MODULE_ALIAS("dm-raid6");
  1095. MODULE_AUTHOR("Neil Brown <dm-devel@redhat.com>");
  1096. MODULE_LICENSE("GPL");