static int read_one_block_group(struct btrfs_fs_info *info,
struct btrfs_block_group_item_v2 *bgi,
- const struct btrfs_key *key,
- bool need_clear)
+ const struct btrfs_key *key)
{
struct btrfs_block_group *cache;
const bool mixed = btrfs_fs_incompat(info, MIXED_GROUPS);
btrfs_set_free_space_tree_thresholds(cache);
- if (need_clear) {
- /*
- * When we mount with old space cache, we need to
- * set BTRFS_DC_CLEAR and set dirty flag.
- *
- * a) Setting 'BTRFS_DC_CLEAR' makes sure that we
- * truncate the old free space cache inode and
- * setup a new one.
- * b) Setting 'dirty flag' makes sure that we flush
- * the new space cache info onto disk.
- */
- if (btrfs_test_opt(info, SPACE_CACHE))
- cache->disk_cache_state = BTRFS_DC_CLEAR;
- }
if (!mixed && ((cache->flags & BTRFS_BLOCK_GROUP_METADATA) &&
(cache->flags & BTRFS_BLOCK_GROUP_DATA))) {
btrfs_err(info,
struct btrfs_block_group *cache;
struct btrfs_space_info *space_info;
struct btrfs_key key;
- bool need_clear = false;
- u64 cache_gen;
/*
* Either no extent root (with ibadroots rescue option) or we have
if (!path)
return -ENOMEM;
- cache_gen = btrfs_super_cache_generation(info->super_copy);
- if (btrfs_test_opt(info, SPACE_CACHE) &&
- btrfs_super_generation(info->super_copy) != cache_gen)
- need_clear = true;
- if (btrfs_test_opt(info, CLEAR_CACHE))
- need_clear = true;
-
while (1) {
struct btrfs_block_group_item_v2 bgi;
struct extent_buffer *leaf;
btrfs_item_key_to_cpu(leaf, &key, slot);
btrfs_release_path(path);
- ret = read_one_block_group(info, &bgi, &key, need_clear);
+ ret = read_one_block_group(info, &bgi, &key);
if (ret < 0)
goto error;
key.objectid += key.offset;
spin_lock(&space_info->lock);
spin_lock(&cache->lock);
- if (btrfs_test_opt(info, SPACE_CACHE) &&
- cache->disk_cache_state < BTRFS_DC_CLEAR)
- cache->disk_cache_state = BTRFS_DC_CLEAR;
-
old_val = cache->used;
if (alloc) {
old_val += num_bytes;
struct btrfs_inode;
struct btrfs_trans_handle;
-enum btrfs_disk_cache_state {
- BTRFS_DC_WRITTEN,
- BTRFS_DC_ERROR,
- BTRFS_DC_CLEAR,
- BTRFS_DC_SETUP,
-};
-
enum btrfs_block_group_size_class {
/* Unset */
BTRFS_BG_SZ_NONE,
u64 delalloc_bytes;
u64 bytes_super;
u64 flags;
- u64 cache_generation;
u64 global_root_id;
u64 remap_bytes;
u32 identity_remap_count;
unsigned long full_stripe_len;
unsigned long runtime_flags;
- enum btrfs_disk_cache_state disk_cache_state;
-
/* Cache tracking stuff */
enum btrfs_caching_type cached;
struct btrfs_caching_control *caching_ctl;
{
struct btrfs_fs_info *fs_info = block_group->fs_info;
struct inode *inode = NULL;
- u32 flags = BTRFS_INODE_NODATASUM | BTRFS_INODE_NODATACOW;
spin_lock(&block_group->lock);
if (block_group->inode)
return inode;
spin_lock(&block_group->lock);
- if (!((BTRFS_I(inode)->flags & flags) == flags)) {
- btrfs_info(fs_info, "Old style space inode found, converting.");
- BTRFS_I(inode)->flags |= BTRFS_INODE_NODATASUM |
- BTRFS_INODE_NODATACOW;
- block_group->disk_cache_state = BTRFS_DC_CLEAR;
- }
-
if (!test_and_set_bit(BLOCK_GROUP_FLAG_IREF, &block_group->runtime_flags))
block_group->inode = BTRFS_I(igrab(inode));
spin_unlock(&block_group->lock);