Thread (32 messages) 32 messages, 6 authors, 2016-12-22
STALE3456d
Revisions (3)
  1. v2 current
  2. v3 [diff vs current]
  3. v5 [diff vs current]

[PATCH 7/9] jbd2: make the whole kjournald2 kthread NOFS safe

From: Michal Hocko <mhocko@kernel.org>
Date: 2016-12-15 14:07:13
Also in: ceph-devel, linux-btrfs, linux-f2fs-devel, linux-fsdevel, linux-mm, linux-nfs, linux-xfs, lkml
Subsystem: filesystems (vfs and infrastructure), journalling layer for block devices (jbd2), the rest · Maintainers: Alexander Viro, Christian Brauner, "Theodore Ts'o", Jan Kara, Linus Torvalds

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>
Signed-off-by: Michal Hocko <mhocko@suse.com>
---
 fs/jbd2/journal.c | 7 +++++++
 1 file changed, 7 insertions(+)
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 8ed971eeab44..6dad8c5d6ddf 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -206,6 +206,13 @@ 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);
-- 
2.10.2

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help