* [PATCH] f2fs: fix not to allocate max_nid
@ 2013-03-18 5:53 Jaegeuk Kim
2013-03-18 9:29 ` Namjae Jeon
0 siblings, 1 reply; 4+ messages in thread
From: Jaegeuk Kim @ 2013-03-18 5:53 UTC (permalink / raw)
Cc: Jaegeuk Kim, linux-fsdevel, linux-kernel, linux-f2fs-devel
The build_free_nid should not add free nids over nm_i->max_nid.
But, there was a hole that invalid free nid was added by the following scenario.
Let's suppose nm_i->max_nid = 150 and the last NAT page has 100 ~ 200 nids.
build_free_nids
- get_current_nat_page loads the last NAT page
- scan_nat_page can add 100 ~ 200 nids
-> Bug here!
So, when scanning an NAT page, we should check each candidate whether it is
over max_nid or not.
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
---
fs/f2fs/node.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index c60919f..3fb6dfe 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1270,6 +1270,8 @@ static int scan_nat_page(struct f2fs_nm_info *nm_i,
i = start_nid % NAT_ENTRY_PER_BLOCK;
for (; i < NAT_ENTRY_PER_BLOCK; i++, start_nid++) {
+ if (start_nid >= nm_i->max_nid)
+ return fcnt;
blk_addr = le32_to_cpu(nat_blk->entries[i].block_addr);
BUG_ON(blk_addr == NEW_ADDR);
if (blk_addr == NULL_ADDR)
--
1.8.1.3.566.gaa39828
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] f2fs: fix not to allocate max_nid
2013-03-18 5:53 [PATCH] f2fs: fix not to allocate max_nid Jaegeuk Kim
@ 2013-03-18 9:29 ` Namjae Jeon
2013-03-18 10:13 ` Jaegeuk Kim
0 siblings, 1 reply; 4+ messages in thread
From: Namjae Jeon @ 2013-03-18 9:29 UTC (permalink / raw)
To: Jaegeuk Kim; +Cc: linux-fsdevel, linux-kernel, linux-f2fs-devel
2013/3/18, Jaegeuk Kim <jaegeuk.kim@samsung.com>:
> The build_free_nid should not add free nids over nm_i->max_nid.
> But, there was a hole that invalid free nid was added by the following
> scenario.
>
> Let's suppose nm_i->max_nid = 150 and the last NAT page has 100 ~ 200 nids.
>
> build_free_nids
> - get_current_nat_page loads the last NAT page
> - scan_nat_page can add 100 ~ 200 nids
> -> Bug here!
> So, when scanning an NAT page, we should check each candidate whether it is
> over max_nid or not.
>
> Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
> ---
> fs/f2fs/node.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> index c60919f..3fb6dfe 100644
> --- a/fs/f2fs/node.c
> +++ b/fs/f2fs/node.c
> @@ -1270,6 +1270,8 @@ static int scan_nat_page(struct f2fs_nm_info *nm_i,
> i = start_nid % NAT_ENTRY_PER_BLOCK;
>
> for (; i < NAT_ENTRY_PER_BLOCK; i++, start_nid++) {
> + if (start_nid >= nm_i->max_nid)
> + return fcnt;
Hi Jaegeuk.
How about use "break;" instread of "return fcnt" ?
I think that break is better because there is no extra condition before return.
Thanks.
> blk_addr = le32_to_cpu(nat_blk->entries[i].block_addr);
> BUG_ON(blk_addr == NEW_ADDR);
> if (blk_addr == NULL_ADDR)
> --
> 1.8.1.3.566.gaa39828
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] f2fs: fix not to allocate max_nid
2013-03-18 9:29 ` Namjae Jeon
@ 2013-03-18 10:13 ` Jaegeuk Kim
2013-03-18 11:28 ` Namjae Jeon
0 siblings, 1 reply; 4+ messages in thread
From: Jaegeuk Kim @ 2013-03-18 10:13 UTC (permalink / raw)
To: Namjae Jeon; +Cc: linux-fsdevel, linux-kernel, linux-f2fs-devel
[-- Attachment #1: Type: text/plain, Size: 2003 bytes --]
2013-03-18 (월), 18:29 +0900, Namjae Jeon:
> 2013/3/18, Jaegeuk Kim <jaegeuk.kim@samsung.com>:
> > The build_free_nid should not add free nids over nm_i->max_nid.
> > But, there was a hole that invalid free nid was added by the following
> > scenario.
> >
> > Let's suppose nm_i->max_nid = 150 and the last NAT page has 100 ~ 200 nids.
> >
> > build_free_nids
> > - get_current_nat_page loads the last NAT page
> > - scan_nat_page can add 100 ~ 200 nids
> > -> Bug here!
> > So, when scanning an NAT page, we should check each candidate whether it is
> > over max_nid or not.
> >
> > Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
> > ---
> > fs/f2fs/node.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> > index c60919f..3fb6dfe 100644
> > --- a/fs/f2fs/node.c
> > +++ b/fs/f2fs/node.c
> > @@ -1270,6 +1270,8 @@ static int scan_nat_page(struct f2fs_nm_info *nm_i,
> > i = start_nid % NAT_ENTRY_PER_BLOCK;
> >
> > for (; i < NAT_ENTRY_PER_BLOCK; i++, start_nid++) {
> > + if (start_nid >= nm_i->max_nid)
> > + return fcnt;
> Hi Jaegeuk.
> How about use "break;" instread of "return fcnt" ?
> I think that break is better because there is no extra condition before return.
Ok, thanks. :)
>
> Thanks.
> > blk_addr = le32_to_cpu(nat_blk->entries[i].block_addr);
> > BUG_ON(blk_addr == NEW_ADDR);
> > if (blk_addr == NULL_ADDR)
> > --
> > 1.8.1.3.566.gaa39828
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> >
> --
> 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/
--
Jaegeuk Kim
Samsung
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] f2fs: fix not to allocate max_nid
2013-03-18 10:13 ` Jaegeuk Kim
@ 2013-03-18 11:28 ` Namjae Jeon
0 siblings, 0 replies; 4+ messages in thread
From: Namjae Jeon @ 2013-03-18 11:28 UTC (permalink / raw)
To: jaegeuk.kim; +Cc: linux-fsdevel, linux-kernel, linux-f2fs-devel
2013/3/18, Jaegeuk Kim <jaegeuk.kim@samsung.com>:
> 2013-03-18 (월), 18:29 +0900, Namjae Jeon:
>> 2013/3/18, Jaegeuk Kim <jaegeuk.kim@samsung.com>:
>> > The build_free_nid should not add free nids over nm_i->max_nid.
>> > But, there was a hole that invalid free nid was added by the following
>> > scenario.
>> >
>> > Let's suppose nm_i->max_nid = 150 and the last NAT page has 100 ~ 200
>> > nids.
>> >
>> > build_free_nids
>> > - get_current_nat_page loads the last NAT page
>> > - scan_nat_page can add 100 ~ 200 nids
>> > -> Bug here!
>> > So, when scanning an NAT page, we should check each candidate whether it
>> > is
>> > over max_nid or not.
>> >
>> > Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
>> > ---
>> > fs/f2fs/node.c | 2 ++
>> > 1 file changed, 2 insertions(+)
>> >
>> > diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
>> > index c60919f..3fb6dfe 100644
>> > --- a/fs/f2fs/node.c
>> > +++ b/fs/f2fs/node.c
>> > @@ -1270,6 +1270,8 @@ static int scan_nat_page(struct f2fs_nm_info
>> > *nm_i,
>> > i = start_nid % NAT_ENTRY_PER_BLOCK;
>> >
>> > for (; i < NAT_ENTRY_PER_BLOCK; i++, start_nid++) {
>> > + if (start_nid >= nm_i->max_nid)
>> > + return fcnt;
>> Hi Jaegeuk.
>> How about use "break;" instread of "return fcnt" ?
>> I think that break is better because there is no extra condition before
>> return.
>
> Ok, thanks. :)
Okay, you can add
Reviewed-by: Namjae Jeon <namjae.jeon@samsung.com>
Thanks.
>
>>
>> Thanks.
>> > blk_addr = le32_to_cpu(nat_blk->entries[i].block_addr);
>> > BUG_ON(blk_addr == NEW_ADDR);
>> > if (blk_addr == NULL_ADDR)
>> > --
>> > 1.8.1.3.566.gaa39828
>> >
>> > --
>> > To unsubscribe from this list: send the line "unsubscribe linux-fsdevel"
>> > in
>> > the body of a message to majordomo@vger.kernel.org
>> > More majordomo info at http://vger.kernel.org/majordomo-info.html
>> >
>> --
>> 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/
>
> --
> Jaegeuk Kim
> Samsung
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-03-18 11:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-18 5:53 [PATCH] f2fs: fix not to allocate max_nid Jaegeuk Kim
2013-03-18 9:29 ` Namjae Jeon
2013-03-18 10:13 ` Jaegeuk Kim
2013-03-18 11:28 ` Namjae Jeon
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.