return ret;
}
-static int btrfs_set_inode_index(struct inode *dir, struct inode *inode)
+static int btrfs_set_inode_index(struct inode *dir, struct inode *inode,
+ u64 *index)
{
int ret = 0;
return ret;
}
- BTRFS_I(inode)->index = BTRFS_I(dir)->index_cnt;
+ *index = BTRFS_I(dir)->index_cnt;
BTRFS_I(dir)->index_cnt++;
return ret;
u64 ref_objectid,
u64 objectid,
struct btrfs_block_group_cache *group,
- int mode)
+ int mode, u64 *index)
{
struct inode *inode;
struct btrfs_inode_item *inode_item;
return ERR_PTR(-ENOMEM);
if (dir) {
- ret = btrfs_set_inode_index(dir, inode);
+ ret = btrfs_set_inode_index(dir, inode, index);
if (ret)
return ERR_PTR(ret);
- } else {
- BTRFS_I(inode)->index = 0;
}
/*
* index_cnt is ignored for everything but a dir,
ref = btrfs_item_ptr(path->nodes[0], path->slots[0] + 1,
struct btrfs_inode_ref);
btrfs_set_inode_ref_name_len(path->nodes[0], ref, name_len);
- btrfs_set_inode_ref_index(path->nodes[0], ref, BTRFS_I(inode)->index);
+ btrfs_set_inode_ref_index(path->nodes[0], ref, *index);
ptr = (unsigned long)(ref + 1);
write_extent_buffer(path->nodes[0], name, ptr, name_len);
static int btrfs_add_link(struct btrfs_trans_handle *trans,
struct dentry *dentry, struct inode *inode,
- int add_backref)
+ int add_backref, u64 index)
{
int ret;
struct btrfs_key key;
dentry->d_name.name, dentry->d_name.len,
dentry->d_parent->d_inode->i_ino,
&key, btrfs_inode_type(inode),
- BTRFS_I(inode)->index);
+ index);
if (ret == 0) {
if (add_backref) {
ret = btrfs_insert_inode_ref(trans, root,
dentry->d_name.len,
inode->i_ino,
parent_inode->i_ino,
- BTRFS_I(inode)->index);
+ index);
}
btrfs_i_size_write(parent_inode, parent_inode->i_size +
dentry->d_name.len * 2);
static int btrfs_add_nondir(struct btrfs_trans_handle *trans,
struct dentry *dentry, struct inode *inode,
- int backref)
+ int backref, u64 index)
{
- int err = btrfs_add_link(trans, dentry, inode, backref);
+ int err = btrfs_add_link(trans, dentry, inode, backref, index);
if (!err) {
d_instantiate(dentry, inode);
return 0;
int drop_inode = 0;
u64 objectid;
unsigned long nr = 0;
+ u64 index = 0;
if (!new_valid_dev(rdev))
return -EINVAL;
inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name,
dentry->d_name.len,
dentry->d_parent->d_inode->i_ino, objectid,
- BTRFS_I(dir)->block_group, mode);
+ BTRFS_I(dir)->block_group, mode, &index);
err = PTR_ERR(inode);
if (IS_ERR(inode))
goto out_unlock;
}
btrfs_set_trans_block_group(trans, inode);
- err = btrfs_add_nondir(trans, dentry, inode, 0);
+ err = btrfs_add_nondir(trans, dentry, inode, 0, index);
if (err)
drop_inode = 1;
else {
int drop_inode = 0;
unsigned long nr = 0;
u64 objectid;
+ u64 index = 0;
err = btrfs_check_free_space(root, 1, 0);
if (err)
inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name,
dentry->d_name.len,
dentry->d_parent->d_inode->i_ino,
- objectid, BTRFS_I(dir)->block_group, mode);
+ objectid, BTRFS_I(dir)->block_group, mode,
+ &index);
err = PTR_ERR(inode);
if (IS_ERR(inode))
goto out_unlock;
}
btrfs_set_trans_block_group(trans, inode);
- err = btrfs_add_nondir(trans, dentry, inode, 0);
+ err = btrfs_add_nondir(trans, dentry, inode, 0, index);
if (err)
drop_inode = 1;
else {
struct btrfs_trans_handle *trans;
struct btrfs_root *root = BTRFS_I(dir)->root;
struct inode *inode = old_dentry->d_inode;
+ u64 index;
unsigned long nr = 0;
int err;
int drop_inode = 0;
err = btrfs_check_free_space(root, 1, 0);
if (err)
goto fail;
- err = btrfs_set_inode_index(dir, inode);
+ err = btrfs_set_inode_index(dir, inode, &index);
if (err)
goto fail;
btrfs_set_trans_block_group(trans, dir);
atomic_inc(&inode->i_count);
- err = btrfs_add_nondir(trans, dentry, inode, 1);
+ err = btrfs_add_nondir(trans, dentry, inode, 1, index);
if (err)
drop_inode = 1;
int err = 0;
int drop_on_err = 0;
u64 objectid = 0;
+ u64 index = 0;
unsigned long nr = 1;
err = btrfs_check_free_space(root, 1, 0);
inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name,
dentry->d_name.len,
dentry->d_parent->d_inode->i_ino, objectid,
- BTRFS_I(dir)->block_group, S_IFDIR | mode);
+ BTRFS_I(dir)->block_group, S_IFDIR | mode,
+ &index);
if (IS_ERR(inode)) {
err = PTR_ERR(inode);
goto out_fail;
if (err)
goto out_fail;
- err = btrfs_add_link(trans, dentry, inode, 0);
+ err = btrfs_add_link(trans, dentry, inode, 0, index);
if (err)
goto out_fail;
struct btrfs_block_group_cache *block_group)
{
struct inode *inode;
+ u64 index = 0;
inode = btrfs_new_inode(trans, new_root, NULL, "..", 2, new_dirid,
- new_dirid, block_group, S_IFDIR | 0700);
+ new_dirid, block_group, S_IFDIR | 0700, &index);
if (IS_ERR(inode))
return PTR_ERR(inode);
inode->i_op = &btrfs_dir_inode_operations;
struct inode *new_inode = new_dentry->d_inode;
struct inode *old_inode = old_dentry->d_inode;
struct timespec ctime = CURRENT_TIME;
+ u64 index = 0;
int ret;
if (S_ISDIR(old_inode->i_mode) && new_inode &&
goto out_fail;
}
}
- ret = btrfs_set_inode_index(new_dir, old_inode);
+ ret = btrfs_set_inode_index(new_dir, old_inode, &index);
if (ret)
goto out_fail;
- ret = btrfs_add_link(trans, new_dentry, old_inode, 1);
+ ret = btrfs_add_link(trans, new_dentry, old_inode, 1, index);
if (ret)
goto out_fail;
int err;
int drop_inode = 0;
u64 objectid;
+ u64 index = 0 ;
int name_len;
int datasize;
unsigned long ptr;
inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name,
dentry->d_name.len,
dentry->d_parent->d_inode->i_ino, objectid,
- BTRFS_I(dir)->block_group, S_IFLNK|S_IRWXUGO);
+ BTRFS_I(dir)->block_group, S_IFLNK|S_IRWXUGO,
+ &index);
err = PTR_ERR(inode);
if (IS_ERR(inode))
goto out_unlock;
}
btrfs_set_trans_block_group(trans, inode);
- err = btrfs_add_nondir(trans, dentry, inode, 0);
+ err = btrfs_add_nondir(trans, dentry, inode, 0, index);
if (err)
drop_inode = 1;
else {