Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
[linux-2.6-microblaze.git] / drivers / md / bcache / btree.c
index fa872df..b12186c 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/random.h>
 #include <linux/rcupdate.h>
 #include <linux/sched/clock.h>
+#include <linux/sched/signal.h>
 #include <linux/rculist.h>
 #include <linux/delay.h>
 #include <trace/events/bcache.h>
@@ -1913,6 +1914,18 @@ static int bch_gc_thread(void *arg)
 
 int bch_gc_thread_start(struct cache_set *c)
 {
+       /*
+        * In case previous btree check operation occupies too many
+        * system memory for bcache btree node cache, and the
+        * registering process is selected by OOM killer. Here just
+        * ignore the SIGKILL sent by OOM killer if there is, to
+        * avoid kthread_run() being failed by pending signals. The
+        * bcache registering process will exit after the registration
+        * done.
+        */
+       if (signal_pending(current))
+               flush_signals(current);
+
        c->gc_thread = kthread_run(bch_gc_thread, c, "bcache_gc");
        return PTR_ERR_OR_ZERO(c->gc_thread);
 }