All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ext4: annotate unhandled kmem_cache_alloc() error
@ 2008-12-23 10:40 Akinobu Mita
  2008-12-23 14:29 ` Josef Bacik
  0 siblings, 1 reply; 9+ messages in thread
From: Akinobu Mita @ 2008-12-23 10:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, Theodore Tso, adilger, linux-ext4

kmem_cache_alloc() error in ext4_mb_free_metadata is not handled.
I don't know how to fix it. But I can put BUG_ON to let others
know the problem.

Cc: Theodore Tso <tytso@mit.edu>
Cc: adilger@sun.com
Cc: linux-ext4@vger.kernel.org
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
 fs/ext4/mballoc.c |    1 +
 1 file changed, 1 insertion(+)

Index: 2.6-rc/fs/ext4/mballoc.c
===================================================================
--- 2.6-rc.orig/fs/ext4/mballoc.c
+++ 2.6-rc/fs/ext4/mballoc.c
@@ -4417,6 +4417,7 @@ ext4_mb_free_metadata(handle_t *handle, 
 	BUG_ON(e4b->bd_buddy_page == NULL);
 
 	new_entry  = kmem_cache_alloc(ext4_free_ext_cachep, GFP_NOFS);
+	BUG_ON(!new_entry);
 	new_entry->start_blk = block;
 	new_entry->group  = group;
 	new_entry->count = count;

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] ext4: annotate unhandled kmem_cache_alloc() error
  2008-12-23 10:40 [PATCH] ext4: annotate unhandled kmem_cache_alloc() error Akinobu Mita
@ 2008-12-23 14:29 ` Josef Bacik
  2008-12-23 22:37   ` Akinobu Mita
  0 siblings, 1 reply; 9+ messages in thread
From: Josef Bacik @ 2008-12-23 14:29 UTC (permalink / raw)
  To: Akinobu Mita; +Cc: linux-kernel, akpm, Theodore Tso, adilger, linux-ext4

On Tue, Dec 23, 2008 at 07:40:18PM +0900, Akinobu Mita wrote:
> kmem_cache_alloc() error in ext4_mb_free_metadata is not handled.
> I don't know how to fix it. But I can put BUG_ON to let others
> know the problem.
> 
> Cc: Theodore Tso <tytso@mit.edu>
> Cc: adilger@sun.com
> Cc: linux-ext4@vger.kernel.org
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> ---
>  fs/ext4/mballoc.c |    1 +
>  1 file changed, 1 insertion(+)
> 
> Index: 2.6-rc/fs/ext4/mballoc.c
> ===================================================================
> --- 2.6-rc.orig/fs/ext4/mballoc.c
> +++ 2.6-rc/fs/ext4/mballoc.c
> @@ -4417,6 +4417,7 @@ ext4_mb_free_metadata(handle_t *handle, 
>  	BUG_ON(e4b->bd_buddy_page == NULL);
>  
>  	new_entry  = kmem_cache_alloc(ext4_free_ext_cachep, GFP_NOFS);
> +	BUG_ON(!new_entry);
>  	new_entry->start_blk = block;
>  	new_entry->group  = group;
>  	new_entry->count = count;

BUG_ON is good for devel things, but for stable stuff it's better to let
somebody know an error occured rather than panic'ing the box.  The proper
solution would be to do

if (!new_entry)
	return -ENOMEM;

or if there is some out: label set ret to -ENOMEM and goto out, whatever is
appropriate in the context.  Thanks,

Josef

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] ext4: annotate unhandled kmem_cache_alloc() error
  2008-12-23 14:29 ` Josef Bacik
@ 2008-12-23 22:37   ` Akinobu Mita
  2009-01-11  2:03     ` [PATCH] ext4: fix unhandled ext4_free_data allocation failure Akinobu Mita
  0 siblings, 1 reply; 9+ messages in thread
From: Akinobu Mita @ 2008-12-23 22:37 UTC (permalink / raw)
  To: Josef Bacik; +Cc: linux-kernel, akpm, Theodore Tso, adilger, linux-ext4

> BUG_ON is good for devel things, but for stable stuff it's better to let
> somebody know an error occured rather than panic'ing the box.  The proper
> solution would be to do
>
> if (!new_entry)
>        return -ENOMEM;
>
> or if there is some out: label set ret to -ENOMEM and goto out, whatever is
> appropriate in the context.  Thanks,

I don't understand the code around here well.
But I think it is not that simple.

The "new_entry" is needed to free blocks. If it just returns error,
it leaks something.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH] ext4: fix unhandled ext4_free_data allocation failure
  2008-12-23 22:37   ` Akinobu Mita
@ 2009-01-11  2:03     ` Akinobu Mita
  2009-01-11 14:39       ` Josef Bacik
  0 siblings, 1 reply; 9+ messages in thread
From: Akinobu Mita @ 2009-01-11  2:03 UTC (permalink / raw)
  To: Josef Bacik; +Cc: linux-kernel, akpm, Theodore Tso, adilger, linux-ext4

In ext4_mb_free_blocks() ext4_free_data allocation failure
is not handled. This error handling cannot be simple error return because
ext4_mb_free_blocks() cannot fail.

This patch add __GFP_NOFAIL to gfp mask for the allocation.

Cc: Theodore Tso <tytso@mit.edu>
Cc: adilger@sun.com
Cc: linux-ext4@vger.kernel.org
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
 fs/ext4/mballoc.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: 2.6-git/fs/ext4/mballoc.c
===================================================================
--- 2.6-git.orig/fs/ext4/mballoc.c
+++ 2.6-git/fs/ext4/mballoc.c
@@ -4885,7 +4885,8 @@ do_more:
 		 * blocks being freed are metadata. these blocks shouldn't
 		 * be used until this transaction is committed
 		 */
-		new_entry  = kmem_cache_alloc(ext4_free_ext_cachep, GFP_NOFS);
+		new_entry  = kmem_cache_alloc(ext4_free_ext_cachep,
+						GFP_NOFS | __GFP_NOFAIL);
 		new_entry->start_blk = bit;
 		new_entry->group  = block_group;
 		new_entry->count = count;

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] ext4: fix unhandled ext4_free_data allocation failure
  2009-01-11  2:03     ` [PATCH] ext4: fix unhandled ext4_free_data allocation failure Akinobu Mita
@ 2009-01-11 14:39       ` Josef Bacik
  2009-01-11 14:46         ` Eric Sandeen
  0 siblings, 1 reply; 9+ messages in thread
From: Josef Bacik @ 2009-01-11 14:39 UTC (permalink / raw)
  To: Akinobu Mita
  Cc: Josef Bacik, linux-kernel, akpm, Theodore Tso, adilger, linux-ext4

On Sun, Jan 11, 2009 at 11:03:53AM +0900, Akinobu Mita wrote:
> In ext4_mb_free_blocks() ext4_free_data allocation failure
> is not handled. This error handling cannot be simple error return because
> ext4_mb_free_blocks() cannot fail.
> 
> This patch add __GFP_NOFAIL to gfp mask for the allocation.
> 
> Cc: Theodore Tso <tytso@mit.edu>
> Cc: adilger@sun.com
> Cc: linux-ext4@vger.kernel.org
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>

Sorry but thats still not right, the fs should never force the box to come up
with memory, it should be able to gracefully handle ENOMEM cases.  This patch
does this properly.  Thanks,

Signed-off-by: Josef Bacik <jbacik@redhat.com>

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 918aec0..e97ea09 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -4886,6 +4886,10 @@ do_more:
 		 * be used until this transaction is committed
 		 */
 		new_entry  = kmem_cache_alloc(ext4_free_ext_cachep, GFP_NOFS);
+		if (!new_entry) {
+			err = -ENOMEM;
+			goto error_return;
+		}
 		new_entry->start_blk = bit;
 		new_entry->group  = block_group;
 		new_entry->count = count;

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] ext4: fix unhandled ext4_free_data allocation failure
  2009-01-11 14:39       ` Josef Bacik
@ 2009-01-11 14:46         ` Eric Sandeen
  2009-01-12  3:58           ` Theodore Tso
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Sandeen @ 2009-01-11 14:46 UTC (permalink / raw)
  To: Josef Bacik
  Cc: Akinobu Mita, linux-kernel, akpm, Theodore Tso, adilger, linux-ext4

Josef Bacik wrote:
> On Sun, Jan 11, 2009 at 11:03:53AM +0900, Akinobu Mita wrote:
>> In ext4_mb_free_blocks() ext4_free_data allocation failure
>> is not handled. This error handling cannot be simple error return because
>> ext4_mb_free_blocks() cannot fail.
>>
>> This patch add __GFP_NOFAIL to gfp mask for the allocation.
>>
>> Cc: Theodore Tso <tytso@mit.edu>
>> Cc: adilger@sun.com
>> Cc: linux-ext4@vger.kernel.org
>> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> 
> Sorry but thats still not right, the fs should never force the box to come up
> with memory, it should be able to gracefully handle ENOMEM cases.  This patch
> does this properly.  Thanks,
> 
> Signed-off-by: Josef Bacik <jbacik@redhat.com>
> 
> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index 918aec0..e97ea09 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -4886,6 +4886,10 @@ do_more:
>  		 * be used until this transaction is committed
>  		 */
>  		new_entry  = kmem_cache_alloc(ext4_free_ext_cachep, GFP_NOFS);
> +		if (!new_entry) {
> +			err = -ENOMEM;
> +			goto error_return;
> +		}
>  		new_entry->start_blk = bit;
>  		new_entry->group  = block_group;
>  		new_entry->count = count;

Well, this will now force a filesystem error (then remount-ro or panic
(or ignore) if the allocation fails.  I'm not sure that's better...?

-Eric

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] ext4: fix unhandled ext4_free_data allocation failure
  2009-01-11 14:46         ` Eric Sandeen
@ 2009-01-12  3:58           ` Theodore Tso
  2009-01-12 15:03               ` Theodore Tso
  0 siblings, 1 reply; 9+ messages in thread
From: Theodore Tso @ 2009-01-12  3:58 UTC (permalink / raw)
  To: Eric Sandeen
  Cc: Josef Bacik, Akinobu Mita, linux-kernel, akpm, adilger, linux-ext4

On Sun, Jan 11, 2009 at 08:46:32AM -0600, Eric Sandeen wrote:
> 
> Well, this will now force a filesystem error (then remount-ro or panic
> (or ignore) if the allocation fails.  I'm not sure that's better...?
> 

Well, our choices basically are:

1)  Force a filesystem error
2)  Sleep and retry the allocation
3)  Don't add the freed blocks to the list regions that mballoc should
    be allowed to allocate from after the transaction commits.  This 
    results in the blocks getting "leaked" until the filesystem is
    mounted/unounted.

						- Ted

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] ext4: fix unhandled ext4_free_data allocation failure
  2009-01-12  3:58           ` Theodore Tso
@ 2009-01-12 15:03               ` Theodore Tso
  0 siblings, 0 replies; 9+ messages in thread
From: Theodore Tso @ 2009-01-12 15:03 UTC (permalink / raw)
  To: Eric Sandeen, Josef Bacik, Akinobu Mita, linux-kernel, akpm,
	adilger, linux-ext4

On Sun, Jan 11, 2009 at 10:58:35PM -0500, Theodore Tso wrote:
> On Sun, Jan 11, 2009 at 08:46:32AM -0600, Eric Sandeen wrote:
> > 
> > Well, this will now force a filesystem error (then remount-ro or panic
> > (or ignore) if the allocation fails.  I'm not sure that's better...?
> > 
> 
> Well, our choices basically are:
> 
> 1)  Force a filesystem error
> 2)  Sleep and retry the allocation
> 3)  Don't add the freed blocks to the list regions that mballoc should
>     be allowed to allocate from after the transaction commits.  This 
>     results in the blocks getting "leaked" until the filesystem is
>     mounted/unounted.

I just thought of another alternative:

4) Mark the buddy cache has being in need of being completely rebuilt
after the transaction commits. 

Someone want to try coding that up?

						- Ted

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] ext4: fix unhandled ext4_free_data allocation failure
@ 2009-01-12 15:03               ` Theodore Tso
  0 siblings, 0 replies; 9+ messages in thread
From: Theodore Tso @ 2009-01-12 15:03 UTC (permalink / raw)
  To: Eric Sandeen, Josef Bacik, Akinobu Mita, linux-kernel, akpm, adilger, li

On Sun, Jan 11, 2009 at 10:58:35PM -0500, Theodore Tso wrote:
> On Sun, Jan 11, 2009 at 08:46:32AM -0600, Eric Sandeen wrote:
> > 
> > Well, this will now force a filesystem error (then remount-ro or panic
> > (or ignore) if the allocation fails.  I'm not sure that's better...?
> > 
> 
> Well, our choices basically are:
> 
> 1)  Force a filesystem error
> 2)  Sleep and retry the allocation
> 3)  Don't add the freed blocks to the list regions that mballoc should
>     be allowed to allocate from after the transaction commits.  This 
>     results in the blocks getting "leaked" until the filesystem is
>     mounted/unounted.

I just thought of another alternative:

4) Mark the buddy cache has being in need of being completely rebuilt
after the transaction commits. 

Someone want to try coding that up?

						- Ted

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-01-12 15:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-23 10:40 [PATCH] ext4: annotate unhandled kmem_cache_alloc() error Akinobu Mita
2008-12-23 14:29 ` Josef Bacik
2008-12-23 22:37   ` Akinobu Mita
2009-01-11  2:03     ` [PATCH] ext4: fix unhandled ext4_free_data allocation failure Akinobu Mita
2009-01-11 14:39       ` Josef Bacik
2009-01-11 14:46         ` Eric Sandeen
2009-01-12  3:58           ` Theodore Tso
2009-01-12 15:03             ` Theodore Tso
2009-01-12 15:03               ` Theodore Tso

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.