mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 19:08:57 +09:00
FROMGIT: f2fs: don't sleep while grabing nat_tree_lock
This tries to fix priority inversion in the below condition resulting in
long checkpoint delay.
f2fs_get_node_info()
- nat_tree_lock
-> sleep to grab journal_rwsem by contention
checkpoint
- waiting for nat_tree_lock
In order to let checkpoint go, let's release nat_tree_lock, if there's a
journal_rwsem contention.
Signed-off-by: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Bug: 191987855
(cherry picked from commit 2eeb0dce72
git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev)
Change-Id: I97ac4f9d3bde399ab4f17f5b3a6e949ae9b79f0f
Signed-off-by: Daeho Jeong <daehojeong@google.com>
This commit is contained in:
@@ -552,7 +552,7 @@ int f2fs_get_node_info(struct f2fs_sb_info *sbi, nid_t nid,
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
ni->nid = nid;
|
ni->nid = nid;
|
||||||
|
retry:
|
||||||
/* Check nat cache */
|
/* Check nat cache */
|
||||||
down_read(&nm_i->nat_tree_lock);
|
down_read(&nm_i->nat_tree_lock);
|
||||||
e = __lookup_nat_cache(nm_i, nid);
|
e = __lookup_nat_cache(nm_i, nid);
|
||||||
@@ -564,10 +564,19 @@ int f2fs_get_node_info(struct f2fs_sb_info *sbi, nid_t nid,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&ne, 0, sizeof(struct f2fs_nat_entry));
|
/*
|
||||||
|
* Check current segment summary by trying to grab journal_rwsem first.
|
||||||
|
* This sem is on the critical path on the checkpoint requiring the above
|
||||||
|
* nat_tree_lock. Therefore, we should retry, if we failed to grab here
|
||||||
|
* while not bothering checkpoint.
|
||||||
|
*/
|
||||||
|
if (!rwsem_is_locked(&sbi->cp_global_sem)) {
|
||||||
|
down_read(&curseg->journal_rwsem);
|
||||||
|
} else if (!down_read_trylock(&curseg->journal_rwsem)) {
|
||||||
|
up_read(&nm_i->nat_tree_lock);
|
||||||
|
goto retry;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check current segment summary */
|
|
||||||
down_read(&curseg->journal_rwsem);
|
|
||||||
i = f2fs_lookup_journal_in_cursum(journal, NAT_JOURNAL, nid, 0);
|
i = f2fs_lookup_journal_in_cursum(journal, NAT_JOURNAL, nid, 0);
|
||||||
if (i >= 0) {
|
if (i >= 0) {
|
||||||
ne = nat_in_journal(journal, i);
|
ne = nat_in_journal(journal, i);
|
||||||
|
|||||||
Reference in New Issue
Block a user