diff options
-rw-r--r-- | ext4_utils/allocate.c | 14 | ||||
-rw-r--r-- | ext4_utils/allocate.h | 1 | ||||
-rw-r--r-- | ext4_utils/extent.c | 2 |
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; |