Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

f2fs: don't track new nat entry in nat set

Nat entry set is used only in checkpoint(), and during checkpoint() we
won't flush new nat entry with unallocated address, so we don't need to
add new nat entry into nat set, then nat_entry_set::entry_cnt can
indicate actual entry count we need to flush in checkpoint().

Signed-off-by: Yunlei He <heyunlei@huawei.com>
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

authored by

Chao Yu and committed by
Jaegeuk Kim
780de47c df033caf

+26 -4
+25 -4
fs/f2fs/node.c
··· 193 193 __free_nat_entry(e); 194 194 } 195 195 196 - static void __set_nat_cache_dirty(struct f2fs_nm_info *nm_i, 197 - struct nat_entry *ne) 196 + static struct nat_entry_set *__grab_nat_entry_set(struct f2fs_nm_info *nm_i, 197 + struct nat_entry *ne) 198 198 { 199 199 nid_t set = NAT_BLOCK_OFFSET(ne->ni.nid); 200 200 struct nat_entry_set *head; ··· 209 209 head->entry_cnt = 0; 210 210 f2fs_radix_tree_insert(&nm_i->nat_set_root, set, head); 211 211 } 212 + return head; 213 + } 214 + 215 + static void __set_nat_cache_dirty(struct f2fs_nm_info *nm_i, 216 + struct nat_entry *ne) 217 + { 218 + struct nat_entry_set *head; 219 + bool new_ne = nat_get_blkaddr(ne) == NEW_ADDR; 220 + 221 + if (!new_ne) 222 + head = __grab_nat_entry_set(nm_i, ne); 223 + 224 + /* 225 + * update entry_cnt in below condition: 226 + * 1. update NEW_ADDR to valid block address; 227 + * 2. update old block address to new one; 228 + */ 229 + if (!new_ne && (get_nat_flag(ne, IS_PREALLOC) || 230 + !get_nat_flag(ne, IS_DIRTY))) 231 + head->entry_cnt++; 232 + 233 + set_nat_flag(ne, IS_PREALLOC, new_ne); 212 234 213 235 if (get_nat_flag(ne, IS_DIRTY)) 214 236 goto refresh_list; 215 237 216 238 nm_i->dirty_nat_cnt++; 217 - head->entry_cnt++; 218 239 set_nat_flag(ne, IS_DIRTY, true); 219 240 refresh_list: 220 - if (nat_get_blkaddr(ne) == NEW_ADDR) 241 + if (new_ne) 221 242 list_del_init(&ne->list); 222 243 else 223 244 list_move_tail(&ne->list, &head->entry_list);
+1
fs/f2fs/node.h
··· 44 44 HAS_FSYNCED_INODE, /* is the inode fsynced before? */ 45 45 HAS_LAST_FSYNC, /* has the latest node fsync mark? */ 46 46 IS_DIRTY, /* this nat entry is dirty? */ 47 + IS_PREALLOC, /* nat entry is preallocated */ 47 48 }; 48 49 49 50 /*