diff options
author | Martin K. Petersen <martin.petersen@oracle.com> | 2009-03-30 23:27:02 -0400 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2009-03-30 23:27:02 -0400 |
commit | 3f9d99c12a533809342b475c95452e82761bcc1c (patch) | |
tree | 8e8bcc72dce1b69e958317f77c351bc0bd4e1c28 | |
parent | 355a43e641b948a7b755cb4c2466ec548d5b495f (diff) |
MD data integrity support
md: Add support for data integrity to MD
If all subdevices support the same protection format the MD device is
flagged as integrity capable.
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: NeilBrown <neilb@suse.de>
-rw-r--r-- | drivers/md/md.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index a99c50e217c0..f30b4618c02c 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -1438,6 +1438,38 @@ static int match_mddev_units(mddev_t *mddev1, mddev_t *mddev2) | |||
1438 | 1438 | ||
1439 | static LIST_HEAD(pending_raid_disks); | 1439 | static LIST_HEAD(pending_raid_disks); |
1440 | 1440 | ||
1441 | static void md_integrity_check(mdk_rdev_t *rdev, mddev_t *mddev) | ||
1442 | { | ||
1443 | struct mdk_personality *pers = mddev->pers; | ||
1444 | struct gendisk *disk = mddev->gendisk; | ||
1445 | struct blk_integrity *bi_rdev = bdev_get_integrity(rdev->bdev); | ||
1446 | struct blk_integrity *bi_mddev = blk_get_integrity(disk); | ||
1447 | |||
1448 | /* Data integrity passthrough not supported on RAID 4, 5 and 6 */ | ||
1449 | if (pers && pers->level >= 4 && pers->level <= 6) | ||
1450 | return; | ||
1451 | |||
1452 | /* If rdev is integrity capable, register profile for mddev */ | ||
1453 | if (!bi_mddev && bi_rdev) { | ||
1454 | if (blk_integrity_register(disk, bi_rdev)) | ||
1455 | printk(KERN_ERR "%s: %s Could not register integrity!\n", | ||
1456 | __func__, disk->disk_name); | ||
1457 | else | ||
1458 | printk(KERN_NOTICE "Enabling data integrity on %s\n", | ||
1459 | disk->disk_name); | ||
1460 | return; | ||
1461 | } | ||
1462 | |||
1463 | /* Check that mddev and rdev have matching profiles */ | ||
1464 | if (blk_integrity_compare(disk, rdev->bdev->bd_disk) < 0) { | ||
1465 | printk(KERN_ERR "%s: %s/%s integrity mismatch!\n", __func__, | ||
1466 | disk->disk_name, rdev->bdev->bd_disk->disk_name); | ||
1467 | printk(KERN_NOTICE "Disabling data integrity on %s\n", | ||
1468 | disk->disk_name); | ||
1469 | blk_integrity_unregister(disk); | ||
1470 | } | ||
1471 | } | ||
1472 | |||
1441 | static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev) | 1473 | static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev) |
1442 | { | 1474 | { |
1443 | char b[BDEVNAME_SIZE]; | 1475 | char b[BDEVNAME_SIZE]; |
@@ -1508,6 +1540,8 @@ static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev) | |||
1508 | 1540 | ||
1509 | /* May as well allow recovery to be retried once */ | 1541 | /* May as well allow recovery to be retried once */ |
1510 | mddev->recovery_disabled = 0; | 1542 | mddev->recovery_disabled = 0; |
1543 | |||
1544 | md_integrity_check(rdev, mddev); | ||
1511 | return 0; | 1545 | return 0; |
1512 | 1546 | ||
1513 | fail: | 1547 | fail: |
@@ -3794,6 +3828,10 @@ static int do_md_run(mddev_t * mddev) | |||
3794 | mddev->level = pers->level; | 3828 | mddev->level = pers->level; |
3795 | strlcpy(mddev->clevel, pers->name, sizeof(mddev->clevel)); | 3829 | strlcpy(mddev->clevel, pers->name, sizeof(mddev->clevel)); |
3796 | 3830 | ||
3831 | if (pers->level >= 4 && pers->level <= 6) | ||
3832 | /* Cannot support integrity (yet) */ | ||
3833 | blk_integrity_unregister(mddev->gendisk); | ||
3834 | |||
3797 | if (mddev->reshape_position != MaxSector && | 3835 | if (mddev->reshape_position != MaxSector && |
3798 | pers->start_reshape == NULL) { | 3836 | pers->start_reshape == NULL) { |
3799 | /* This personality cannot handle reshaping... */ | 3837 | /* This personality cannot handle reshaping... */ |
@@ -4129,6 +4167,7 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open) | |||
4129 | printk(KERN_INFO "md: %s switched to read-only mode.\n", | 4167 | printk(KERN_INFO "md: %s switched to read-only mode.\n", |
4130 | mdname(mddev)); | 4168 | mdname(mddev)); |
4131 | err = 0; | 4169 | err = 0; |
4170 | blk_integrity_unregister(disk); | ||
4132 | md_new_event(mddev); | 4171 | md_new_event(mddev); |
4133 | sysfs_notify_dirent(mddev->sysfs_state); | 4172 | sysfs_notify_dirent(mddev->sysfs_state); |
4134 | out: | 4173 | out: |