• Filipe Manana's avatar
    btrfs: remove location key from struct btrfs_inode · 068fc8f9
    Filipe Manana authored
    Currently struct btrfs_inode has a key member, named "location", that is
    either:
    
    1) The key of the inode's item. In this case the objectid is the number
       of the inode;
    
    2) A key stored in a dir entry with a type of BTRFS_ROOT_ITEM_KEY, for
       the case where we have a root that is a snapshot of a subvolume that
       points to other subvolumes. In this case the objectid is the ID of
       a subvolume inside the snapshotted parent subvolume.
    
    The key is only used to lookup the inode item for the first case, while
    for the second it's never used since it corresponds to directory stubs
    created with new_simple_dir() and which are marked as dummy, so there's
    no actual inode item to ever update. In the second case we only check
    the key type at btrfs_ino() for 32 bits platforms and its objectid is
    only needed for unlink.
    
    Instead of using a key we can do fine with just the objectid, since we
    can generate the key whenever we need it having only the objectid, as
    in all use cases the type is always BTRFS_INODE_ITEM_KEY and the offset
    is always 0.
    
    So use only an objectid instead of a full key. This reduces the size of
    struct btrfs_inode from 1048 bytes down to 1040 bytes on a release kernel.
    Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    068fc8f9
btrfs_inode.h 20.8 KB