Commit 500af87a authored by NeilBrown's avatar NeilBrown Committed by Linus Torvalds

[PATCH] md: tidy up daemon stop/start code in md/bitmap.c

The bitmap code used to have two daemons, so there is some 'common' start/stop
code.  But now there is only one, so the common code is just noise.

This patch tidies this up somewhat.
Signed-off-by: default avatarNeil Brown <neilb@cse.unsw.edu.au>
Signed-off-by: default avatarAdrian Bunk <bunk@stusta.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 9ba00538
...@@ -626,7 +626,7 @@ static void bitmap_file_unmap(struct bitmap *bitmap) ...@@ -626,7 +626,7 @@ static void bitmap_file_unmap(struct bitmap *bitmap)
page_cache_release(sb_page); page_cache_release(sb_page);
} }
static void bitmap_stop_daemons(struct bitmap *bitmap); static void bitmap_stop_daemon(struct bitmap *bitmap);
/* dequeue the next item in a page list -- don't call from irq context */ /* dequeue the next item in a page list -- don't call from irq context */
static struct page_list *dequeue_page(struct bitmap *bitmap) static struct page_list *dequeue_page(struct bitmap *bitmap)
...@@ -668,7 +668,7 @@ static void bitmap_file_put(struct bitmap *bitmap) ...@@ -668,7 +668,7 @@ static void bitmap_file_put(struct bitmap *bitmap)
bitmap->file = NULL; bitmap->file = NULL;
spin_unlock_irqrestore(&bitmap->lock, flags); spin_unlock_irqrestore(&bitmap->lock, flags);
bitmap_stop_daemons(bitmap); bitmap_stop_daemon(bitmap);
drain_write_queues(bitmap); drain_write_queues(bitmap);
...@@ -1188,21 +1188,12 @@ static void bitmap_writeback_daemon(mddev_t *mddev) ...@@ -1188,21 +1188,12 @@ static void bitmap_writeback_daemon(mddev_t *mddev)
} }
} }
static int bitmap_start_daemon(struct bitmap *bitmap, mdk_thread_t **ptr, static mdk_thread_t *bitmap_start_daemon(struct bitmap *bitmap,
void (*func)(mddev_t *), char *name) void (*func)(mddev_t *), char *name)
{ {
mdk_thread_t *daemon; mdk_thread_t *daemon;
unsigned long flags;
char namebuf[32]; char namebuf[32];
spin_lock_irqsave(&bitmap->lock, flags);
*ptr = NULL;
if (!bitmap->file) /* no need for daemon if there's no backing file */
goto out_unlock;
spin_unlock_irqrestore(&bitmap->lock, flags);
#ifdef INJECT_FATAL_FAULT_2 #ifdef INJECT_FATAL_FAULT_2
daemon = NULL; daemon = NULL;
#else #else
...@@ -1212,47 +1203,32 @@ static int bitmap_start_daemon(struct bitmap *bitmap, mdk_thread_t **ptr, ...@@ -1212,47 +1203,32 @@ static int bitmap_start_daemon(struct bitmap *bitmap, mdk_thread_t **ptr,
if (!daemon) { if (!daemon) {
printk(KERN_ERR "%s: failed to start bitmap daemon\n", printk(KERN_ERR "%s: failed to start bitmap daemon\n",
bmname(bitmap)); bmname(bitmap));
return -ECHILD; return ERR_PTR(-ECHILD);
} }
spin_lock_irqsave(&bitmap->lock, flags);
*ptr = daemon;
md_wakeup_thread(daemon); /* start it running */ md_wakeup_thread(daemon); /* start it running */
PRINTK("%s: %s daemon (pid %d) started...\n", PRINTK("%s: %s daemon (pid %d) started...\n",
bmname(bitmap), name, daemon->tsk->pid); bmname(bitmap), name, daemon->tsk->pid);
out_unlock:
spin_unlock_irqrestore(&bitmap->lock, flags);
return 0;
}
static int bitmap_start_daemons(struct bitmap *bitmap) return daemon;
{
int err = bitmap_start_daemon(bitmap, &bitmap->writeback_daemon,
bitmap_writeback_daemon, "bitmap_wb");
return err;
} }
static void bitmap_stop_daemon(struct bitmap *bitmap, mdk_thread_t **ptr) static void bitmap_stop_daemon(struct bitmap *bitmap)
{ {
/* the daemon can't stop itself... it'll just exit instead... */
if (bitmap->writeback_daemon && ! IS_ERR(bitmap->writeback_daemon) &&
current->pid != bitmap->writeback_daemon->tsk->pid) {
mdk_thread_t *daemon; mdk_thread_t *daemon;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&bitmap->lock, flags); spin_lock_irqsave(&bitmap->lock, flags);
daemon = *ptr; daemon = bitmap->writeback_daemon;
*ptr = NULL; bitmap->writeback_daemon = NULL;
spin_unlock_irqrestore(&bitmap->lock, flags); spin_unlock_irqrestore(&bitmap->lock, flags);
if (daemon) if (daemon && ! IS_ERR(daemon))
md_unregister_thread(daemon); /* destroy the thread */ md_unregister_thread(daemon); /* destroy the thread */
} }
static void bitmap_stop_daemons(struct bitmap *bitmap)
{
/* the daemons can't stop themselves... they'll just exit instead... */
if (bitmap->writeback_daemon &&
current->pid != bitmap->writeback_daemon->tsk->pid)
bitmap_stop_daemon(bitmap, &bitmap->writeback_daemon);
} }
static bitmap_counter_t *bitmap_get_counter(struct bitmap *bitmap, static bitmap_counter_t *bitmap_get_counter(struct bitmap *bitmap,
...@@ -1637,10 +1613,15 @@ int bitmap_create(mddev_t *mddev) ...@@ -1637,10 +1613,15 @@ int bitmap_create(mddev_t *mddev)
mddev->bitmap = bitmap; mddev->bitmap = bitmap;
/* kick off the bitmap daemons */ if (file)
err = bitmap_start_daemons(bitmap); /* kick off the bitmap writeback daemon */
if (err) bitmap->writeback_daemon =
return err; bitmap_start_daemon(bitmap,
bitmap_writeback_daemon,
"bitmap_wb");
if (IS_ERR(bitmap->writeback_daemon))
return PTR_ERR(bitmap->writeback_daemon);
return bitmap_update_sb(bitmap); return bitmap_update_sb(bitmap);
error: error:
......
...@@ -1703,7 +1703,7 @@ static int raid1_reshape(mddev_t *mddev, int raid_disks) ...@@ -1703,7 +1703,7 @@ static int raid1_reshape(mddev_t *mddev, int raid_disks)
return 0; return 0;
} }
void raid1_quiesce(mddev_t *mddev, int state) static void raid1_quiesce(mddev_t *mddev, int state)
{ {
conf_t *conf = mddev_to_conf(mddev); conf_t *conf = mddev_to_conf(mddev);
......
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