diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/md/bitmap.c | 73 | ||||
-rw-r--r-- | drivers/md/raid1.c | 2 |
2 files changed, 28 insertions, 47 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index 87145faac491..2fba2bbe72d8 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c | |||
@@ -626,7 +626,7 @@ static void bitmap_file_unmap(struct bitmap *bitmap) | |||
626 | page_cache_release(sb_page); | 626 | page_cache_release(sb_page); |
627 | } | 627 | } |
628 | 628 | ||
629 | static void bitmap_stop_daemons(struct bitmap *bitmap); | 629 | static void bitmap_stop_daemon(struct bitmap *bitmap); |
630 | 630 | ||
631 | /* dequeue the next item in a page list -- don't call from irq context */ | 631 | /* dequeue the next item in a page list -- don't call from irq context */ |
632 | static struct page_list *dequeue_page(struct bitmap *bitmap) | 632 | static struct page_list *dequeue_page(struct bitmap *bitmap) |
@@ -668,7 +668,7 @@ static void bitmap_file_put(struct bitmap *bitmap) | |||
668 | bitmap->file = NULL; | 668 | bitmap->file = NULL; |
669 | spin_unlock_irqrestore(&bitmap->lock, flags); | 669 | spin_unlock_irqrestore(&bitmap->lock, flags); |
670 | 670 | ||
671 | bitmap_stop_daemons(bitmap); | 671 | bitmap_stop_daemon(bitmap); |
672 | 672 | ||
673 | drain_write_queues(bitmap); | 673 | drain_write_queues(bitmap); |
674 | 674 | ||
@@ -1188,21 +1188,12 @@ static void bitmap_writeback_daemon(mddev_t *mddev) | |||
1188 | } | 1188 | } |
1189 | } | 1189 | } |
1190 | 1190 | ||
1191 | static int bitmap_start_daemon(struct bitmap *bitmap, mdk_thread_t **ptr, | 1191 | static mdk_thread_t *bitmap_start_daemon(struct bitmap *bitmap, |
1192 | void (*func)(mddev_t *), char *name) | 1192 | void (*func)(mddev_t *), char *name) |
1193 | { | 1193 | { |
1194 | mdk_thread_t *daemon; | 1194 | mdk_thread_t *daemon; |
1195 | unsigned long flags; | ||
1196 | char namebuf[32]; | 1195 | char namebuf[32]; |
1197 | 1196 | ||
1198 | spin_lock_irqsave(&bitmap->lock, flags); | ||
1199 | *ptr = NULL; | ||
1200 | |||
1201 | if (!bitmap->file) /* no need for daemon if there's no backing file */ | ||
1202 | goto out_unlock; | ||
1203 | |||
1204 | spin_unlock_irqrestore(&bitmap->lock, flags); | ||
1205 | |||
1206 | #ifdef INJECT_FATAL_FAULT_2 | 1197 | #ifdef INJECT_FATAL_FAULT_2 |
1207 | daemon = NULL; | 1198 | daemon = NULL; |
1208 | #else | 1199 | #else |
@@ -1212,47 +1203,32 @@ static int bitmap_start_daemon(struct bitmap *bitmap, mdk_thread_t **ptr, | |||
1212 | if (!daemon) { | 1203 | if (!daemon) { |
1213 | printk(KERN_ERR "%s: failed to start bitmap daemon\n", | 1204 | printk(KERN_ERR "%s: failed to start bitmap daemon\n", |
1214 | bmname(bitmap)); | 1205 | bmname(bitmap)); |
1215 | return -ECHILD; | 1206 | return ERR_PTR(-ECHILD); |
1216 | } | 1207 | } |
1217 | 1208 | ||
1218 | spin_lock_irqsave(&bitmap->lock, flags); | ||
1219 | *ptr = daemon; | ||
1220 | |||
1221 | md_wakeup_thread(daemon); /* start it running */ | 1209 | md_wakeup_thread(daemon); /* start it running */ |
1222 | 1210 | ||
1223 | PRINTK("%s: %s daemon (pid %d) started...\n", | 1211 | PRINTK("%s: %s daemon (pid %d) started...\n", |
1224 | bmname(bitmap), name, daemon->tsk->pid); | 1212 | bmname(bitmap), name, daemon->tsk->pid); |
1225 | out_unlock: | ||
1226 | spin_unlock_irqrestore(&bitmap->lock, flags); | ||
1227 | return 0; | ||
1228 | } | ||
1229 | 1213 | ||
1230 | static int bitmap_start_daemons(struct bitmap *bitmap) | 1214 | return daemon; |
1231 | { | ||
1232 | int err = bitmap_start_daemon(bitmap, &bitmap->writeback_daemon, | ||
1233 | bitmap_writeback_daemon, "bitmap_wb"); | ||
1234 | return err; | ||
1235 | } | 1215 | } |
1236 | 1216 | ||
1237 | static void bitmap_stop_daemon(struct bitmap *bitmap, mdk_thread_t **ptr) | 1217 | static void bitmap_stop_daemon(struct bitmap *bitmap) |
1238 | { | 1218 | { |
1239 | mdk_thread_t *daemon; | 1219 | /* the daemon can't stop itself... it'll just exit instead... */ |
1240 | unsigned long flags; | 1220 | if (bitmap->writeback_daemon && ! IS_ERR(bitmap->writeback_daemon) && |
1241 | 1221 | current->pid != bitmap->writeback_daemon->tsk->pid) { | |
1242 | spin_lock_irqsave(&bitmap->lock, flags); | 1222 | mdk_thread_t *daemon; |
1243 | daemon = *ptr; | 1223 | unsigned long flags; |
1244 | *ptr = NULL; | ||
1245 | spin_unlock_irqrestore(&bitmap->lock, flags); | ||
1246 | if (daemon) | ||
1247 | md_unregister_thread(daemon); /* destroy the thread */ | ||
1248 | } | ||
1249 | 1224 | ||
1250 | static void bitmap_stop_daemons(struct bitmap *bitmap) | 1225 | spin_lock_irqsave(&bitmap->lock, flags); |
1251 | { | 1226 | daemon = bitmap->writeback_daemon; |
1252 | /* the daemons can't stop themselves... they'll just exit instead... */ | 1227 | bitmap->writeback_daemon = NULL; |
1253 | if (bitmap->writeback_daemon && | 1228 | spin_unlock_irqrestore(&bitmap->lock, flags); |
1254 | current->pid != bitmap->writeback_daemon->tsk->pid) | 1229 | if (daemon && ! IS_ERR(daemon)) |
1255 | bitmap_stop_daemon(bitmap, &bitmap->writeback_daemon); | 1230 | md_unregister_thread(daemon); /* destroy the thread */ |
1231 | } | ||
1256 | } | 1232 | } |
1257 | 1233 | ||
1258 | static bitmap_counter_t *bitmap_get_counter(struct bitmap *bitmap, | 1234 | static bitmap_counter_t *bitmap_get_counter(struct bitmap *bitmap, |
@@ -1637,10 +1613,15 @@ int bitmap_create(mddev_t *mddev) | |||
1637 | 1613 | ||
1638 | mddev->bitmap = bitmap; | 1614 | mddev->bitmap = bitmap; |
1639 | 1615 | ||
1640 | /* kick off the bitmap daemons */ | 1616 | if (file) |
1641 | err = bitmap_start_daemons(bitmap); | 1617 | /* kick off the bitmap writeback daemon */ |
1642 | if (err) | 1618 | bitmap->writeback_daemon = |
1643 | return err; | 1619 | bitmap_start_daemon(bitmap, |
1620 | bitmap_writeback_daemon, | ||
1621 | "bitmap_wb"); | ||
1622 | |||
1623 | if (IS_ERR(bitmap->writeback_daemon)) | ||
1624 | return PTR_ERR(bitmap->writeback_daemon); | ||
1644 | return bitmap_update_sb(bitmap); | 1625 | return bitmap_update_sb(bitmap); |
1645 | 1626 | ||
1646 | error: | 1627 | error: |
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index bfe78571586b..a93ca478142a 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -1703,7 +1703,7 @@ static int raid1_reshape(mddev_t *mddev, int raid_disks) | |||
1703 | return 0; | 1703 | return 0; |
1704 | } | 1704 | } |
1705 | 1705 | ||
1706 | void raid1_quiesce(mddev_t *mddev, int state) | 1706 | static void raid1_quiesce(mddev_t *mddev, int state) |
1707 | { | 1707 | { |
1708 | conf_t *conf = mddev_to_conf(mddev); | 1708 | conf_t *conf = mddev_to_conf(mddev); |
1709 | 1709 | ||