Skip to content

Commit

Permalink
Ocfs2/move_extents: helper to calculate the defraging length in one run.
Browse files Browse the repository at this point in the history
The helper is to calculate the defrag length in one run according to a threshold,
it will proceed doing defragmentation until the threshold was meet, and skip a
LARGE extent if any.

Signed-off-by: Tristan Ye <tristan.ye@oracle.com>
  • Loading branch information
Tristan Ye committed May 25, 2011
1 parent e084771 commit ee16cc0
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions 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 ee16cc0

Please sign in to comment.