From: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
To: David Sterba <dave@jikos.cz>
Cc: linux-btrfs@vger.kernel.org, chris.mason@oracle.com
Subject: Re: [PATCH] Btrfs: check return value of kmalloc()
Date: Fri, 22 Apr 2011 10:23:14 +0900 [thread overview]
Message-ID: <4DB0D882.4010207@jp.fujitsu.com> (raw)
In-Reply-To: <20110421121810.GC31675@twin.jikos.cz>
(2011/04/21 21:18), David Sterba wrote:
> On Wed, Apr 20, 2011 at 09:51:30AM +0900, Tsutomu Itoh wrote:
>>> 2030 delayed = kmalloc(sizeof(*delayed), GFP_NOFS | __GFP_NOFAIL);
>>
>> I think that it doesn't fail ordinary when __GFP_NOFAIL is specified...
>
> yes I agree with you, my oversight. However, from linux/gfp.h
>
> * __GFP_NOFAIL: The VM implementation _must_ retry infinitely: the
> * caller cannot handle allocation failures. This modifier is
> * deprecated and no new users should be added.
>
> in long-term, redoing without NOFAIL would be probably wise. Currently
> the btrfs_add_delayed_iput is called at places which do not seem to
> like failure, I'm not sure whether possibly blocking indefinetely is
> better than occasional failure with chance to do recovery ...
>
>>
>>>
>>> and in extent-tree.c:relocate_one_extent()
>>>
>>> 7992 new_extents = kmalloc(sizeof(*new_extents),
>>> 7993 GFP_NOFS);
>>>
>>> the value is checked later, new_extents is passed to get_new_locations
>>> and there it's checked, but no other callers pass potential NULL and the
>>> check fits here and can be dropped from get_new_locations;
>
>>> there's a
>>> little chance that get_new_locations will be able to succesfully
>>> allocate the same data a jiffy later.
>>
>> Yes, therefore I did not check 'new_extents'.
>
> heh reading it again after myself, it sounds quite the opposite than I
> wanted: I'd rather see the kmalloc checked right at the callsite, easier
> to read and understand, than diving into get_new_locations and there
> seeing checking extents for NULL and doing own alloc/free.
OK, I understand.
But, reading code again, I noticed nobody use relocate_one_extent() now. ;-)
However, because there is a possibility to be going to be used in the future,
I'll add the check of 'new_extents' for the readability.
Thanks,
Tsutomu
>
>
> david
>
>
next prev parent reply other threads:[~2011-04-22 1:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-19 5:27 [PATCH] Btrfs: check return value of kmalloc() Tsutomu Itoh
2011-04-19 11:12 ` David Sterba
2011-04-20 0:51 ` Tsutomu Itoh
2011-04-21 12:18 ` David Sterba
2011-04-22 1:23 ` Tsutomu Itoh [this message]
2011-04-22 12:02 ` David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4DB0D882.4010207@jp.fujitsu.com \
--to=t-itoh@jp.fujitsu.com \
--cc=chris.mason@oracle.com \
--cc=dave@jikos.cz \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).