Commit db0a669f authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: Make btrfs_add_link take btrfs_inode

Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 9e3e97f4
...@@ -3129,7 +3129,7 @@ int btrfs_unlink_inode(struct btrfs_trans_handle *trans, ...@@ -3129,7 +3129,7 @@ int btrfs_unlink_inode(struct btrfs_trans_handle *trans,
struct btrfs_inode *dir, struct btrfs_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 btrfs_inode *parent_inode, struct btrfs_inode *inode,
const char *name, int name_len, int add_backref, u64 index); const char *name, int name_len, int add_backref, u64 index);
int btrfs_unlink_subvol(struct btrfs_trans_handle *trans, int btrfs_unlink_subvol(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_root *root,
......
...@@ -6251,18 +6251,18 @@ static inline u8 btrfs_inode_type(struct inode *inode) ...@@ -6251,18 +6251,18 @@ static inline u8 btrfs_inode_type(struct inode *inode)
* inode to the parent directory. * inode to the parent directory.
*/ */
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 btrfs_inode *parent_inode, struct btrfs_inode *inode,
const char *name, int name_len, int add_backref, u64 index) const char *name, int name_len, int add_backref, u64 index)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
int ret = 0; int ret = 0;
struct btrfs_key key; struct btrfs_key key;
struct btrfs_root *root = BTRFS_I(parent_inode)->root; struct btrfs_root *root = parent_inode->root;
u64 ino = btrfs_ino(BTRFS_I(inode)); u64 ino = btrfs_ino(inode);
u64 parent_ino = btrfs_ino(BTRFS_I(parent_inode)); u64 parent_ino = btrfs_ino(parent_inode);
if (unlikely(ino == BTRFS_FIRST_FREE_OBJECTID)) { if (unlikely(ino == BTRFS_FIRST_FREE_OBJECTID)) {
memcpy(&key, &BTRFS_I(inode)->root->root_key, sizeof(key)); memcpy(&key, &inode->root->root_key, sizeof(key));
} else { } else {
key.objectid = ino; key.objectid = ino;
key.type = BTRFS_INODE_ITEM_KEY; key.type = BTRFS_INODE_ITEM_KEY;
...@@ -6283,8 +6283,8 @@ int btrfs_add_link(struct btrfs_trans_handle *trans, ...@@ -6283,8 +6283,8 @@ int btrfs_add_link(struct btrfs_trans_handle *trans,
return ret; return ret;
ret = btrfs_insert_dir_item(trans, root, name, name_len, ret = btrfs_insert_dir_item(trans, root, name, name_len,
BTRFS_I(parent_inode), &key, parent_inode, &key,
btrfs_inode_type(inode), index); btrfs_inode_type(&inode->vfs_inode), index);
if (ret == -EEXIST || ret == -EOVERFLOW) if (ret == -EEXIST || ret == -EOVERFLOW)
goto fail_dir_item; goto fail_dir_item;
else if (ret) { else if (ret) {
...@@ -6292,12 +6292,12 @@ int btrfs_add_link(struct btrfs_trans_handle *trans, ...@@ -6292,12 +6292,12 @@ int btrfs_add_link(struct btrfs_trans_handle *trans,
return ret; return ret;
} }
btrfs_i_size_write(BTRFS_I(parent_inode), parent_inode->i_size + btrfs_i_size_write(parent_inode, parent_inode->vfs_inode.i_size +
name_len * 2); name_len * 2);
inode_inc_iversion(parent_inode); inode_inc_iversion(&parent_inode->vfs_inode);
parent_inode->i_mtime = parent_inode->i_ctime = parent_inode->vfs_inode.i_mtime = parent_inode->vfs_inode.i_ctime =
current_time(parent_inode); current_time(&parent_inode->vfs_inode);
ret = btrfs_update_inode(trans, root, parent_inode); ret = btrfs_update_inode(trans, root, &parent_inode->vfs_inode);
if (ret) if (ret)
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
return ret; return ret;
...@@ -6324,7 +6324,7 @@ static int btrfs_add_nondir(struct btrfs_trans_handle *trans, ...@@ -6324,7 +6324,7 @@ static int btrfs_add_nondir(struct btrfs_trans_handle *trans,
struct inode *dir, struct dentry *dentry, struct inode *dir, struct dentry *dentry,
struct inode *inode, int backref, u64 index) struct inode *inode, int backref, u64 index)
{ {
int err = btrfs_add_link(trans, dir, inode, int err = btrfs_add_link(trans, BTRFS_I(dir), BTRFS_I(inode),
dentry->d_name.name, dentry->d_name.len, dentry->d_name.name, dentry->d_name.len,
backref, index); backref, index);
if (err > 0) if (err > 0)
...@@ -6601,7 +6601,8 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) ...@@ -6601,7 +6601,8 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
if (err) if (err)
goto out_fail_inode; goto out_fail_inode;
err = btrfs_add_link(trans, dir, inode, dentry->d_name.name, err = btrfs_add_link(trans, BTRFS_I(dir), BTRFS_I(inode),
dentry->d_name.name,
dentry->d_name.len, 0, index); dentry->d_name.len, 0, index);
if (err) if (err)
goto out_fail_inode; goto out_fail_inode;
...@@ -9592,7 +9593,7 @@ static int btrfs_rename_exchange(struct inode *old_dir, ...@@ -9592,7 +9593,7 @@ static int btrfs_rename_exchange(struct inode *old_dir,
goto out_fail; goto out_fail;
} }
ret = btrfs_add_link(trans, new_dir, old_inode, ret = btrfs_add_link(trans, BTRFS_I(new_dir), BTRFS_I(old_inode),
new_dentry->d_name.name, new_dentry->d_name.name,
new_dentry->d_name.len, 0, old_idx); new_dentry->d_name.len, 0, old_idx);
if (ret) { if (ret) {
...@@ -9600,7 +9601,7 @@ static int btrfs_rename_exchange(struct inode *old_dir, ...@@ -9600,7 +9601,7 @@ static int btrfs_rename_exchange(struct inode *old_dir,
goto out_fail; goto out_fail;
} }
ret = btrfs_add_link(trans, old_dir, new_inode, ret = btrfs_add_link(trans, BTRFS_I(old_dir), BTRFS_I(new_inode),
old_dentry->d_name.name, old_dentry->d_name.name,
old_dentry->d_name.len, 0, new_idx); old_dentry->d_name.len, 0, new_idx);
if (ret) { if (ret) {
...@@ -9877,7 +9878,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -9877,7 +9878,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
} }
} }
ret = btrfs_add_link(trans, new_dir, old_inode, ret = btrfs_add_link(trans, BTRFS_I(new_dir), BTRFS_I(old_inode),
new_dentry->d_name.name, new_dentry->d_name.name,
new_dentry->d_name.len, 0, index); new_dentry->d_name.len, 0, index);
if (ret) { if (ret) {
......
...@@ -1322,8 +1322,9 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans, ...@@ -1322,8 +1322,9 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans,
} }
/* insert our name */ /* insert our name */
ret = btrfs_add_link(trans, dir, inode, name, namelen, ret = btrfs_add_link(trans, BTRFS_I(dir),
0, ref_index); BTRFS_I(inode),
name, namelen, 0, ref_index);
if (ret) if (ret)
goto out; goto out;
...@@ -1641,7 +1642,8 @@ static noinline int insert_one_name(struct btrfs_trans_handle *trans, ...@@ -1641,7 +1642,8 @@ static noinline int insert_one_name(struct btrfs_trans_handle *trans,
return -EIO; return -EIO;
} }
ret = btrfs_add_link(trans, dir, inode, name, name_len, 1, index); ret = btrfs_add_link(trans, BTRFS_I(dir), BTRFS_I(inode), name,
name_len, 1, index);
/* FIXME, put inode into FIXUP list */ /* FIXME, put inode into FIXUP list */
......
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