All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mbcache: fix to detect failure of register_shrinker
@ 2016-05-16 15:16 Chao Yu
  2016-05-16 15:31 ` Jan Kara
  2016-07-05 20:16 ` Theodore Ts'o
  0 siblings, 2 replies; 6+ messages in thread
From: Chao Yu @ 2016-05-16 15:16 UTC (permalink / raw)
  To: tytso, jack; +Cc: viro, linux-ext4, linux-fsdevel, Chao Yu

From: Chao Yu <yuchao0@huawei.com>

register_shrinker in mb_cache_create may fail due to no memory. This
patch fixes to do the check of return value of register_shrinker and
handle the error case, otherwise mb_cache_create may return with no
error, but losing the inner shrinker.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
 fs/mbcache.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/mbcache.c b/fs/mbcache.c
index eccda3a..c5bd19f 100644
--- a/fs/mbcache.c
+++ b/fs/mbcache.c
@@ -366,7 +366,11 @@ struct mb_cache *mb_cache_create(int bucket_bits)
 	cache->c_shrink.count_objects = mb_cache_count;
 	cache->c_shrink.scan_objects = mb_cache_scan;
 	cache->c_shrink.seeks = DEFAULT_SEEKS;
-	register_shrinker(&cache->c_shrink);
+	if (register_shrinker(&cache->c_shrink)) {
+		kfree(cache->c_hash);
+		kfree(cache);
+		goto err_out;
+	}
 
 	INIT_WORK(&cache->c_shrink_work, mb_cache_shrink_worker);
 
-- 
2.7.2


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

* Re: [PATCH] mbcache: fix to detect failure of register_shrinker
  2016-05-16 15:16 [PATCH] mbcache: fix to detect failure of register_shrinker Chao Yu
@ 2016-05-16 15:31 ` Jan Kara
  2016-07-05 20:16 ` Theodore Ts'o
  1 sibling, 0 replies; 6+ messages in thread
From: Jan Kara @ 2016-05-16 15:31 UTC (permalink / raw)
  To: Chao Yu; +Cc: tytso, jack, viro, linux-ext4, linux-fsdevel, Chao Yu

On Mon 16-05-16 23:16:38, Chao Yu wrote:
> From: Chao Yu <yuchao0@huawei.com>
> 
> register_shrinker in mb_cache_create may fail due to no memory. This
> patch fixes to do the check of return value of register_shrinker and
> handle the error case, otherwise mb_cache_create may return with no
> error, but losing the inner shrinker.
> 
> Signed-off-by: Chao Yu <yuchao0@huawei.com>

Thanks for fixing this. The patch looks good. You can add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: mbcache: fix to detect failure of register_shrinker
  2016-05-16 15:16 [PATCH] mbcache: fix to detect failure of register_shrinker Chao Yu
  2016-05-16 15:31 ` Jan Kara
@ 2016-07-05 20:16 ` Theodore Ts'o
  2016-08-31 15:31   ` Chao Yu
  1 sibling, 1 reply; 6+ messages in thread
From: Theodore Ts'o @ 2016-07-05 20:16 UTC (permalink / raw)
  To: Chao Yu; +Cc: jack, viro, linux-ext4, linux-fsdevel, Chao Yu

On Mon, May 16, 2016 at 11:16:38PM +0800, Chao Yu wrote:
> From: Chao Yu <yuchao0@huawei.com>
> 
> register_shrinker in mb_cache_create may fail due to no memory. This
> patch fixes to do the check of return value of register_shrinker and
> handle the error case, otherwise mb_cache_create may return with no
> error, but losing the inner shrinker.
> 
> Signed-off-by: Chao Yu <yuchao0@huawei.com>
> Reviewed-by: Jan Kara <jack@suse.cz>

Applied, thanks.  (Apologies for the delay; this patch slipped through
the cracks.)

					- Ted

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

* Re: mbcache: fix to detect failure of register_shrinker
  2016-07-05 20:16 ` Theodore Ts'o
@ 2016-08-31 15:31   ` Chao Yu
  2016-08-31 15:48     ` Theodore Ts'o
  0 siblings, 1 reply; 6+ messages in thread
From: Chao Yu @ 2016-08-31 15:31 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: jack, viro, linux-ext4, linux-fsdevel, Chao Yu

On 2016/7/6 4:16, Theodore Ts'o wrote:
> On Mon, May 16, 2016 at 11:16:38PM +0800, Chao Yu wrote:
>> From: Chao Yu <yuchao0@huawei.com>
>>
>> register_shrinker in mb_cache_create may fail due to no memory. This
>> patch fixes to do the check of return value of register_shrinker and
>> handle the error case, otherwise mb_cache_create may return with no
>> error, but losing the inner shrinker.
>>
>> Signed-off-by: Chao Yu <yuchao0@huawei.com>
>> Reviewed-by: Jan Kara <jack@suse.cz>
> 
> Applied, thanks.  (Apologies for the delay; this patch slipped through
> the cracks.)

Ping, didn't see it in mainline, is this patch still under testing now?

> 
> 					- Ted
> 

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

* Re: mbcache: fix to detect failure of register_shrinker
  2016-08-31 15:31   ` Chao Yu
@ 2016-08-31 15:48     ` Theodore Ts'o
  2016-08-31 16:19       ` Chao Yu
  0 siblings, 1 reply; 6+ messages in thread
From: Theodore Ts'o @ 2016-08-31 15:48 UTC (permalink / raw)
  To: Chao Yu; +Cc: jack, viro, linux-ext4, linux-fsdevel, Chao Yu

On Wed, Aug 31, 2016 at 11:31:17PM +0800, Chao Yu wrote:
> On 2016/7/6 4:16, Theodore Ts'o wrote:
> > On Mon, May 16, 2016 at 11:16:38PM +0800, Chao Yu wrote:
> >> From: Chao Yu <yuchao0@huawei.com>
> >>
> >> register_shrinker in mb_cache_create may fail due to no memory. This
> >> patch fixes to do the check of return value of register_shrinker and
> >> handle the error case, otherwise mb_cache_create may return with no
> >> error, but losing the inner shrinker.
> >>
> >> Signed-off-by: Chao Yu <yuchao0@huawei.com>
> >> Reviewed-by: Jan Kara <jack@suse.cz>
> > 
> > Applied, thanks.  (Apologies for the delay; this patch slipped through
> > the cracks.)
> 
> Ping, didn't see it in mainline, is this patch still under testing now?

I'm sorry, I'm not sure how it got dropped, but it's not in mainline
and I'm not sure how it got dropped from the ext4 tree.

It's now queued up in the dev tree.

Thanks for checking back,

						- Ted

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

* Re: mbcache: fix to detect failure of register_shrinker
  2016-08-31 15:48     ` Theodore Ts'o
@ 2016-08-31 16:19       ` Chao Yu
  0 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2016-08-31 16:19 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: jack, viro, linux-ext4, linux-fsdevel, Chao Yu

On 2016/8/31 23:48, Theodore Ts'o wrote:
> On Wed, Aug 31, 2016 at 11:31:17PM +0800, Chao Yu wrote:
>> On 2016/7/6 4:16, Theodore Ts'o wrote:
>>> On Mon, May 16, 2016 at 11:16:38PM +0800, Chao Yu wrote:
>>>> From: Chao Yu <yuchao0@huawei.com>
>>>>
>>>> register_shrinker in mb_cache_create may fail due to no memory. This
>>>> patch fixes to do the check of return value of register_shrinker and
>>>> handle the error case, otherwise mb_cache_create may return with no
>>>> error, but losing the inner shrinker.
>>>>
>>>> Signed-off-by: Chao Yu <yuchao0@huawei.com>
>>>> Reviewed-by: Jan Kara <jack@suse.cz>
>>>
>>> Applied, thanks.  (Apologies for the delay; this patch slipped through
>>> the cracks.)
>>
>> Ping, didn't see it in mainline, is this patch still under testing now?
> 
> I'm sorry, I'm not sure how it got dropped, but it's not in mainline
> and I'm not sure how it got dropped from the ext4 tree.
> 
> It's now queued up in the dev tree.
> 
> Thanks for checking back,

Thanks for merging! ;)

> 
> 						- Ted
> 

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

end of thread, other threads:[~2016-08-31 16:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-16 15:16 [PATCH] mbcache: fix to detect failure of register_shrinker Chao Yu
2016-05-16 15:31 ` Jan Kara
2016-07-05 20:16 ` Theodore Ts'o
2016-08-31 15:31   ` Chao Yu
2016-08-31 15:48     ` Theodore Ts'o
2016-08-31 16:19       ` Chao Yu

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.