diff options
| -rw-r--r-- | fs/ocfs2/move_extents.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/fs/ocfs2/move_extents.c b/fs/ocfs2/move_extents.c index efc509b3af1f..4c5488468c14 100644 --- a/fs/ocfs2/move_extents.c +++ b/fs/ocfs2/move_extents.c | |||
| @@ -220,6 +220,9 @@ out: | |||
| 220 | /* | 220 | /* |
| 221 | * Using one journal handle to guarantee the data consistency in case | 221 | * Using one journal handle to guarantee the data consistency in case |
| 222 | * crash happens anywhere. | 222 | * crash happens anywhere. |
| 223 | * | ||
| 224 | * XXX: defrag can end up with finishing partial extent as requested, | ||
| 225 | * due to not enough contiguous clusters can be found in allocator. | ||
| 223 | */ | 226 | */ |
| 224 | static int ocfs2_defrag_extent(struct ocfs2_move_extents_context *context, | 227 | static int ocfs2_defrag_extent(struct ocfs2_move_extents_context *context, |
| 225 | u32 cpos, u32 phys_cpos, u32 *len, int ext_flags) | 228 | u32 cpos, u32 phys_cpos, u32 *len, int ext_flags) |
| @@ -876,9 +879,11 @@ static int __ocfs2_move_extents_range(struct buffer_head *di_bh, | |||
| 876 | else | 879 | else |
| 877 | len_to_move = 0; | 880 | len_to_move = 0; |
| 878 | 881 | ||
| 879 | if (do_defrag) | 882 | if (do_defrag) { |
| 880 | defrag_thresh = range->me_threshold >> osb->s_clustersize_bits; | 883 | defrag_thresh = range->me_threshold >> osb->s_clustersize_bits; |
| 881 | else | 884 | if (defrag_thresh <= 1) |
| 885 | goto done; | ||
| 886 | } else | ||
| 882 | new_phys_cpos = ocfs2_blocks_to_clusters(inode->i_sb, | 887 | new_phys_cpos = ocfs2_blocks_to_clusters(inode->i_sb, |
| 883 | range->me_goal); | 888 | range->me_goal); |
| 884 | 889 | ||
| @@ -950,6 +955,7 @@ next: | |||
| 950 | len_to_move -= alloc_size; | 955 | len_to_move -= alloc_size; |
| 951 | } | 956 | } |
| 952 | 957 | ||
| 958 | done: | ||
| 953 | range->me_flags |= OCFS2_MOVE_EXT_FL_COMPLETE; | 959 | range->me_flags |= OCFS2_MOVE_EXT_FL_COMPLETE; |
| 954 | 960 | ||
| 955 | out: | 961 | out: |
| @@ -1098,13 +1104,17 @@ int ocfs2_ioctl_move_extents(struct file *filp, void __user *argp) | |||
| 1098 | 1104 | ||
| 1099 | if (range.me_flags & OCFS2_MOVE_EXT_FL_AUTO_DEFRAG) { | 1105 | if (range.me_flags & OCFS2_MOVE_EXT_FL_AUTO_DEFRAG) { |
| 1100 | context->auto_defrag = 1; | 1106 | context->auto_defrag = 1; |
| 1107 | /* | ||
| 1108 | * ok, the default theshold for the defragmentation | ||
| 1109 | * is 1M, since our maximum clustersize was 1M also. | ||
| 1110 | * any thought? | ||
| 1111 | */ | ||
| 1101 | if (!range.me_threshold) | 1112 | if (!range.me_threshold) |
| 1102 | /* | ||
| 1103 | * ok, the default theshold for the defragmentation | ||
| 1104 | * is 1M, since our maximum clustersize was 1M also. | ||
| 1105 | * any thought? | ||
| 1106 | */ | ||
| 1107 | range.me_threshold = 1024 * 1024; | 1113 | range.me_threshold = 1024 * 1024; |
| 1114 | |||
| 1115 | if (range.me_threshold > i_size_read(inode)) | ||
| 1116 | range.me_threshold = i_size_read(inode); | ||
| 1117 | |||
| 1108 | if (range.me_flags & OCFS2_MOVE_EXT_FL_PART_DEFRAG) | 1118 | if (range.me_flags & OCFS2_MOVE_EXT_FL_PART_DEFRAG) |
| 1109 | context->partial = 1; | 1119 | context->partial = 1; |
| 1110 | } else { | 1120 | } else { |
