f2fs: avoid down_write on nat_tree_lock during checkpoint
authorJaegeuk Kim <jaegeuk@kernel.org>
Mon, 13 Dec 2021 21:28:40 +0000 (13:28 -0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Tue, 4 Jan 2022 21:20:19 +0000 (13:20 -0800)
Let's cache nat entry if there's no lock contention only.

Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/node.c

index 556fcd8457f3f26d3564842eeef0714106769661..b1bc7d76da3b6031cf819891161fd73e8d105ad4 100644 (file)
@@ -430,6 +430,10 @@ static void cache_nat_entry(struct f2fs_sb_info *sbi, nid_t nid,
        struct f2fs_nm_info *nm_i = NM_I(sbi);
        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(sbi, nid, false);
        if (!new)
                return;