[7/7] jbd2: make the whole kjournald2 kthread NOFS safe
diff mbox

Message ID 20170306131408.9828-8-mhocko@kernel.org
State New
Headers show

Commit Message

Michal Hocko March 6, 2017, 1:14 p.m. UTC
From: Michal Hocko <mhocko@suse.com>

kjournald2 is central to the transaction commit processing. As such any
potential allocation from this kernel thread has to be GFP_NOFS. Make
sure to mark the whole kernel thread GFP_NOFS by the memalloc_nofs_save.

Suggested-by: Jan Kara <jack@suse.cz>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Michal Hocko <mhocko@suse.com>
 fs/jbd2/journal.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff mbox

diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index a1a359bfcc9c..78433ce1db40 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -43,6 +43,7 @@ 
 #include <linux/backing-dev.h>
 #include <linux/bitops.h>
 #include <linux/ratelimit.h>
+#include <linux/sched/mm.h>
 #include <trace/events/jbd2.h>
@@ -206,6 +207,13 @@  static int kjournald2(void *arg)
+	 * Make sure that no allocations from this kernel thread will ever recurse
+	 * to the fs layer because we are responsible for the transaction commit
+	 * and any fs involvement might get stuck waiting for the trasn. commit.
+	 */
+	memalloc_nofs_save();
+	/*
 	 * And now, wait forever for commit wakeup events.