aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/free-space-cache.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/free-space-cache.c')
-rw-r--r--fs/btrfs/free-space-cache.c37
1 files changed, 16 insertions, 21 deletions
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 42f4015988ec..850104f05178 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -1175,6 +1175,16 @@ static void add_new_bitmap(struct btrfs_block_group_cache *block_group,
1175 recalculate_thresholds(block_group); 1175 recalculate_thresholds(block_group);
1176} 1176}
1177 1177
1178static void free_bitmap(struct btrfs_block_group_cache *block_group,
1179 struct btrfs_free_space *bitmap_info)
1180{
1181 unlink_free_space(block_group, bitmap_info);
1182 kfree(bitmap_info->bitmap);
1183 kfree(bitmap_info);
1184 block_group->total_bitmaps--;
1185 recalculate_thresholds(block_group);
1186}
1187
1178static noinline int remove_from_bitmap(struct btrfs_block_group_cache *block_group, 1188static noinline int remove_from_bitmap(struct btrfs_block_group_cache *block_group,
1179 struct btrfs_free_space *bitmap_info, 1189 struct btrfs_free_space *bitmap_info,
1180 u64 *offset, u64 *bytes) 1190 u64 *offset, u64 *bytes)
@@ -1215,13 +1225,8 @@ again:
1215 1225
1216 if (*bytes) { 1226 if (*bytes) {
1217 struct rb_node *next = rb_next(&bitmap_info->offset_index); 1227 struct rb_node *next = rb_next(&bitmap_info->offset_index);
1218 if (!bitmap_info->bytes) { 1228 if (!bitmap_info->bytes)
1219 unlink_free_space(block_group, bitmap_info); 1229 free_bitmap(block_group, bitmap_info);
1220 kfree(bitmap_info->bitmap);
1221 kfree(bitmap_info);
1222 block_group->total_bitmaps--;
1223 recalculate_thresholds(block_group);
1224 }
1225 1230
1226 /* 1231 /*
1227 * no entry after this bitmap, but we still have bytes to 1232 * no entry after this bitmap, but we still have bytes to
@@ -1254,13 +1259,8 @@ again:
1254 return -EAGAIN; 1259 return -EAGAIN;
1255 1260
1256 goto again; 1261 goto again;
1257 } else if (!bitmap_info->bytes) { 1262 } else if (!bitmap_info->bytes)
1258 unlink_free_space(block_group, bitmap_info); 1263 free_bitmap(block_group, bitmap_info);
1259 kfree(bitmap_info->bitmap);
1260 kfree(bitmap_info);
1261 block_group->total_bitmaps--;
1262 recalculate_thresholds(block_group);
1263 }
1264 1264
1265 return 0; 1265 return 0;
1266} 1266}
@@ -1689,13 +1689,8 @@ u64 btrfs_find_space_for_alloc(struct btrfs_block_group_cache *block_group,
1689 ret = offset; 1689 ret = offset;
1690 if (entry->bitmap) { 1690 if (entry->bitmap) {
1691 bitmap_clear_bits(block_group, entry, offset, bytes); 1691 bitmap_clear_bits(block_group, entry, offset, bytes);
1692 if (!entry->bytes) { 1692 if (!entry->bytes)
1693 unlink_free_space(block_group, entry); 1693 free_bitmap(block_group, entry);
1694 kfree(entry->bitmap);
1695 kfree(entry);
1696 block_group->total_bitmaps--;
1697 recalculate_thresholds(block_group);
1698 }
1699 } else { 1694 } else {
1700 unlink_free_space(block_group, entry); 1695 unlink_free_space(block_group, entry);
1701 entry->offset += bytes; 1696 entry->offset += bytes;