Skip to content

Commit b15c2e5

Browse files
neilbrownLinus Torvalds
authored andcommitted
[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>
1 parent 6ff8d8e commit b15c2e5

File tree

5 files changed

+15
-35
lines changed

5 files changed

+15
-35
lines changed

drivers/md/bitmap.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,6 +1530,8 @@ void bitmap_destroy(mddev_t *mddev)
15301530
return;
15311531

15321532
mddev->bitmap = NULL; /* disconnect from the md device */
1533+
if (mddev->thread)
1534+
mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT;
15331535

15341536
bitmap_free(bitmap);
15351537
}
@@ -1636,6 +1638,8 @@ int bitmap_create(mddev_t *mddev)
16361638

16371639
if (IS_ERR(bitmap->writeback_daemon))
16381640
return PTR_ERR(bitmap->writeback_daemon);
1641+
mddev->thread->timeout = bitmap->daemon_sleep * HZ;
1642+
16391643
return bitmap_update_sb(bitmap);
16401644

16411645
error:

drivers/md/md.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2054,13 +2054,15 @@ static int do_md_run(mddev_t * mddev)
20542054
if (start_readonly)
20552055
mddev->ro = 2; /* read-only, but switch on first write */
20562056

2057-
/* before we start the array running, initialise the bitmap */
2058-
err = bitmap_create(mddev);
2059-
if (err)
2060-
printk(KERN_ERR "%s: failed to create bitmap (%d)\n",
2061-
mdname(mddev), err);
2062-
else
2063-
err = mddev->pers->run(mddev);
2057+
err = mddev->pers->run(mddev);
2058+
if (!err && mddev->pers->sync_request) {
2059+
err = bitmap_create(mddev);
2060+
if (err) {
2061+
printk(KERN_ERR "%s: failed to create bitmap (%d)\n",
2062+
mdname(mddev), err);
2063+
mddev->pers->stop(mddev);
2064+
}
2065+
}
20642066
if (err) {
20652067
printk(KERN_ERR "md: pers->run() failed ...\n");
20662068
module_put(mddev->pers->owner);

drivers/md/raid1.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,7 +1611,6 @@ static int run(mddev_t *mddev)
16111611
mdname(mddev));
16121612
goto out_free_conf;
16131613
}
1614-
if (mddev->bitmap) mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ;
16151614

16161615
printk(KERN_INFO
16171616
"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)
17831782
lower_barrier(conf);
17841783
break;
17851784
}
1786-
if (mddev->thread) {
1787-
if (mddev->bitmap)
1788-
mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ;
1789-
else
1790-
mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT;
1791-
md_wakeup_thread(mddev->thread);
1792-
}
17931785
}
17941786

17951787

drivers/md/raid5.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1964,9 +1964,6 @@ static int run(mddev_t *mddev)
19641964
/* Ok, everything is just fine now */
19651965
sysfs_create_group(&mddev->kobj, &raid5_attrs_group);
19661966

1967-
if (mddev->bitmap)
1968-
mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ;
1969-
19701967
mddev->queue->unplug_fn = raid5_unplug_device;
19711968
mddev->queue->issue_flush_fn = raid5_issue_flush;
19721969

@@ -2200,14 +2197,8 @@ static void raid5_quiesce(mddev_t *mddev, int state)
22002197
spin_unlock_irq(&conf->device_lock);
22012198
break;
22022199
}
2203-
if (mddev->thread) {
2204-
if (mddev->bitmap)
2205-
mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ;
2206-
else
2207-
mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT;
2208-
md_wakeup_thread(mddev->thread);
2209-
}
22102200
}
2201+
22112202
static mdk_personality_t raid5_personality=
22122203
{
22132204
.name = "raid5",

drivers/md/raid6main.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1990,9 +1990,6 @@ static int run(mddev_t *mddev)
19901990
/* Ok, everything is just fine now */
19911991
mddev->array_size = mddev->size * (mddev->raid_disks - 2);
19921992

1993-
if (mddev->bitmap)
1994-
mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ;
1995-
19961993
mddev->queue->unplug_fn = raid6_unplug_device;
19971994
mddev->queue->issue_flush_fn = raid6_issue_flush;
19981995
return 0;
@@ -2228,14 +2225,8 @@ static void raid6_quiesce(mddev_t *mddev, int state)
22282225
spin_unlock_irq(&conf->device_lock);
22292226
break;
22302227
}
2231-
if (mddev->thread) {
2232-
if (mddev->bitmap)
2233-
mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ;
2234-
else
2235-
mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT;
2236-
md_wakeup_thread(mddev->thread);
2237-
}
22382228
}
2229+
22392230
static mdk_personality_t raid6_personality=
22402231
{
22412232
.name = "raid6",

0 commit comments

Comments
 (0)