Commit bab5d712 authored by Neil Brown's avatar Neil Brown Committed by Trond Myklebust

[PATCH] MD - Remove dependance on superblock

Remove dependance on superblock

All the remaining field of interest in the superblock
get duplicated in the mddev struture and this is treated as
authoritative.  The superblock gets completely generated at
write time, and all useful information extracted at read time.

This means that we can slot in different superblock formats
without affecting the bulk of the code.
parent 5e601b35
...@@ -55,7 +55,7 @@ static int linear_run (mddev_t *mddev) ...@@ -55,7 +55,7 @@ static int linear_run (mddev_t *mddev)
int j = rdev->raid_disk; int j = rdev->raid_disk;
dev_info_t *disk = conf->disks + j; dev_info_t *disk = conf->disks + j;
if (j < 0 || j > mddev->sb->raid_disks || disk->bdev) { if (j < 0 || j > mddev->raid_disks || disk->bdev) {
printk("linear: disk numbering problem. Aborting!\n"); printk("linear: disk numbering problem. Aborting!\n");
goto out; goto out;
} }
...@@ -67,7 +67,7 @@ static int linear_run (mddev_t *mddev) ...@@ -67,7 +67,7 @@ static int linear_run (mddev_t *mddev)
conf->smallest = disk; conf->smallest = disk;
cnt++; cnt++;
} }
if (cnt != mddev->sb->raid_disks) { if (cnt != mddev->raid_disks) {
printk("linear: not enough drives present. Aborting!\n"); printk("linear: not enough drives present. Aborting!\n");
goto out; goto out;
} }
...@@ -186,7 +186,7 @@ static int linear_status (char *page, mddev_t *mddev) ...@@ -186,7 +186,7 @@ static int linear_status (char *page, mddev_t *mddev)
} }
sz += sprintf(page+sz, "\n"); sz += sprintf(page+sz, "\n");
#endif #endif
sz += sprintf(page+sz, " %dk rounding", mddev->sb->chunk_size/1024); sz += sprintf(page+sz, " %dk rounding", mddev->chunk_size/1024);
return sz; return sz;
} }
......
This diff is collapsed.
...@@ -424,7 +424,7 @@ static void multipathd (void *data) ...@@ -424,7 +424,7 @@ static void multipathd (void *data)
"multipath: detected IO path differences!\n" "multipath: detected IO path differences!\n"
#define ARRAY_IS_ACTIVE KERN_INFO \ #define ARRAY_IS_ACTIVE KERN_INFO \
"multipath: array md%d active with %d out of %d IO paths (%d spare IO paths)\n" "multipath: array md%d active with %d out of %d IO paths\n"
#define THREAD_ERROR KERN_ERR \ #define THREAD_ERROR KERN_ERR \
"multipath: couldn't allocate thread for md%d\n" "multipath: couldn't allocate thread for md%d\n"
...@@ -434,15 +434,14 @@ static int multipath_run (mddev_t *mddev) ...@@ -434,15 +434,14 @@ static int multipath_run (mddev_t *mddev)
multipath_conf_t *conf; multipath_conf_t *conf;
int disk_idx; int disk_idx;
struct multipath_info *disk; struct multipath_info *disk;
mdp_super_t *sb = mddev->sb;
mdk_rdev_t *rdev; mdk_rdev_t *rdev;
struct list_head *tmp; struct list_head *tmp;
int num_rdevs = 0; int num_rdevs = 0;
MOD_INC_USE_COUNT; MOD_INC_USE_COUNT;
if (sb->level != LEVEL_MULTIPATH) { if (mddev->level != LEVEL_MULTIPATH) {
printk(INVALID_LEVEL, mdidx(mddev), sb->level); printk(INVALID_LEVEL, mdidx(mddev), mddev->level);
goto out; goto out;
} }
/* /*
...@@ -492,7 +491,7 @@ static int multipath_run (mddev_t *mddev) ...@@ -492,7 +491,7 @@ static int multipath_run (mddev_t *mddev)
num_rdevs++; num_rdevs++;
} }
conf->raid_disks = sb->raid_disks = num_rdevs; conf->raid_disks = mddev->raid_disks = num_rdevs;
mddev->sb_dirty = 1; mddev->sb_dirty = 1;
conf->mddev = mddev; conf->mddev = mddev;
conf->device_lock = SPIN_LOCK_UNLOCKED; conf->device_lock = SPIN_LOCK_UNLOCKED;
...@@ -520,8 +519,8 @@ static int multipath_run (mddev_t *mddev) ...@@ -520,8 +519,8 @@ static int multipath_run (mddev_t *mddev)
} }
} }
printk(ARRAY_IS_ACTIVE, mdidx(mddev), sb->active_disks, printk(ARRAY_IS_ACTIVE, mdidx(mddev), conf->working_disks,
sb->raid_disks, sb->spare_disks); mddev->raid_disks);
/* /*
* Ok, everything is just fine now * Ok, everything is just fine now
*/ */
......
...@@ -89,7 +89,7 @@ static int create_strip_zones (mddev_t *mddev) ...@@ -89,7 +89,7 @@ static int create_strip_zones (mddev_t *mddev)
ITERATE_RDEV(mddev, rdev1, tmp1) { ITERATE_RDEV(mddev, rdev1, tmp1) {
int j = rdev1->sb->this_disk.raid_disk; int j = rdev1->sb->this_disk.raid_disk;
if (j < 0 || j >= mddev->sb->raid_disks) { if (j < 0 || j >= mddev->raid_disks) {
printk("raid0: bad disk number %d - aborting!\n", j); printk("raid0: bad disk number %d - aborting!\n", j);
goto abort; goto abort;
} }
...@@ -102,9 +102,9 @@ static int create_strip_zones (mddev_t *mddev) ...@@ -102,9 +102,9 @@ static int create_strip_zones (mddev_t *mddev)
smallest = rdev1; smallest = rdev1;
cnt++; cnt++;
} }
if (cnt != mddev->sb->raid_disks) { if (cnt != mddev->raid_disks) {
printk("raid0: too few disks (%d of %d) - aborting!\n", cnt, printk("raid0: too few disks (%d of %d) - aborting!\n", cnt,
mddev->sb->raid_disks); mddev->raid_disks);
goto abort; goto abort;
} }
zone->nb_dev = cnt; zone->nb_dev = cnt;
...@@ -271,7 +271,7 @@ static int raid0_make_request (request_queue_t *q, struct bio *bio) ...@@ -271,7 +271,7 @@ static int raid0_make_request (request_queue_t *q, struct bio *bio)
mdk_rdev_t *tmp_dev; mdk_rdev_t *tmp_dev;
unsigned long chunk, block, rsect; unsigned long chunk, block, rsect;
chunk_size = mddev->sb->chunk_size >> 10; chunk_size = mddev->chunk_size >> 10;
chunksize_bits = ffz(~chunk_size); chunksize_bits = ffz(~chunk_size);
block = bio->bi_sector >> 1; block = bio->bi_sector >> 1;
hash = conf->hash_table + block / conf->smallest->size; hash = conf->hash_table + block / conf->smallest->size;
...@@ -360,7 +360,7 @@ static int raid0_status (char *page, mddev_t *mddev) ...@@ -360,7 +360,7 @@ static int raid0_status (char *page, mddev_t *mddev)
conf->strip_zone[j].size); conf->strip_zone[j].size);
} }
#endif #endif
sz += sprintf(page + sz, " %dk chunks", mddev->sb->chunk_size/1024); sz += sprintf(page + sz, " %dk chunks", mddev->chunk_size/1024);
return sz; return sz;
} }
......
...@@ -1060,7 +1060,7 @@ static int sync_request(mddev_t *mddev, sector_t sector_nr, int go_faster) ...@@ -1060,7 +1060,7 @@ static int sync_request(mddev_t *mddev, sector_t sector_nr, int go_faster)
if (init_resync(conf)) if (init_resync(conf))
return -ENOMEM; return -ENOMEM;
max_sector = mddev->sb->size << 1; max_sector = mddev->size << 1;
if (sector_nr >= max_sector) { if (sector_nr >= max_sector) {
close_sync(conf); close_sync(conf);
return 0; return 0;
...@@ -1180,14 +1180,13 @@ static int run(mddev_t *mddev) ...@@ -1180,14 +1180,13 @@ static int run(mddev_t *mddev)
conf_t *conf; conf_t *conf;
int i, j, disk_idx; int i, j, disk_idx;
mirror_info_t *disk; mirror_info_t *disk;
mdp_super_t *sb = mddev->sb;
mdk_rdev_t *rdev; mdk_rdev_t *rdev;
struct list_head *tmp; struct list_head *tmp;
MOD_INC_USE_COUNT; MOD_INC_USE_COUNT;
if (sb->level != 1) { if (mddev->level != 1) {
printk(INVALID_LEVEL, mdidx(mddev), sb->level); printk(INVALID_LEVEL, mdidx(mddev), mddev->level);
goto out; goto out;
} }
/* /*
...@@ -1266,7 +1265,7 @@ static int run(mddev_t *mddev) ...@@ -1266,7 +1265,7 @@ static int run(mddev_t *mddev)
disk->head_position = 0; disk->head_position = 0;
} }
} }
conf->raid_disks = sb->raid_disks; conf->raid_disks = mddev->raid_disks;
conf->mddev = mddev; conf->mddev = mddev;
conf->device_lock = SPIN_LOCK_UNLOCKED; conf->device_lock = SPIN_LOCK_UNLOCKED;
...@@ -1316,7 +1315,7 @@ static int run(mddev_t *mddev) ...@@ -1316,7 +1315,7 @@ static int run(mddev_t *mddev)
} }
} }
printk(ARRAY_IS_ACTIVE, mdidx(mddev), sb->raid_disks - mddev->degraded, sb->raid_disks); printk(ARRAY_IS_ACTIVE, mdidx(mddev), mddev->raid_disks - mddev->degraded, mddev->raid_disks);
/* /*
* Ok, everything is just fine now * Ok, everything is just fine now
*/ */
......
...@@ -1290,7 +1290,7 @@ static int sync_request (mddev_t *mddev, sector_t sector_nr, int go_faster) ...@@ -1290,7 +1290,7 @@ static int sync_request (mddev_t *mddev, sector_t sector_nr, int go_faster)
int raid_disks = conf->raid_disks; int raid_disks = conf->raid_disks;
int data_disks = raid_disks-1; int data_disks = raid_disks-1;
if (sector_nr >= mddev->sb->size <<1) if (sector_nr >= mddev->size <<1)
/* just being told to finish up .. nothing to do */ /* just being told to finish up .. nothing to do */
return 0; return 0;
...@@ -1364,15 +1364,14 @@ static int run (mddev_t *mddev) ...@@ -1364,15 +1364,14 @@ static int run (mddev_t *mddev)
{ {
raid5_conf_t *conf; raid5_conf_t *conf;
int i, raid_disk, memory; int i, raid_disk, memory;
mdp_super_t *sb = mddev->sb;
mdk_rdev_t *rdev; mdk_rdev_t *rdev;
struct disk_info *disk; struct disk_info *disk;
struct list_head *tmp; struct list_head *tmp;
MOD_INC_USE_COUNT; MOD_INC_USE_COUNT;
if (sb->level != 5 && sb->level != 4) { if (mddev->level != 5 && mddev->level != 4) {
printk("raid5: md%d: raid level not set to 4/5 (%d)\n", mdidx(mddev), sb->level); printk("raid5: md%d: raid level not set to 4/5 (%d)\n", mdidx(mddev), mddev->level);
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
return -EIO; return -EIO;
} }
...@@ -1444,7 +1443,7 @@ static int run (mddev_t *mddev) ...@@ -1444,7 +1443,7 @@ static int run (mddev_t *mddev)
} }
} }
for (i = 0; i < sb->raid_disks; i++) { for (i = 0; i < conf->raid_disks; i++) {
disk = conf->disks + i; disk = conf->disks + i;
if (!disk->used_slot) { if (!disk->used_slot) {
...@@ -1457,15 +1456,15 @@ static int run (mddev_t *mddev) ...@@ -1457,15 +1456,15 @@ static int run (mddev_t *mddev)
} }
} }
conf->raid_disks = sb->raid_disks; conf->raid_disks = mddev->raid_disks;
/* /*
* 0 for a fully functional array, 1 for a degraded array. * 0 for a fully functional array, 1 for a degraded array.
*/ */
mddev->degraded = conf->failed_disks = conf->raid_disks - conf->working_disks; mddev->degraded = conf->failed_disks = conf->raid_disks - conf->working_disks;
conf->mddev = mddev; conf->mddev = mddev;
conf->chunk_size = sb->chunk_size; conf->chunk_size = mddev->chunk_size;
conf->level = sb->level; conf->level = mddev->level;
conf->algorithm = sb->layout; conf->algorithm = mddev->layout;
conf->max_nr_stripes = NR_STRIPES; conf->max_nr_stripes = NR_STRIPES;
#if 0 #if 0
...@@ -1490,7 +1489,7 @@ static int run (mddev_t *mddev) ...@@ -1490,7 +1489,7 @@ static int run (mddev_t *mddev)
} }
if (mddev->degraded == 1 && if (mddev->degraded == 1 &&
!(sb->state & (1<<MD_SB_CLEAN))) { !(mddev->state & (1<<MD_SB_CLEAN))) {
printk(KERN_ERR "raid5: cannot start dirty degraded array for md%d\n", mdidx(mddev)); printk(KERN_ERR "raid5: cannot start dirty degraded array for md%d\n", mdidx(mddev));
goto abort; goto abort;
} }
...@@ -1515,10 +1514,12 @@ static int run (mddev_t *mddev) ...@@ -1515,10 +1514,12 @@ static int run (mddev_t *mddev)
} else } else
printk(KERN_INFO "raid5: allocated %dkB for md%d\n", memory, mdidx(mddev)); printk(KERN_INFO "raid5: allocated %dkB for md%d\n", memory, mdidx(mddev));
if (conf->working_disks == conf->raid_disks) if (mddev->degraded == 0)
printk("raid5: raid level %d set md%d active with %d out of %d devices, algorithm %d\n", conf->level, mdidx(mddev), sb->active_disks, sb->raid_disks, conf->algorithm); printk("raid5: raid level %d set md%d active with %d out of %d devices, algorithm %d\n", conf->level, mdidx(mddev),
mddev->raid_disks-mddev->degraded, mddev->raid_disks, conf->algorithm);
else else
printk(KERN_ALERT "raid5: raid level %d set md%d active with %d out of %d devices, algorithm %d\n", conf->level, mdidx(mddev), sb->active_disks, sb->raid_disks, conf->algorithm); printk(KERN_ALERT "raid5: raid level %d set md%d active with %d out of %d devices, algorithm %d\n", conf->level, mdidx(mddev),
mddev->raid_disks = mddev->degraded, mddev->raid_disks, conf->algorithm);
print_raid5_conf(conf); print_raid5_conf(conf);
...@@ -1590,10 +1591,9 @@ static void printall (raid5_conf_t *conf) ...@@ -1590,10 +1591,9 @@ static void printall (raid5_conf_t *conf)
static int status (char *page, mddev_t *mddev) static int status (char *page, mddev_t *mddev)
{ {
raid5_conf_t *conf = (raid5_conf_t *) mddev->private; raid5_conf_t *conf = (raid5_conf_t *) mddev->private;
mdp_super_t *sb = mddev->sb;
int sz = 0, i; int sz = 0, i;
sz += sprintf (page+sz, " level %d, %dk chunk, algorithm %d", sb->level, sb->chunk_size >> 10, sb->layout); sz += sprintf (page+sz, " level %d, %dk chunk, algorithm %d", mddev->level, mddev->chunk_size >> 10, mddev->layout);
sz += sprintf (page+sz, " [%d/%d] [", conf->raid_disks, conf->working_disks); sz += sprintf (page+sz, " [%d/%d] [", conf->raid_disks, conf->working_disks);
for (i = 0; i < conf->raid_disks; i++) for (i = 0; i < conf->raid_disks; i++)
sz += sprintf (page+sz, "%s", conf->disks[i].operational ? "U" : "_"); sz += sprintf (page+sz, "%s", conf->disks[i].operational ? "U" : "_");
......
...@@ -175,7 +175,20 @@ struct mddev_s ...@@ -175,7 +175,20 @@ struct mddev_s
int sb_dirty; int sb_dirty;
int ro; int ro;
/* Superblock information */
int major_version,
minor_version,
patch_version;
int persistent; int persistent;
int chunk_size;
time_t ctime, utime;
int level, layout;
int raid_disks;
unsigned long state;
sector_t size; /* used size of component devices */
__u64 events;
char uuid[16];
struct mdk_thread_s *sync_thread; /* doing resync or reconstruct */ struct mdk_thread_s *sync_thread; /* doing resync or reconstruct */
unsigned long curr_resync; /* blocks scheduled */ unsigned long curr_resync; /* blocks scheduled */
......
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