]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - fs/btrfs/free-space-cache.c
Merge branch 'akpm' (patches from Andrew Morton)
[karo-tx-linux.git] / fs / btrfs / free-space-cache.c
index 34ecc651c9abd2eff9674af6fafb56a4463cce84..3f0ddfce96e6ff2bdaaef019ea7ee00f9af070af 100644 (file)
@@ -221,12 +221,10 @@ int btrfs_truncate_free_space_cache(struct btrfs_root *root,
                                    struct btrfs_path *path,
                                    struct inode *inode)
 {
-       loff_t oldsize;
        int ret = 0;
 
-       oldsize = i_size_read(inode);
        btrfs_i_size_write(inode, 0);
-       truncate_pagecache(inode, oldsize, 0);
+       truncate_pagecache(inode, 0);
 
        /*
         * We don't need an orphan item because truncating the free space cache
@@ -308,7 +306,7 @@ static void io_ctl_unmap_page(struct io_ctl *io_ctl)
 
 static void io_ctl_map_page(struct io_ctl *io_ctl, int clear)
 {
-       BUG_ON(io_ctl->index >= io_ctl->num_pages);
+       ASSERT(io_ctl->index < io_ctl->num_pages);
        io_ctl->page = io_ctl->pages[io_ctl->index++];
        io_ctl->cur = kmap(io_ctl->page);
        io_ctl->orig = io_ctl->cur;
@@ -673,8 +671,7 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
                btrfs_err(root->fs_info,
                        "free space inode generation (%llu) "
                        "did not match free space cache generation (%llu)",
-                       (unsigned long long)BTRFS_I(inode)->generation,
-                       (unsigned long long)generation);
+                       BTRFS_I(inode)->generation, generation);
                return 0;
        }
 
@@ -729,7 +726,7 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
                                goto free_cache;
                        }
                } else {
-                       BUG_ON(!num_bitmaps);
+                       ASSERT(num_bitmaps);
                        num_bitmaps--;
                        e->bitmap = kzalloc(PAGE_CACHE_SIZE, GFP_NOFS);
                        if (!e->bitmap) {
@@ -1029,7 +1026,7 @@ static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode,
        leaf = path->nodes[0];
        if (ret > 0) {
                struct btrfs_key found_key;
-               BUG_ON(!path->slots[0]);
+               ASSERT(path->slots[0]);
                path->slots[0]--;
                btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]);
                if (found_key.objectid != BTRFS_FREE_SPACE_OBJECTID ||
@@ -1117,7 +1114,7 @@ int btrfs_write_out_cache(struct btrfs_root *root,
 static inline unsigned long offset_to_bit(u64 bitmap_start, u32 unit,
                                          u64 offset)
 {
-       BUG_ON(offset < bitmap_start);
+       ASSERT(offset >= bitmap_start);
        offset -= bitmap_start;
        return (unsigned long)(div_u64(offset, unit));
 }
@@ -1272,7 +1269,7 @@ tree_search_offset(struct btrfs_free_space_ctl *ctl,
                if (n) {
                        entry = rb_entry(n, struct btrfs_free_space,
                                        offset_index);
-                       BUG_ON(entry->offset > offset);
+                       ASSERT(entry->offset <= offset);
                } else {
                        if (fuzzy)
                                return entry;
@@ -1336,7 +1333,7 @@ static int link_free_space(struct btrfs_free_space_ctl *ctl,
 {
        int ret = 0;
 
-       BUG_ON(!info->bitmap && !info->bytes);
+       ASSERT(info->bytes || info->bitmap);
        ret = tree_insert_offset(&ctl->free_space_offset, info->offset,
                                 &info->offset_index, (info->bitmap != NULL));
        if (ret)
@@ -1359,7 +1356,7 @@ static void recalculate_thresholds(struct btrfs_free_space_ctl *ctl)
 
        max_bitmaps = max(max_bitmaps, 1);
 
-       BUG_ON(ctl->total_bitmaps > max_bitmaps);
+       ASSERT(ctl->total_bitmaps <= max_bitmaps);
 
        /*
         * The goal is to keep the total amount of memory used per 1gb of space
@@ -1403,7 +1400,7 @@ static inline void __bitmap_clear_bits(struct btrfs_free_space_ctl *ctl,
 
        start = offset_to_bit(info->offset, ctl->unit, offset);
        count = bytes_to_bits(bytes, ctl->unit);
-       BUG_ON(start + count > BITS_PER_BITMAP);
+       ASSERT(start + count <= BITS_PER_BITMAP);
 
        bitmap_clear(info->bitmap, start, count);
 
@@ -1426,7 +1423,7 @@ static void bitmap_set_bits(struct btrfs_free_space_ctl *ctl,
 
        start = offset_to_bit(info->offset, ctl->unit, offset);
        count = bytes_to_bits(bytes, ctl->unit);
-       BUG_ON(start + count > BITS_PER_BITMAP);
+       ASSERT(start + count <= BITS_PER_BITMAP);
 
        bitmap_set(info->bitmap, start, count);
 
@@ -1742,7 +1739,7 @@ no_cluster_bitmap:
        bitmap_info = tree_search_offset(ctl, offset_to_bitmap(ctl, offset),
                                         1, 0);
        if (!bitmap_info) {
-               BUG_ON(added);
+               ASSERT(added == 0);
                goto new_bitmap;
        }
 
@@ -1882,7 +1879,7 @@ out:
 
        if (ret) {
                printk(KERN_CRIT "btrfs: unable to add free space :%d\n", ret);
-               BUG_ON(ret == -EEXIST);
+               ASSERT(ret != -EEXIST);
        }
 
        return ret;
@@ -1991,8 +1988,7 @@ void btrfs_dump_free_space(struct btrfs_block_group_cache *block_group,
                if (info->bytes >= bytes && !block_group->ro)
                        count++;
                printk(KERN_CRIT "entry offset %llu, bytes %llu, bitmap %s\n",
-                      (unsigned long long)info->offset,
-                      (unsigned long long)info->bytes,
+                      info->offset, info->bytes,
                       (info->bitmap) ? "yes" : "no");
        }
        printk(KERN_INFO "block group has cluster?: %s\n",
@@ -2371,7 +2367,7 @@ again:
        rb_erase(&entry->offset_index, &ctl->free_space_offset);
        ret = tree_insert_offset(&cluster->root, entry->offset,
                                 &entry->offset_index, 1);
-       BUG_ON(ret); /* -EEXIST; Logic error */
+       ASSERT(!ret); /* -EEXIST; Logic error */
 
        trace_btrfs_setup_cluster(block_group, cluster,
                                  total_found * ctl->unit, 1);
@@ -2464,7 +2460,7 @@ setup_cluster_no_bitmap(struct btrfs_block_group_cache *block_group,
                ret = tree_insert_offset(&cluster->root, entry->offset,
                                         &entry->offset_index, 0);
                total_size += entry->bytes;
-               BUG_ON(ret); /* -EEXIST; Logic error */
+               ASSERT(!ret); /* -EEXIST; Logic error */
        } while (node && entry != last);
 
        cluster->max_size = max_extent;
@@ -2855,7 +2851,7 @@ u64 btrfs_find_ino_for_alloc(struct btrfs_root *fs_root)
 
                ret = search_bitmap(ctl, entry, &offset, &count);
                /* Logic error; Should be empty if it can't find anything */
-               BUG_ON(ret);
+               ASSERT(!ret);
 
                ino = offset;
                bitmap_clear_bits(ctl, entry, offset, 1);