summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohamad Ayyash <mkayyash@google.com>2016-04-29 11:14:02 -0700
committerMohamad Ayyash <mkayyash@google.com>2016-04-29 11:14:02 -0700
commitf7124d6c955c0453361b0ff47c5c94619e68087f (patch)
treee7423d7166f3ef6dd0fa2aa9d3d28c080ac22f7a
parentd2ed02a94086e1221041bc59825add3d0a657e19 (diff)
downloadextras-f7124d6c955c0453361b0ff47c5c94619e68087f.tar.gz
Incr Ext4: Properly merge block_allocation lists
BUG: 27698960 Change-Id: Ia31b8319e0d1c8644ae1798116007a4b35c39e9b Signed-off-by: Mohamad Ayyash <mkayyash@google.com>
-rw-r--r--ext4_utils/allocate.c14
-rw-r--r--ext4_utils/allocate.h1
-rw-r--r--ext4_utils/extent.c2
3 files changed, 16 insertions, 1 deletions
diff --git a/ext4_utils/allocate.c b/ext4_utils/allocate.c
index f5fd4fa0..497f580e 100644
--- a/ext4_utils/allocate.c
+++ b/ext4_utils/allocate.c
@@ -97,6 +97,20 @@ void region_list_append(struct region_list *list, struct region *reg)
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 cac543f5..4a733d00 100644
--- a/ext4_utils/allocate.h
+++ b/ext4_utils/allocate.h
@@ -94,6 +94,7 @@ void append_region(struct block_allocation *alloc,
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 42ddd97d..78874882 100644
--- a/ext4_utils/extent.c
+++ b/ext4_utils/extent.c
@@ -96,7 +96,7 @@ static struct block_allocation *do_inode_allocate_extents(
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;