BACKPORT: f2fs: avoid down_write on nat_tree_lock during checkpoint

Let's cache nat entry if there's no lock contention only.

Bug: 214413989
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
(cherry picked from commit 0df035c7208c5e3e2ae7685548353ae536a19015
    git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master)
[ Address merge conflict ]
Change-Id: I0bf70451bc0b148ebb88429d6294ea8e68008e48
This commit is contained in:
Jaegeuk Kim
2021-12-13 13:28:40 -08:00
committed by Jaegeuk Kim
parent c8701aa0a7
commit fa055ddfd5

View File

@@ -428,6 +428,10 @@ static void cache_nat_entry(struct f2fs_sb_info *sbi, nid_t nid,
struct f2fs_nm_info *nm_i = NM_I(sbi); struct f2fs_nm_info *nm_i = NM_I(sbi);
struct nat_entry *new, *e; struct nat_entry *new, *e;
/* Let's mitigate lock contention of nat_tree_lock during checkpoint */
if (rwsem_is_locked(&sbi->cp_global_sem))
return;
new = __alloc_nat_entry(nid, false); new = __alloc_nat_entry(nid, false);
if (!new) if (!new)
return; return;