diff options
author | Pavel Emelianov <xemul@sw.ru> | 2007-05-08 03:30:42 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-08 14:15:13 -0400 |
commit | 97f067846786d255888ccad14e2f38a1f63d8e9b (patch) | |
tree | ebff291172a51b25a0a0c69c85463f0c789bb2ce | |
parent | ee6f958291e2a768fd727e7a67badfff0b67711a (diff) |
jbd: check for error returned by kthread_create on creating journal thread
If the thread failed to create the subsequent wait_event will hang forever.
This is likely to happen if kernel hits max_threads limit.
Will be critical for virtualization systems that limit the number of tasks
and kernel memory usage within the container.
(akpm: JBD should be converted fully to the kthread API: kthread_should_stop()
and kthread_stop()).
Cc: <linux-ext4@vger.kernel.org>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | fs/jbd/journal.c | 13 | ||||
-rw-r--r-- | fs/jbd2/journal.c | 13 |
2 files changed, 18 insertions, 8 deletions
diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c index e1eb7e999ae8..46fe7439fb91 100644 --- a/fs/jbd/journal.c +++ b/fs/jbd/journal.c | |||
@@ -210,10 +210,16 @@ end_loop: | |||
210 | return 0; | 210 | return 0; |
211 | } | 211 | } |
212 | 212 | ||
213 | static void journal_start_thread(journal_t *journal) | 213 | static int journal_start_thread(journal_t *journal) |
214 | { | 214 | { |
215 | kthread_run(kjournald, journal, "kjournald"); | 215 | struct task_struct *t; |
216 | |||
217 | t = kthread_run(kjournald, journal, "kjournald"); | ||
218 | if (IS_ERR(t)) | ||
219 | return PTR_ERR(t); | ||
220 | |||
216 | wait_event(journal->j_wait_done_commit, journal->j_task != 0); | 221 | wait_event(journal->j_wait_done_commit, journal->j_task != 0); |
222 | return 0; | ||
217 | } | 223 | } |
218 | 224 | ||
219 | static void journal_kill_thread(journal_t *journal) | 225 | static void journal_kill_thread(journal_t *journal) |
@@ -839,8 +845,7 @@ static int journal_reset(journal_t *journal) | |||
839 | 845 | ||
840 | /* Add the dynamic fields and write it to disk. */ | 846 | /* Add the dynamic fields and write it to disk. */ |
841 | journal_update_superblock(journal, 1); | 847 | journal_update_superblock(journal, 1); |
842 | journal_start_thread(journal); | 848 | return journal_start_thread(journal); |
843 | return 0; | ||
844 | } | 849 | } |
845 | 850 | ||
846 | /** | 851 | /** |
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index 6b3158ec9e2c..78d63b818f0b 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c | |||
@@ -210,10 +210,16 @@ end_loop: | |||
210 | return 0; | 210 | return 0; |
211 | } | 211 | } |
212 | 212 | ||
213 | static void jbd2_journal_start_thread(journal_t *journal) | 213 | static int jbd2_journal_start_thread(journal_t *journal) |
214 | { | 214 | { |
215 | kthread_run(kjournald2, journal, "kjournald2"); | 215 | struct task_struct *t; |
216 | |||
217 | t = kthread_run(kjournald2, journal, "kjournald2"); | ||
218 | if (IS_ERR(t)) | ||
219 | return PTR_ERR(t); | ||
220 | |||
216 | wait_event(journal->j_wait_done_commit, journal->j_task != 0); | 221 | wait_event(journal->j_wait_done_commit, journal->j_task != 0); |
222 | return 0; | ||
217 | } | 223 | } |
218 | 224 | ||
219 | static void journal_kill_thread(journal_t *journal) | 225 | static void journal_kill_thread(journal_t *journal) |
@@ -839,8 +845,7 @@ static int journal_reset(journal_t *journal) | |||
839 | 845 | ||
840 | /* Add the dynamic fields and write it to disk. */ | 846 | /* Add the dynamic fields and write it to disk. */ |
841 | jbd2_journal_update_superblock(journal, 1); | 847 | jbd2_journal_update_superblock(journal, 1); |
842 | jbd2_journal_start_thread(journal); | 848 | return jbd2_journal_start_thread(journal); |
843 | return 0; | ||
844 | } | 849 | } |
845 | 850 | ||
846 | /** | 851 | /** |