* [PATCH] reiserfs: handle cnode allocation failure gracefully
@ 2005-11-24 0:16 Jeff Mahoney
2005-11-24 4:59 ` Hans Reiser
0 siblings, 1 reply; 5+ messages in thread
From: Jeff Mahoney @ 2005-11-24 0:16 UTC (permalink / raw)
To: ReiserFS List
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.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
diff -ruNpX dontdiff linux-2.6.13.orig/fs/reiserfs/journal.c linux-2.6.13.fixed/fs/reiserfs/journal.c
--- linux-2.6.13.orig/fs/reiserfs/journal.c 2005-09-16 11:42:58.000000000 -0400
+++ linux-2.6.13.fixed/fs/reiserfs/journal.c 2005-11-23 19:14:17.000000000 -0500
@@ -2757,6 +2757,13 @@ int journal_init(struct super_block *p_s
journal->j_cnode_used = 0;
journal->j_must_wait = 0;
+ if (journal->j_cnode_free == 0) {
+ reiserfs_warning(p_s_sb, "journal-2004: Journal cnode memory "
+ "allocation failed. Journal is too large "
+ "for available memory.");
+ goto free_and_return;
+ }
+
init_journal_hash(p_s_sb);
jl = journal->j_current_jl;
jl->j_list_bitmap = get_list_bitmap(p_s_sb, jl);
--
Jeff Mahoney
SuSE Labs
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] reiserfs: handle cnode allocation failure gracefully
2005-11-24 0:16 [PATCH] reiserfs: handle cnode allocation failure gracefully Jeff Mahoney
@ 2005-11-24 4:59 ` Hans Reiser
2005-11-28 21:27 ` Jeff Mahoney
0 siblings, 1 reply; 5+ messages in thread
From: Hans Reiser @ 2005-11-24 4:59 UTC (permalink / raw)
To: Jeff Mahoney; +Cc: ReiserFS List
Jeff Mahoney wrote:
> 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.
>
>Signed-off-by: Jeff Mahoney <jeffm@suse.com>
>
>diff -ruNpX dontdiff linux-2.6.13.orig/fs/reiserfs/journal.c linux-2.6.13.fixed/fs/reiserfs/journal.c
>--- linux-2.6.13.orig/fs/reiserfs/journal.c 2005-09-16 11:42:58.000000000 -0400
>+++ linux-2.6.13.fixed/fs/reiserfs/journal.c 2005-11-23 19:14:17.000000000 -0500
>@@ -2757,6 +2757,13 @@ int journal_init(struct super_block *p_s
> journal->j_cnode_used = 0;
> journal->j_must_wait = 0;
>
>+ if (journal->j_cnode_free == 0) {
>+ reiserfs_warning(p_s_sb, "journal-2004: Journal cnode memory "
>+ "allocation failed. Journal is too large "
>+ "for available memory.");
>+ goto free_and_return;
>+ }
>+
> init_journal_hash(p_s_sb);
> jl = journal->j_current_jl;
> jl->j_list_bitmap = get_list_bitmap(p_s_sb, jl);
>
>
>
This is better than handling it ungracefully but..... can there be a
memory shortage for some other reason and then this prints the wrong
diagnostic? Forgive me, it is hard to know the answer looking at the
patch by itself.....
Hans
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] reiserfs: handle cnode allocation failure gracefully
2005-11-24 4:59 ` Hans Reiser
@ 2005-11-28 21:27 ` Jeff Mahoney
2005-11-29 0:42 ` Hans Reiser
0 siblings, 1 reply; 5+ messages in thread
From: Jeff Mahoney @ 2005-11-28 21:27 UTC (permalink / raw)
To: Hans Reiser; +Cc: ReiserFS List
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hans Reiser wrote:
> Jeff Mahoney wrote:
>
>> 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.
>>
>> Signed-off-by: Jeff Mahoney <jeffm@suse.com>
>>
>> diff -ruNpX dontdiff linux-2.6.13.orig/fs/reiserfs/journal.c linux-2.6.13.fixed/fs/reiserfs/journal.c
>> --- linux-2.6.13.orig/fs/reiserfs/journal.c 2005-09-16 11:42:58.000000000 -0400
>> +++ linux-2.6.13.fixed/fs/reiserfs/journal.c 2005-11-23 19:14:17.000000000 -0500
>> @@ -2757,6 +2757,13 @@ int journal_init(struct super_block *p_s
>> journal->j_cnode_used = 0;
>> journal->j_must_wait = 0;
>>
>> + if (journal->j_cnode_free == 0) {
>> + reiserfs_warning(p_s_sb, "journal-2004: Journal cnode memory "
>> + "allocation failed. Journal is too large "
>> + "for available memory.");
>> + goto free_and_return;
>> + }
>> +
>> init_journal_hash(p_s_sb);
>> jl = journal->j_current_jl;
>> jl->j_list_bitmap = get_list_bitmap(p_s_sb, jl);
>>
>>
>>
> This is better than handling it ungracefully but..... can there be a
> memory shortage for some other reason and then this prints the wrong
> diagnostic? Forgive me, it is hard to know the answer looking at the
> patch by itself.....
Well, the error message is always true. ;) The failure will always be
because it couldn't allocate enough memory to support the internal
housekeeping for the journal. However, it's possible for other causes
than JUST the journal being oversized to cause the allocation failure.
On x86, the vmalloc area is limited to ~128MB. If other sources
(including other reiserfs file systems) are taking up most of the
vmalloc area, it could fail with a standard journal size. When the
vmalloc limit isn't a factor, memory could simply be unavailable to fill
the request, even a small one.
In most cases, though, it's a result of allocate_cnodes() asking for too
much memory. Using the standard 8192 block journal size, a 32-bit system
will allocate 288K for cnodes. If an external 8 GB partition is used,
2*1024*1024 blocks will be needed, causing 72 MB of RAM to be allocated
for cnodes alone.
I wouldn't be opposed to changing the error message to:
journal-2004: Journal cnode memory allocation failed (%lu bytes).
Journal may be too large or your system does not have enough available
memory.
- -Jeff
- --
Jeff Mahoney
SUSE Labs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFDi3YwLPWxlyuTD7IRAugMAKCQjNIalS04Ul8447C8l3OvDbioAACeOjea
R6Z256+nUh5o7Wd6bhawRIw=
=rZIi
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] reiserfs: handle cnode allocation failure gracefully
2005-11-28 21:27 ` Jeff Mahoney
@ 2005-11-29 0:42 ` Hans Reiser
0 siblings, 0 replies; 5+ messages in thread
From: Hans Reiser @ 2005-11-29 0:42 UTC (permalink / raw)
To: Jeff Mahoney; +Cc: ReiserFS List
Jeff Mahoney wrote:
> Hans Reiser wrote:
>
> >Jeff Mahoney wrote:
>
> >>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.
> >>
> >>Signed-off-by: Jeff Mahoney <jeffm@suse.com>
> >>
> >>diff -ruNpX dontdiff linux-2.6.13.orig/fs/reiserfs/journal.c
> linux-2.6.13.fixed/fs/reiserfs/journal.c
> >>--- linux-2.6.13.orig/fs/reiserfs/journal.c 2005-09-16
> 11:42:58.000000000 -0400
> >>+++ linux-2.6.13.fixed/fs/reiserfs/journal.c 2005-11-23
> 19:14:17.000000000 -0500
> >>@@ -2757,6 +2757,13 @@ int journal_init(struct super_block *p_s
> >> journal->j_cnode_used = 0;
> >> journal->j_must_wait = 0;
> >>
> >>+ if (journal->j_cnode_free == 0) {
> >>+ reiserfs_warning(p_s_sb, "journal-2004: Journal cnode
> memory "
> >>+ "allocation failed. Journal is too large "
> >>+ "for available memory.");
> >>+ goto free_and_return;
> >>+ }
> >>+
> >> init_journal_hash(p_s_sb);
> >> jl = journal->j_current_jl;
> >> jl->j_list_bitmap = get_list_bitmap(p_s_sb, jl);
> >>
> >>
> >>
> >This is better than handling it ungracefully but..... can there be a
> >memory shortage for some other reason and then this prints the wrong
> >diagnostic? Forgive me, it is hard to know the answer looking at the
> >patch by itself.....
>
>
> Well, the error message is always true. ;) The failure will always be
> because it couldn't allocate enough memory to support the internal
> housekeeping for the journal. However, it's possible for other causes
> than JUST the journal being oversized to cause the allocation failure.
> On x86, the vmalloc area is limited to ~128MB. If other sources
> (including other reiserfs file systems) are taking up most of the
> vmalloc area, it could fail with a standard journal size. When the
> vmalloc limit isn't a factor, memory could simply be unavailable to fill
> the request, even a small one.
>
> In most cases, though, it's a result of allocate_cnodes() asking for too
> much memory. Using the standard 8192 block journal size, a 32-bit system
> will allocate 288K for cnodes. If an external 8 GB partition is used,
> 2*1024*1024 blocks will be needed, causing 72 MB of RAM to be allocated
> for cnodes alone.
>
> I wouldn't be opposed to changing the error message to:
> journal-2004: Journal cnode memory allocation failed (%lu bytes).
> Journal may be too large or your system does not have enough available
> memory.
How about: Journal is too large for the available memory. Usually this
is because the journal is too large a device.
>
> -Jeff
>
> --
> Jeff Mahoney
> SUSE Labs
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] reiserfs: handle cnode allocation failure gracefully
@ 2005-11-29 21:44 Jeff Mahoney
0 siblings, 0 replies; 5+ messages in thread
From: Jeff Mahoney @ 2005-11-29 21:44 UTC (permalink / raw)
To: Andrew Morton, Linus Torvalds, Linux Kernel Mailing List; +Cc: ReiserFS List
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 <jeffm@suse.com>
diff -ruNpX dontdiff a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
--- a/fs/reiserfs/journal.c 2005-09-16 11:42:58.000000000 -0400
+++ b/fs/reiserfs/journal.c 2005-11-23 19:14:17.000000000 -0500
@@ -2757,6 +2757,15 @@ int journal_init(struct super_block *p_s
journal->j_cnode_used = 0;
journal->j_must_wait = 0;
+ if (journal->j_cnode_free == 0) {
+ reiserfs_warning(p_s_sb, "journal-2004: Journal cnode memory "
+ "allocation failed (%ld bytes). Journal is "
+ "too large for available memory. Usually "
+ "this is due to a journal that is too large.",
+ sizeof (struct reiserfs_journal_cnode) * num_cnodes);
+ goto free_and_return;
+ }
+
init_journal_hash(p_s_sb);
jl = journal->j_current_jl;
jl->j_list_bitmap = get_list_bitmap(p_s_sb, jl);
--
Jeff Mahoney
SuSE Labs
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-11-29 21:44 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-24 0:16 [PATCH] reiserfs: handle cnode allocation failure gracefully Jeff Mahoney
2005-11-24 4:59 ` Hans Reiser
2005-11-28 21:27 ` Jeff Mahoney
2005-11-29 0:42 ` Hans Reiser
-- strict thread matches above, loose matches on Subject: below --
2005-11-29 21:44 Jeff Mahoney
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.