From: Chao Yu <chao@kernel.org>
To: jaegeuk@kernel.org
Cc: linux-f2fs-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, Chao Yu <yuchao0@huawei.com>
Subject: [PATCH 5/7] f2fs: exclude free nids building and allocation
Date: Tue, 11 Oct 2016 22:31:34 +0800 [thread overview]
Message-ID: <20161011143136.2107-5-chao@kernel.org> (raw)
In-Reply-To: <20161011143136.2107-1-chao@kernel.org>
From: Chao Yu <yuchao0@huawei.com>
During nid allocation, it needs to exclude building and allocating flow
of free nids, this is because while building free nid cache, there are two
steps: a) load free nids from unused nat entries in NAT pages, b) update
free nid cache by checking nat journal. The two steps should be atomical,
otherwise an used nid can be allocated as free one after a) and before b).
This patch adds missing lock which covers build_free_nids in
unlock_operation and f2fs_balance_fs_bg to avoid that.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
fs/f2fs/node.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 92c9aa4..c68e92d 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1824,7 +1824,7 @@ static void scan_nat_page(struct f2fs_sb_info *sbi,
}
}
-void build_free_nids(struct f2fs_sb_info *sbi)
+void __build_free_nids(struct f2fs_sb_info *sbi)
{
struct f2fs_nm_info *nm_i = NM_I(sbi);
struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA);
@@ -1878,6 +1878,13 @@ void build_free_nids(struct f2fs_sb_info *sbi)
nm_i->ra_nid_pages, META_NAT, false);
}
+void build_free_nids(struct f2fs_sb_info *sbi)
+{
+ mutex_lock(&NM_I(sbi)->build_lock);
+ __build_free_nids(sbi);
+ mutex_unlock(&NM_I(sbi)->build_lock);
+}
+
/*
* If this function returns success, caller can obtain a new nid
* from second parameter of this function.
@@ -1913,9 +1920,7 @@ retry:
spin_unlock(&nm_i->free_nid_list_lock);
/* Let's scan nat pages and its caches to get free nids */
- mutex_lock(&nm_i->build_lock);
build_free_nids(sbi);
- mutex_unlock(&nm_i->build_lock);
goto retry;
}
--
2.10.1
next prev parent reply other threads:[~2016-10-11 14:35 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-11 14:31 [PATCH 1/7] f2fs: split free nid list Chao Yu
2016-10-11 14:31 ` [PATCH 2/7] f2fs: clean up nid list operation Chao Yu
2016-10-11 14:31 ` [PATCH 3/7] f2fs: rename free nid cache operation Chao Yu
2016-10-11 17:19 ` Jaegeuk Kim
2016-10-12 15:14 ` Chao Yu
2016-10-12 17:15 ` Jaegeuk Kim
2016-10-13 10:26 ` Chao Yu
2016-10-11 14:31 ` [PATCH 4/7] f2fs: show pending allocated nids count in debugfs Chao Yu
2016-10-11 17:20 ` Jaegeuk Kim
2016-10-11 14:31 ` Chao Yu [this message]
2016-10-11 17:25 ` [PATCH 5/7] f2fs: exclude free nids building and allocation Jaegeuk Kim
2016-10-11 14:31 ` [PATCH 6/7] f2fs: don't interrupt free nids building during nid allocation Chao Yu
2016-10-11 14:31 ` [PATCH 7/7] f2fs: avoid casted negative value as shrink count Chao Yu
2016-10-11 17:09 ` [PATCH 1/7] f2fs: split free nid list Jaegeuk Kim
2016-10-12 1:14 ` Chao Yu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161011143136.2107-5-chao@kernel.org \
--to=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=yuchao0@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox