Commit 43fb3e86 authored by Neil Brown's avatar Neil Brown Committed by Trond Myklebust

[PATCH] MD - Remove the sb from the mddev

Remove the sb from the mddev

Now that al the important information is in mddev, we don't need
to have an sb off the mddev.  We only keep the per-device ones.

Previously we determined if "set_array_info" had been run byb checking
mddev->sb.  Now we check mddev->raid_disks on the assumption that
any valid array MUST have a non-zero number of devices.
parent bab5d712
...@@ -175,7 +175,7 @@ static void mddev_put(mddev_t *mddev) ...@@ -175,7 +175,7 @@ static void mddev_put(mddev_t *mddev)
{ {
if (!atomic_dec_and_lock(&mddev->active, &all_mddevs_lock)) if (!atomic_dec_and_lock(&mddev->active, &all_mddevs_lock))
return; return;
if (!mddev->sb && list_empty(&mddev->disks)) { if (!mddev->raid_disks && list_empty(&mddev->disks)) {
list_del(&mddev->all_mddevs); list_del(&mddev->all_mddevs);
mddev_map[mdidx(mddev)] = NULL; mddev_map[mdidx(mddev)] = NULL;
kfree(mddev); kfree(mddev);
...@@ -350,20 +350,6 @@ static unsigned int zoned_raid_size(mddev_t *mddev) ...@@ -350,20 +350,6 @@ static unsigned int zoned_raid_size(mddev_t *mddev)
#define BAD_CSUM KERN_WARNING \ #define BAD_CSUM KERN_WARNING \
"md: invalid superblock checksum on %s\n" "md: invalid superblock checksum on %s\n"
static int alloc_array_sb(mddev_t * mddev)
{
if (mddev->sb) {
MD_BUG();
return 0;
}
mddev->sb = (mdp_super_t *) __get_free_page (GFP_KERNEL);
if (!mddev->sb)
return -ENOMEM;
clear_page(mddev->sb);
return 0;
}
static int alloc_disk_sb(mdk_rdev_t * rdev) static int alloc_disk_sb(mdk_rdev_t * rdev)
{ {
if (rdev->sb_page) if (rdev->sb_page)
...@@ -624,12 +610,6 @@ static void export_array(mddev_t *mddev) ...@@ -624,12 +610,6 @@ static void export_array(mddev_t *mddev)
{ {
struct list_head *tmp; struct list_head *tmp;
mdk_rdev_t *rdev; mdk_rdev_t *rdev;
mdp_super_t *sb = mddev->sb;
if (mddev->sb) {
mddev->sb = NULL;
free_page((unsigned long) sb);
}
ITERATE_RDEV(mddev,rdev,tmp) { ITERATE_RDEV(mddev,rdev,tmp) {
if (!rdev->mddev) { if (!rdev->mddev) {
...@@ -640,6 +620,7 @@ static void export_array(mddev_t *mddev) ...@@ -640,6 +620,7 @@ static void export_array(mddev_t *mddev)
} }
if (!list_empty(&mddev->disks)) if (!list_empty(&mddev->disks))
MD_BUG(); MD_BUG();
mddev->raid_disks = 0;
} }
static void free_mddev(mddev_t *mddev) static void free_mddev(mddev_t *mddev)
...@@ -726,12 +707,6 @@ void md_print_devices(void) ...@@ -726,12 +707,6 @@ void md_print_devices(void)
ITERATE_RDEV(mddev,rdev,tmp2) ITERATE_RDEV(mddev,rdev,tmp2)
printk("<%s>", partition_name(rdev->dev)); printk("<%s>", partition_name(rdev->dev));
if (mddev->sb) {
printk(" array superblock:\n");
print_sb(mddev->sb);
} else
printk(" no array superblock.\n");
ITERATE_RDEV(mddev,rdev,tmp2) ITERATE_RDEV(mddev,rdev,tmp2)
print_rdev(rdev); print_rdev(rdev);
} }
...@@ -835,13 +810,16 @@ static int write_disk_sb(mdk_rdev_t * rdev) ...@@ -835,13 +810,16 @@ static int write_disk_sb(mdk_rdev_t * rdev)
return 1; return 1;
} }
static int sync_sbs(mddev_t * mddev) static void sync_sbs(mddev_t * mddev)
{ {
mdk_rdev_t *rdev; mdk_rdev_t *rdev;
mdp_super_t *sb; mdp_super_t *sb;
struct list_head *tmp; struct list_head *tmp;
/* make sb->disks match mddev->disks /* make all rdev->sb match mddev data..
* we setup the data in the first rdev and copy it
* to the others.
*
* 1/ zero out disks * 1/ zero out disks
* 2/ Add info for each disk, keeping track of highest desc_nr * 2/ Add info for each disk, keeping track of highest desc_nr
* 3/ any empty disks < highest become removed * 3/ any empty disks < highest become removed
...@@ -854,7 +832,13 @@ static int sync_sbs(mddev_t * mddev) ...@@ -854,7 +832,13 @@ static int sync_sbs(mddev_t * mddev)
int i; int i;
int active=0, working=0,failed=0,spare=0,nr_disks=0; int active=0, working=0,failed=0,spare=0,nr_disks=0;
sb = mddev->sb; if (list_empty(&mddev->disks)) {
MD_BUG();
return;
}
rdev = list_entry(&mddev->disks.next, mdk_rdev_t, same_set);
sb = rdev->sb;
memset(sb, 0, sizeof(*sb)); memset(sb, 0, sizeof(*sb));
sb->md_magic = MD_SB_MAGIC; sb->md_magic = MD_SB_MAGIC;
...@@ -922,14 +906,16 @@ static int sync_sbs(mddev_t * mddev) ...@@ -922,14 +906,16 @@ static int sync_sbs(mddev_t * mddev)
sb->spare_disks = spare; sb->spare_disks = spare;
ITERATE_RDEV(mddev,rdev,tmp) { ITERATE_RDEV(mddev,rdev,tmp) {
mdp_super_t *this_sb;
if (rdev->faulty || rdev->alias_device) if (rdev->faulty || rdev->alias_device)
continue; continue;
sb = rdev->sb; this_sb = rdev->sb;
*sb = *mddev->sb; if (this_sb != sb)
sb->this_disk = sb->disks[rdev->desc_nr]; *this_sb = *sb;
sb->sb_csum = calc_sb_csum(sb); this_sb->this_disk = this_sb->disks[rdev->desc_nr];
this_sb->sb_csum = calc_sb_csum(this_sb);
} }
return 0;
} }
static void md_update_sb(mddev_t * mddev) static void md_update_sb(mddev_t * mddev)
...@@ -1127,9 +1113,6 @@ static int analyze_sbs(mddev_t * mddev) ...@@ -1127,9 +1113,6 @@ static int analyze_sbs(mddev_t * mddev)
* find the freshest superblock, that one will be the superblock * find the freshest superblock, that one will be the superblock
* that represents the whole array. * that represents the whole array.
*/ */
if (alloc_array_sb(mddev))
goto abort;
sb = mddev->sb;
freshest = NULL; freshest = NULL;
ITERATE_RDEV(mddev,rdev,tmp) { ITERATE_RDEV(mddev,rdev,tmp) {
...@@ -1167,7 +1150,8 @@ static int analyze_sbs(mddev_t * mddev) ...@@ -1167,7 +1150,8 @@ static int analyze_sbs(mddev_t * mddev)
printk(OUT_OF_DATE); printk(OUT_OF_DATE);
printk(KERN_INFO "md: freshest: %s\n", partition_name(freshest->dev)); printk(KERN_INFO "md: freshest: %s\n", partition_name(freshest->dev));
} }
memcpy (sb, freshest->sb, sizeof(*sb));
sb = freshest->sb;
mddev->major_version = sb->major_version; mddev->major_version = sb->major_version;
mddev->minor_version = sb->minor_version; mddev->minor_version = sb->minor_version;
...@@ -1381,7 +1365,7 @@ static int do_md_run(mddev_t * mddev) ...@@ -1381,7 +1365,7 @@ static int do_md_run(mddev_t * mddev)
/* /*
* Analyze all RAID superblock(s) * Analyze all RAID superblock(s)
*/ */
if (!mddev->sb && analyze_sbs(mddev)) { if (!mddev->raid_disks && analyze_sbs(mddev)) {
MD_BUG(); MD_BUG();
return -EINVAL; return -EINVAL;
} }
...@@ -1584,7 +1568,7 @@ static int do_md_stop(mddev_t * mddev, int ro) ...@@ -1584,7 +1568,7 @@ static int do_md_stop(mddev_t * mddev, int ro)
if (mddev->ro) if (mddev->ro)
mddev->ro = 0; mddev->ro = 0;
} }
if (mddev->sb) { if (mddev->raid_disks) {
/* /*
* mark it clean only if there was no resync * mark it clean only if there was no resync
* interrupted. * interrupted.
...@@ -1707,7 +1691,7 @@ static void autorun_devices(void) ...@@ -1707,7 +1691,7 @@ static void autorun_devices(void)
if (mddev_lock(mddev)) if (mddev_lock(mddev))
printk(KERN_WARNING "md: md%d locked, cannot run\n", printk(KERN_WARNING "md: md%d locked, cannot run\n",
mdidx(mddev)); mdidx(mddev));
else if (mddev->sb || !list_empty(&mddev->disks)) { else if (mddev->raid_disks || !list_empty(&mddev->disks)) {
printk(KERN_WARNING "md: md%d already running, cannot run %s\n", printk(KERN_WARNING "md: md%d already running, cannot run %s\n",
mdidx(mddev), partition_name(rdev0->dev)); mdidx(mddev), partition_name(rdev0->dev));
mddev_unlock(mddev); mddev_unlock(mddev);
...@@ -1941,7 +1925,7 @@ static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info) ...@@ -1941,7 +1925,7 @@ static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info)
mdk_rdev_t *rdev; mdk_rdev_t *rdev;
kdev_t dev; kdev_t dev;
dev = mk_kdev(info->major,info->minor); dev = mk_kdev(info->major,info->minor);
if (!mddev->sb) { if (!mddev->raid_disks) {
/* expecting a device which has a superblock */ /* expecting a device which has a superblock */
rdev = md_import_device(dev, 1); rdev = md_import_device(dev, 1);
if (IS_ERR(rdev)) { if (IS_ERR(rdev)) {
...@@ -2166,9 +2150,6 @@ static int hot_add_disk(mddev_t * mddev, kdev_t dev) ...@@ -2166,9 +2150,6 @@ static int hot_add_disk(mddev_t * mddev, kdev_t dev)
static int set_array_info(mddev_t * mddev, mdu_array_info_t *info) static int set_array_info(mddev_t * mddev, mdu_array_info_t *info)
{ {
if (alloc_array_sb(mddev))
return -ENOMEM;
mddev->major_version = MD_MAJOR_VERSION; mddev->major_version = MD_MAJOR_VERSION;
mddev->minor_version = MD_MINOR_VERSION; mddev->minor_version = MD_MINOR_VERSION;
mddev->patch_version = MD_PATCHLEVEL_VERSION; mddev->patch_version = MD_PATCHLEVEL_VERSION;
...@@ -2316,8 +2297,8 @@ static int md_ioctl(struct inode *inode, struct file *file, ...@@ -2316,8 +2297,8 @@ static int md_ioctl(struct inode *inode, struct file *file,
err = -EBUSY; err = -EBUSY;
goto abort_unlock; goto abort_unlock;
} }
if (mddev->sb) { if (mddev->raid_disks) {
printk(KERN_WARNING "md: array md%d already has a superblock!\n", printk(KERN_WARNING "md: array md%d already initialised!\n",
mdidx(mddev)); mdidx(mddev));
err = -EBUSY; err = -EBUSY;
goto abort_unlock; goto abort_unlock;
...@@ -2342,8 +2323,8 @@ static int md_ioctl(struct inode *inode, struct file *file, ...@@ -2342,8 +2323,8 @@ static int md_ioctl(struct inode *inode, struct file *file,
/* /*
* Commands querying/configuring an existing array: * Commands querying/configuring an existing array:
*/ */
/* if we don't have a superblock yet, only ADD_NEW_DISK or STOP_ARRAY is allowed */ /* if we are initialised yet, only ADD_NEW_DISK or STOP_ARRAY is allowed */
if (!mddev->sb && cmd != ADD_NEW_DISK && cmd != STOP_ARRAY && cmd != RUN_ARRAY) { if (!mddev->raid_disks && cmd != ADD_NEW_DISK && cmd != STOP_ARRAY && cmd != RUN_ARRAY) {
err = -ENODEV; err = -ENODEV;
goto abort_unlock; goto abort_unlock;
} }
...@@ -3086,14 +3067,12 @@ static void md_do_sync(void *data) ...@@ -3086,14 +3067,12 @@ static void md_do_sync(void *data)
void md_do_recovery(void *data) void md_do_recovery(void *data)
{ {
mddev_t *mddev; mddev_t *mddev;
mdp_super_t *sb;
struct list_head *tmp; struct list_head *tmp;
dprintk(KERN_INFO "md: recovery thread got woken up ...\n"); dprintk(KERN_INFO "md: recovery thread got woken up ...\n");
ITERATE_MDDEV(mddev,tmp) if (mddev_lock(mddev)==0) { ITERATE_MDDEV(mddev,tmp) if (mddev_lock(mddev)==0) {
sb = mddev->sb; if (!mddev->raid_disks || !mddev->pers || mddev->ro)
if (!sb || !mddev->pers || mddev->ro)
goto unlock; goto unlock;
if (mddev->sb_dirty) if (mddev->sb_dirty)
md_update_sb(mddev); md_update_sb(mddev);
...@@ -3483,7 +3462,7 @@ void __init md_setup_drive(void) ...@@ -3483,7 +3462,7 @@ void __init md_setup_drive(void)
continue; continue;
} }
if (mddev->sb || !list_empty(&mddev->disks)) { if (mddev->raid_disks || !list_empty(&mddev->disks)) {
printk(KERN_WARNING printk(KERN_WARNING
"md: Ignoring md=%d, already autodetected. (Use raid=noautodetect)\n", "md: Ignoring md=%d, already autodetected. (Use raid=noautodetect)\n",
minor); minor);
......
...@@ -170,7 +170,6 @@ struct mddev_s ...@@ -170,7 +170,6 @@ struct mddev_s
void *private; void *private;
mdk_personality_t *pers; mdk_personality_t *pers;
int __minor; int __minor;
mdp_super_t *sb;
struct list_head disks; struct list_head disks;
int sb_dirty; int sb_dirty;
int ro; int ro;
......
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