Skip to content

Commit 576f6d7

Browse files
jeffmahoneyLinus Torvalds
authored andcommitted
[PATCH] reiserfs: handle cnode allocation failure gracefully
If an external device is used for a journal, by default it will use the entire device. The reiserfs journal code allocates structures per journal block when it mounts the file system. If the journal device is too large, and memory cannot be allocated for the structures, it will continue and ultimately panic when it can't pull one off the free list. This patch handles the allocation failure gracefully and prints an error message at mount time. Changes: Updated error message to be more descriptive to the user. Discussed and approved on ReiserFS Mailing List, Nov 28. Signed-off-by: Jeff Mahoney <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 9f232a1 commit 576f6d7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

fs/reiserfs/journal.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2757,6 +2757,15 @@ int journal_init(struct super_block *p_s_sb, const char *j_dev_name,
27572757
journal->j_cnode_used = 0;
27582758
journal->j_must_wait = 0;
27592759

2760+
if (journal->j_cnode_free == 0) {
2761+
reiserfs_warning(p_s_sb, "journal-2004: Journal cnode memory "
2762+
"allocation failed (%ld bytes). Journal is "
2763+
"too large for available memory. Usually "
2764+
"this is due to a journal that is too large.",
2765+
sizeof (struct reiserfs_journal_cnode) * num_cnodes);
2766+
goto free_and_return;
2767+
}
2768+
27602769
init_journal_hash(p_s_sb);
27612770
jl = journal->j_current_jl;
27622771
jl->j_list_bitmap = get_list_bitmap(p_s_sb, jl);

0 commit comments

Comments
 (0)