diff options
author | David Sterba <dsterba@suse.com> | 2019-10-23 18:48:15 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2019-11-18 17:51:45 +0100 |
commit | 3d976388daa9ed77c9d2ded914ad07385b37d97e (patch) | |
tree | 42a5a30a670c4aaa806baaa30d31279b9ab58e19 /fs/btrfs | |
parent | btrfs: move block_group_item::flags to block group (diff) | |
download | linux-3d976388daa9ed77c9d2ded914ad07385b37d97e.tar.xz linux-3d976388daa9ed77c9d2ded914ad07385b37d97e.zip |
btrfs: remove embedded block_group_cache::item
The members ::used and ::flags are now in the block group cache
structure, the last one is chunk_objectid, but that's set to a fixed
value and otherwise unused. The item is constructed from a local
variable before write, so we can remove the embedded one from block
group.
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/block-group.c | 16 | ||||
-rw-r--r-- | fs/btrfs/block-group.h | 1 |
2 files changed, 5 insertions, 12 deletions
diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c index 52e2a05c8345..0bb1cc5f3263 100644 --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c @@ -1752,8 +1752,7 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info) read_extent_buffer(leaf, &bgi, btrfs_item_ptr_offset(leaf, path->slots[0]), sizeof(bgi)); - /* Duplicate as the item is still partially used */ - memcpy(&cache->item, &bgi, sizeof(bgi)); + /* cache::chunk_objectid is unused */ cache->used = btrfs_block_group_used(&bgi); cache->flags = btrfs_block_group_flags(&bgi); if (!mixed && @@ -1879,12 +1878,9 @@ void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans) goto next; spin_lock(&block_group->lock); - /* - * Copy partially filled item from the cache and ovewrite used - * that has the correct value - */ - memcpy(&item, &block_group->item, sizeof(item)); btrfs_set_block_group_used(&item, block_group->used); + btrfs_set_block_group_chunk_objectid(&item, + BTRFS_FIRST_CHUNK_TREE_OBJECTID); btrfs_set_block_group_flags(&item, block_group->flags); memcpy(&key, &block_group->key, sizeof(key)); spin_unlock(&block_group->lock); @@ -1919,8 +1915,6 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans, u64 bytes_used, return -ENOMEM; cache->used = bytes_used; - btrfs_set_block_group_chunk_objectid(&cache->item, - BTRFS_FIRST_CHUNK_TREE_OBJECTID); cache->flags = type; cache->last_byte_to_unpin = (u64)-1; cache->cached = BTRFS_CACHE_FINISHED; @@ -2136,9 +2130,9 @@ static int write_one_cache_group(struct btrfs_trans_handle *trans, leaf = path->nodes[0]; bi = btrfs_item_ptr_offset(leaf, path->slots[0]); - /* Partial copy of item, update the rest from memory */ - memcpy(&bgi, &cache->item, sizeof(bgi)); btrfs_set_block_group_used(&bgi, cache->used); + btrfs_set_block_group_chunk_objectid(&bgi, + BTRFS_FIRST_CHUNK_TREE_OBJECTID); btrfs_set_block_group_flags(&bgi, cache->flags); write_extent_buffer(leaf, &bgi, bi, sizeof(bgi)); btrfs_mark_buffer_dirty(leaf); diff --git a/fs/btrfs/block-group.h b/fs/btrfs/block-group.h index 8fa4a70228ee..d78fce7cd3a4 100644 --- a/fs/btrfs/block-group.h +++ b/fs/btrfs/block-group.h @@ -44,7 +44,6 @@ struct btrfs_caching_control { struct btrfs_block_group_cache { struct btrfs_key key; - struct btrfs_block_group_item item; struct btrfs_fs_info *fs_info; struct inode *inode; spinlock_t lock; |