diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-05-30 10:21:32 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-05-30 10:21:32 -0400 |
commit | 9b25940b9d4e73c4d66461018536dfba97c1e212 (patch) | |
tree | c158eb41b3df0949ddd7f85f842625adc6d3a872 | |
parent | 832427bdbad9c2e7ad9635ddc1cad05563d9d16a (diff) |
data vs metadata flag for block groups
-rw-r--r-- | btrfsck.c | 5 | ||||
-rw-r--r-- | ctree.h | 5 | ||||
-rw-r--r-- | mkfs.c | 7 | ||||
-rw-r--r-- | print-tree.c | 4 |
4 files changed, 16 insertions, 5 deletions
@@ -316,10 +316,11 @@ static int run_next_block(struct btrfs_root *root, 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) != @@ -330,6 +331,8 @@ static int run_next_block(struct btrfs_root *root, 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), @@ -240,10 +240,13 @@ struct btrfs_device_item { /* 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 { @@ -71,6 +71,7 @@ static int make_block_groups(struct btrfs_trans_handle *trans, u64 total_blocks; u64 cur_start; int ret; + u64 nr = 0; struct btrfs_block_group_cache *cache; root = root->fs_info->extent_root; @@ -97,11 +98,15 @@ static int make_block_groups(struct btrfs_trans_handle *trans, 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; @@ -378,8 +383,8 @@ int main(int ac, char **av) 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); diff --git a/print-tree.c b/print-tree.c index c313a0a9..35399cb3 100644 --- a/print-tree.c +++ b/print-tree.c @@ -110,8 +110,8 @@ void btrfs_print_leaf(struct btrfs_root *root, struct btrfs_leaf *l) 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); |