btrfs: reserve correct number of items for inode creation
authorOmar Sandoval <osandov@fb.com>
Tue, 15 Mar 2022 01:12:34 +0000 (18:12 -0700)
committerDavid Sterba <dsterba@suse.com>
Mon, 16 May 2022 15:03:08 +0000 (17:03 +0200)
commit3538d68dbd97a2f5599bf39aeee47f027417fc39
treeeb1126687925a136a5c1a13f15ed22abf6b833ae
parent5f465bf1f15aec52bed8d3e17738b303ae8e1a3c
btrfs: reserve correct number of items for inode creation

The various inode creation code paths do not account for the compression
property, POSIX ACLs, or the parent inode item when starting a
transaction. Fix it by refactoring all of these code paths to use a new
function, btrfs_new_inode_prepare(), which computes the correct number
of items. To do so, it needs to know whether POSIX ACLs will be created,
so move the ACL creation into that function. To reduce the number of
arguments that need to be passed around for inode creation, define
struct btrfs_new_inode_args containing all of the relevant information.

btrfs_new_inode_prepare() will also be a good place to set up the
fscrypt context and encrypted filename in the future.

Reviewed-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/acl.c
fs/btrfs/ctree.h
fs/btrfs/inode.c
fs/btrfs/ioctl.c