aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikolay Borisov <nborisov@suse.com>2017-02-20 06:51:08 -0500
committerDavid Sterba <dsterba@suse.com>2017-02-28 05:30:11 -0500
commitdb0a669fb002416faafe34481d6a6e21cdf0e926 (patch)
tree116497fc52f46809094ce545b8f3a6620a048955
parent9e3e97f45c1f4debe53f72ad309ec06890d3aac2 (diff)
btrfs: Make btrfs_add_link take btrfs_inode
Signed-off-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--fs/btrfs/ctree.h2
-rw-r--r--fs/btrfs/inode.c39
-rw-r--r--fs/btrfs/tree-log.c8
3 files changed, 26 insertions, 23 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 809736ec549b..f03c2f285eb1 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -3129,7 +3129,7 @@ int btrfs_unlink_inode(struct btrfs_trans_handle *trans,
3129 struct btrfs_inode *dir, struct btrfs_inode *inode, 3129 struct btrfs_inode *dir, struct btrfs_inode *inode,
3130 const char *name, int name_len); 3130 const char *name, int name_len);
3131int btrfs_add_link(struct btrfs_trans_handle *trans, 3131int btrfs_add_link(struct btrfs_trans_handle *trans,
3132 struct inode *parent_inode, struct inode *inode, 3132 struct btrfs_inode *parent_inode, struct btrfs_inode *inode,
3133 const char *name, int name_len, int add_backref, u64 index); 3133 const char *name, int name_len, int add_backref, u64 index);
3134int btrfs_unlink_subvol(struct btrfs_trans_handle *trans, 3134int btrfs_unlink_subvol(struct btrfs_trans_handle *trans,
3135 struct btrfs_root *root, 3135 struct btrfs_root *root,
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 1934db1af2fc..91c6be6a72df 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -6251,18 +6251,18 @@ static inline u8 btrfs_inode_type(struct inode *inode)
6251 * inode to the parent directory. 6251 * inode to the parent directory.
6252 */ 6252 */
6253int btrfs_add_link(struct btrfs_trans_handle *trans, 6253int btrfs_add_link(struct btrfs_trans_handle *trans,
6254 struct inode *parent_inode, struct inode *inode, 6254 struct btrfs_inode *parent_inode, struct btrfs_inode *inode,
6255 const char *name, int name_len, int add_backref, u64 index) 6255 const char *name, int name_len, int add_backref, u64 index)
6256{ 6256{
6257 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); 6257 struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
6258 int ret = 0; 6258 int ret = 0;
6259 struct btrfs_key key; 6259 struct btrfs_key key;
6260 struct btrfs_root *root = BTRFS_I(parent_inode)->root; 6260 struct btrfs_root *root = parent_inode->root;
6261 u64 ino = btrfs_ino(BTRFS_I(inode)); 6261 u64 ino = btrfs_ino(inode);
6262 u64 parent_ino = btrfs_ino(BTRFS_I(parent_inode)); 6262 u64 parent_ino = btrfs_ino(parent_inode);
6263 6263
6264 if (unlikely(ino == BTRFS_FIRST_FREE_OBJECTID)) { 6264 if (unlikely(ino == BTRFS_FIRST_FREE_OBJECTID)) {
6265 memcpy(&key, &BTRFS_I(inode)->root->root_key, sizeof(key)); 6265 memcpy(&key, &inode->root->root_key, sizeof(key));
6266 } else { 6266 } else {
6267 key.objectid = ino; 6267 key.objectid = ino;
6268 key.type = BTRFS_INODE_ITEM_KEY; 6268 key.type = BTRFS_INODE_ITEM_KEY;
@@ -6283,8 +6283,8 @@ int btrfs_add_link(struct btrfs_trans_handle *trans,
6283 return ret; 6283 return ret;
6284 6284
6285 ret = btrfs_insert_dir_item(trans, root, name, name_len, 6285 ret = btrfs_insert_dir_item(trans, root, name, name_len,
6286 BTRFS_I(parent_inode), &key, 6286 parent_inode, &key,
6287 btrfs_inode_type(inode), index); 6287 btrfs_inode_type(&inode->vfs_inode), index);
6288 if (ret == -EEXIST || ret == -EOVERFLOW) 6288 if (ret == -EEXIST || ret == -EOVERFLOW)
6289 goto fail_dir_item; 6289 goto fail_dir_item;
6290 else if (ret) { 6290 else if (ret) {
@@ -6292,12 +6292,12 @@ int btrfs_add_link(struct btrfs_trans_handle *trans,
6292 return ret; 6292 return ret;
6293 } 6293 }
6294 6294
6295 btrfs_i_size_write(BTRFS_I(parent_inode), parent_inode->i_size + 6295 btrfs_i_size_write(parent_inode, parent_inode->vfs_inode.i_size +
6296 name_len * 2); 6296 name_len * 2);
6297 inode_inc_iversion(parent_inode); 6297 inode_inc_iversion(&parent_inode->vfs_inode);
6298 parent_inode->i_mtime = parent_inode->i_ctime = 6298 parent_inode->vfs_inode.i_mtime = parent_inode->vfs_inode.i_ctime =
6299 current_time(parent_inode); 6299 current_time(&parent_inode->vfs_inode);
6300 ret = btrfs_update_inode(trans, root, parent_inode); 6300 ret = btrfs_update_inode(trans, root, &parent_inode->vfs_inode);
6301 if (ret) 6301 if (ret)
6302 btrfs_abort_transaction(trans, ret); 6302 btrfs_abort_transaction(trans, ret);
6303 return ret; 6303 return ret;
@@ -6324,7 +6324,7 @@ static int btrfs_add_nondir(struct btrfs_trans_handle *trans,
6324 struct inode *dir, struct dentry *dentry, 6324 struct inode *dir, struct dentry *dentry,
6325 struct inode *inode, int backref, u64 index) 6325 struct inode *inode, int backref, u64 index)
6326{ 6326{
6327 int err = btrfs_add_link(trans, dir, inode, 6327 int err = btrfs_add_link(trans, BTRFS_I(dir), BTRFS_I(inode),
6328 dentry->d_name.name, dentry->d_name.len, 6328 dentry->d_name.name, dentry->d_name.len,
6329 backref, index); 6329 backref, index);
6330 if (err > 0) 6330 if (err > 0)
@@ -6601,8 +6601,9 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
6601 if (err) 6601 if (err)
6602 goto out_fail_inode; 6602 goto out_fail_inode;
6603 6603
6604 err = btrfs_add_link(trans, dir, inode, dentry->d_name.name, 6604 err = btrfs_add_link(trans, BTRFS_I(dir), BTRFS_I(inode),
6605 dentry->d_name.len, 0, index); 6605 dentry->d_name.name,
6606 dentry->d_name.len, 0, index);
6606 if (err) 6607 if (err)
6607 goto out_fail_inode; 6608 goto out_fail_inode;
6608 6609
@@ -9592,7 +9593,7 @@ static int btrfs_rename_exchange(struct inode *old_dir,
9592 goto out_fail; 9593 goto out_fail;
9593 } 9594 }
9594 9595
9595 ret = btrfs_add_link(trans, new_dir, old_inode, 9596 ret = btrfs_add_link(trans, BTRFS_I(new_dir), BTRFS_I(old_inode),
9596 new_dentry->d_name.name, 9597 new_dentry->d_name.name,
9597 new_dentry->d_name.len, 0, old_idx); 9598 new_dentry->d_name.len, 0, old_idx);
9598 if (ret) { 9599 if (ret) {
@@ -9600,7 +9601,7 @@ static int btrfs_rename_exchange(struct inode *old_dir,
9600 goto out_fail; 9601 goto out_fail;
9601 } 9602 }
9602 9603
9603 ret = btrfs_add_link(trans, old_dir, new_inode, 9604 ret = btrfs_add_link(trans, BTRFS_I(old_dir), BTRFS_I(new_inode),
9604 old_dentry->d_name.name, 9605 old_dentry->d_name.name,
9605 old_dentry->d_name.len, 0, new_idx); 9606 old_dentry->d_name.len, 0, new_idx);
9606 if (ret) { 9607 if (ret) {
@@ -9877,7 +9878,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
9877 } 9878 }
9878 } 9879 }
9879 9880
9880 ret = btrfs_add_link(trans, new_dir, old_inode, 9881 ret = btrfs_add_link(trans, BTRFS_I(new_dir), BTRFS_I(old_inode),
9881 new_dentry->d_name.name, 9882 new_dentry->d_name.name,
9882 new_dentry->d_name.len, 0, index); 9883 new_dentry->d_name.len, 0, index);
9883 if (ret) { 9884 if (ret) {
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index f8965b081212..c9ada4b90004 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -1322,8 +1322,9 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans,
1322 } 1322 }
1323 1323
1324 /* insert our name */ 1324 /* insert our name */
1325 ret = btrfs_add_link(trans, dir, inode, name, namelen, 1325 ret = btrfs_add_link(trans, BTRFS_I(dir),
1326 0, ref_index); 1326 BTRFS_I(inode),
1327 name, namelen, 0, ref_index);
1327 if (ret) 1328 if (ret)
1328 goto out; 1329 goto out;
1329 1330
@@ -1641,7 +1642,8 @@ static noinline int insert_one_name(struct btrfs_trans_handle *trans,
1641 return -EIO; 1642 return -EIO;
1642 } 1643 }
1643 1644
1644 ret = btrfs_add_link(trans, dir, inode, name, name_len, 1, index); 1645 ret = btrfs_add_link(trans, BTRFS_I(dir), BTRFS_I(inode), name,
1646 name_len, 1, index);
1645 1647
1646 /* FIXME, put inode into FIXUP list */ 1648 /* FIXME, put inode into FIXUP list */
1647 1649