From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jaegeuk Kim Subject: Re: [PATCH] f2fs: fix not to allocate max_nid Date: Mon, 18 Mar 2013 19:13:14 +0900 Message-ID: <1363601594.14386.72.camel@kjgkr> References: <1363586028-8617-1-git-send-email-jaegeuk.kim@samsung.com> Reply-To: jaegeuk.kim@samsung.com Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-XmmzpoPqVqNx4ZLh3CW4" Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net To: Namjae Jeon Return-path: In-reply-to: Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org --=-XmmzpoPqVqNx4ZLh3CW4 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 2013-03-18 (=EC=9B=94), 18:29 +0900, Namjae Jeon: > 2013/3/18, Jaegeuk Kim : > > 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 =3D 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 i= t is > > over max_nid or not. > > > > Signed-off-by: Jaegeuk Kim > > --- > > 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 =3D start_nid % NAT_ENTRY_PER_BLOCK; > > > > for (; i < NAT_ENTRY_PER_BLOCK; i++, start_nid++) { > > + if (start_nid >=3D 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 r= eturn. Ok, thanks. :) >=20 > Thanks. > > blk_addr =3D le32_to_cpu(nat_blk->entries[i].block_addr); > > BUG_ON(blk_addr =3D=3D NEW_ADDR); > > if (blk_addr =3D=3D 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" i= n > 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/ --=20 Jaegeuk Kim Samsung --=-XmmzpoPqVqNx4ZLh3CW4 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQIcBAABAgAGBQJRRui6AAoJEEAUqH6CSFDSWEwP/Rgv6EJctBWpxDpx54aQt6uM kJpZGbY6/Ec/MldFvNLOoBQo9AR7zmHvaFV5b0XqIgCnl5jk+L5IMLGJKETeRar0 tmJif7/dtqe6XmH90d3QWM9nX0sYNETXL0crtsg88XH3rtHboQrZptHTVg4DZPGE jdugDComNAtefG8qBqPfpRMJMzYTPJWRD3zEE3usK86hEiCH4MrQOZmcAfFv2SoR XTpdRyjbaoOoFctzlwvuksKNm7iKUpOgQTOCAqKZqRaWICO1sIxW1V4dZawaVVof jLxkjQ5/1YB3EoKDkzj9UgCs0D4nhqyk62HH0RaSb6y1MmvwLkLdF9UIAacMGGfY maUXtS4qSfyBaeaVkyxu7c7O7zR+m8/ABOCQRpfqGUJUPnhvWZZayeV8aD9icpYV 9PXLHkZwly6tEZqhWEyeOe2b8i8DPJQZtF6xWIIlMIPJ9+MTsfL22SmtBdIdS4Cn DC9FhPJO8oJOd61wHP/WY8o4pzrSML+CMNXIomZQdZ5lSNJSU8MZtRVMujZuz8HK Aqoti3dZSfRxzvyDFe3XWLlLP3okkthVETtg2hxUddKw8TBpAtCZqg1POSim6dAK L6Xyaqkfc/OZ4urkVpmyxVRgh/wQP8BxhCoE80kZDKXm8bpWo+rFqpJ1sMX7BzL3 57+9xGkmEAxMgGpur4or =oRkl -----END PGP SIGNATURE----- --=-XmmzpoPqVqNx4ZLh3CW4--