Commit 999a2029 authored by Neil Brown's avatar Neil Brown Committed by Trond Myklebust

[PATCH] MD - Set desc_nr more sanely.

Set desc_nr more sanely.

Currently rdev->desc_nr is set in sync_sbs which is typcially
called just before writing out the superblocks, which is an
odd place to set it.
It is also called when a new disk is added (which is sane) and
when an old disc is imported ... which is quesitonable.

With this patch it is set when a new disk is added, and when
the superblocks are being analysed, which makes lots of sense.

MULTIPATH is particularly an issue here.  The old code tried
to figure the desc_nr for an rdev by matching device numbers in
the superblock.  This doesn't make a lot of sense as
device numbers can change.  Now MULTIPATH components
get sequential desc_nrs.
parent 6f42312c
...@@ -876,7 +876,6 @@ static void set_this_disk(mddev_t *mddev, mdk_rdev_t *rdev) ...@@ -876,7 +876,6 @@ static void set_this_disk(mddev_t *mddev, mdk_rdev_t *rdev)
#endif #endif
if (kdev_same(mk_kdev(desc->major,desc->minor), rdev->dev)) { if (kdev_same(mk_kdev(desc->major,desc->minor), rdev->dev)) {
rdev->sb->this_disk = *desc; rdev->sb->this_disk = *desc;
rdev->desc_nr = desc->number;
ok = 1; ok = 1;
break; break;
} }
...@@ -1019,14 +1018,11 @@ static mdk_rdev_t *md_import_device(kdev_t newdev, int on_disk) ...@@ -1019,14 +1018,11 @@ static mdk_rdev_t *md_import_device(kdev_t newdev, int on_disk)
goto abort_free; goto abort_free;
} }
if (rdev->sb->level != LEVEL_MULTIPATH) { if (rdev->sb->level != LEVEL_MULTIPATH)
rdev->old_dev = mk_kdev(rdev->sb->this_disk.major, rdev->old_dev = mk_kdev(rdev->sb->this_disk.major,
rdev->sb->this_disk.minor); rdev->sb->this_disk.minor);
rdev->desc_nr = rdev->sb->this_disk.number; else
} else {
rdev->old_dev = NODEV; rdev->old_dev = NODEV;
rdev->desc_nr = -1;
}
} }
INIT_LIST_HEAD(&rdev->same_set); INIT_LIST_HEAD(&rdev->same_set);
...@@ -1065,7 +1061,7 @@ static mdk_rdev_t *md_import_device(kdev_t newdev, int on_disk) ...@@ -1065,7 +1061,7 @@ static mdk_rdev_t *md_import_device(kdev_t newdev, int on_disk)
static int analyze_sbs(mddev_t * mddev) static int analyze_sbs(mddev_t * mddev)
{ {
int out_of_date = 0, i, first; int out_of_date = 0, i;
struct list_head *tmp, *tmp2; struct list_head *tmp, *tmp2;
mdk_rdev_t *rdev, *rdev2, *freshest; mdk_rdev_t *rdev, *rdev2, *freshest;
mdp_super_t *sb; mdp_super_t *sb;
...@@ -1173,6 +1169,18 @@ static int analyze_sbs(mddev_t * mddev) ...@@ -1173,6 +1169,18 @@ static int analyze_sbs(mddev_t * mddev)
} }
} }
/* set rdev->desc_nr for each device.
* for MULTIPATH, we just us sequential number as
* nothing else is meaningful
*/
i = 0;
ITERATE_RDEV(mddev,rdev,tmp) {
if (sb->level == LEVEL_MULTIPATH) {
rdev->alias_device = !!i;
rdev->desc_nr = i++;
} else
rdev->desc_nr = rdev->sb->this_disk.number;
}
/* /*
* Fix up changed device names ... but only if this disk has a * Fix up changed device names ... but only if this disk has a
* recent update time. Use faulty checksum ones too. * recent update time. Use faulty checksum ones too.
...@@ -1301,7 +1309,6 @@ static int analyze_sbs(mddev_t * mddev) ...@@ -1301,7 +1309,6 @@ static int analyze_sbs(mddev_t * mddev)
* Double check wether all devices mentioned in the * Double check wether all devices mentioned in the
* superblock are in the rdev ring. * superblock are in the rdev ring.
*/ */
first = 1;
for (i = 0; i < MD_SB_DISKS; i++) { for (i = 0; i < MD_SB_DISKS; i++) {
mdp_disk_t *desc; mdp_disk_t *desc;
kdev_t dev; kdev_t dev;
...@@ -1322,23 +1329,6 @@ static int analyze_sbs(mddev_t * mddev) ...@@ -1322,23 +1329,6 @@ static int analyze_sbs(mddev_t * mddev)
MD_BUG(); MD_BUG();
goto abort; goto abort;
} }
/*
* In the case of Multipath-IO, we have no
* other information source to find out which
* disk is which, only the position of the device
* in the superblock:
*/
if (mddev->sb->level == LEVEL_MULTIPATH) {
if ((rdev->desc_nr != -1) && (rdev->desc_nr != i)) {
MD_BUG();
goto abort;
}
rdev->desc_nr = i;
if (!first)
rdev->alias_device = 1;
else
first = 0;
}
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment