[PATCH] md: move bitmap_create to after md array has been initialised

This is important because bitmap_create uses
  mddev->resync_max_sectors
and that doesn't have a valid value until after the array
has been initialised (with pers->run()).
[It doesn't make a difference for current personalities that
 support bitmaps, but will make a difference for raid10]

This has the added advantage of meaning with can move the thread->timeout
manipulation inside the bitmap.c code instead of sprinkling identical code
throughout all personalities.

Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
NeilBrown 2006-01-06 00:20:16 -08:00 committed by Linus Torvalds
parent 6ff8d8ec06
commit b15c2e57f0
5 changed files with 15 additions and 35 deletions

View File

@ -1530,6 +1530,8 @@ void bitmap_destroy(mddev_t *mddev)
return; return;
mddev->bitmap = NULL; /* disconnect from the md device */ mddev->bitmap = NULL; /* disconnect from the md device */
if (mddev->thread)
mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT;
bitmap_free(bitmap); bitmap_free(bitmap);
} }
@ -1636,6 +1638,8 @@ int bitmap_create(mddev_t *mddev)
if (IS_ERR(bitmap->writeback_daemon)) if (IS_ERR(bitmap->writeback_daemon))
return PTR_ERR(bitmap->writeback_daemon); return PTR_ERR(bitmap->writeback_daemon);
mddev->thread->timeout = bitmap->daemon_sleep * HZ;
return bitmap_update_sb(bitmap); return bitmap_update_sb(bitmap);
error: error:

View File

@ -2054,13 +2054,15 @@ static int do_md_run(mddev_t * mddev)
if (start_readonly) if (start_readonly)
mddev->ro = 2; /* read-only, but switch on first write */ mddev->ro = 2; /* read-only, but switch on first write */
/* before we start the array running, initialise the bitmap */ err = mddev->pers->run(mddev);
err = bitmap_create(mddev); if (!err && mddev->pers->sync_request) {
if (err) err = bitmap_create(mddev);
printk(KERN_ERR "%s: failed to create bitmap (%d)\n", if (err) {
mdname(mddev), err); printk(KERN_ERR "%s: failed to create bitmap (%d)\n",
else mdname(mddev), err);
err = mddev->pers->run(mddev); mddev->pers->stop(mddev);
}
}
if (err) { if (err) {
printk(KERN_ERR "md: pers->run() failed ...\n"); printk(KERN_ERR "md: pers->run() failed ...\n");
module_put(mddev->pers->owner); module_put(mddev->pers->owner);

View File

@ -1611,7 +1611,6 @@ static int run(mddev_t *mddev)
mdname(mddev)); mdname(mddev));
goto out_free_conf; goto out_free_conf;
} }
if (mddev->bitmap) mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ;
printk(KERN_INFO printk(KERN_INFO
"raid1: raid set %s active with %d out of %d mirrors\n", "raid1: raid set %s active with %d out of %d mirrors\n",
@ -1783,13 +1782,6 @@ static void raid1_quiesce(mddev_t *mddev, int state)
lower_barrier(conf); lower_barrier(conf);
break; break;
} }
if (mddev->thread) {
if (mddev->bitmap)
mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ;
else
mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT;
md_wakeup_thread(mddev->thread);
}
} }

View File

@ -1964,9 +1964,6 @@ static int run(mddev_t *mddev)
/* Ok, everything is just fine now */ /* Ok, everything is just fine now */
sysfs_create_group(&mddev->kobj, &raid5_attrs_group); sysfs_create_group(&mddev->kobj, &raid5_attrs_group);
if (mddev->bitmap)
mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ;
mddev->queue->unplug_fn = raid5_unplug_device; mddev->queue->unplug_fn = raid5_unplug_device;
mddev->queue->issue_flush_fn = raid5_issue_flush; mddev->queue->issue_flush_fn = raid5_issue_flush;
@ -2200,14 +2197,8 @@ static void raid5_quiesce(mddev_t *mddev, int state)
spin_unlock_irq(&conf->device_lock); spin_unlock_irq(&conf->device_lock);
break; break;
} }
if (mddev->thread) {
if (mddev->bitmap)
mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ;
else
mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT;
md_wakeup_thread(mddev->thread);
}
} }
static mdk_personality_t raid5_personality= static mdk_personality_t raid5_personality=
{ {
.name = "raid5", .name = "raid5",

View File

@ -1990,9 +1990,6 @@ static int run(mddev_t *mddev)
/* Ok, everything is just fine now */ /* Ok, everything is just fine now */
mddev->array_size = mddev->size * (mddev->raid_disks - 2); mddev->array_size = mddev->size * (mddev->raid_disks - 2);
if (mddev->bitmap)
mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ;
mddev->queue->unplug_fn = raid6_unplug_device; mddev->queue->unplug_fn = raid6_unplug_device;
mddev->queue->issue_flush_fn = raid6_issue_flush; mddev->queue->issue_flush_fn = raid6_issue_flush;
return 0; return 0;
@ -2228,14 +2225,8 @@ static void raid6_quiesce(mddev_t *mddev, int state)
spin_unlock_irq(&conf->device_lock); spin_unlock_irq(&conf->device_lock);
break; break;
} }
if (mddev->thread) {
if (mddev->bitmap)
mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ;
else
mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT;
md_wakeup_thread(mddev->thread);
}
} }
static mdk_personality_t raid6_personality= static mdk_personality_t raid6_personality=
{ {
.name = "raid6", .name = "raid6",