diff options
-rw-r--r-- | fs/f2fs/node.c | 28 | ||||
-rw-r--r-- | fs/f2fs/node.h | 3 | ||||
-rw-r--r-- | fs/f2fs/segment.c | 3 |
3 files changed, 26 insertions, 8 deletions
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index 44b8afef43d9..4ea2c4728156 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c | |||
@@ -31,22 +31,38 @@ bool available_free_memory(struct f2fs_sb_info *sbi, int type) | |||
31 | { | 31 | { |
32 | struct f2fs_nm_info *nm_i = NM_I(sbi); | 32 | struct f2fs_nm_info *nm_i = NM_I(sbi); |
33 | struct sysinfo val; | 33 | struct sysinfo val; |
34 | unsigned long avail_ram; | ||
34 | unsigned long mem_size = 0; | 35 | unsigned long mem_size = 0; |
35 | bool res = false; | 36 | bool res = false; |
36 | 37 | ||
37 | si_meminfo(&val); | 38 | si_meminfo(&val); |
38 | /* give 25%, 25%, 50% memory for each components respectively */ | 39 | |
40 | /* only uses low memory */ | ||
41 | avail_ram = val.totalram - val.totalhigh; | ||
42 | |||
43 | /* give 25%, 25%, 50%, 50% memory for each components respectively */ | ||
39 | if (type == FREE_NIDS) { | 44 | if (type == FREE_NIDS) { |
40 | mem_size = (nm_i->fcnt * sizeof(struct free_nid)) >> 12; | 45 | mem_size = (nm_i->fcnt * sizeof(struct free_nid)) >> |
41 | res = mem_size < ((val.totalram * nm_i->ram_thresh / 100) >> 2); | 46 | PAGE_CACHE_SHIFT; |
47 | res = mem_size < ((avail_ram * nm_i->ram_thresh / 100) >> 2); | ||
42 | } else if (type == NAT_ENTRIES) { | 48 | } else if (type == NAT_ENTRIES) { |
43 | mem_size = (nm_i->nat_cnt * sizeof(struct nat_entry)) >> 12; | 49 | mem_size = (nm_i->nat_cnt * sizeof(struct nat_entry)) >> |
44 | res = mem_size < ((val.totalram * nm_i->ram_thresh / 100) >> 2); | 50 | PAGE_CACHE_SHIFT; |
51 | res = mem_size < ((avail_ram * nm_i->ram_thresh / 100) >> 2); | ||
45 | } else if (type == DIRTY_DENTS) { | 52 | } else if (type == DIRTY_DENTS) { |
46 | if (sbi->sb->s_bdi->dirty_exceeded) | 53 | if (sbi->sb->s_bdi->dirty_exceeded) |
47 | return false; | 54 | return false; |
48 | mem_size = get_pages(sbi, F2FS_DIRTY_DENTS); | 55 | mem_size = get_pages(sbi, F2FS_DIRTY_DENTS); |
49 | res = mem_size < ((val.totalram * nm_i->ram_thresh / 100) >> 1); | 56 | res = mem_size < ((avail_ram * nm_i->ram_thresh / 100) >> 1); |
57 | } else if (type == INO_ENTRIES) { | ||
58 | int i; | ||
59 | |||
60 | if (sbi->sb->s_bdi->dirty_exceeded) | ||
61 | return false; | ||
62 | for (i = 0; i <= UPDATE_INO; i++) | ||
63 | mem_size += (sbi->ino_num[i] * sizeof(struct ino_entry)) | ||
64 | >> PAGE_CACHE_SHIFT; | ||
65 | res = mem_size < ((avail_ram * nm_i->ram_thresh / 100) >> 1); | ||
50 | } | 66 | } |
51 | return res; | 67 | return res; |
52 | } | 68 | } |
diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h index acb71e507a7a..d10b6448a671 100644 --- a/fs/f2fs/node.h +++ b/fs/f2fs/node.h | |||
@@ -106,7 +106,8 @@ static inline void raw_nat_from_node_info(struct f2fs_nat_entry *raw_ne, | |||
106 | enum mem_type { | 106 | enum mem_type { |
107 | FREE_NIDS, /* indicates the free nid list */ | 107 | FREE_NIDS, /* indicates the free nid list */ |
108 | NAT_ENTRIES, /* indicates the cached nat entry */ | 108 | NAT_ENTRIES, /* indicates the cached nat entry */ |
109 | DIRTY_DENTS /* indicates dirty dentry pages */ | 109 | DIRTY_DENTS, /* indicates dirty dentry pages */ |
110 | INO_ENTRIES, /* indicates inode entries */ | ||
110 | }; | 111 | }; |
111 | 112 | ||
112 | struct nat_entry_set { | 113 | struct nat_entry_set { |
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 16721b5dffa4..e094675497d8 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c | |||
@@ -276,7 +276,8 @@ void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi) | |||
276 | { | 276 | { |
277 | /* check the # of cached NAT entries and prefree segments */ | 277 | /* check the # of cached NAT entries and prefree segments */ |
278 | if (try_to_free_nats(sbi, NAT_ENTRY_PER_BLOCK) || | 278 | if (try_to_free_nats(sbi, NAT_ENTRY_PER_BLOCK) || |
279 | excess_prefree_segs(sbi)) | 279 | excess_prefree_segs(sbi) || |
280 | available_free_memory(sbi, INO_ENTRIES)) | ||
280 | f2fs_sync_fs(sbi->sb, true); | 281 | f2fs_sync_fs(sbi->sb, true); |
281 | } | 282 | } |
282 | 283 | ||