Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1297723 > unrolled thread

[PATCH 2/4] f2fs: return early when trying to read null nid

Started byJaegeuk Kim <jaegeuk@kernel.org>
First post2015-12-24 03:20 +0100
Last post2015-12-25 02:00 +0100
Articles 4 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 2/4] f2fs: return early when trying to read null nid Jaegeuk Kim <jaegeuk@kernel.org> - 2015-12-24 03:20 +0100
    RE: [f2fs-dev] [PATCH 2/4] f2fs: return early when trying to read null  nid Chao Yu <chao2.yu@samsung.com> - 2015-12-24 07:00 +0100
      Re: [f2fs-dev] [PATCH 2/4] f2fs: return early when trying to read  null nid Jaegeuk Kim <jaegeuk@kernel.org> - 2015-12-24 21:20 +0100
        RE: [f2fs-dev] [PATCH 2/4] f2fs: return early when trying to read null  nid Chao Yu <chao2.yu@samsung.com> - 2015-12-25 02:00 +0100

#1297723 — [PATCH 2/4] f2fs: return early when trying to read null nid

FromJaegeuk Kim <jaegeuk@kernel.org>
Date2015-12-24 03:20 +0100
Subject[PATCH 2/4] f2fs: return early when trying to read null nid
Message-ID<qJ3Fv-Na-5@gated-at.bofh.it>
If get_node_page() gets zero nid, we can return early without getting a wrong
page. For example, get_dnode_of_data() can try to do that.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/node.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 341de5d..e17128d 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1059,6 +1059,9 @@ struct page *get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid)
 {
 	struct page *page;
 	int err;
+
+	if (!nid)
+		return ERR_PTR(-ENOENT);
 repeat:
 	page = grab_cache_page(NODE_MAPPING(sbi), nid);
 	if (!page)
-- 
2.5.4 (Apple Git-61)

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1297764 — RE: [f2fs-dev] [PATCH 2/4] f2fs: return early when trying to read null nid

FromChao Yu <chao2.yu@samsung.com>
Date2015-12-24 07:00 +0100
SubjectRE: [f2fs-dev] [PATCH 2/4] f2fs: return early when trying to read null nid
Message-ID<qJ76q-2O5-11@gated-at.bofh.it>
In reply to#1297723
Hi Jaegeuk,

> -----Original Message-----
> From: Jaegeuk Kim [mailto:jaegeuk@kernel.org]
> Sent: Thursday, December 24, 2015 10:15 AM
> To: linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org;
> linux-f2fs-devel@lists.sourceforge.net
> Cc: Jaegeuk Kim
> Subject: [f2fs-dev] [PATCH 2/4] f2fs: return early when trying to read null nid
> 
> If get_node_page() gets zero nid, we can return early without getting a wrong
> page. For example, get_dnode_of_data() can try to do that.

Good catch!

> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>  fs/f2fs/node.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> index 341de5d..e17128d 100644
> --- a/fs/f2fs/node.c
> +++ b/fs/f2fs/node.c
> @@ -1059,6 +1059,9 @@ struct page *get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid)
>  {
>  	struct page *page;
>  	int err;
> +
> +	if (!nid)
> +		return ERR_PTR(-ENOENT);

How about expand to check upper and lower boundary:

	if (check_nid_range)
		return ERR_PTR(-ENOENT);

Thanks,

>  repeat:
>  	page = grab_cache_page(NODE_MAPPING(sbi), nid);
>  	if (!page)
> --
> 2.5.4 (Apple Git-61)
> 
> 
> ------------------------------------------------------------------------------
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1298039 — Re: [f2fs-dev] [PATCH 2/4] f2fs: return early when trying to read null nid

FromJaegeuk Kim <jaegeuk@kernel.org>
Date2015-12-24 21:20 +0100
SubjectRe: [f2fs-dev] [PATCH 2/4] f2fs: return early when trying to read null nid
Message-ID<qJkwF-2Mm-5@gated-at.bofh.it>
In reply to#1297764
On Thu, Dec 24, 2015 at 01:49:24PM +0800, Chao Yu wrote:
> Hi Jaegeuk,
> 
> > -----Original Message-----
> > From: Jaegeuk Kim [mailto:jaegeuk@kernel.org]
> > Sent: Thursday, December 24, 2015 10:15 AM
> > To: linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org;
> > linux-f2fs-devel@lists.sourceforge.net
> > Cc: Jaegeuk Kim
> > Subject: [f2fs-dev] [PATCH 2/4] f2fs: return early when trying to read null nid
> > 
> > If get_node_page() gets zero nid, we can return early without getting a wrong
> > page. For example, get_dnode_of_data() can try to do that.
> 
> Good catch!
> 
> > 
> > Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> > ---
> >  fs/f2fs/node.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> > index 341de5d..e17128d 100644
> > --- a/fs/f2fs/node.c
> > +++ b/fs/f2fs/node.c
> > @@ -1059,6 +1059,9 @@ struct page *get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid)
> >  {
> >  	struct page *page;
> >  	int err;
> > +
> > +	if (!nid)
> > +		return ERR_PTR(-ENOENT);
> 
> How about expand to check upper and lower boundary:
> 
> 	if (check_nid_range)
> 		return ERR_PTR(-ENOENT);

It'd better to add f2fs_bug_on(check_nid_range()) after this.
Cause check_nid_range() checks its nid as *unlikely*, but this case seems
*likely*.

Thanks,

> 
> Thanks,
> 
> >  repeat:
> >  	page = grab_cache_page(NODE_MAPPING(sbi), nid);
> >  	if (!page)
> > --
> > 2.5.4 (Apple Git-61)
> > 
> > 
> > ------------------------------------------------------------------------------
> > _______________________________________________
> > Linux-f2fs-devel mailing list
> > Linux-f2fs-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1298069 — RE: [f2fs-dev] [PATCH 2/4] f2fs: return early when trying to read null nid

FromChao Yu <chao2.yu@samsung.com>
Date2015-12-25 02:00 +0100
SubjectRE: [f2fs-dev] [PATCH 2/4] f2fs: return early when trying to read null nid
Message-ID<qJoTD-5bI-3@gated-at.bofh.it>
In reply to#1298039
> -----Original Message-----
> From: Jaegeuk Kim [mailto:jaegeuk@kernel.org]
> Sent: Friday, December 25, 2015 4:16 AM
> To: Chao Yu
> Cc: linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org;
> linux-f2fs-devel@lists.sourceforge.net
> Subject: Re: [f2fs-dev] [PATCH 2/4] f2fs: return early when trying to read null nid
> 
> On Thu, Dec 24, 2015 at 01:49:24PM +0800, Chao Yu wrote:
> > Hi Jaegeuk,
> >
> > > -----Original Message-----
> > > From: Jaegeuk Kim [mailto:jaegeuk@kernel.org]
> > > Sent: Thursday, December 24, 2015 10:15 AM
> > > To: linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org;
> > > linux-f2fs-devel@lists.sourceforge.net
> > > Cc: Jaegeuk Kim
> > > Subject: [f2fs-dev] [PATCH 2/4] f2fs: return early when trying to read null nid
> > >
> > > If get_node_page() gets zero nid, we can return early without getting a wrong
> > > page. For example, get_dnode_of_data() can try to do that.
> >
> > Good catch!
> >
> > >
> > > Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> > > ---
> > >  fs/f2fs/node.c | 3 +++
> > >  1 file changed, 3 insertions(+)
> > >
> > > diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> > > index 341de5d..e17128d 100644
> > > --- a/fs/f2fs/node.c
> > > +++ b/fs/f2fs/node.c
> > > @@ -1059,6 +1059,9 @@ struct page *get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid)
> > >  {
> > >  	struct page *page;
> > >  	int err;
> > > +
> > > +	if (!nid)
> > > +		return ERR_PTR(-ENOENT);
> >
> > How about expand to check upper and lower boundary:
> >
> > 	if (check_nid_range)
> > 		return ERR_PTR(-ENOENT);
> 
> It'd better to add f2fs_bug_on(check_nid_range()) after this.
> Cause check_nid_range() checks its nid as *unlikely*, but this case seems
> *likely*.

Agreed.

Thanks,

> 
> Thanks,
> 
> >
> > Thanks,
> >
> > >  repeat:
> > >  	page = grab_cache_page(NODE_MAPPING(sbi), nid);
> > >  	if (!page)
> > > --
> > > 2.5.4 (Apple Git-61)
> > >
> > >
> > > ------------------------------------------------------------------------------
> > > _______________________________________________
> > > Linux-f2fs-devel mailing list
> > > Linux-f2fs-devel@lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web