aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2
diff options
context:
space:
mode:
authorTristan Ye <tristan.ye@oracle.com>2011-03-18 02:35:40 -0400
committerTristan Ye <tristan.ye@oracle.com>2011-05-25 03:17:12 -0400
commitee16cc037e255801892481a2d0b7c1fff2adf1aa (patch)
tree00ec3109caf8becea9da524282bf66469361ed7c /fs/ocfs2
parente08477176d5575493ba4c30041245c34f2737ad4 (diff)
Ocfs2/move_extents: helper to calculate the defraging length in one run.
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>
Diffstat (limited to 'fs/ocfs2')
-rw-r--r--fs/ocfs2/move_extents.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/fs/ocfs2/move_extents.c b/fs/ocfs2/move_extents.c
index ae15c998a82a..1c822e08fea0 100644
--- a/fs/ocfs2/move_extents.c
+++ b/fs/ocfs2/move_extents.c
@@ -797,3 +797,33 @@ out:
797 797
798 return ret; 798 return ret;
799} 799}
800
801/*
802 * Helper to calculate the defraging length in one run according to threshold.
803 */
804static void ocfs2_calc_extent_defrag_len(u32 *alloc_size, u32 *len_defraged,
805 u32 threshold, int *skip)
806{
807 if ((*alloc_size + *len_defraged) < threshold) {
808 /*
809 * proceed defragmentation until we meet the thresh
810 */
811 *len_defraged += *alloc_size;
812 } else if (*len_defraged == 0) {
813 /*
814 * XXX: skip a large extent.
815 */
816 *skip = 1;
817 } else {
818 /*
819 * split this extent to coalesce with former pieces as
820 * to reach the threshold.
821 *
822 * we're done here with one cycle of defragmentation
823 * in a size of 'thresh', resetting 'len_defraged'
824 * forces a new defragmentation.
825 */
826 *alloc_size = threshold - *len_defraged;
827 *len_defraged = 0;
828 }
829}