Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / mm / pdflush.c
index 1e682be..c4b6d0a 100644 (file)
 #include <linux/gfp.h>
 #include <linux/init.h>
 #include <linux/module.h>
-#include <linux/suspend.h>
 #include <linux/fs.h>          // Needed by writeback.h
 #include <linux/writeback.h>   // Prototypes pdflush_operation()
 #include <linux/kthread.h>
+#include <linux/cpuset.h>
 
 
 /*
@@ -45,7 +45,7 @@ static void start_one_pdflush_thread(void);
  * All the pdflush threads.  Protected by pdflush_lock
  */
 static LIST_HEAD(pdflush_list);
-static spinlock_t pdflush_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(pdflush_lock);
 
 /*
  * The count of currently-running pdflush threads.  Protected
@@ -90,7 +90,7 @@ struct pdflush_work {
 
 static int __pdflush(struct pdflush_work *my_work)
 {
-       current->flags |= PF_FLUSHER;
+       current->flags |= PF_FLUSHER | PF_SWAPWRITE;
        my_work->fn = NULL;
        my_work->who = current;
        INIT_LIST_HEAD(&my_work->list);
@@ -106,8 +106,7 @@ static int __pdflush(struct pdflush_work *my_work)
                spin_unlock_irq(&pdflush_lock);
 
                schedule();
-               if (current->flags & PF_FREEZE) {
-                       refrigerator(PF_FREEZE);
+               if (try_to_freeze()) {
                        spin_lock_irq(&pdflush_lock);
                        continue;
                }
@@ -172,12 +171,24 @@ static int __pdflush(struct pdflush_work *my_work)
 static int pdflush(void *dummy)
 {
        struct pdflush_work my_work;
+       cpumask_t cpus_allowed;
 
        /*
         * pdflush can spend a lot of time doing encryption via dm-crypt.  We
         * don't want to do that at keventd's priority.
         */
        set_user_nice(current, 0);
+
+       /*
+        * Some configs put our parent kthread in a limited cpuset,
+        * which kthread() overrides, forcing cpus_allowed == CPU_MASK_ALL.
+        * Our needs are more modest - cut back to our cpusets cpus_allowed.
+        * This is needed as pdflush's are dynamically created and destroyed.
+        * The boottime pdflush's are easily placed w/o these 2 lines.
+        */
+       cpus_allowed = cpuset_cpus_allowed(current);
+       set_cpus_allowed(current, cpus_allowed);
+
        return __pdflush(&my_work);
 }