data vs metadata flag for block groups

This commit is contained in:
Chris Mason 2007-05-30 10:21:32 -04:00 committed by David Woodhouse
parent 832427bdba
commit 9b25940b9d
4 changed files with 16 additions and 5 deletions

View file

@ -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),

View file

@ -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 {

7
mkfs.c
View file

@ -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);

View file

@ -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);