diff options
author | Arnd Bergmann <arnd@arndb.de> | 2011-10-20 18:30:25 +0200 |
---|---|---|
committer | Arnd Bergmann <arnd@arndb.de> | 2011-10-20 18:30:25 +0200 |
commit | 995a0605a6665858d73f9e80053414909be33f27 (patch) | |
tree | fcc66a6a77acdaae492f77c0c58c0233db74a2b4 /mm/backing-dev.c | |
parent | a32750c2ca6f697903b19063fc86f4272865e3a1 (diff) | |
parent | 677d3e2f07d1b3d6d2f76fd5552d16a53b9236a0 (diff) | |
download | blackbird-op-linux-995a0605a6665858d73f9e80053414909be33f27.tar.gz blackbird-op-linux-995a0605a6665858d73f9e80053414909be33f27.zip |
Merge branch 'at91/trng' into next/driver
Diffstat (limited to 'mm/backing-dev.c')
-rw-r--r-- | mm/backing-dev.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/mm/backing-dev.c b/mm/backing-dev.c index d6edf8d14f9c..a87da524a4a0 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -359,6 +359,17 @@ static unsigned long bdi_longest_inactive(void) return max(5UL * 60 * HZ, interval); } +/* + * Clear pending bit and wakeup anybody waiting for flusher thread creation or + * shutdown + */ +static void bdi_clear_pending(struct backing_dev_info *bdi) +{ + clear_bit(BDI_pending, &bdi->state); + smp_mb__after_clear_bit(); + wake_up_bit(&bdi->state, BDI_pending); +} + static int bdi_forker_thread(void *ptr) { struct bdi_writeback *me = ptr; @@ -390,6 +401,13 @@ static int bdi_forker_thread(void *ptr) } spin_lock_bh(&bdi_lock); + /* + * In the following loop we are going to check whether we have + * some work to do without any synchronization with tasks + * waking us up to do work for them. So we have to set task + * state already here so that we don't miss wakeups coming + * after we verify some condition. + */ set_current_state(TASK_INTERRUPTIBLE); list_for_each_entry(bdi, &bdi_list, bdi_list) { @@ -469,11 +487,13 @@ static int bdi_forker_thread(void *ptr) spin_unlock_bh(&bdi->wb_lock); wake_up_process(task); } + bdi_clear_pending(bdi); break; case KILL_THREAD: __set_current_state(TASK_RUNNING); kthread_stop(task); + bdi_clear_pending(bdi); break; case NO_ACTION: @@ -489,16 +509,8 @@ static int bdi_forker_thread(void *ptr) else schedule_timeout(msecs_to_jiffies(dirty_writeback_interval * 10)); try_to_freeze(); - /* Back to the main loop */ - continue; + break; } - - /* - * Clear pending bit and wakeup anybody waiting to tear us down. - */ - clear_bit(BDI_pending, &bdi->state); - smp_mb__after_clear_bit(); - wake_up_bit(&bdi->state, BDI_pending); } return 0; |