aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/free-space-cache.c
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fusionio.com>2013-08-26 17:14:08 -0400
committerChris Mason <chris.mason@fusionio.com>2013-09-01 08:16:33 -0400
commitb12d6869f67a95692017d26313ea5736d4043d0f (patch)
treec8f7dcce4abd830fc964e99f527a8b877049316c /fs/btrfs/free-space-cache.c
parent2e17c7c65e5dcbb53a6384a3406244f62bca189c (diff)
Btrfs: convert all bug_ons in free-space-cache.c
All of these are logic checks to make sure we're not breaking anything, so convert them over to ASSERT(). Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs/btrfs/free-space-cache.c')
-rw-r--r--fs/btrfs/free-space-cache.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 23182648976b..ef3bea7bb257 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -308,7 +308,7 @@ static void io_ctl_unmap_page(struct io_ctl *io_ctl)
308 308
309static void io_ctl_map_page(struct io_ctl *io_ctl, int clear) 309static void io_ctl_map_page(struct io_ctl *io_ctl, int clear)
310{ 310{
311 BUG_ON(io_ctl->index >= io_ctl->num_pages); 311 ASSERT(io_ctl->index < io_ctl->num_pages);
312 io_ctl->page = io_ctl->pages[io_ctl->index++]; 312 io_ctl->page = io_ctl->pages[io_ctl->index++];
313 io_ctl->cur = kmap(io_ctl->page); 313 io_ctl->cur = kmap(io_ctl->page);
314 io_ctl->orig = io_ctl->cur; 314 io_ctl->orig = io_ctl->cur;
@@ -728,7 +728,7 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
728 goto free_cache; 728 goto free_cache;
729 } 729 }
730 } else { 730 } else {
731 BUG_ON(!num_bitmaps); 731 ASSERT(num_bitmaps);
732 num_bitmaps--; 732 num_bitmaps--;
733 e->bitmap = kzalloc(PAGE_CACHE_SIZE, GFP_NOFS); 733 e->bitmap = kzalloc(PAGE_CACHE_SIZE, GFP_NOFS);
734 if (!e->bitmap) { 734 if (!e->bitmap) {
@@ -1028,7 +1028,7 @@ static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode,
1028 leaf = path->nodes[0]; 1028 leaf = path->nodes[0];
1029 if (ret > 0) { 1029 if (ret > 0) {
1030 struct btrfs_key found_key; 1030 struct btrfs_key found_key;
1031 BUG_ON(!path->slots[0]); 1031 ASSERT(path->slots[0]);
1032 path->slots[0]--; 1032 path->slots[0]--;
1033 btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); 1033 btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]);
1034 if (found_key.objectid != BTRFS_FREE_SPACE_OBJECTID || 1034 if (found_key.objectid != BTRFS_FREE_SPACE_OBJECTID ||
@@ -1116,7 +1116,7 @@ int btrfs_write_out_cache(struct btrfs_root *root,
1116static inline unsigned long offset_to_bit(u64 bitmap_start, u32 unit, 1116static inline unsigned long offset_to_bit(u64 bitmap_start, u32 unit,
1117 u64 offset) 1117 u64 offset)
1118{ 1118{
1119 BUG_ON(offset < bitmap_start); 1119 ASSERT(offset >= bitmap_start);
1120 offset -= bitmap_start; 1120 offset -= bitmap_start;
1121 return (unsigned long)(div_u64(offset, unit)); 1121 return (unsigned long)(div_u64(offset, unit));
1122} 1122}
@@ -1271,7 +1271,7 @@ tree_search_offset(struct btrfs_free_space_ctl *ctl,
1271 if (n) { 1271 if (n) {
1272 entry = rb_entry(n, struct btrfs_free_space, 1272 entry = rb_entry(n, struct btrfs_free_space,
1273 offset_index); 1273 offset_index);
1274 BUG_ON(entry->offset > offset); 1274 ASSERT(entry->offset <= offset);
1275 } else { 1275 } else {
1276 if (fuzzy) 1276 if (fuzzy)
1277 return entry; 1277 return entry;
@@ -1335,7 +1335,7 @@ static int link_free_space(struct btrfs_free_space_ctl *ctl,
1335{ 1335{
1336 int ret = 0; 1336 int ret = 0;
1337 1337
1338 BUG_ON(!info->bitmap && !info->bytes); 1338 ASSERT(info->bytes || info->bitmap);
1339 ret = tree_insert_offset(&ctl->free_space_offset, info->offset, 1339 ret = tree_insert_offset(&ctl->free_space_offset, info->offset,
1340 &info->offset_index, (info->bitmap != NULL)); 1340 &info->offset_index, (info->bitmap != NULL));
1341 if (ret) 1341 if (ret)
@@ -1358,7 +1358,7 @@ static void recalculate_thresholds(struct btrfs_free_space_ctl *ctl)
1358 1358
1359 max_bitmaps = max(max_bitmaps, 1); 1359 max_bitmaps = max(max_bitmaps, 1);
1360 1360
1361 BUG_ON(ctl->total_bitmaps > max_bitmaps); 1361 ASSERT(ctl->total_bitmaps <= max_bitmaps);
1362 1362
1363 /* 1363 /*
1364 * The goal is to keep the total amount of memory used per 1gb of space 1364 * The goal is to keep the total amount of memory used per 1gb of space
@@ -1402,7 +1402,7 @@ static inline void __bitmap_clear_bits(struct btrfs_free_space_ctl *ctl,
1402 1402
1403 start = offset_to_bit(info->offset, ctl->unit, offset); 1403 start = offset_to_bit(info->offset, ctl->unit, offset);
1404 count = bytes_to_bits(bytes, ctl->unit); 1404 count = bytes_to_bits(bytes, ctl->unit);
1405 BUG_ON(start + count > BITS_PER_BITMAP); 1405 ASSERT(start + count <= BITS_PER_BITMAP);
1406 1406
1407 bitmap_clear(info->bitmap, start, count); 1407 bitmap_clear(info->bitmap, start, count);
1408 1408
@@ -1425,7 +1425,7 @@ static void bitmap_set_bits(struct btrfs_free_space_ctl *ctl,
1425 1425
1426 start = offset_to_bit(info->offset, ctl->unit, offset); 1426 start = offset_to_bit(info->offset, ctl->unit, offset);
1427 count = bytes_to_bits(bytes, ctl->unit); 1427 count = bytes_to_bits(bytes, ctl->unit);
1428 BUG_ON(start + count > BITS_PER_BITMAP); 1428 ASSERT(start + count <= BITS_PER_BITMAP);
1429 1429
1430 bitmap_set(info->bitmap, start, count); 1430 bitmap_set(info->bitmap, start, count);
1431 1431
@@ -1741,7 +1741,7 @@ no_cluster_bitmap:
1741 bitmap_info = tree_search_offset(ctl, offset_to_bitmap(ctl, offset), 1741 bitmap_info = tree_search_offset(ctl, offset_to_bitmap(ctl, offset),
1742 1, 0); 1742 1, 0);
1743 if (!bitmap_info) { 1743 if (!bitmap_info) {
1744 BUG_ON(added); 1744 ASSERT(added == 0);
1745 goto new_bitmap; 1745 goto new_bitmap;
1746 } 1746 }
1747 1747
@@ -1881,7 +1881,7 @@ out:
1881 1881
1882 if (ret) { 1882 if (ret) {
1883 printk(KERN_CRIT "btrfs: unable to add free space :%d\n", ret); 1883 printk(KERN_CRIT "btrfs: unable to add free space :%d\n", ret);
1884 BUG_ON(ret == -EEXIST); 1884 ASSERT(ret != -EEXIST);
1885 } 1885 }
1886 1886
1887 return ret; 1887 return ret;
@@ -2369,7 +2369,7 @@ again:
2369 rb_erase(&entry->offset_index, &ctl->free_space_offset); 2369 rb_erase(&entry->offset_index, &ctl->free_space_offset);
2370 ret = tree_insert_offset(&cluster->root, entry->offset, 2370 ret = tree_insert_offset(&cluster->root, entry->offset,
2371 &entry->offset_index, 1); 2371 &entry->offset_index, 1);
2372 BUG_ON(ret); /* -EEXIST; Logic error */ 2372 ASSERT(!ret); /* -EEXIST; Logic error */
2373 2373
2374 trace_btrfs_setup_cluster(block_group, cluster, 2374 trace_btrfs_setup_cluster(block_group, cluster,
2375 total_found * ctl->unit, 1); 2375 total_found * ctl->unit, 1);
@@ -2462,7 +2462,7 @@ setup_cluster_no_bitmap(struct btrfs_block_group_cache *block_group,
2462 ret = tree_insert_offset(&cluster->root, entry->offset, 2462 ret = tree_insert_offset(&cluster->root, entry->offset,
2463 &entry->offset_index, 0); 2463 &entry->offset_index, 0);
2464 total_size += entry->bytes; 2464 total_size += entry->bytes;
2465 BUG_ON(ret); /* -EEXIST; Logic error */ 2465 ASSERT(!ret); /* -EEXIST; Logic error */
2466 } while (node && entry != last); 2466 } while (node && entry != last);
2467 2467
2468 cluster->max_size = max_extent; 2468 cluster->max_size = max_extent;
@@ -2853,7 +2853,7 @@ u64 btrfs_find_ino_for_alloc(struct btrfs_root *fs_root)
2853 2853
2854 ret = search_bitmap(ctl, entry, &offset, &count); 2854 ret = search_bitmap(ctl, entry, &offset, &count);
2855 /* Logic error; Should be empty if it can't find anything */ 2855 /* Logic error; Should be empty if it can't find anything */
2856 BUG_ON(ret); 2856 ASSERT(!ret);
2857 2857
2858 ino = offset; 2858 ino = offset;
2859 bitmap_clear_bits(ctl, entry, offset, 1); 2859 bitmap_clear_bits(ctl, entry, offset, 1);