data vs metadata flag for block groups
This commit is contained in:
parent
832427bdba
commit
9b25940b9d
|
@ -316,10 +316,11 @@ static int run_next_block(struct btrfs_root *root,
|
||||||
struct btrfs_block_group_item *bi;
|
struct btrfs_block_group_item *bi;
|
||||||
bi = btrfs_item_ptr(leaf, i,
|
bi = btrfs_item_ptr(leaf, i,
|
||||||
struct btrfs_block_group_item);
|
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_objectid(disk_key),
|
||||||
btrfs_disk_key_offset(disk_key),
|
btrfs_disk_key_offset(disk_key),
|
||||||
btrfs_block_group_used(bi));
|
btrfs_block_group_used(bi));
|
||||||
|
fprintf(stderr, "flags %x\n", bi->flags);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (btrfs_disk_key_type(&leaf->items[i].key) !=
|
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) !=
|
if (btrfs_file_extent_type(fi) !=
|
||||||
BTRFS_FILE_EXTENT_REG)
|
BTRFS_FILE_EXTENT_REG)
|
||||||
continue;
|
continue;
|
||||||
|
if (btrfs_file_extent_disk_blocknr(fi) == 0)
|
||||||
|
continue;
|
||||||
ret = add_extent_rec(extent_radix, NULL, blocknr,
|
ret = add_extent_rec(extent_radix, NULL, blocknr,
|
||||||
btrfs_file_extent_disk_blocknr(fi),
|
btrfs_file_extent_disk_blocknr(fi),
|
||||||
btrfs_file_extent_disk_num_blocks(fi),
|
btrfs_file_extent_disk_num_blocks(fi),
|
||||||
|
|
5
ctree.h
5
ctree.h
|
@ -240,10 +240,13 @@ struct btrfs_device_item {
|
||||||
|
|
||||||
/* tag for the radix tree of block groups in ram */
|
/* tag for the radix tree of block groups in ram */
|
||||||
#define BTRFS_BLOCK_GROUP_DIRTY 0
|
#define BTRFS_BLOCK_GROUP_DIRTY 0
|
||||||
#define BTRFS_BLOCK_GROUP_HINTS 8
|
|
||||||
#define BTRFS_BLOCK_GROUP_SIZE (256 * 1024 * 1024)
|
#define BTRFS_BLOCK_GROUP_SIZE (256 * 1024 * 1024)
|
||||||
|
|
||||||
|
|
||||||
|
#define BTRFS_BLOCK_GROUP_DATA 1
|
||||||
struct btrfs_block_group_item {
|
struct btrfs_block_group_item {
|
||||||
__le64 used;
|
__le64 used;
|
||||||
|
u8 flags;
|
||||||
} __attribute__ ((__packed__));
|
} __attribute__ ((__packed__));
|
||||||
|
|
||||||
struct btrfs_block_group_cache {
|
struct btrfs_block_group_cache {
|
||||||
|
|
7
mkfs.c
7
mkfs.c
|
@ -71,6 +71,7 @@ static int make_block_groups(struct btrfs_trans_handle *trans,
|
||||||
u64 total_blocks;
|
u64 total_blocks;
|
||||||
u64 cur_start;
|
u64 cur_start;
|
||||||
int ret;
|
int ret;
|
||||||
|
u64 nr = 0;
|
||||||
struct btrfs_block_group_cache *cache;
|
struct btrfs_block_group_cache *cache;
|
||||||
|
|
||||||
root = root->fs_info->extent_root;
|
root = root->fs_info->extent_root;
|
||||||
|
@ -97,11 +98,15 @@ static int make_block_groups(struct btrfs_trans_handle *trans,
|
||||||
cache->key.flags = 0;
|
cache->key.flags = 0;
|
||||||
btrfs_set_key_type(&cache->key, BTRFS_BLOCK_GROUP_ITEM_KEY);
|
btrfs_set_key_type(&cache->key, BTRFS_BLOCK_GROUP_ITEM_KEY);
|
||||||
memset(&cache->item, 0, sizeof(cache->item));
|
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,
|
ret = radix_tree_insert(&root->fs_info->block_group_radix,
|
||||||
cur_start + group_size_blocks - 1,
|
cur_start + group_size_blocks - 1,
|
||||||
(void *)cache);
|
(void *)cache);
|
||||||
BUG_ON(ret);
|
BUG_ON(ret);
|
||||||
cur_start += group_size_blocks;
|
cur_start += group_size_blocks;
|
||||||
|
nr++;
|
||||||
}
|
}
|
||||||
/* then insert all the items */
|
/* then insert all the items */
|
||||||
cur_start = 0;
|
cur_start = 0;
|
||||||
|
@ -378,8 +383,8 @@ int main(int ac, char **av)
|
||||||
fprintf(stderr, "unable to find %s size\n", file);
|
fprintf(stderr, "unable to find %s size\n", file);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
block_count /= 4096;
|
||||||
}
|
}
|
||||||
block_count /= 4096;
|
|
||||||
if (block_count < 256) {
|
if (block_count < 256) {
|
||||||
fprintf(stderr, "device %s is too small\n", file);
|
fprintf(stderr, "device %s is too small\n", file);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
|
@ -110,8 +110,8 @@ void btrfs_print_leaf(struct btrfs_root *root, struct btrfs_leaf *l)
|
||||||
case BTRFS_BLOCK_GROUP_ITEM_KEY:
|
case BTRFS_BLOCK_GROUP_ITEM_KEY:
|
||||||
bi = btrfs_item_ptr(l, i,
|
bi = btrfs_item_ptr(l, i,
|
||||||
struct btrfs_block_group_item);
|
struct btrfs_block_group_item);
|
||||||
printf("\t\tblock group used %Lu\n",
|
printf("\t\tblock group used %Lu flags %x\n",
|
||||||
btrfs_block_group_used(bi));
|
btrfs_block_group_used(bi), bi->flags);
|
||||||
break;
|
break;
|
||||||
case BTRFS_DEV_ITEM_KEY:
|
case BTRFS_DEV_ITEM_KEY:
|
||||||
devi = btrfs_item_ptr(l, i, struct btrfs_device_item);
|
devi = btrfs_item_ptr(l, i, struct btrfs_device_item);
|
||||||
|
|
Loading…
Reference in New Issue