dm-raid.c 34 KB

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