Commit d571b483 authored by Neil Brown's avatar Neil Brown Committed by Linus Torvalds

[PATCH] md: factor out MD superblock handling code

Define an interface for interpreting and updating superblocks
so we can more easily define new formats.

With this patch, (almost) all superblock layout information is
locating in a small set of routines dedicated to superblock
handling.  This will allow us to provide a similar set for
a different format.

The two exceptions are:
 1/ autostart_array where the devices listed in the superblock
    are searched for.
 2/ raid5 'knows' the maximum number of devices for
     compute_parity.

These will be addressed in a later patch.
parent 6932d2d5
This diff is collapsed.
...@@ -59,7 +59,7 @@ static void mp_pool_free(void *mpb, void *data) ...@@ -59,7 +59,7 @@ static void mp_pool_free(void *mpb, void *data)
static int multipath_map (mddev_t *mddev, mdk_rdev_t **rdevp) static int multipath_map (mddev_t *mddev, mdk_rdev_t **rdevp)
{ {
multipath_conf_t *conf = mddev_to_conf(mddev); multipath_conf_t *conf = mddev_to_conf(mddev);
int i, disks = MD_SB_DISKS; int i, disks = mddev->max_disks;
/* /*
* Later we do read balancing on the read side * Later we do read balancing on the read side
...@@ -147,7 +147,7 @@ static int multipath_read_balance (multipath_conf_t *conf) ...@@ -147,7 +147,7 @@ static int multipath_read_balance (multipath_conf_t *conf)
{ {
int disk; int disk;
for (disk = 0; disk < MD_SB_DISKS; disk++) { for (disk = 0; disk < conf->mddev->max_disks; disk++) {
mdk_rdev_t *rdev = conf->multipaths[disk].rdev; mdk_rdev_t *rdev = conf->multipaths[disk].rdev;
if (rdev && rdev->in_sync) if (rdev && rdev->in_sync)
return disk; return disk;
...@@ -259,7 +259,7 @@ static void print_multipath_conf (multipath_conf_t *conf) ...@@ -259,7 +259,7 @@ static void print_multipath_conf (multipath_conf_t *conf)
printk(" --- wd:%d rd:%d\n", conf->working_disks, printk(" --- wd:%d rd:%d\n", conf->working_disks,
conf->raid_disks); conf->raid_disks);
for (i = 0; i < MD_SB_DISKS; i++) { for (i = 0; i < conf->mddev->max_disks; i++) {
tmp = conf->multipaths + i; tmp = conf->multipaths + i;
if (tmp->rdev) if (tmp->rdev)
printk(" disk%d, o:%d, dev:%s\n", printk(" disk%d, o:%d, dev:%s\n",
......
...@@ -151,8 +151,9 @@ struct mdk_rdev_s ...@@ -151,8 +151,9 @@ struct mdk_rdev_s
struct block_device *bdev; /* block device handle */ struct block_device *bdev; /* block device handle */
struct page *sb_page; struct page *sb_page;
mdp_super_t *sb; int sb_loaded;
sector_t sb_offset; sector_t sb_offset;
int preferred_minor; /* autorun support */
/* A device can be in one of three states based on two flags: /* A device can be in one of three states based on two flags:
* Not working: faulty==1 in_sync==0 * Not working: faulty==1 in_sync==0
...@@ -196,6 +197,7 @@ struct mddev_s ...@@ -196,6 +197,7 @@ struct mddev_s
time_t ctime, utime; time_t ctime, utime;
int level, layout; int level, layout;
int raid_disks; int raid_disks;
int max_disks;
unsigned long state; unsigned long state;
sector_t size; /* used size of component devices */ sector_t size; /* used size of component devices */
__u64 events; __u64 events;
......
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