Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752509AbbHTJOk (ORCPT ); Thu, 20 Aug 2015 05:14:40 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:40525 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751584AbbHTJMw (ORCPT ); Thu, 20 Aug 2015 05:12:52 -0400 X-AuditID: cbfee61b-f79706d000001b96-8a-55d59a13723d From: Chao Yu To: "'Jaegeuk Kim'" , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net References: <1439887589-35190-1-git-send-email-jaegeuk@kernel.org> <1439887589-35190-5-git-send-email-jaegeuk@kernel.org> In-reply-to: <1439887589-35190-5-git-send-email-jaegeuk@kernel.org> Subject: RE: [f2fs-dev] [PATCH 5/5] f2fs: check the node block address of newly allocated nid Date: Thu, 20 Aug 2015 17:12:03 +0800 Message-id: <01bb01d0db28$61844ea0$248cebe0$@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: AQMbK+U27TEaBuzOkuL9EYWgZcyS+gL3ywKSm2gwOMA= Content-language: zh-cn X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrHLMWRmVeSWpSXmKPExsVy+t9jQV3hWVdDDVZOE7Z4sn4Ws8WlRe4W e/aeZLG4vGsOmwOLx6ZVnWweuxd8ZvL4vEkugDmKyyYlNSezLLVI3y6BK2PPxmb2gl7Bilfb brA3MH7g7WLk5JAQMJGYcX0xI4QtJnHh3nq2LkYuDiGBWYwS/9ffZ4FwXjFK3O0+ygZSxSag IrG84z8TSEJEoJdR4seZfmaQhJBAtcSkJVPBijgFnCWalm1iAbGFBeIllk7vBbNZBFQl/l9f D2bzClhK/H7/mR3CFpT4MfkeWJxZQEti/c7jTBC2vMTmNW+ZIc5TkNhx9jXYqSICVhI/O/+x QtSIS2w8cotlAqPgLCSjZiEZNQvJqFlIWhYwsqxilEgtSC4oTkrPNcpLLdcrTswtLs1L10vO z93ECA71Z9I7GA/vcj/EKMDBqMTDe0H4aqgQa2JZcWXuIUYJDmYlEd7rM4BCvCmJlVWpRfnx RaU5qcWHGKU5WJTEefVNNoUKCaQnlqRmp6YWpBbBZJk4OKUaGJev7juseOZLVsPiQyJbDe5c jZD/IHftNaN3lvD+J08snicG8bxcJxEmbvH4xpSsD693f6t05DiUW2dqH+8iIGji7vPnlNyB loDpCaK6jJe/BwUt+OAWe/Jm4U+tE3q75r5I+t9fuGLSlm/aId5nb/3ctGe6XJdsO4NsSWV/ ml/xtG9ub69O11JiKc5INNRiLipOBADTFbv9cQIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2366 Lines: 73 Hi Jaegeuk, > -----Original Message----- > From: Jaegeuk Kim [mailto:jaegeuk@kernel.org] > Sent: Tuesday, August 18, 2015 4:46 PM > To: linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org; > linux-f2fs-devel@lists.sourceforge.net > Cc: Jaegeuk Kim > Subject: [f2fs-dev] [PATCH 5/5] f2fs: check the node block address of newly allocated nid > > This patch adds a routine which checks the block address of newly allocated nid. > If an nid has already allocated by other thread due to subtle data races, it > will result in filesystem corruption. > So, it needs to check whether its block address was already allocated or not > in prior to nid allocation as the last chance. > > Signed-off-by: Jaegeuk Kim > --- > fs/f2fs/node.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c > index 3cc32b8..6bef5a2 100644 > --- a/fs/f2fs/node.c > +++ b/fs/f2fs/node.c > @@ -1573,6 +1573,8 @@ retry: > > /* We should not use stale free nids created by build_free_nids */ > if (nm_i->fcnt && !on_build_free_nids(nm_i)) { > + struct node_info ni; > + > f2fs_bug_on(sbi, list_empty(&nm_i->free_nid_list)); > list_for_each_entry(i, &nm_i->free_nid_list, list) > if (i->state == NID_NEW) > @@ -1583,6 +1585,13 @@ retry: > i->state = NID_ALLOC; > nm_i->fcnt--; > spin_unlock(&nm_i->free_nid_list_lock); > + > + /* check nid is allocated already */ > + get_node_info(sbi, *nid, &ni); > + if (ni.blk_addr != NULL_ADDR) { I didn't get it, why free nid is with non-NULL blkaddr? Could you please explain more about this? > + alloc_nid_done(sbi, *nid); Will another thread call alloc_nid_done too, making this free nid being released again? Thanks, > + goto retry; > + } > return true; > } > spin_unlock(&nm_i->free_nid_list_lock); > -- > 2.1.1 > > > ------------------------------------------------------------------------------ > _______________________________________________ > 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/