Merge tag 'v3.10.87' into update
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / md / md.c
index 37ff00d014b42761aa2e5b1b2d4016380c18032c..ed0c6a6b79818fef2fe0d818e16c810270e73020 100644 (file)
@@ -33,6 +33,7 @@
 */
 
 #include <linux/kthread.h>
+#include <linux/freezer.h>
 #include <linux/blkdev.h>
 #include <linux/sysctl.h>
 #include <linux/seq_file.h>
@@ -7371,11 +7372,14 @@ void md_do_sync(struct md_thread *thread)
         *
         */
 
+       set_freezable();
+
        do {
                mddev->curr_resync = 2;
 
        try_again:
-               if (kthread_should_stop())
+
+               if (kthread_freezable_should_stop(NULL))
                        set_bit(MD_RECOVERY_INTR, &mddev->recovery);
 
                if (test_bit(MD_RECOVERY_INTR, &mddev->recovery))
@@ -7397,6 +7401,9 @@ void md_do_sync(struct md_thread *thread)
                                         * time 'round when curr_resync == 2
                                         */
                                        continue;
+
+                               try_to_freeze();
+
                                /* We need to wait 'interruptible' so as not to
                                 * contribute to the load average, and not to
                                 * be caught by 'softlockup'
@@ -7409,6 +7416,7 @@ void md_do_sync(struct md_thread *thread)
                                               " share one or more physical units)\n",
                                               desc, mdname(mddev), mdname(mddev2));
                                        mddev_put(mddev2);
+                                       try_to_freeze();
                                        if (signal_pending(current))
                                                flush_signals(current);
                                        schedule();
@@ -7539,7 +7547,7 @@ void md_do_sync(struct md_thread *thread)
                                                 || kthread_should_stop());
                }
 
-               if (kthread_should_stop())
+               if (kthread_freezable_should_stop(NULL))
                        goto interrupted;
 
                sectors = mddev->pers->sync_request(mddev, j, &skipped,
@@ -7583,8 +7591,7 @@ void md_do_sync(struct md_thread *thread)
                        last_mark = next;
                }
 
-
-               if (kthread_should_stop())
+               if (kthread_freezable_should_stop(NULL))
                        goto interrupted;
 
 
@@ -7761,8 +7768,10 @@ no_add:
  */
 void md_check_recovery(struct mddev *mddev)
 {
-       if (mddev->suspended)
+#ifdef CONFIG_FREEZER
+       if (mddev->suspended || unlikely(atomic_read(&system_freezing_cnt)))
                return;
+#endif
 
        if (mddev->bitmap)
                bitmap_daemon_work(mddev);