Skip to contentSkip to conversation

jbd2: make the whole kjournald2 kthread NOFS safe

PATCH New [email protected] 1 participant 1 message May 3, 2017 Journalling layer for block devices (JBD2)

lore
Share & tools
lore
#0 lore raw

PATCH 37/102 jbd2: make the whole kjournald2 kthread NOFS safe

From: Michal Hocko <[email protected]>
Subject: jbd2: make the whole kjournald2 kthread NOFS safe

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.

[[email protected]: coding-style fixes]
Cc Dave Chinner <[email protected]>
Cc Theodore Ts'o <[email protected]>
Cc Chris Mason <[email protected]>
Cc David Sterba <[email protected]>
Cc Brian Foster <[email protected]>
Cc Darrick J. Wong <[email protected]>
Cc Nikolay Borisov <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Vlastimil Babka <[email protected]>

---

 fs/jbd2/journal.c |    9 +++++++++
 1 file changed, 9 insertions(+)
fs/jbd2/journal.c renamed from fs/jbd2/journal.c~jbd2-make-the-whole-kjournald2-kthread-nofs-safe +9 -0
diff -puN fs/jbd2/journal.c~jbd2-make-the-whole-kjournald2-kthread-nofs-safe 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>
 
 #define CREATE_TRACE_POINTS
 #include <trace/events/jbd2.h>
@@ -206,6 +207,14 @@ static int kjournald2(void *arg)
 	wake_up(&journal->j_wait_done_commit);
 
 	/*
+	 * 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.
 	 */
 	write_lock(&journal->j_state_lock);

_