diff options
author | Jaegeuk Kim <jaegeuk@kernel.org> | 2014-11-06 18:16:04 -0500 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2014-11-06 18:17:43 -0500 |
commit | 8c402946f0743af91d22eca31d98b058b3371054 (patch) | |
tree | 97b15edaafd72a6b86352e0356829715b4b7f090 /fs/f2fs | |
parent | a344b9fda0cc2eda54433227837029d410dfb12f (diff) |
f2fs: introduce the number of inode entries
This patch adds to monitor the number of ino entries.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs')
-rw-r--r-- | fs/f2fs/checkpoint.c | 27 | ||||
-rw-r--r-- | fs/f2fs/debug.c | 4 | ||||
-rw-r--r-- | fs/f2fs/f2fs.h | 2 |
3 files changed, 19 insertions, 14 deletions
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index dd6a357a59de..bcd686e0dded 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c | |||
@@ -318,6 +318,8 @@ retry: | |||
318 | e->ino = ino; | 318 | e->ino = ino; |
319 | 319 | ||
320 | list_add_tail(&e->list, &sbi->ino_list[type]); | 320 | list_add_tail(&e->list, &sbi->ino_list[type]); |
321 | if (type != ORPHAN_INO) | ||
322 | sbi->ino_num[type]++; | ||
321 | } | 323 | } |
322 | spin_unlock(&sbi->ino_lock[type]); | 324 | spin_unlock(&sbi->ino_lock[type]); |
323 | } | 325 | } |
@@ -331,8 +333,7 @@ static void __remove_ino_entry(struct f2fs_sb_info *sbi, nid_t ino, int type) | |||
331 | if (e) { | 333 | if (e) { |
332 | list_del(&e->list); | 334 | list_del(&e->list); |
333 | radix_tree_delete(&sbi->ino_root[type], ino); | 335 | radix_tree_delete(&sbi->ino_root[type], ino); |
334 | if (type == ORPHAN_INO) | 336 | sbi->ino_num[type]--; |
335 | sbi->n_orphans--; | ||
336 | spin_unlock(&sbi->ino_lock[type]); | 337 | spin_unlock(&sbi->ino_lock[type]); |
337 | kmem_cache_free(ino_entry_slab, e); | 338 | kmem_cache_free(ino_entry_slab, e); |
338 | return; | 339 | return; |
@@ -373,6 +374,7 @@ void release_dirty_inode(struct f2fs_sb_info *sbi) | |||
373 | list_del(&e->list); | 374 | list_del(&e->list); |
374 | radix_tree_delete(&sbi->ino_root[i], e->ino); | 375 | radix_tree_delete(&sbi->ino_root[i], e->ino); |
375 | kmem_cache_free(ino_entry_slab, e); | 376 | kmem_cache_free(ino_entry_slab, e); |
377 | sbi->ino_num[i]--; | ||
376 | } | 378 | } |
377 | spin_unlock(&sbi->ino_lock[i]); | 379 | spin_unlock(&sbi->ino_lock[i]); |
378 | } | 380 | } |
@@ -383,10 +385,10 @@ int acquire_orphan_inode(struct f2fs_sb_info *sbi) | |||
383 | int err = 0; | 385 | int err = 0; |
384 | 386 | ||
385 | spin_lock(&sbi->ino_lock[ORPHAN_INO]); | 387 | spin_lock(&sbi->ino_lock[ORPHAN_INO]); |
386 | if (unlikely(sbi->n_orphans >= sbi->max_orphans)) | 388 | if (unlikely(sbi->ino_num[ORPHAN_INO] >= sbi->max_orphans)) |
387 | err = -ENOSPC; | 389 | err = -ENOSPC; |
388 | else | 390 | else |
389 | sbi->n_orphans++; | 391 | sbi->ino_num[ORPHAN_INO]++; |
390 | spin_unlock(&sbi->ino_lock[ORPHAN_INO]); | 392 | spin_unlock(&sbi->ino_lock[ORPHAN_INO]); |
391 | 393 | ||
392 | return err; | 394 | return err; |
@@ -395,8 +397,8 @@ int acquire_orphan_inode(struct f2fs_sb_info *sbi) | |||
395 | void release_orphan_inode(struct f2fs_sb_info *sbi) | 397 | void release_orphan_inode(struct f2fs_sb_info *sbi) |
396 | { | 398 | { |
397 | spin_lock(&sbi->ino_lock[ORPHAN_INO]); | 399 | spin_lock(&sbi->ino_lock[ORPHAN_INO]); |
398 | f2fs_bug_on(sbi, sbi->n_orphans == 0); | 400 | f2fs_bug_on(sbi, sbi->ino_num[ORPHAN_INO] == 0); |
399 | sbi->n_orphans--; | 401 | sbi->ino_num[ORPHAN_INO]--; |
400 | spin_unlock(&sbi->ino_lock[ORPHAN_INO]); | 402 | spin_unlock(&sbi->ino_lock[ORPHAN_INO]); |
401 | } | 403 | } |
402 | 404 | ||
@@ -460,11 +462,12 @@ static void write_orphan_inodes(struct f2fs_sb_info *sbi, block_t start_blk) | |||
460 | struct f2fs_orphan_block *orphan_blk = NULL; | 462 | struct f2fs_orphan_block *orphan_blk = NULL; |
461 | unsigned int nentries = 0; | 463 | unsigned int nentries = 0; |
462 | unsigned short index; | 464 | unsigned short index; |
463 | unsigned short orphan_blocks = | 465 | unsigned short orphan_blocks; |
464 | (unsigned short)GET_ORPHAN_BLOCKS(sbi->n_orphans); | ||
465 | struct page *page = NULL; | 466 | struct page *page = NULL; |
466 | struct ino_entry *orphan = NULL; | 467 | struct ino_entry *orphan = NULL; |
467 | 468 | ||
469 | orphan_blocks = GET_ORPHAN_BLOCKS(sbi->ino_num[ORPHAN_INO]); | ||
470 | |||
468 | for (index = 0; index < orphan_blocks; index++) | 471 | for (index = 0; index < orphan_blocks; index++) |
469 | grab_meta_page(sbi, start_blk + index); | 472 | grab_meta_page(sbi, start_blk + index); |
470 | 473 | ||
@@ -892,7 +895,7 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc) | |||
892 | else | 895 | else |
893 | clear_ckpt_flags(ckpt, CP_COMPACT_SUM_FLAG); | 896 | clear_ckpt_flags(ckpt, CP_COMPACT_SUM_FLAG); |
894 | 897 | ||
895 | orphan_blocks = GET_ORPHAN_BLOCKS(sbi->n_orphans); | 898 | orphan_blocks = GET_ORPHAN_BLOCKS(sbi->ino_num[ORPHAN_INO]); |
896 | ckpt->cp_pack_start_sum = cpu_to_le32(1 + cp_payload_blks + | 899 | ckpt->cp_pack_start_sum = cpu_to_le32(1 + cp_payload_blks + |
897 | orphan_blocks); | 900 | orphan_blocks); |
898 | 901 | ||
@@ -908,7 +911,7 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc) | |||
908 | orphan_blocks); | 911 | orphan_blocks); |
909 | } | 912 | } |
910 | 913 | ||
911 | if (sbi->n_orphans) | 914 | if (sbi->ino_num[ORPHAN_INO]) |
912 | set_ckpt_flags(ckpt, CP_ORPHAN_PRESENT_FLAG); | 915 | set_ckpt_flags(ckpt, CP_ORPHAN_PRESENT_FLAG); |
913 | else | 916 | else |
914 | clear_ckpt_flags(ckpt, CP_ORPHAN_PRESENT_FLAG); | 917 | clear_ckpt_flags(ckpt, CP_ORPHAN_PRESENT_FLAG); |
@@ -943,7 +946,7 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc) | |||
943 | f2fs_put_page(cp_page, 1); | 946 | f2fs_put_page(cp_page, 1); |
944 | } | 947 | } |
945 | 948 | ||
946 | if (sbi->n_orphans) { | 949 | if (sbi->ino_num[ORPHAN_INO]) { |
947 | write_orphan_inodes(sbi, start_blk); | 950 | write_orphan_inodes(sbi, start_blk); |
948 | start_blk += orphan_blocks; | 951 | start_blk += orphan_blocks; |
949 | } | 952 | } |
@@ -1045,6 +1048,7 @@ void init_ino_entry_info(struct f2fs_sb_info *sbi) | |||
1045 | INIT_RADIX_TREE(&sbi->ino_root[i], GFP_ATOMIC); | 1048 | INIT_RADIX_TREE(&sbi->ino_root[i], GFP_ATOMIC); |
1046 | spin_lock_init(&sbi->ino_lock[i]); | 1049 | spin_lock_init(&sbi->ino_lock[i]); |
1047 | INIT_LIST_HEAD(&sbi->ino_list[i]); | 1050 | INIT_LIST_HEAD(&sbi->ino_list[i]); |
1051 | sbi->ino_num[i] = 0; | ||
1048 | } | 1052 | } |
1049 | 1053 | ||
1050 | /* | 1054 | /* |
@@ -1053,7 +1057,6 @@ void init_ino_entry_info(struct f2fs_sb_info *sbi) | |||
1053 | * orphan entries with the limitation one reserved segment | 1057 | * orphan entries with the limitation one reserved segment |
1054 | * for cp pack we can have max 1020*504 orphan entries | 1058 | * for cp pack we can have max 1020*504 orphan entries |
1055 | */ | 1059 | */ |
1056 | sbi->n_orphans = 0; | ||
1057 | sbi->max_orphans = (sbi->blocks_per_seg - F2FS_CP_PACKS - | 1060 | sbi->max_orphans = (sbi->blocks_per_seg - F2FS_CP_PACKS - |
1058 | NR_CURSEG_TYPE) * F2FS_ORPHANS_PER_BLOCK; | 1061 | NR_CURSEG_TYPE) * F2FS_ORPHANS_PER_BLOCK; |
1059 | } | 1062 | } |
diff --git a/fs/f2fs/debug.c b/fs/f2fs/debug.c index 86e6e926278d..74a0d78dbd3e 100644 --- a/fs/f2fs/debug.c +++ b/fs/f2fs/debug.c | |||
@@ -119,6 +119,7 @@ static void update_mem_info(struct f2fs_sb_info *sbi) | |||
119 | { | 119 | { |
120 | struct f2fs_stat_info *si = F2FS_STAT(sbi); | 120 | struct f2fs_stat_info *si = F2FS_STAT(sbi); |
121 | unsigned npages; | 121 | unsigned npages; |
122 | int i; | ||
122 | 123 | ||
123 | if (si->base_mem) | 124 | if (si->base_mem) |
124 | goto get_cache; | 125 | goto get_cache; |
@@ -168,8 +169,9 @@ get_cache: | |||
168 | si->cache_mem += npages << PAGE_CACHE_SHIFT; | 169 | si->cache_mem += npages << PAGE_CACHE_SHIFT; |
169 | npages = META_MAPPING(sbi)->nrpages; | 170 | npages = META_MAPPING(sbi)->nrpages; |
170 | si->cache_mem += npages << PAGE_CACHE_SHIFT; | 171 | si->cache_mem += npages << PAGE_CACHE_SHIFT; |
171 | si->cache_mem += sbi->n_orphans * sizeof(struct ino_entry); | ||
172 | si->cache_mem += sbi->n_dirty_dirs * sizeof(struct dir_inode_entry); | 172 | si->cache_mem += sbi->n_dirty_dirs * sizeof(struct dir_inode_entry); |
173 | for (i = 0; i <= UPDATE_INO; i++) | ||
174 | si->cache_mem += sbi->ino_num[i] * sizeof(struct ino_entry); | ||
173 | } | 175 | } |
174 | 176 | ||
175 | static int stat_show(struct seq_file *s, void *v) | 177 | static int stat_show(struct seq_file *s, void *v) |
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index d45f3f4d7f93..994b87eb7a7d 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h | |||
@@ -532,9 +532,9 @@ struct f2fs_sb_info { | |||
532 | struct radix_tree_root ino_root[MAX_INO_ENTRY]; /* ino entry array */ | 532 | struct radix_tree_root ino_root[MAX_INO_ENTRY]; /* ino entry array */ |
533 | spinlock_t ino_lock[MAX_INO_ENTRY]; /* for ino entry lock */ | 533 | spinlock_t ino_lock[MAX_INO_ENTRY]; /* for ino entry lock */ |
534 | struct list_head ino_list[MAX_INO_ENTRY]; /* inode list head */ | 534 | struct list_head ino_list[MAX_INO_ENTRY]; /* inode list head */ |
535 | unsigned long ino_num[MAX_INO_ENTRY]; /* number of entries */ | ||
535 | 536 | ||
536 | /* for orphan inode, use 0'th array */ | 537 | /* for orphan inode, use 0'th array */ |
537 | unsigned int n_orphans; /* # of orphan inodes */ | ||
538 | unsigned int max_orphans; /* max orphan inodes */ | 538 | unsigned int max_orphans; /* max orphan inodes */ |
539 | 539 | ||
540 | /* for directory inode management */ | 540 | /* for directory inode management */ |