mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: zengjx95@gmail.com
Cc: reiserfs-devel@vger.kernel.org, willy@infradead.org,
	jlayton@kernel.org, damien.lemoal@opensource.wdc.com,
	jack@suse.cz, edward.shishkin@gmail.com,
	linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk,
	kasong@tencent.com, Zeng Jingxiang <linuszeng@tencent.com>
Subject: Re: [PATCH] fs/reiserfs/inode: remove dead code in _get_block_create_0()
Date: Tue, 26 Jul 2022 12:48:42 +0200	[thread overview]
Message-ID: <20220726104842.flhaivkpbikqlhki@quack3> (raw)
In-Reply-To: <20220720083029.1065578-1-zengjx95@gmail.com>

On Wed 20-07-22 16:30:29, zengjx95@gmail.com wrote:
> From: Zeng Jingxiang <linuszeng@tencent.com>
> 
> Since commit 27b3a5c51b50 ("kill-the-bkl/reiserfs: drop the fs race
> watchdog from _get_block_create_0()"), which removed a label that may
> have the pointer 'p' touched in its control flow, related if statements
> now eval to constant value now. Just remove them.
> 
> Assigning value NULL to p here
> 293     char *p = NULL;
> 
> In the following conditional expression, the value of p is always NULL,
> As a result, the kunmap() cannot be executed.
> 308	if (p)
> 309		kunmap(bh_result->b_page);
> 
> 355	if (p)
> 356		kunmap(bh_result->b_page);
> 
> 366	if (p)
> 367		kunmap(bh_result->b_page);
> 
> Also, the kmap() cannot be executed.
> 399	if (!p)
> 400		p = (char *)kmap(bh_result->b_page);
> 
> Signed-off-by: Zeng Jingxiang <linuszeng@tencent.com>
> Signed-off-by: Kairui Song <kasong@tencent.com>

Thanks! I've added the patch to my tree. I've also removed the unnecessary
initialization of 'p' to NULL. I'll push the patch to Linus in the coming
merge window.

									Honza

> ---
>  fs/reiserfs/inode.c | 10 +---------
>  1 file changed, 1 insertion(+), 9 deletions(-)
> 
> diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
> index 0cffe054b78e..fe26e1746af9 100644
> --- a/fs/reiserfs/inode.c
> +++ b/fs/reiserfs/inode.c
> @@ -305,8 +305,6 @@ static int _get_block_create_0(struct inode *inode, sector_t block,
>  	result = search_for_position_by_key(inode->i_sb, &key, &path);
>  	if (result != POSITION_FOUND) {
>  		pathrelse(&path);
> -		if (p)
> -			kunmap(bh_result->b_page);
>  		if (result == IO_ERROR)
>  			return -EIO;
>  		/*
> @@ -352,8 +350,6 @@ static int _get_block_create_0(struct inode *inode, sector_t block,
>  		}
>  
>  		pathrelse(&path);
> -		if (p)
> -			kunmap(bh_result->b_page);
>  		return ret;
>  	}
>  	/* requested data are in direct item(s) */
> @@ -363,8 +359,6 @@ static int _get_block_create_0(struct inode *inode, sector_t block,
>  		 * when it is stored in direct item(s)
>  		 */
>  		pathrelse(&path);
> -		if (p)
> -			kunmap(bh_result->b_page);
>  		return -ENOENT;
>  	}
>  
> @@ -396,9 +390,7 @@ static int _get_block_create_0(struct inode *inode, sector_t block,
>  	 * sure we need to.  But, this means the item might move if
>  	 * kmap schedules
>  	 */
> -	if (!p)
> -		p = (char *)kmap(bh_result->b_page);
> -
> +	p = (char *)kmap(bh_result->b_page);
>  	p += offset;
>  	memset(p, 0, inode->i_sb->s_blocksize);
>  	do {
> -- 
> 2.27.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  reply	other threads:[~2022-07-26 10:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-20  8:30 zengjx95
2022-07-26 10:48 ` Jan Kara [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-07-20  6:33 zengjx95
2022-07-20  6:57 ` Al Viro

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=20220726104842.flhaivkpbikqlhki@quack3 \
    --to=jack@suse.cz \
    --cc=damien.lemoal@opensource.wdc.com \
    --cc=edward.shishkin@gmail.com \
    --cc=jlayton@kernel.org \
    --cc=kasong@tencent.com \
    --cc=linuszeng@tencent.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=reiserfs-devel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    --cc=zengjx95@gmail.com \
    /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

all inboxes | Powered by JetHome®