Incr Ext4: Properly merge block_allocation lists
am: f7124d6c95
* commit 'f7124d6c955c0453361b0ff47c5c94619e68087f':
Incr Ext4: Properly merge block_allocation lists
Change-Id: I9d343f1762c183aaf4cacd9f7fd613af174896e3
diff --git a/ext4_utils/allocate.c b/ext4_utils/allocate.c
index f5fd4fa..497f580 100644
--- a/ext4_utils/allocate.c
+++ b/ext4_utils/allocate.c
@@ -97,6 +97,20 @@
reg->next = NULL;
}
+void region_list_merge(struct region_list *list1, struct region_list *list2)
+{
+ if (list1->first == NULL) {
+ list1->first = list2->first;
+ list1->last = list2->last;
+ list1->iter = list2->first;
+ list1->partial_iter = 0;
+ list1->first->prev = NULL;
+ } else {
+ list1->last->next = list2->first;
+ list2->first->prev = list1->last;
+ list1->last = list2->last;
+ }
+}
#if 0
static void dump_starting_from(struct region *reg)
{
diff --git a/ext4_utils/allocate.h b/ext4_utils/allocate.h
index cac543f..4a733d0 100644
--- a/ext4_utils/allocate.h
+++ b/ext4_utils/allocate.h
@@ -94,6 +94,7 @@
struct block_allocation *create_allocation();
int append_oob_allocation(struct block_allocation *alloc, u32 len);
void region_list_append(struct region_list *list, struct region *reg);
+void region_list_merge(struct region_list *list1, struct region_list *list2);
void print_blocks(FILE* f, struct block_allocation *alloc, char separator);
void reserve_bg_chunk(int bg, u32 start_block, u32 size);
int reserve_blocks_for_allocation(struct block_allocation *alloc);
diff --git a/ext4_utils/extent.c b/ext4_utils/extent.c
index 42ddd97..7887488 100644
--- a/ext4_utils/extent.c
+++ b/ext4_utils/extent.c
@@ -96,7 +96,7 @@
block_len + 1 - prealloc_block_len);
return NULL;
}
- region_list_append(&prealloc->list, alloc->list.first);
+ region_list_merge(&prealloc->list, &alloc->list);
free(alloc);
}
alloc = prealloc;