Commit 4ec5934e authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: Make btrfs_unlink_inode take btrfs_inode

Signed-off-by: default avatarNikolay Borisov <n.borisov.lkml@gmail.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 51cc0d32
...@@ -3127,7 +3127,7 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry); ...@@ -3127,7 +3127,7 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry);
int btrfs_set_inode_index(struct inode *dir, u64 *index); int btrfs_set_inode_index(struct inode *dir, u64 *index);
int btrfs_unlink_inode(struct btrfs_trans_handle *trans, int btrfs_unlink_inode(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_root *root,
struct inode *dir, struct inode *inode, struct btrfs_inode *dir, struct btrfs_inode *inode,
const char *name, int name_len); const char *name, int name_len);
int btrfs_add_link(struct btrfs_trans_handle *trans, int btrfs_add_link(struct btrfs_trans_handle *trans,
struct inode *parent_inode, struct inode *inode, struct inode *parent_inode, struct inode *inode,
......
...@@ -3981,7 +3981,8 @@ noinline int btrfs_update_inode_fallback(struct btrfs_trans_handle *trans, ...@@ -3981,7 +3981,8 @@ noinline int btrfs_update_inode_fallback(struct btrfs_trans_handle *trans,
*/ */
static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans, static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_root *root,
struct inode *dir, struct inode *inode, struct btrfs_inode *dir,
struct btrfs_inode *inode,
const char *name, int name_len) const char *name, int name_len)
{ {
struct btrfs_fs_info *fs_info = root->fs_info; struct btrfs_fs_info *fs_info = root->fs_info;
...@@ -3991,8 +3992,8 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans, ...@@ -3991,8 +3992,8 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans,
struct btrfs_dir_item *di; struct btrfs_dir_item *di;
struct btrfs_key key; struct btrfs_key key;
u64 index; u64 index;
u64 ino = btrfs_ino(BTRFS_I(inode)); u64 ino = btrfs_ino(inode);
u64 dir_ino = btrfs_ino(BTRFS_I(dir)); u64 dir_ino = btrfs_ino(dir);
path = btrfs_alloc_path(); path = btrfs_alloc_path();
if (!path) { if (!path) {
...@@ -4028,10 +4029,10 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans, ...@@ -4028,10 +4029,10 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans,
* that we delay to delete it, and just do this deletion when * that we delay to delete it, and just do this deletion when
* we update the inode item. * we update the inode item.
*/ */
if (BTRFS_I(inode)->dir_index) { if (inode->dir_index) {
ret = btrfs_delayed_delete_inode_ref(BTRFS_I(inode)); ret = btrfs_delayed_delete_inode_ref(inode);
if (!ret) { if (!ret) {
index = BTRFS_I(inode)->dir_index; index = inode->dir_index;
goto skip_backref; goto skip_backref;
} }
} }
...@@ -4046,21 +4047,21 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans, ...@@ -4046,21 +4047,21 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans,
goto err; goto err;
} }
skip_backref: skip_backref:
ret = btrfs_delete_delayed_dir_index(trans, fs_info, BTRFS_I(dir), index); ret = btrfs_delete_delayed_dir_index(trans, fs_info, dir, index);
if (ret) { if (ret) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto err; goto err;
} }
ret = btrfs_del_inode_ref_in_log(trans, root, name, name_len, ret = btrfs_del_inode_ref_in_log(trans, root, name, name_len, inode,
BTRFS_I(inode), dir_ino); dir_ino);
if (ret != 0 && ret != -ENOENT) { if (ret != 0 && ret != -ENOENT) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto err; goto err;
} }
ret = btrfs_del_dir_entries_in_log(trans, root, name, name_len, ret = btrfs_del_dir_entries_in_log(trans, root, name, name_len, dir,
BTRFS_I(dir), index); index);
if (ret == -ENOENT) if (ret == -ENOENT)
ret = 0; ret = 0;
else if (ret) else if (ret)
...@@ -4070,26 +4071,27 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans, ...@@ -4070,26 +4071,27 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans,
if (ret) if (ret)
goto out; goto out;
btrfs_i_size_write(dir, dir->i_size - name_len * 2); btrfs_i_size_write(&dir->vfs_inode,
inode_inc_iversion(inode); dir->vfs_inode.i_size - name_len * 2);
inode_inc_iversion(dir); inode_inc_iversion(&inode->vfs_inode);
inode->i_ctime = dir->i_mtime = inode_inc_iversion(&dir->vfs_inode);
dir->i_ctime = current_time(inode); inode->vfs_inode.i_ctime = dir->vfs_inode.i_mtime =
ret = btrfs_update_inode(trans, root, dir); dir->vfs_inode.i_ctime = current_time(&inode->vfs_inode);
ret = btrfs_update_inode(trans, root, &dir->vfs_inode);
out: out:
return ret; return ret;
} }
int btrfs_unlink_inode(struct btrfs_trans_handle *trans, int btrfs_unlink_inode(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_root *root,
struct inode *dir, struct inode *inode, struct btrfs_inode *dir, struct btrfs_inode *inode,
const char *name, int name_len) const char *name, int name_len)
{ {
int ret; int ret;
ret = __btrfs_unlink_inode(trans, root, dir, inode, name, name_len); ret = __btrfs_unlink_inode(trans, root, dir, inode, name, name_len);
if (!ret) { if (!ret) {
drop_nlink(inode); drop_nlink(&inode->vfs_inode);
ret = btrfs_update_inode(trans, root, inode); ret = btrfs_update_inode(trans, root, &inode->vfs_inode);
} }
return ret; return ret;
} }
...@@ -4127,10 +4129,12 @@ static int btrfs_unlink(struct inode *dir, struct dentry *dentry) ...@@ -4127,10 +4129,12 @@ static int btrfs_unlink(struct inode *dir, struct dentry *dentry)
if (IS_ERR(trans)) if (IS_ERR(trans))
return PTR_ERR(trans); return PTR_ERR(trans);
btrfs_record_unlink_dir(trans, BTRFS_I(dir), BTRFS_I(d_inode(dentry)), 0); btrfs_record_unlink_dir(trans, BTRFS_I(dir), BTRFS_I(d_inode(dentry)),
0);
ret = btrfs_unlink_inode(trans, root, dir, d_inode(dentry), ret = btrfs_unlink_inode(trans, root, BTRFS_I(dir),
dentry->d_name.name, dentry->d_name.len); BTRFS_I(d_inode(dentry)), dentry->d_name.name,
dentry->d_name.len);
if (ret) if (ret)
goto out; goto out;
...@@ -4259,8 +4263,9 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry) ...@@ -4259,8 +4263,9 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry)
last_unlink_trans = BTRFS_I(inode)->last_unlink_trans; last_unlink_trans = BTRFS_I(inode)->last_unlink_trans;
/* now the directory is empty */ /* now the directory is empty */
err = btrfs_unlink_inode(trans, root, dir, d_inode(dentry), err = btrfs_unlink_inode(trans, root, BTRFS_I(dir),
dentry->d_name.name, dentry->d_name.len); BTRFS_I(d_inode(dentry)), dentry->d_name.name,
dentry->d_name.len);
if (!err) { if (!err) {
btrfs_i_size_write(inode, 0); btrfs_i_size_write(inode, 0);
/* /*
...@@ -9599,8 +9604,8 @@ static int btrfs_rename_exchange(struct inode *old_dir, ...@@ -9599,8 +9604,8 @@ static int btrfs_rename_exchange(struct inode *old_dir,
old_dentry->d_name.name, old_dentry->d_name.name,
old_dentry->d_name.len); old_dentry->d_name.len);
} else { /* src is an inode */ } else { /* src is an inode */
ret = __btrfs_unlink_inode(trans, root, old_dir, ret = __btrfs_unlink_inode(trans, root, BTRFS_I(old_dir),
old_dentry->d_inode, BTRFS_I(old_dentry->d_inode),
old_dentry->d_name.name, old_dentry->d_name.name,
old_dentry->d_name.len); old_dentry->d_name.len);
if (!ret) if (!ret)
...@@ -9619,8 +9624,8 @@ static int btrfs_rename_exchange(struct inode *old_dir, ...@@ -9619,8 +9624,8 @@ static int btrfs_rename_exchange(struct inode *old_dir,
new_dentry->d_name.name, new_dentry->d_name.name,
new_dentry->d_name.len); new_dentry->d_name.len);
} else { /* dest is an inode */ } else { /* dest is an inode */
ret = __btrfs_unlink_inode(trans, dest, new_dir, ret = __btrfs_unlink_inode(trans, dest, BTRFS_I(new_dir),
new_dentry->d_inode, BTRFS_I(new_dentry->d_inode),
new_dentry->d_name.name, new_dentry->d_name.name,
new_dentry->d_name.len); new_dentry->d_name.len);
if (!ret) if (!ret)
...@@ -9875,8 +9880,8 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -9875,8 +9880,8 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
old_dentry->d_name.name, old_dentry->d_name.name,
old_dentry->d_name.len); old_dentry->d_name.len);
} else { } else {
ret = __btrfs_unlink_inode(trans, root, old_dir, ret = __btrfs_unlink_inode(trans, root, BTRFS_I(old_dir),
d_inode(old_dentry), BTRFS_I(d_inode(old_dentry)),
old_dentry->d_name.name, old_dentry->d_name.name,
old_dentry->d_name.len); old_dentry->d_name.len);
if (!ret) if (!ret)
...@@ -9899,8 +9904,8 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -9899,8 +9904,8 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
new_dentry->d_name.len); new_dentry->d_name.len);
BUG_ON(new_inode->i_nlink == 0); BUG_ON(new_inode->i_nlink == 0);
} else { } else {
ret = btrfs_unlink_inode(trans, dest, new_dir, ret = btrfs_unlink_inode(trans, dest, BTRFS_I(new_dir),
d_inode(new_dentry), BTRFS_I(d_inode(new_dentry)),
new_dentry->d_name.name, new_dentry->d_name.name,
new_dentry->d_name.len); new_dentry->d_name.len);
} }
......
...@@ -875,7 +875,8 @@ static noinline int drop_one_dir_item(struct btrfs_trans_handle *trans, ...@@ -875,7 +875,8 @@ static noinline int drop_one_dir_item(struct btrfs_trans_handle *trans,
if (ret) if (ret)
goto out; goto out;
ret = btrfs_unlink_inode(trans, root, dir, inode, name, name_len); ret = btrfs_unlink_inode(trans, root, BTRFS_I(dir), BTRFS_I(inode),
name, name_len);
if (ret) if (ret)
goto out; goto out;
else else
...@@ -1050,9 +1051,9 @@ static inline int __add_inode_ref(struct btrfs_trans_handle *trans, ...@@ -1050,9 +1051,9 @@ static inline int __add_inode_ref(struct btrfs_trans_handle *trans,
inc_nlink(inode); inc_nlink(inode);
btrfs_release_path(path); btrfs_release_path(path);
ret = btrfs_unlink_inode(trans, root, dir, ret = btrfs_unlink_inode(trans, root,
inode, victim_name, BTRFS_I(dir), BTRFS_I(inode),
victim_name_len); victim_name, victim_name_len);
kfree(victim_name); kfree(victim_name);
if (ret) if (ret)
return ret; return ret;
...@@ -1121,10 +1122,10 @@ static inline int __add_inode_ref(struct btrfs_trans_handle *trans, ...@@ -1121,10 +1122,10 @@ static inline int __add_inode_ref(struct btrfs_trans_handle *trans,
btrfs_release_path(path); btrfs_release_path(path);
ret = btrfs_unlink_inode(trans, root, ret = btrfs_unlink_inode(trans, root,
victim_parent, BTRFS_I(victim_parent),
inode, BTRFS_I(inode),
victim_name, victim_name,
victim_name_len); victim_name_len);
if (!ret) if (!ret)
ret = btrfs_run_delayed_items( ret = btrfs_run_delayed_items(
trans, trans,
...@@ -2052,8 +2053,8 @@ static noinline int check_item_in_log(struct btrfs_trans_handle *trans, ...@@ -2052,8 +2053,8 @@ static noinline int check_item_in_log(struct btrfs_trans_handle *trans,
} }
inc_nlink(inode); inc_nlink(inode);
ret = btrfs_unlink_inode(trans, root, dir, inode, ret = btrfs_unlink_inode(trans, root, BTRFS_I(dir),
name, name_len); BTRFS_I(inode), name, name_len);
if (!ret) if (!ret)
ret = btrfs_run_delayed_items(trans, fs_info); ret = btrfs_run_delayed_items(trans, fs_info);
kfree(name); kfree(name);
......
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