Updated to 2.6.32.27
/fs/btrfs/ioctl.c
blob:0bc5776950612f7b4b8e6e0d7794d97b2c7f294b -> blob:b9840fa0982ead5db3562b859aad727cb7d9953f
--- fs/btrfs/ioctl.c
+++ fs/btrfs/ioctl.c
@@ -237,6 +237,7 @@ static noinline int create_subvol(struct
u64 objectid;
u64 new_dirid = BTRFS_FIRST_FREE_OBJECTID;
u64 index = 0;
+ unsigned long nr = 1;
/*
* 1 - inode item
@@ -289,7 +290,7 @@ static noinline int create_subvol(struct
btrfs_set_root_generation(&root_item, trans->transid);
btrfs_set_root_level(&root_item, 0);
btrfs_set_root_refs(&root_item, 1);
- btrfs_set_root_used(&root_item, leaf->len);
+ btrfs_set_root_used(&root_item, 0);
btrfs_set_root_last_snapshot(&root_item, 0);
memset(&root_item.drop_progress, 0, sizeof(root_item.drop_progress));
@@ -341,21 +342,24 @@ static noinline int create_subvol(struct
d_instantiate(dentry, btrfs_lookup_dentry(dir, dentry));
fail:
+ nr = trans->blocks_used;
err = btrfs_commit_transaction(trans, root);
if (err && !ret)
ret = err;
btrfs_unreserve_metadata_space(root, 6);
+ btrfs_btree_balance_dirty(root, nr);
return ret;
}
static int create_snapshot(struct btrfs_root *root, struct dentry *dentry,
char *name, int namelen)
{
- struct inode *inode;
struct btrfs_pending_snapshot *pending_snapshot;
struct btrfs_trans_handle *trans;
- int ret;
+ int ret = 0;
+ int err;
+ unsigned long nr = 0;
if (!root->ref_cows)
return -EINVAL;
@@ -368,20 +372,20 @@ static int create_snapshot(struct btrfs_
*/
ret = btrfs_reserve_metadata_space(root, 6);
if (ret)
- goto fail;
+ goto fail_unlock;
pending_snapshot = kzalloc(sizeof(*pending_snapshot), GFP_NOFS);
if (!pending_snapshot) {
ret = -ENOMEM;
btrfs_unreserve_metadata_space(root, 6);
- goto fail;
+ goto fail_unlock;
}
pending_snapshot->name = kmalloc(namelen + 1, GFP_NOFS);
if (!pending_snapshot->name) {
ret = -ENOMEM;
kfree(pending_snapshot);
btrfs_unreserve_metadata_space(root, 6);
- goto fail;
+ goto fail_unlock;
}
memcpy(pending_snapshot->name, name, namelen);
pending_snapshot->name[namelen] = '\0';
@@ -391,19 +395,10 @@ static int create_snapshot(struct btrfs_
pending_snapshot->root = root;
list_add(&pending_snapshot->list,
&trans->transaction->pending_snapshots);
- ret = btrfs_commit_transaction(trans, root);
- BUG_ON(ret);
- btrfs_unreserve_metadata_space(root, 6);
+ err = btrfs_commit_transaction(trans, root);
- inode = btrfs_lookup_dentry(dentry->d_parent->d_inode, dentry);
- if (IS_ERR(inode)) {
- ret = PTR_ERR(inode);
- goto fail;
- }
- BUG_ON(!inode);
- d_instantiate(dentry, inode);
- ret = 0;
-fail:
+fail_unlock:
+ btrfs_btree_balance_dirty(root, nr);
return ret;
}
@@ -1037,7 +1032,8 @@ static noinline long btrfs_ioctl_clone(s
BUG_ON(!trans);
/* punch hole in destination first */
- btrfs_drop_extents(trans, inode, off, off + len, &hint_byte, 1);
+ btrfs_drop_extents(trans, root, inode, off, off + len,
+ off + len, 0, &hint_byte, 1);
/* clone data */
key.objectid = src->i_ino;