diff options
author | NeilBrown <neilb@suse.de> | 2007-02-28 23:11:35 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-03-01 17:53:36 -0500 |
commit | 7dd5e7c3dbe8c4ffb507ddc0ea8fab07c8b11b0b (patch) | |
tree | c045b733c5cf959e8f4e8608f4344f49e69d4e6c /drivers/md | |
parent | a723406c4aeedb9dc5d54fb81130d13c757f41bc (diff) |
[PATCH] md: move warning about creating a raid array on partitions of the one device
md tries to warn the user if they e.g. create a raid1 using two partitions of
the same device, as this does not provide true redundancy.
However it also warns if a raid0 is created like this, and there is nothing
wrong with that.
At the place where the warning is currently printer, we don't necessarily know
what level the array will be, so move the warning from the point where the
device is added to the point where the array is started.
Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/md.c | 63 |
1 files changed, 37 insertions, 26 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 05febfd9f071..c8c40c361532 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -1296,27 +1296,17 @@ static struct super_type super_types[] = { | |||
1296 | .sync_super = super_1_sync, | 1296 | .sync_super = super_1_sync, |
1297 | }, | 1297 | }, |
1298 | }; | 1298 | }; |
1299 | |||
1300 | static mdk_rdev_t * match_dev_unit(mddev_t *mddev, mdk_rdev_t *dev) | ||
1301 | { | ||
1302 | struct list_head *tmp; | ||
1303 | mdk_rdev_t *rdev; | ||
1304 | |||
1305 | ITERATE_RDEV(mddev,rdev,tmp) | ||
1306 | if (rdev->bdev->bd_contains == dev->bdev->bd_contains) | ||
1307 | return rdev; | ||
1308 | |||
1309 | return NULL; | ||
1310 | } | ||
1311 | 1299 | ||
1312 | static int match_mddev_units(mddev_t *mddev1, mddev_t *mddev2) | 1300 | static int match_mddev_units(mddev_t *mddev1, mddev_t *mddev2) |
1313 | { | 1301 | { |
1314 | struct list_head *tmp; | 1302 | struct list_head *tmp, *tmp2; |
1315 | mdk_rdev_t *rdev; | 1303 | mdk_rdev_t *rdev, *rdev2; |
1316 | 1304 | ||
1317 | ITERATE_RDEV(mddev1,rdev,tmp) | 1305 | ITERATE_RDEV(mddev1,rdev,tmp) |
1318 | if (match_dev_unit(mddev2, rdev)) | 1306 | ITERATE_RDEV(mddev2, rdev2, tmp2) |
1319 | return 1; | 1307 | if (rdev->bdev->bd_contains == |
1308 | rdev2->bdev->bd_contains) | ||
1309 | return 1; | ||
1320 | 1310 | ||
1321 | return 0; | 1311 | return 0; |
1322 | } | 1312 | } |
@@ -1325,8 +1315,7 @@ static LIST_HEAD(pending_raid_disks); | |||
1325 | 1315 | ||
1326 | static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev) | 1316 | static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev) |
1327 | { | 1317 | { |
1328 | mdk_rdev_t *same_pdev; | 1318 | char b[BDEVNAME_SIZE]; |
1329 | char b[BDEVNAME_SIZE], b2[BDEVNAME_SIZE]; | ||
1330 | struct kobject *ko; | 1319 | struct kobject *ko; |
1331 | char *s; | 1320 | char *s; |
1332 | 1321 | ||
@@ -1342,14 +1331,6 @@ static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev) | |||
1342 | else | 1331 | else |
1343 | mddev->size = rdev->size; | 1332 | mddev->size = rdev->size; |
1344 | } | 1333 | } |
1345 | same_pdev = match_dev_unit(mddev, rdev); | ||
1346 | if (same_pdev) | ||
1347 | printk(KERN_WARNING | ||
1348 | "%s: WARNING: %s appears to be on the same physical" | ||
1349 | " disk as %s. True\n protection against single-disk" | ||
1350 | " failure might be compromised.\n", | ||
1351 | mdname(mddev), bdevname(rdev->bdev,b), | ||
1352 | bdevname(same_pdev->bdev,b2)); | ||
1353 | 1334 | ||
1354 | /* Verify rdev->desc_nr is unique. | 1335 | /* Verify rdev->desc_nr is unique. |
1355 | * If it is -1, assign a free number, else | 1336 | * If it is -1, assign a free number, else |
@@ -3109,6 +3090,36 @@ static int do_md_run(mddev_t * mddev) | |||
3109 | return -EINVAL; | 3090 | return -EINVAL; |
3110 | } | 3091 | } |
3111 | 3092 | ||
3093 | if (pers->sync_request) { | ||
3094 | /* Warn if this is a potentially silly | ||
3095 | * configuration. | ||
3096 | */ | ||
3097 | char b[BDEVNAME_SIZE], b2[BDEVNAME_SIZE]; | ||
3098 | mdk_rdev_t *rdev2; | ||
3099 | struct list_head *tmp2; | ||
3100 | int warned = 0; | ||
3101 | ITERATE_RDEV(mddev, rdev, tmp) { | ||
3102 | ITERATE_RDEV(mddev, rdev2, tmp2) { | ||
3103 | if (rdev < rdev2 && | ||
3104 | rdev->bdev->bd_contains == | ||
3105 | rdev2->bdev->bd_contains) { | ||
3106 | printk(KERN_WARNING | ||
3107 | "%s: WARNING: %s appears to be" | ||
3108 | " on the same physical disk as" | ||
3109 | " %s.\n", | ||
3110 | mdname(mddev), | ||
3111 | bdevname(rdev->bdev,b), | ||
3112 | bdevname(rdev2->bdev,b2)); | ||
3113 | warned = 1; | ||
3114 | } | ||
3115 | } | ||
3116 | } | ||
3117 | if (warned) | ||
3118 | printk(KERN_WARNING | ||
3119 | "True protection against single-disk" | ||
3120 | " failure might be compromised.\n"); | ||
3121 | } | ||
3122 | |||
3112 | mddev->recovery = 0; | 3123 | mddev->recovery = 0; |
3113 | mddev->resync_max_sectors = mddev->size << 1; /* may be over-ridden by personality */ | 3124 | mddev->resync_max_sectors = mddev->size << 1; /* may be over-ridden by personality */ |
3114 | mddev->barriers_work = 1; | 3125 | mddev->barriers_work = 1; |