]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
jbd: check for error returned by kthread_create on creating journal thread
authorPavel Emelianov <xemul@sw.ru>
Tue, 8 May 2007 07:30:42 +0000 (00:30 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Tue, 8 May 2007 18:15:13 +0000 (11:15 -0700)
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>
fs/jbd/journal.c
fs/jbd2/journal.c

index e1eb7e999ae832d8dae2030eb6610a6bf7c21a88..46fe7439fb919b6c602e8e751e33cc42e94c1b8e 100644 (file)
@@ -210,10 +210,16 @@ end_loop:
        return 0;
 }
 
-static void journal_start_thread(journal_t *journal)
+static int journal_start_thread(journal_t *journal)
 {
-       kthread_run(kjournald, journal, "kjournald");
+       struct task_struct *t;
+
+       t = kthread_run(kjournald, journal, "kjournald");
+       if (IS_ERR(t))
+               return PTR_ERR(t);
+
        wait_event(journal->j_wait_done_commit, journal->j_task != 0);
+       return 0;
 }
 
 static void journal_kill_thread(journal_t *journal)
@@ -839,8 +845,7 @@ static int journal_reset(journal_t *journal)
 
        /* Add the dynamic fields and write it to disk. */
        journal_update_superblock(journal, 1);
-       journal_start_thread(journal);
-       return 0;
+       return journal_start_thread(journal);
 }
 
 /**
index 6b3158ec9e2c72fe9240f2784096b3c50aa9b7f5..78d63b818f0b2daac94a2432396577480522ee84 100644 (file)
@@ -210,10 +210,16 @@ end_loop:
        return 0;
 }
 
-static void jbd2_journal_start_thread(journal_t *journal)
+static int jbd2_journal_start_thread(journal_t *journal)
 {
-       kthread_run(kjournald2, journal, "kjournald2");
+       struct task_struct *t;
+
+       t = kthread_run(kjournald2, journal, "kjournald2");
+       if (IS_ERR(t))
+               return PTR_ERR(t);
+
        wait_event(journal->j_wait_done_commit, journal->j_task != 0);
+       return 0;
 }
 
 static void journal_kill_thread(journal_t *journal)
@@ -839,8 +845,7 @@ static int journal_reset(journal_t *journal)
 
        /* Add the dynamic fields and write it to disk. */
        jbd2_journal_update_superblock(journal, 1);
-       jbd2_journal_start_thread(journal);
-       return 0;
+       return jbd2_journal_start_thread(journal);
 }
 
 /**