Commit 81512e89 authored by Omar Sandoval's avatar Omar Sandoval Committed by David Sterba

btrfs: get rid of btrfs_add_nondir()

This is a trivial wrapper around btrfs_add_link(). The only thing it
does other than moving arguments around is translating a > 0 return
value to -EEXIST. As far as I can tell, btrfs_add_link() won't return >
0 (and if it did, the existing callsites in, e.g., btrfs_mkdir() would
be broken). The check itself dates back to commit 2c90e5d6 ("Btrfs:
still corruption hunting"), so it's probably left over from debugging.
Let's just get rid of btrfs_add_nondir().
Reviewed-by: default avatarSweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: default avatarOmar Sandoval <osandov@fb.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 2256e901
...@@ -6350,18 +6350,6 @@ int btrfs_add_link(struct btrfs_trans_handle *trans, ...@@ -6350,18 +6350,6 @@ int btrfs_add_link(struct btrfs_trans_handle *trans,
return ret; return ret;
} }
static int btrfs_add_nondir(struct btrfs_trans_handle *trans,
struct btrfs_inode *dir, struct dentry *dentry,
struct btrfs_inode *inode, int backref, u64 index)
{
int err = btrfs_add_link(trans, dir, inode,
dentry->d_name.name, dentry->d_name.len,
backref, index);
if (err > 0)
err = -EEXIST;
return err;
}
static int btrfs_mknod(struct user_namespace *mnt_userns, struct inode *dir, static int btrfs_mknod(struct user_namespace *mnt_userns, struct inode *dir,
struct dentry *dentry, umode_t mode, dev_t rdev) struct dentry *dentry, umode_t mode, dev_t rdev)
{ {
...@@ -6408,8 +6396,8 @@ static int btrfs_mknod(struct user_namespace *mnt_userns, struct inode *dir, ...@@ -6408,8 +6396,8 @@ static int btrfs_mknod(struct user_namespace *mnt_userns, struct inode *dir,
if (err) if (err)
goto out_unlock; goto out_unlock;
err = btrfs_add_nondir(trans, BTRFS_I(dir), dentry, BTRFS_I(inode), err = btrfs_add_link(trans, BTRFS_I(dir), BTRFS_I(inode),
0, index); dentry->d_name.name, dentry->d_name.len, 0, index);
if (err) if (err)
goto out_unlock; goto out_unlock;
...@@ -6476,8 +6464,8 @@ static int btrfs_create(struct user_namespace *mnt_userns, struct inode *dir, ...@@ -6476,8 +6464,8 @@ static int btrfs_create(struct user_namespace *mnt_userns, struct inode *dir,
if (err) if (err)
goto out_unlock; goto out_unlock;
err = btrfs_add_nondir(trans, BTRFS_I(dir), dentry, BTRFS_I(inode), err = btrfs_add_link(trans, BTRFS_I(dir), BTRFS_I(inode),
0, index); dentry->d_name.name, dentry->d_name.len, 0, index);
if (err) if (err)
goto out_unlock; goto out_unlock;
...@@ -6536,8 +6524,8 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir, ...@@ -6536,8 +6524,8 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
ihold(inode); ihold(inode);
set_bit(BTRFS_INODE_COPY_EVERYTHING, &BTRFS_I(inode)->runtime_flags); set_bit(BTRFS_INODE_COPY_EVERYTHING, &BTRFS_I(inode)->runtime_flags);
err = btrfs_add_nondir(trans, BTRFS_I(dir), dentry, BTRFS_I(inode), err = btrfs_add_link(trans, BTRFS_I(dir), BTRFS_I(inode),
1, index); dentry->d_name.name, dentry->d_name.len, 1, index);
if (err) { if (err) {
drop_inode = 1; drop_inode = 1;
...@@ -9317,8 +9305,8 @@ static int btrfs_whiteout_for_rename(struct btrfs_trans_handle *trans, ...@@ -9317,8 +9305,8 @@ static int btrfs_whiteout_for_rename(struct btrfs_trans_handle *trans,
if (ret) if (ret)
goto out; goto out;
ret = btrfs_add_nondir(trans, BTRFS_I(dir), dentry, ret = btrfs_add_link(trans, BTRFS_I(dir), BTRFS_I(inode),
BTRFS_I(inode), 0, index); dentry->d_name.name, dentry->d_name.len, 0, index);
if (ret) if (ret)
goto out; goto out;
...@@ -9856,8 +9844,9 @@ static int btrfs_symlink(struct user_namespace *mnt_userns, struct inode *dir, ...@@ -9856,8 +9844,9 @@ static int btrfs_symlink(struct user_namespace *mnt_userns, struct inode *dir,
* elsewhere above. * elsewhere above.
*/ */
if (!err) if (!err)
err = btrfs_add_nondir(trans, BTRFS_I(dir), dentry, err = btrfs_add_link(trans, BTRFS_I(dir), BTRFS_I(inode),
BTRFS_I(inode), 0, index); dentry->d_name.name, dentry->d_name.len, 0,
index);
if (err) if (err)
goto out_unlock; goto out_unlock;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment