linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Yunlong Song <yunlong.song@huawei.com>
Cc: cm224.lee@samsung.com, yuchao0@huawei.com, chao@kernel.org,
	sylinux@163.com, bintian.wang@huawei.com, houpengyang@huawei.com,
	heyunlei@huawei.com, liushuoran@huawei.com, shiguojun@huawei.com,
	linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] f2fs: Return the errno to the caller to avoid using a wrong page
Date: Wed, 25 May 2016 09:54:38 -0700	[thread overview]
Message-ID: <20160525165438.GB47096@jaegeuk.gateway> (raw)
In-Reply-To: <1464181261-3980-1-git-send-email-yunlong.song@huawei.com>

Hi Yunlong,

Do we have a bug report in terms of this?

Thanks,

On Wed, May 25, 2016 at 09:01:01PM +0800, Yunlong Song wrote:
> Commit aaf9607516ed38825268515ef4d773289a44f429 ("f2fs: check node page
> contents all the time") pointed out that "sometimes it was reported that
> its contents was missing", so it checks the page's mapping and contents.
> When "nid != nid_of_node(page)", ERR_PTR(-EIO) will be returned to the
> caller. However, commit e1c51b9f1df2f9efc2ec11488717e40cd12015f9 ("f2fs:
> clean up node page updating flow") moves "nid != nid_of_node(page)" test
> to "f2fs_bug_on(sbi, nid != nid_of_node(page))", this will return a
> wrong page to the caller when F2FS_CHECK_FS is off when "sometimes it
> was reported that its contents was missing" happens.
> 
> This patch restores to check node page contents all the time, and
> returns the errno to make the caller known something is wrong and avoid
> to use the page. This patch also moves f2fs_bug_on to its proper location.
> 
> Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
> ---
>  fs/f2fs/node.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> index 1f21aae..4b04af4 100644
> --- a/fs/f2fs/node.c
> +++ b/fs/f2fs/node.c
> @@ -1140,16 +1140,16 @@ repeat:
>  	if (err < 0) {
>  		f2fs_put_page(page, 1);
>  		return ERR_PTR(err);
> -	} else if (err == LOCKED_PAGE) {
> -		goto page_hit;
> +	} else if (err != LOCKED_PAGE) {
> +		lock_page(page);
>  	}
>  
>  	if (parent)
>  		ra_node_pages(parent, start + 1, MAX_RA_NODE);
>  
> -	lock_page(page);
> -
> -	if (unlikely(!PageUptodate(page))) {
> +	if (unlikely(!PageUptodate(page) || nid != nid_of_node(page))) {
> +		f2fs_bug_on(sbi, 1);
> +		ClearPageUptodate(page);
>  		f2fs_put_page(page, 1);
>  		return ERR_PTR(-EIO);
>  	}
> @@ -1157,8 +1157,6 @@ repeat:
>  		f2fs_put_page(page, 1);
>  		goto repeat;
>  	}
> -page_hit:
> -	f2fs_bug_on(sbi, nid != nid_of_node(page));
>  	return page;
>  }
>  
> -- 
> 1.8.5.2

  reply	other threads:[~2016-05-25 16:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-25 13:01 [PATCH] f2fs: Return the errno to the caller to avoid using a wrong page Yunlong Song
2016-05-25 16:54 ` Jaegeuk Kim [this message]
2016-05-27 12:22   ` Yunlong Song
2016-05-26  4:38 ` [PATCH v2] " Yunlong Song
2016-05-26 11:30   ` Yunlong Song
2016-05-26 11:40 ` [PATCH v3] " Yunlong Song
2016-05-26  4:31 [PATCH] " Yunlong Song
2016-05-26  4:31 ` Yunlong Song

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=20160525165438.GB47096@jaegeuk.gateway \
    --to=jaegeuk@kernel.org \
    --cc=bintian.wang@huawei.com \
    --cc=chao@kernel.org \
    --cc=cm224.lee@samsung.com \
    --cc=heyunlei@huawei.com \
    --cc=houpengyang@huawei.com \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liushuoran@huawei.com \
    --cc=shiguojun@huawei.com \
    --cc=sylinux@163.com \
    --cc=yuchao0@huawei.com \
    --cc=yunlong.song@huawei.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;
as well as URLs for NNTP newsgroup(s).