mirror of https://github.com/torvalds/linux.git
btrfs: remove redundant zero/NULL initializations in btrfs_alloc_root()
We have allocated the root with kzalloc() so all the memory is already
zero initialized, therefore it's redundant to assign 0 and NULL to several
of the root members. Remove all of them except the atomic initializations
since atomic_t is an opaque type and it's not a good practice to assume
its internals.
This slightly reduces the binary size.
With gcc 14.2.0-19 from Debian on x86_64, before this change:
$ size fs/btrfs/btrfs.ko
text data bss dec hex filename
1939404 162963 15592 2117959 205147 fs/btrfs/btrfs.ko
After this change:
$ size fs/btrfs/btrfs.ko
text data bss dec hex filename
1939212 162963 15592 2117767 205087 fs/btrfs/btrfs.ko
Reviewed-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
10934c131f
commit
1c3e03b340
|
|
@ -652,20 +652,10 @@ static struct btrfs_root *btrfs_alloc_root(struct btrfs_fs_info *fs_info,
|
|||
if (!root)
|
||||
return NULL;
|
||||
|
||||
memset(&root->root_key, 0, sizeof(root->root_key));
|
||||
memset(&root->root_item, 0, sizeof(root->root_item));
|
||||
memset(&root->defrag_progress, 0, sizeof(root->defrag_progress));
|
||||
root->fs_info = fs_info;
|
||||
root->root_key.objectid = objectid;
|
||||
root->node = NULL;
|
||||
root->commit_root = NULL;
|
||||
root->state = 0;
|
||||
RB_CLEAR_NODE(&root->rb_node);
|
||||
|
||||
btrfs_set_root_last_trans(root, 0);
|
||||
root->free_objectid = 0;
|
||||
root->nr_delalloc_inodes = 0;
|
||||
root->nr_ordered_extents = 0;
|
||||
xa_init(&root->inodes);
|
||||
xa_init(&root->delayed_nodes);
|
||||
|
||||
|
|
@ -699,10 +689,7 @@ static struct btrfs_root *btrfs_alloc_root(struct btrfs_fs_info *fs_info,
|
|||
refcount_set(&root->refs, 1);
|
||||
atomic_set(&root->snapshot_force_cow, 0);
|
||||
atomic_set(&root->nr_swapfiles, 0);
|
||||
btrfs_set_root_log_transid(root, 0);
|
||||
root->log_transid_committed = -1;
|
||||
btrfs_set_root_last_log_commit(root, 0);
|
||||
root->anon_dev = 0;
|
||||
if (!btrfs_is_testing(fs_info)) {
|
||||
btrfs_extent_io_tree_init(fs_info, &root->dirty_log_pages,
|
||||
IO_TREE_ROOT_DIRTY_LOG_PAGES);
|
||||
|
|
|
|||
Loading…
Reference in New Issue