Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 348156
b: refs/heads/master
c: 029cd28
h: refs/heads/master
v: v3
  • Loading branch information
Jaegeuk Kim committed Dec 28, 2012
1 parent 5464e3f commit c4cce96
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 36 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f58ad8f51a5a0f34c8d41ffc065e0f1c896c991c
refs/heads/master: 029cd28c1f739bbfc5105035696d5f1f4e45d161
36 changes: 2 additions & 34 deletions trunk/fs/f2fs/segment.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,48 +19,16 @@
#include "segment.h"
#include "node.h"

static int need_to_flush(struct f2fs_sb_info *sbi)
{
unsigned int pages_per_sec = (1 << sbi->log_blocks_per_seg) *
sbi->segs_per_sec;
int node_secs = ((get_pages(sbi, F2FS_DIRTY_NODES) + pages_per_sec - 1)
>> sbi->log_blocks_per_seg) / sbi->segs_per_sec;
int dent_secs = ((get_pages(sbi, F2FS_DIRTY_DENTS) + pages_per_sec - 1)
>> sbi->log_blocks_per_seg) / sbi->segs_per_sec;

if (sbi->por_doing)
return 0;

if (free_sections(sbi) <= (node_secs + 2 * dent_secs +
reserved_sections(sbi)))
return 1;
return 0;
}

/*
* This function balances dirty node and dentry pages.
* In addition, it controls garbage collection.
*/
void f2fs_balance_fs(struct f2fs_sb_info *sbi)
{
struct writeback_control wbc = {
.sync_mode = WB_SYNC_ALL,
.nr_to_write = LONG_MAX,
.for_reclaim = 0,
};

if (sbi->por_doing)
return;

/*
* We should do checkpoint when there are so many dirty node pages
* with enough free segments. After then, we should do GC.
* We should do GC or end up with checkpoint, if there are so many dirty
* dir/node pages without enough free segments.
*/
if (need_to_flush(sbi)) {
sync_dirty_dir_inodes(sbi);
sync_node_pages(sbi, 0, &wbc);
}

if (has_not_enough_free_secs(sbi)) {
mutex_lock(&sbi->gc_mutex);
f2fs_gc(sbi, 1);
Expand Down
15 changes: 14 additions & 1 deletion trunk/fs/f2fs/segment.h
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,20 @@ static inline int get_ssr_segment(struct f2fs_sb_info *sbi, int type)

static inline bool has_not_enough_free_secs(struct f2fs_sb_info *sbi)
{
return free_sections(sbi) <= reserved_sections(sbi);
unsigned int pages_per_sec = (1 << sbi->log_blocks_per_seg) *
sbi->segs_per_sec;
int node_secs = ((get_pages(sbi, F2FS_DIRTY_NODES) + pages_per_sec - 1)
>> sbi->log_blocks_per_seg) / sbi->segs_per_sec;
int dent_secs = ((get_pages(sbi, F2FS_DIRTY_DENTS) + pages_per_sec - 1)
>> sbi->log_blocks_per_seg) / sbi->segs_per_sec;

if (sbi->por_doing)
return false;

if (free_sections(sbi) <= (node_secs + 2 * dent_secs +
reserved_sections(sbi)))
return true;
return false;
}

static inline int utilization(struct f2fs_sb_info *sbi)
Expand Down

0 comments on commit c4cce96

Please sign in to comment.