]> www.infradead.org Git - users/dwmw2/linux.git/commit
btrfs: unify index_cnt and csum_bytes from struct btrfs_inode
authorFilipe Manana <fdmanana@suse.com>
Tue, 30 Apr 2024 09:55:05 +0000 (10:55 +0100)
committerDavid Sterba <dsterba@suse.com>
Thu, 11 Jul 2024 13:33:17 +0000 (15:33 +0200)
commitd9891ae28b0d3d3a188c502d33f04c1fb3ffd950
tree66a73d8b4cb708fe54e82f3cda4c24e592c21dd6
parente2844cce75c9e61a27dcc29f0773afe970cde296
btrfs: unify index_cnt and csum_bytes from struct btrfs_inode

The index_cnt field of struct btrfs_inode is used only for two purposes:

1) To store the index for the next entry added to a directory;

2) For the data relocation inode to track the logical start address of the
   block group currently being relocated.

For the relocation case we use index_cnt because it's not used for
anything else in the relocation use case - we could have used other fields
that are not used by relocation such as defrag_bytes, last_unlink_trans
or last_reflink_trans for example (among others).

Since the csum_bytes field is not used for directories, do the following
changes:

1) Put index_cnt and csum_bytes in a union, and index_cnt is only
   initialized when the inode is a directory. The csum_bytes is only
   accessed in IO paths for regular files, so we're fine here;

2) Use the defrag_bytes field for relocation, since the data relocation
   inode is never used for defrag purposes. And to make the naming better,
   alias it to reloc_block_group_start by using a union.

This reduces the size of struct btrfs_inode by 8 bytes in a release
kernel, from 1056 bytes down to 1048 bytes.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/btrfs_inode.h
fs/btrfs/delayed-inode.c
fs/btrfs/inode.c
fs/btrfs/relocation.c
fs/btrfs/tree-log.c