From 9b25940b9d4e73c4d66461018536dfba97c1e212 Mon Sep 17 00:00:00 2001 From: Chris Mason Date: Wed, 30 May 2007 10:21:32 -0400 Subject: [PATCH] data vs metadata flag for block groups --- btrfsck.c | 5 ++++- ctree.h | 5 ++++- mkfs.c | 7 ++++++- print-tree.c | 4 ++-- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/btrfsck.c b/btrfsck.c index bdb8b301..580fe440 100644 --- a/btrfsck.c +++ b/btrfsck.c @@ -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), diff --git a/ctree.h b/ctree.h index c3f8c525..68edbaa6 100644 --- a/ctree.h +++ b/ctree.h @@ -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 { diff --git a/mkfs.c b/mkfs.c index e21eecae..1d5c0d6c 100644 --- a/mkfs.c +++ b/mkfs.c @@ -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);