aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/ocfs2/alloc.c29
1 files changed, 6 insertions, 23 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index 778a850b4634..33d5cab5e690 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -354,7 +354,6 @@ struct ocfs2_insert_type {
354 enum ocfs2_append_type ins_appending; 354 enum ocfs2_append_type ins_appending;
355 enum ocfs2_contig_type ins_contig; 355 enum ocfs2_contig_type ins_contig;
356 int ins_contig_index; 356 int ins_contig_index;
357 int ins_free_records;
358 int ins_tree_depth; 357 int ins_tree_depth;
359}; 358};
360 359
@@ -3593,6 +3592,7 @@ static int ocfs2_figure_insert_type(struct inode *inode,
3593 struct buffer_head *di_bh, 3592 struct buffer_head *di_bh,
3594 struct buffer_head **last_eb_bh, 3593 struct buffer_head **last_eb_bh,
3595 struct ocfs2_extent_rec *insert_rec, 3594 struct ocfs2_extent_rec *insert_rec,
3595 int *free_records,
3596 struct ocfs2_insert_type *insert) 3596 struct ocfs2_insert_type *insert)
3597{ 3597{
3598 int ret; 3598 int ret;
@@ -3633,7 +3633,7 @@ static int ocfs2_figure_insert_type(struct inode *inode,
3633 * XXX: This test is simplistic, we can search for empty 3633 * XXX: This test is simplistic, we can search for empty
3634 * extent records too. 3634 * extent records too.
3635 */ 3635 */
3636 insert->ins_free_records = le16_to_cpu(el->l_count) - 3636 *free_records = le16_to_cpu(el->l_count) -
3637 le16_to_cpu(el->l_next_free_rec); 3637 le16_to_cpu(el->l_next_free_rec);
3638 3638
3639 if (!insert->ins_tree_depth) { 3639 if (!insert->ins_tree_depth) {
@@ -3730,6 +3730,7 @@ int ocfs2_insert_extent(struct ocfs2_super *osb,
3730 struct ocfs2_alloc_context *meta_ac) 3730 struct ocfs2_alloc_context *meta_ac)
3731{ 3731{
3732 int status; 3732 int status;
3733 int uninitialized_var(free_records);
3733 struct buffer_head *last_eb_bh = NULL; 3734 struct buffer_head *last_eb_bh = NULL;
3734 struct ocfs2_insert_type insert = {0, }; 3735 struct ocfs2_insert_type insert = {0, };
3735 struct ocfs2_extent_rec rec; 3736 struct ocfs2_extent_rec rec;
@@ -3752,7 +3753,7 @@ int ocfs2_insert_extent(struct ocfs2_super *osb,
3752 rec.e_flags = flags; 3753 rec.e_flags = flags;
3753 3754
3754 status = ocfs2_figure_insert_type(inode, fe_bh, &last_eb_bh, &rec, 3755 status = ocfs2_figure_insert_type(inode, fe_bh, &last_eb_bh, &rec,
3755 &insert); 3756 &free_records, &insert);
3756 if (status < 0) { 3757 if (status < 0) {
3757 mlog_errno(status); 3758 mlog_errno(status);
3758 goto bail; 3759 goto bail;
@@ -3762,9 +3763,9 @@ int ocfs2_insert_extent(struct ocfs2_super *osb,
3762 "Insert.contig_index: %d, Insert.free_records: %d, " 3763 "Insert.contig_index: %d, Insert.free_records: %d, "
3763 "Insert.tree_depth: %d\n", 3764 "Insert.tree_depth: %d\n",
3764 insert.ins_appending, insert.ins_contig, insert.ins_contig_index, 3765 insert.ins_appending, insert.ins_contig, insert.ins_contig_index,
3765 insert.ins_free_records, insert.ins_tree_depth); 3766 free_records, insert.ins_tree_depth);
3766 3767
3767 if (insert.ins_contig == CONTIG_NONE && insert.ins_free_records == 0) { 3768 if (insert.ins_contig == CONTIG_NONE && free_records == 0) {
3768 status = ocfs2_grow_tree(inode, handle, fe_bh, 3769 status = ocfs2_grow_tree(inode, handle, fe_bh,
3769 &insert.ins_tree_depth, &last_eb_bh, 3770 &insert.ins_tree_depth, &last_eb_bh,
3770 meta_ac); 3771 meta_ac);
@@ -3847,26 +3848,17 @@ leftright:
3847 3848
3848 if (le16_to_cpu(rightmost_el->l_next_free_rec) == 3849 if (le16_to_cpu(rightmost_el->l_next_free_rec) ==
3849 le16_to_cpu(rightmost_el->l_count)) { 3850 le16_to_cpu(rightmost_el->l_count)) {
3850 int old_depth = depth;
3851
3852 ret = ocfs2_grow_tree(inode, handle, di_bh, &depth, last_eb_bh, 3851 ret = ocfs2_grow_tree(inode, handle, di_bh, &depth, last_eb_bh,
3853 meta_ac); 3852 meta_ac);
3854 if (ret) { 3853 if (ret) {
3855 mlog_errno(ret); 3854 mlog_errno(ret);
3856 goto out; 3855 goto out;
3857 } 3856 }
3858
3859 if (old_depth != depth) {
3860 eb = (struct ocfs2_extent_block *)(*last_eb_bh)->b_data;
3861 rightmost_el = &eb->h_list;
3862 }
3863 } 3857 }
3864 3858
3865 memset(&insert, 0, sizeof(struct ocfs2_insert_type)); 3859 memset(&insert, 0, sizeof(struct ocfs2_insert_type));
3866 insert.ins_appending = APPEND_NONE; 3860 insert.ins_appending = APPEND_NONE;
3867 insert.ins_contig = CONTIG_NONE; 3861 insert.ins_contig = CONTIG_NONE;
3868 insert.ins_free_records = le16_to_cpu(rightmost_el->l_count)
3869 - le16_to_cpu(rightmost_el->l_next_free_rec);
3870 insert.ins_tree_depth = depth; 3862 insert.ins_tree_depth = depth;
3871 3863
3872 insert_range = le32_to_cpu(split_rec.e_cpos) + 3864 insert_range = le32_to_cpu(split_rec.e_cpos) +
@@ -4180,27 +4172,18 @@ static int ocfs2_split_tree(struct inode *inode, struct buffer_head *di_bh,
4180 4172
4181 if (le16_to_cpu(rightmost_el->l_next_free_rec) == 4173 if (le16_to_cpu(rightmost_el->l_next_free_rec) ==
4182 le16_to_cpu(rightmost_el->l_count)) { 4174 le16_to_cpu(rightmost_el->l_count)) {
4183 int old_depth = depth;
4184
4185 ret = ocfs2_grow_tree(inode, handle, di_bh, &depth, &last_eb_bh, 4175 ret = ocfs2_grow_tree(inode, handle, di_bh, &depth, &last_eb_bh,
4186 meta_ac); 4176 meta_ac);
4187 if (ret) { 4177 if (ret) {
4188 mlog_errno(ret); 4178 mlog_errno(ret);
4189 goto out; 4179 goto out;
4190 } 4180 }
4191
4192 if (old_depth != depth) {
4193 eb = (struct ocfs2_extent_block *)last_eb_bh->b_data;
4194 rightmost_el = &eb->h_list;
4195 }
4196 } 4181 }
4197 4182
4198 memset(&insert, 0, sizeof(struct ocfs2_insert_type)); 4183 memset(&insert, 0, sizeof(struct ocfs2_insert_type));
4199 insert.ins_appending = APPEND_NONE; 4184 insert.ins_appending = APPEND_NONE;
4200 insert.ins_contig = CONTIG_NONE; 4185 insert.ins_contig = CONTIG_NONE;
4201 insert.ins_split = SPLIT_RIGHT; 4186 insert.ins_split = SPLIT_RIGHT;
4202 insert.ins_free_records = le16_to_cpu(rightmost_el->l_count)
4203 - le16_to_cpu(rightmost_el->l_next_free_rec);
4204 insert.ins_tree_depth = depth; 4187 insert.ins_tree_depth = depth;
4205 4188
4206 ret = ocfs2_do_insert_extent(inode, handle, di_bh, &split_rec, &insert); 4189 ret = ocfs2_do_insert_extent(inode, handle, di_bh, &split_rec, &insert);