mirror of
https://github.com/torvalds/linux.git
synced 2024-11-15 08:31:55 +00:00
btrfs: move btrfs_get_free_objectid() call into btrfs_new_inode()
Every call of btrfs_new_inode() is immediately preceded by a call to
btrfs_get_free_objectid(). Since getting an inode number is part of
creating a new inode, this is better off being moved into
btrfs_new_inode(). While we're here, get rid of the comment about
reclaiming inode numbers, since we only did that when using the ino
cache, which was removed by commit 5297199a8b
("btrfs: remove inode
number cache feature").
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
23c24ef8e4
commit
6437d45835
@ -6090,13 +6090,14 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
|
||||
struct user_namespace *mnt_userns,
|
||||
struct inode *dir,
|
||||
const char *name, int name_len,
|
||||
u64 objectid, umode_t mode, u64 *index)
|
||||
umode_t mode, u64 *index)
|
||||
{
|
||||
struct btrfs_fs_info *fs_info = root->fs_info;
|
||||
struct inode *inode;
|
||||
struct btrfs_inode_item *inode_item;
|
||||
struct btrfs_key *location;
|
||||
struct btrfs_path *path;
|
||||
u64 objectid;
|
||||
struct btrfs_inode_ref *ref;
|
||||
struct btrfs_key key[2];
|
||||
u32 sizes[2];
|
||||
@ -6124,10 +6125,12 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
|
||||
if (!name)
|
||||
set_nlink(inode, 0);
|
||||
|
||||
/*
|
||||
* we have to initialize this early, so we can reclaim the inode
|
||||
* number if we fail afterwards in this function.
|
||||
*/
|
||||
ret = btrfs_get_free_objectid(root, &objectid);
|
||||
if (ret) {
|
||||
btrfs_free_path(path);
|
||||
iput(inode);
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
inode->i_ino = objectid;
|
||||
|
||||
if (dir && name) {
|
||||
@ -6359,7 +6362,6 @@ static int btrfs_mknod(struct user_namespace *mnt_userns, struct inode *dir,
|
||||
struct btrfs_root *root = BTRFS_I(dir)->root;
|
||||
struct inode *inode = NULL;
|
||||
int err;
|
||||
u64 objectid;
|
||||
u64 index = 0;
|
||||
|
||||
/*
|
||||
@ -6371,13 +6373,9 @@ static int btrfs_mknod(struct user_namespace *mnt_userns, struct inode *dir,
|
||||
if (IS_ERR(trans))
|
||||
return PTR_ERR(trans);
|
||||
|
||||
err = btrfs_get_free_objectid(root, &objectid);
|
||||
if (err)
|
||||
goto out_unlock;
|
||||
|
||||
inode = btrfs_new_inode(trans, root, mnt_userns, dir,
|
||||
dentry->d_name.name, dentry->d_name.len,
|
||||
objectid, mode, &index);
|
||||
mode, &index);
|
||||
if (IS_ERR(inode)) {
|
||||
err = PTR_ERR(inode);
|
||||
inode = NULL;
|
||||
@ -6423,7 +6421,6 @@ static int btrfs_create(struct user_namespace *mnt_userns, struct inode *dir,
|
||||
struct btrfs_root *root = BTRFS_I(dir)->root;
|
||||
struct inode *inode = NULL;
|
||||
int err;
|
||||
u64 objectid;
|
||||
u64 index = 0;
|
||||
|
||||
/*
|
||||
@ -6435,13 +6432,9 @@ static int btrfs_create(struct user_namespace *mnt_userns, struct inode *dir,
|
||||
if (IS_ERR(trans))
|
||||
return PTR_ERR(trans);
|
||||
|
||||
err = btrfs_get_free_objectid(root, &objectid);
|
||||
if (err)
|
||||
goto out_unlock;
|
||||
|
||||
inode = btrfs_new_inode(trans, root, mnt_userns, dir,
|
||||
dentry->d_name.name, dentry->d_name.len,
|
||||
objectid, mode, &index);
|
||||
mode, &index);
|
||||
if (IS_ERR(inode)) {
|
||||
err = PTR_ERR(inode);
|
||||
inode = NULL;
|
||||
@ -6568,7 +6561,6 @@ static int btrfs_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
|
||||
struct btrfs_trans_handle *trans;
|
||||
struct btrfs_root *root = BTRFS_I(dir)->root;
|
||||
int err = 0;
|
||||
u64 objectid = 0;
|
||||
u64 index = 0;
|
||||
|
||||
/*
|
||||
@ -6580,13 +6572,8 @@ static int btrfs_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
|
||||
if (IS_ERR(trans))
|
||||
return PTR_ERR(trans);
|
||||
|
||||
err = btrfs_get_free_objectid(root, &objectid);
|
||||
if (err)
|
||||
goto out_fail;
|
||||
|
||||
inode = btrfs_new_inode(trans, root, mnt_userns, dir,
|
||||
dentry->d_name.name, dentry->d_name.len,
|
||||
objectid,
|
||||
S_IFDIR | mode, &index);
|
||||
if (IS_ERR(inode)) {
|
||||
err = PTR_ERR(inode);
|
||||
@ -8764,14 +8751,8 @@ int btrfs_create_subvol_root(struct btrfs_trans_handle *trans,
|
||||
struct inode *inode;
|
||||
int err;
|
||||
u64 index = 0;
|
||||
u64 ino;
|
||||
|
||||
err = btrfs_get_free_objectid(new_root, &ino);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
inode = btrfs_new_inode(trans, new_root, mnt_userns, NULL, "..", 2,
|
||||
ino,
|
||||
S_IFDIR | (~current_umask() & S_IRWXUGO),
|
||||
&index);
|
||||
if (IS_ERR(inode))
|
||||
@ -9274,17 +9255,11 @@ static int btrfs_whiteout_for_rename(struct btrfs_trans_handle *trans,
|
||||
{
|
||||
int ret;
|
||||
struct inode *inode;
|
||||
u64 objectid;
|
||||
u64 index;
|
||||
|
||||
ret = btrfs_get_free_objectid(root, &objectid);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
inode = btrfs_new_inode(trans, root, mnt_userns, dir,
|
||||
dentry->d_name.name,
|
||||
dentry->d_name.len,
|
||||
objectid,
|
||||
S_IFCHR | WHITEOUT_MODE,
|
||||
&index);
|
||||
|
||||
@ -9748,7 +9723,6 @@ static int btrfs_symlink(struct user_namespace *mnt_userns, struct inode *dir,
|
||||
struct btrfs_key key;
|
||||
struct inode *inode = NULL;
|
||||
int err;
|
||||
u64 objectid;
|
||||
u64 index = 0;
|
||||
int name_len;
|
||||
int datasize;
|
||||
@ -9771,13 +9745,8 @@ static int btrfs_symlink(struct user_namespace *mnt_userns, struct inode *dir,
|
||||
if (IS_ERR(trans))
|
||||
return PTR_ERR(trans);
|
||||
|
||||
err = btrfs_get_free_objectid(root, &objectid);
|
||||
if (err)
|
||||
goto out_unlock;
|
||||
|
||||
inode = btrfs_new_inode(trans, root, mnt_userns, dir,
|
||||
dentry->d_name.name, dentry->d_name.len,
|
||||
objectid,
|
||||
S_IFLNK | S_IRWXUGO, &index);
|
||||
if (IS_ERR(inode)) {
|
||||
err = PTR_ERR(inode);
|
||||
@ -10107,7 +10076,6 @@ static int btrfs_tmpfile(struct user_namespace *mnt_userns, struct inode *dir,
|
||||
struct btrfs_trans_handle *trans;
|
||||
struct btrfs_root *root = BTRFS_I(dir)->root;
|
||||
struct inode *inode = NULL;
|
||||
u64 objectid;
|
||||
u64 index;
|
||||
int ret = 0;
|
||||
|
||||
@ -10118,12 +10086,8 @@ static int btrfs_tmpfile(struct user_namespace *mnt_userns, struct inode *dir,
|
||||
if (IS_ERR(trans))
|
||||
return PTR_ERR(trans);
|
||||
|
||||
ret = btrfs_get_free_objectid(root, &objectid);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
inode = btrfs_new_inode(trans, root, mnt_userns, dir, NULL, 0,
|
||||
objectid, mode, &index);
|
||||
mode, &index);
|
||||
if (IS_ERR(inode)) {
|
||||
ret = PTR_ERR(inode);
|
||||
inode = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user