struct btrfs_root *root;
struct btrfs_trans_handle *trans;
int ret;
+ unsigned long nr;
root = BTRFS_I(dir)->root;
mutex_lock(&root->fs_info->fs_mutex);
trans = btrfs_start_transaction(root, 1);
btrfs_set_trans_block_group(trans, dir);
ret = btrfs_unlink_trans(trans, root, dir, dentry);
+ nr = trans->blocks_used;
btrfs_end_transaction(trans, root);
mutex_unlock(&root->fs_info->fs_mutex);
- btrfs_btree_balance_dirty(root);
+ btrfs_btree_balance_dirty(root, nr);
return ret;
}
int found_type;
struct btrfs_leaf *leaf;
char *goodnames = "..";
+ unsigned long nr;
path = btrfs_alloc_path();
BUG_ON(!path);
btrfs_release_path(root, path);
btrfs_free_path(path);
mutex_unlock(&root->fs_info->fs_mutex);
+ nr = trans->blocks_used;
ret = btrfs_end_transaction(trans, root);
- btrfs_btree_balance_dirty(root);
+ btrfs_btree_balance_dirty(root, nr);
if (ret && !err)
err = ret;
return err;
{
struct btrfs_trans_handle *trans;
struct btrfs_root *root = BTRFS_I(inode)->root;
+ unsigned long nr;
int ret;
truncate_inode_pages(&inode->i_data, 0);
ret = btrfs_free_inode(trans, root, inode);
if (ret)
goto no_delete_lock;
+ nr = trans->blocks_used;
btrfs_end_transaction(trans, root);
mutex_unlock(&root->fs_info->fs_mutex);
- btrfs_btree_balance_dirty(root);
+ btrfs_btree_balance_dirty(root, nr);
return;
no_delete_lock:
+ nr = trans->blocks_used;
btrfs_end_transaction(trans, root);
mutex_unlock(&root->fs_info->fs_mutex);
- btrfs_btree_balance_dirty(root);
+ btrfs_btree_balance_dirty(root, nr);
no_delete:
clear_inode(inode);
}
int err;
int drop_inode = 0;
u64 objectid;
+ unsigned long nr;
if (!new_valid_dev(rdev))
return -EINVAL;
btrfs_update_inode_block_group(trans, inode);
btrfs_update_inode_block_group(trans, dir);
out_unlock:
+ nr = trans->blocks_used;
btrfs_end_transaction(trans, root);
mutex_unlock(&root->fs_info->fs_mutex);
inode_dec_link_count(inode);
iput(inode);
}
- btrfs_btree_balance_dirty(root);
+ btrfs_btree_balance_dirty(root, nr);
return err;
}
struct inode *inode;
int err;
int drop_inode = 0;
+ unsigned long nr;
u64 objectid;
mutex_lock(&root->fs_info->fs_mutex);
btrfs_update_inode_block_group(trans, inode);
btrfs_update_inode_block_group(trans, dir);
out_unlock:
+ nr = trans->blocks_used;
btrfs_end_transaction(trans, root);
mutex_unlock(&root->fs_info->fs_mutex);
inode_dec_link_count(inode);
iput(inode);
}
- btrfs_btree_balance_dirty(root);
+ btrfs_btree_balance_dirty(root, nr);
return err;
}
struct btrfs_trans_handle *trans;
struct btrfs_root *root = BTRFS_I(dir)->root;
struct inode *inode = old_dentry->d_inode;
+ unsigned long nr;
int err;
int drop_inode = 0;
if (err)
drop_inode = 1;
+ nr = trans->blocks_used;
btrfs_end_transaction(trans, root);
mutex_unlock(&root->fs_info->fs_mutex);
inode_dec_link_count(inode);
iput(inode);
}
- btrfs_btree_balance_dirty(root);
+ btrfs_btree_balance_dirty(root, nr);
return err;
}
int err = 0;
int drop_on_err = 0;
u64 objectid;
+ unsigned long nr = 1;
mutex_lock(&root->fs_info->fs_mutex);
trans = btrfs_start_transaction(root, 1);
btrfs_update_inode_block_group(trans, dir);
out_fail:
+ nr = trans->blocks_used;
btrfs_end_transaction(trans, root);
out_unlock:
mutex_unlock(&root->fs_info->fs_mutex);
if (drop_on_err)
iput(inode);
- btrfs_btree_balance_dirty(root);
+ btrfs_btree_balance_dirty(root, nr);
return err;
}
struct btrfs_root *root = BTRFS_I(inode)->root;
int ret;
struct btrfs_trans_handle *trans;
+ unsigned long nr;
if (!S_ISREG(inode->i_mode))
return;
/* FIXME, add redo link to tree so we don't leak on crash */
ret = btrfs_truncate_in_trans(trans, root, inode);
btrfs_update_inode(trans, root, inode);
+ nr = trans->blocks_used;
ret = btrfs_end_transaction(trans, root);
BUG_ON(ret);
mutex_unlock(&root->fs_info->fs_mutex);
- btrfs_btree_balance_dirty(root);
+ btrfs_btree_balance_dirty(root, nr);
}
int btrfs_commit_write(struct file *file, struct page *page,
int err;
u64 objectid;
u64 new_dirid = BTRFS_FIRST_FREE_OBJECTID;
+ unsigned long nr = 1;
mutex_lock(&root->fs_info->fs_mutex);
trans = btrfs_start_transaction(root, 1);
if (ret)
goto fail;
fail:
+ nr = trans->blocks_used;
err = btrfs_commit_transaction(trans, root);
if (err && !ret)
ret = err;
fail_commit:
mutex_unlock(&root->fs_info->fs_mutex);
- btrfs_btree_balance_dirty(root);
+ btrfs_btree_balance_dirty(root, nr);
return ret;
}
int ret;
int err;
u64 objectid;
+ unsigned long nr;
if (!root->ref_cows)
return -EINVAL;
if (ret)
goto fail;
fail:
+ nr = trans->blocks_used;
err = btrfs_commit_transaction(trans, root);
if (err && !ret)
ret = err;
mutex_unlock(&root->fs_info->fs_mutex);
up_write(&root->snap_sem);
- btrfs_btree_balance_dirty(root);
+ btrfs_btree_balance_dirty(root, nr);
return ret;
}
int datasize;
char *ptr;
struct btrfs_file_extent_item *ei;
+ unsigned long nr;
name_len = strlen(symname) + 1;
if (name_len > BTRFS_MAX_INLINE_DATA_SIZE(root))
drop_inode = 1;
out_unlock:
+ nr = trans->blocks_used;
btrfs_end_transaction(trans, root);
mutex_unlock(&root->fs_info->fs_mutex);
if (drop_inode) {
inode_dec_link_count(inode);
iput(inode);
}
- btrfs_btree_balance_dirty(root);
+ btrfs_btree_balance_dirty(root, nr);
return err;
}
#include <linux/fs.h>
#include <linux/sched.h>
+#include <linux/writeback.h>
#include "ctree.h"
#include "disk-io.h"
#include "transaction.h"
struct btrfs_fs_info *info = root->fs_info;
int ret;
struct btrfs_trans_handle *trans;
+ unsigned long nr;
if (root->defrag_running)
return 0;
while (1) {
root->defrag_running = 1;
ret = btrfs_defrag_leaves(trans, root, cacheonly);
+ nr = trans->blocks_used;
btrfs_end_transaction(trans, root);
mutex_unlock(&info->fs_mutex);
- btrfs_btree_balance_dirty(root);
+ btrfs_btree_balance_dirty(info->tree_root, nr);
cond_resched();
mutex_lock(&info->fs_mutex);
{
struct dirty_root *dirty;
struct btrfs_trans_handle *trans;
+ unsigned long nr;
u64 num_blocks;
u64 blocks_used;
int ret = 0;
&dirty->root->root_item);
if (err)
ret = err;
+ nr = trans->blocks_used;
ret = btrfs_end_transaction(trans, tree_root);
BUG_ON(ret);
mutex_unlock(&tree_root->fs_info->fs_mutex);
-
- btrfs_btree_balance_dirty(tree_root);
+ btrfs_btree_balance_dirty(tree_root, nr);
schedule();
mutex_lock(&tree_root->fs_info->fs_mutex);
BUG();
break;
}
+ nr = trans->blocks_used;
ret = btrfs_end_transaction(trans, tree_root);
BUG_ON(ret);
kfree(dirty->root);
kfree(dirty);
mutex_unlock(&tree_root->fs_info->fs_mutex);
- btrfs_btree_balance_dirty(tree_root);
+
+ btrfs_btree_balance_dirty(tree_root, nr);
schedule();
}
return ret;