struct btrfs_block_group_item *bi;
bi = btrfs_item_ptr(leaf, i,
struct btrfs_block_group_item);
- fprintf(stderr,"block group %Lu %Lu used %Lu\n",
+ fprintf(stderr,"block group %Lu %Lu used %Lu ",
btrfs_disk_key_objectid(disk_key),
btrfs_disk_key_offset(disk_key),
btrfs_block_group_used(bi));
+ fprintf(stderr, "flags %x\n", bi->flags);
continue;
}
if (btrfs_disk_key_type(&leaf->items[i].key) !=
if (btrfs_file_extent_type(fi) !=
BTRFS_FILE_EXTENT_REG)
continue;
+ if (btrfs_file_extent_disk_blocknr(fi) == 0)
+ continue;
ret = add_extent_rec(extent_radix, NULL, blocknr,
btrfs_file_extent_disk_blocknr(fi),
btrfs_file_extent_disk_num_blocks(fi),
/* tag for the radix tree of block groups in ram */
#define BTRFS_BLOCK_GROUP_DIRTY 0
-#define BTRFS_BLOCK_GROUP_HINTS 8
#define BTRFS_BLOCK_GROUP_SIZE (256 * 1024 * 1024)
+
+
+#define BTRFS_BLOCK_GROUP_DATA 1
struct btrfs_block_group_item {
__le64 used;
+ u8 flags;
} __attribute__ ((__packed__));
struct btrfs_block_group_cache {
u64 total_blocks;
u64 cur_start;
int ret;
+ u64 nr = 0;
struct btrfs_block_group_cache *cache;
root = root->fs_info->extent_root;
cache->key.flags = 0;
btrfs_set_key_type(&cache->key, BTRFS_BLOCK_GROUP_ITEM_KEY);
memset(&cache->item, 0, sizeof(cache->item));
+ if (nr % 3)
+ cache->item.flags |= BTRFS_BLOCK_GROUP_DATA;
+
ret = radix_tree_insert(&root->fs_info->block_group_radix,
cur_start + group_size_blocks - 1,
(void *)cache);
BUG_ON(ret);
cur_start += group_size_blocks;
+ nr++;
}
/* then insert all the items */
cur_start = 0;
fprintf(stderr, "unable to find %s size\n", file);
exit(1);
}
+ block_count /= 4096;
}
- block_count /= 4096;
if (block_count < 256) {
fprintf(stderr, "device %s is too small\n", file);
exit(1);
case BTRFS_BLOCK_GROUP_ITEM_KEY:
bi = btrfs_item_ptr(l, i,
struct btrfs_block_group_item);
- printf("\t\tblock group used %Lu\n",
- btrfs_block_group_used(bi));
+ printf("\t\tblock group used %Lu flags %x\n",
+ btrfs_block_group_used(bi), bi->flags);
break;
case BTRFS_DEV_ITEM_KEY:
devi = btrfs_item_ptr(l, i, struct btrfs_device_item);