From patchwork Mon Mar 9 03:00:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wanpeng Li X-Patchwork-Id: 5964401 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 58F44BF440 for ; Mon, 9 Mar 2015 03:19:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 941DD2024D for ; Mon, 9 Mar 2015 03:19:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A590A2024C for ; Mon, 9 Mar 2015 03:19:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751588AbbCIDTk (ORCPT ); Sun, 8 Mar 2015 23:19:40 -0400 Received: from mga02.intel.com ([134.134.136.20]:20150 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751200AbbCIDTL (ORCPT ); Sun, 8 Mar 2015 23:19:11 -0400 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP; 08 Mar 2015 20:19:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,365,1422950400"; d="scan'208";a="464420979" Received: from kernel.bj.intel.com ([10.238.154.97]) by FMSMGA003.fm.intel.com with ESMTP; 08 Mar 2015 20:12:32 -0700 From: Wanpeng Li To: Jaegeuk Kim Cc: Changman Lee , Chao Yu , linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Wanpeng Li Subject: [PATCH 2/3] f2fs: fix get stale meta pages when build free nids Date: Mon, 9 Mar 2015 11:00:54 +0800 Message-Id: <1425870055-27694-2-git-send-email-wanpeng.li@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1425870055-27694-1-git-send-email-wanpeng.li@linux.intel.com> References: <1425870055-27694-1-git-send-email-wanpeng.li@linux.intel.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The blocks of nat pages to be scanned will be readahead when build free nids. The start blkno will be adjusted to 0 when the intended range over max_nids, then function ra_meta_pages readahead the right blkno, however, function get_current_nat_page which is called in build_free_nids still get the meta pages w/ stale blkno, this patch fix it by adjusting the nid and the blkno which will be readahead in avdance in order to readahead and get the right meta pages. Signed-off-by: Wanpeng Li --- fs/f2fs/checkpoint.c | 3 --- fs/f2fs/node.c | 9 ++++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index 53bc328..aedb441 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c @@ -129,9 +129,6 @@ int ra_meta_pages(struct f2fs_sb_info *sbi, block_t start, int nrpages, int type switch (type) { case META_NAT: - if (unlikely(blkno >= - NAT_BLOCK_OFFSET(NM_I(sbi)->max_nid))) - blkno = 0; /* get nat block addr */ fio.blk_addr = current_nat_addr(sbi, blkno * NAT_ENTRY_PER_BLOCK); diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index 1a7e925..8751375 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -1509,13 +1509,20 @@ static void build_free_nids(struct f2fs_sb_info *sbi) struct f2fs_summary_block *sum = curseg->sum_blk; int i = 0; nid_t nid = nm_i->next_scan_nid; + block_t blkno = NAT_BLOCK_OFFSET(nid); /* Enough entries */ if (nm_i->fcnt > NAT_ENTRY_PER_BLOCK) return; + if (unlikely(blkno >= + NAT_BLOCK_OFFSET(NM_I(sbi)->max_nid))) { + blkno = 0; + nid = 0; + } + /* readahead nat pages to be scanned */ - ra_meta_pages(sbi, NAT_BLOCK_OFFSET(nid), FREE_NID_PAGES, META_NAT); + ra_meta_pages(sbi, blkno, FREE_NID_PAGES, META_NAT); while (1) { struct page *page = get_current_nat_page(sbi, nid);