Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 251812
b: refs/heads/master
c: ee16cc0
h: refs/heads/master
v: v3
  • Loading branch information
Tristan Ye committed May 25, 2011
1 parent 77ebe5a commit 73ae2e3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e08477176d5575493ba4c30041245c34f2737ad4
refs/heads/master: ee16cc037e255801892481a2d0b7c1fff2adf1aa
30 changes: 30 additions & 0 deletions trunk/fs/ocfs2/move_extents.c
Original file line number Diff line number Diff line change
Expand Up @@ -797,3 +797,33 @@ static int ocfs2_move_extent(struct ocfs2_move_extents_context *context,

return ret;
}

/*
* Helper to calculate the defraging length in one run according to threshold.
*/
static void ocfs2_calc_extent_defrag_len(u32 *alloc_size, u32 *len_defraged,
u32 threshold, int *skip)
{
if ((*alloc_size + *len_defraged) < threshold) {
/*
* proceed defragmentation until we meet the thresh
*/
*len_defraged += *alloc_size;
} else if (*len_defraged == 0) {
/*
* XXX: skip a large extent.
*/
*skip = 1;
} else {
/*
* split this extent to coalesce with former pieces as
* to reach the threshold.
*
* we're done here with one cycle of defragmentation
* in a size of 'thresh', resetting 'len_defraged'
* forces a new defragmentation.
*/
*alloc_size = threshold - *len_defraged;
*len_defraged = 0;
}
}

0 comments on commit 73ae2e3

Please sign in to comment.