diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2017-09-13 07:34:46 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2017-09-13 07:34:46 +0000 |
commit | 65ce74ebd4c06567bea3a6a4e843ad37a59c1bd3 (patch) | |
tree | 9f77c29fdb7599f413181f1a9fea9081b48ff5ee | |
parent | 1af0c23c7455a8ca5a992c9d5d8e09fa795cf5f3 (diff) | |
parent | 98e42725761e4df326851f08a491f553619debdf (diff) | |
download | extras-65ce74ebd4c06567bea3a6a4e843ad37a59c1bd3.tar.gz |
release-request-b613f8ce-05b5-465e-b783-c1b87f3c1e95-for-git_oc-mr1-release-4332123 snap-temp-L59300000101925107
Change-Id: I1cfa0cc86fa4379670b6a761cfa4e2b798c73c0c
-rw-r--r-- | ext4_utils/allocate.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/ext4_utils/allocate.c b/ext4_utils/allocate.c index 28fc8e50..6bd77fa5 100644 --- a/ext4_utils/allocate.c +++ b/ext4_utils/allocate.c @@ -231,16 +231,20 @@ static int reserve_blocks(struct block_group_info *bg, u32 bg_num, u32 start, u3 static void free_blocks(struct block_group_info *bg, u32 block, u32 num_blocks) { unsigned int i; + + if (num_blocks == 0) + return; for (i = 0; i < num_blocks; i++, block--) bg->block_bitmap[block / 8] &= ~(1 << (block % 8)); bg->free_blocks += num_blocks; + block++; for (i = bg->chunk_count; i > 0 ;) { --i; if (bg->chunks[i].len >= num_blocks && bg->chunks[i].block <= block) { if (bg->chunks[i].block == block) { bg->chunks[i].block += num_blocks; bg->chunks[i].len -= num_blocks; - } else if (bg->chunks[i].block + bg->chunks[i].len - 1 == block + num_blocks) { + } else if (bg->chunks[i].block + bg->chunks[i].len == block + num_blocks) { bg->chunks[i].len -= num_blocks; } break; |