aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosef Bacik <josef@redhat.com>2011-05-13 14:49:23 -0400
committerJosef Bacik <josef@redhat.com>2011-05-23 13:03:16 -0400
commit207dde8289d9b005b665cb9d8d2bb9464256101d (patch)
treebbe7e61bdf6221468360c31ba293d50197745acb
parentcca1c81f43e26ab60c0d1090fb90992358d69bdf (diff)
Btrfs: check for duplicate entries in the free space cache
If there are duplicate entries in the free space cache, discard the entire cache and load it the old fashioned way. Thanks, Signed-off-by: Josef Bacik <josef@redhat.com>
-rw-r--r--fs/btrfs/free-space-cache.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 63731a1fb0a1..d634a7e42207 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -420,7 +420,14 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info,
420 spin_lock(&block_group->tree_lock); 420 spin_lock(&block_group->tree_lock);
421 ret = link_free_space(block_group, e); 421 ret = link_free_space(block_group, e);
422 spin_unlock(&block_group->tree_lock); 422 spin_unlock(&block_group->tree_lock);
423 BUG_ON(ret); 423 if (ret) {
424 printk(KERN_ERR "Duplicate entries in "
425 "free space cache, dumping\n");
426 kunmap(page);
427 unlock_page(page);
428 page_cache_release(page);
429 goto free_cache;
430 }
424 } else { 431 } else {
425 e->bitmap = kzalloc(PAGE_CACHE_SIZE, GFP_NOFS); 432 e->bitmap = kzalloc(PAGE_CACHE_SIZE, GFP_NOFS);
426 if (!e->bitmap) { 433 if (!e->bitmap) {
@@ -437,6 +444,14 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info,
437 recalculate_thresholds(block_group); 444 recalculate_thresholds(block_group);
438 spin_unlock(&block_group->tree_lock); 445 spin_unlock(&block_group->tree_lock);
439 list_add_tail(&e->list, &bitmaps); 446 list_add_tail(&e->list, &bitmaps);
447 if (ret) {
448 printk(KERN_ERR "Duplicate entries in "
449 "free space cache, dumping\n");
450 kunmap(page);
451 unlock_page(page);
452 page_cache_release(page);
453 goto free_cache;
454 }
440 } 455 }
441 456
442 num_entries--; 457 num_entries--;
@@ -909,10 +924,16 @@ static int tree_insert_offset(struct rb_root *root, u64 offset,
909 * logically. 924 * logically.
910 */ 925 */
911 if (bitmap) { 926 if (bitmap) {
912 WARN_ON(info->bitmap); 927 if (info->bitmap) {
928 WARN_ON_ONCE(1);
929 return -EEXIST;
930 }
913 p = &(*p)->rb_right; 931 p = &(*p)->rb_right;
914 } else { 932 } else {
915 WARN_ON(!info->bitmap); 933 if (!info->bitmap) {
934 WARN_ON_ONCE(1);
935 return -EEXIST;
936 }
916 p = &(*p)->rb_left; 937 p = &(*p)->rb_left;
917 } 938 }
918 } 939 }