btrfs: set inode flags earlier in btrfs_new_inode()
btrfs_new_inode() inherits the inode flags from the parent directory and the mount options _after_ we fill the inode item. This works because all of the callers of btrfs_new_inode() make further changes to the inode and then call btrfs_update_inode(). It'd be better to fully initialize the inode once to avoid the extra update, so as a first step, set the inode flags _before_ filling the inode item. Reviewed-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me> Signed-off-by: Omar Sandoval <osandov@fb.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
6437d45835
commit
305eaac009
|
@ -6156,6 +6156,16 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
|
|||
BTRFS_I(inode)->generation = trans->transid;
|
||||
inode->i_generation = BTRFS_I(inode)->generation;
|
||||
|
||||
btrfs_inherit_iflags(inode, dir);
|
||||
|
||||
if (S_ISREG(mode)) {
|
||||
if (btrfs_test_opt(fs_info, NODATASUM))
|
||||
BTRFS_I(inode)->flags |= BTRFS_INODE_NODATASUM;
|
||||
if (btrfs_test_opt(fs_info, NODATACOW))
|
||||
BTRFS_I(inode)->flags |= BTRFS_INODE_NODATACOW |
|
||||
BTRFS_INODE_NODATASUM;
|
||||
}
|
||||
|
||||
/*
|
||||
* We could have gotten an inode number from somebody who was fsynced
|
||||
* and then removed in this same transaction, so let's just set full
|
||||
|
@ -6231,16 +6241,6 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
|
|||
btrfs_mark_buffer_dirty(path->nodes[0]);
|
||||
btrfs_free_path(path);
|
||||
|
||||
btrfs_inherit_iflags(inode, dir);
|
||||
|
||||
if (S_ISREG(mode)) {
|
||||
if (btrfs_test_opt(fs_info, NODATASUM))
|
||||
BTRFS_I(inode)->flags |= BTRFS_INODE_NODATASUM;
|
||||
if (btrfs_test_opt(fs_info, NODATACOW))
|
||||
BTRFS_I(inode)->flags |= BTRFS_INODE_NODATACOW |
|
||||
BTRFS_INODE_NODATASUM;
|
||||
}
|
||||
|
||||
inode_tree_add(inode);
|
||||
|
||||
trace_btrfs_inode_new(inode);
|
||||
|
|
Loading…
Reference in New Issue