linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Theodore Y. Ts'o" <tytso@mit.edu>
To: fishland <fishland@aliyun.com>
Cc: adilger.kernel@dilger.ca, wang.yi59@zte.com.cn,
	linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org,
	Liu Song <liu.song11@zte.com.cn>
Subject: Re: [PATCH] ext4: direct return when jinode allocate failed
Date: Tue, 16 Oct 2018 15:08:40 -0400	[thread overview]
Message-ID: <20181016190840.GF24131@thunk.org> (raw)
In-Reply-To: <20181016145526.3288-1-fishland@aliyun.com>

On Tue, Oct 16, 2018 at 10:55:26PM +0800, fishland wrote:
> The jinode does not need protected by *i_lock*, we can return
> directly if memory allocation fails.
> 

I don't see anything wrong with this patch, but at the same time, I'm
not sure I see the benefit, either.  Checking for the allocation
failure is cheap, and moving it out spinlock doesn't buy much; not to
mention that the allocation failure is going to be highly uncommon.

What inspired this commit?

						- Ted



> Signed-off-by: Liu Song <liu.song11@zte.com.cn>
> Reviewed-by: Wang Yi <wang.yi59@zte.com.cn>
> ---
>  fs/ext4/inode.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index d767e993591d..67ba6f062de5 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -4384,12 +4384,11 @@ int ext4_inode_attach_jinode(struct inode *inode)
>  		return 0;
>  
>  	jinode = jbd2_alloc_inode(GFP_KERNEL);
> +	if (!jinode)
> +		return -ENOMEM;
> +
>  	spin_lock(&inode->i_lock);
>  	if (!ei->jinode) {
> -		if (!jinode) {
> -			spin_unlock(&inode->i_lock);
> -			return -ENOMEM;
> -		}
>  		ei->jinode = jinode;
>  		jbd2_journal_init_jbd_inode(ei->jinode, inode);
>  		jinode = NULL;
> -- 
> 2.17.1
> 

       reply	other threads:[~2018-10-17  3:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20181016145526.3288-1-fishland@aliyun.com>
2018-10-16 19:08 ` Theodore Y. Ts'o [this message]
     [not found] <20181016145526.3288-1-fishland@aliyun.com,20181016190840.GF24131@thunk.org>
     [not found] ` <201810171026448096961@zte.com.cn>
2018-10-17 23:28   ` [PATCH] ext4: direct return when jinode allocate failed Andreas Dilger
2018-10-18  2:23     ` Theodore Y. Ts'o

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=20181016190840.GF24131@thunk.org \
    --to=tytso@mit.edu \
    --cc=adilger.kernel@dilger.ca \
    --cc=fishland@aliyun.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liu.song11@zte.com.cn \
    --cc=wang.yi59@zte.com.cn \
    /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).