Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753984AbbLYA6M (ORCPT ); Thu, 24 Dec 2015 19:58:12 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:37507 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752886AbbLYA6K (ORCPT ); Thu, 24 Dec 2015 19:58:10 -0500 X-AuditID: cbfee61a-f79266d000003652-8e-567c949fbcc2 From: Chao Yu To: "'Jaegeuk Kim'" Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net References: <1450923320-41113-1-git-send-email-jaegeuk@kernel.org> <1450923320-41113-2-git-send-email-jaegeuk@kernel.org> <015401d13e0e$f214f8e0$d63eeaa0$@samsung.com> <20151224201534.GA43846@jaegeuk.local> In-reply-to: <20151224201534.GA43846@jaegeuk.local> Subject: RE: [f2fs-dev] [PATCH 2/4] f2fs: return early when trying to read null nid Date: Fri, 25 Dec 2015 08:57:19 +0800 Message-id: <017501d13eaf$4fb361d0$ef1a2570$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-index: AQF5tmoBLLG/HOnrNZPMEXRvLq/8pwKf3xz7Aj4vyTECRdtDHJ9Q0f8g Content-language: zh-cn X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrJLMWRmVeSWpSXmKPExsVy+t9jQd35U2rCDE5PVbd4sn4Ws8WlRe4W e/aeZLG4vGsOmwOLx6ZVnWweuxd8ZvL4vEkugDmKyyYlNSezLLVI3y6BK+PGgU/sBfcFK2bf uMjewNjP18XIySEhYCKx6PV9dghbTOLCvfVsXYxcHEICsxglvs5vgXJeMUpsfrOeBaSKTUBF YnnHfyYQW0RATaJ33xQwm1kgU2JC/wt2iIYrjBKrnswHa+AUMJaY8HYXcxcjB4ewQKjE6wtR IGEWAVWJV53NYJt5BSwlep5OZIWwBSV+TL7HAjFTS2L9zuNQ8+UlNq95ywxxqYLEjrOvGSFu cJNYeP8nO0SNuMTGI7dYJjAKzUIyahaSUbOQjJqFpGUBI8sqRonUguSC4qT0XMO81HK94sTc 4tK8dL3k/NxNjOAIeCa1g/HgLvdDjAIcjEo8vB7VNWFCrIllxZW5hxglOJiVRHivH6kOE+JN SaysSi3Kjy8qzUktPsQozcGiJM5beykyTEggPbEkNTs1tSC1CCbLxMEp1cA4b5GVlGzjRdFs /WUbXU3mzxLXlIowlGv4tfyWt+aMVfMfNYis/L6jmzVUe+o00/NOSvl7J9zuvau4+3PsDPOM h3Wr1zwWXjBNajNTgIQo277WpybLr5W8PLK8/MVJvT3aDECbIv/cKPb9yRDiMOmkw/qDKcqJ z9o6mNZW+xm3NO876p0Tr6vEUpyRaKjFXFScCABj3vKJfAIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2442 Lines: 79 > -----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 > > > --- > > > 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/