Commit b53d3f5d authored by Liu Bo's avatar Liu Bo Committed by Josef Bacik

Btrfs: cleanup for btrfs_btree_balance_dirty

- 'nr' is no more used.
- btrfs_btree_balance_dirty() and __btrfs_btree_balance_dirty() can share
  a bunch of code.
Signed-off-by: default avatarLiu Bo <bo.li.liu@oracle.com>
Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
parent 3ef5969c
...@@ -1257,7 +1257,6 @@ static void btrfs_async_run_delayed_node_done(struct btrfs_work *work) ...@@ -1257,7 +1257,6 @@ static void btrfs_async_run_delayed_node_done(struct btrfs_work *work)
struct btrfs_delayed_node *delayed_node = NULL; struct btrfs_delayed_node *delayed_node = NULL;
struct btrfs_root *root; struct btrfs_root *root;
struct btrfs_block_rsv *block_rsv; struct btrfs_block_rsv *block_rsv;
unsigned long nr = 0;
int need_requeue = 0; int need_requeue = 0;
int ret; int ret;
...@@ -1318,11 +1317,9 @@ static void btrfs_async_run_delayed_node_done(struct btrfs_work *work) ...@@ -1318,11 +1317,9 @@ static void btrfs_async_run_delayed_node_done(struct btrfs_work *work)
delayed_node); delayed_node);
mutex_unlock(&delayed_node->mutex); mutex_unlock(&delayed_node->mutex);
nr = trans->blocks_used;
trans->block_rsv = block_rsv; trans->block_rsv = block_rsv;
btrfs_end_transaction_dmeta(trans, root); btrfs_end_transaction_dmeta(trans, root);
__btrfs_btree_balance_dirty(root, nr); btrfs_btree_balance_dirty_nodelay(root);
free_path: free_path:
btrfs_free_path(path); btrfs_free_path(path);
out: out:
......
...@@ -3411,7 +3411,8 @@ void btrfs_mark_buffer_dirty(struct extent_buffer *buf) ...@@ -3411,7 +3411,8 @@ void btrfs_mark_buffer_dirty(struct extent_buffer *buf)
} }
} }
void btrfs_btree_balance_dirty(struct btrfs_root *root, unsigned long nr) static void __btrfs_btree_balance_dirty(struct btrfs_root *root,
int flush_delayed)
{ {
/* /*
* looks as though older kernels can get into trouble with * looks as though older kernels can get into trouble with
...@@ -3423,7 +3424,8 @@ void btrfs_btree_balance_dirty(struct btrfs_root *root, unsigned long nr) ...@@ -3423,7 +3424,8 @@ void btrfs_btree_balance_dirty(struct btrfs_root *root, unsigned long nr)
if (current->flags & PF_MEMALLOC) if (current->flags & PF_MEMALLOC)
return; return;
btrfs_balance_delayed_items(root); if (flush_delayed)
btrfs_balance_delayed_items(root);
num_dirty = root->fs_info->dirty_metadata_bytes; num_dirty = root->fs_info->dirty_metadata_bytes;
...@@ -3434,25 +3436,14 @@ void btrfs_btree_balance_dirty(struct btrfs_root *root, unsigned long nr) ...@@ -3434,25 +3436,14 @@ void btrfs_btree_balance_dirty(struct btrfs_root *root, unsigned long nr)
return; return;
} }
void __btrfs_btree_balance_dirty(struct btrfs_root *root, unsigned long nr) void btrfs_btree_balance_dirty(struct btrfs_root *root)
{ {
/* __btrfs_btree_balance_dirty(root, 1);
* looks as though older kernels can get into trouble with }
* this code, they end up stuck in balance_dirty_pages forever
*/
u64 num_dirty;
unsigned long thresh = 32 * 1024 * 1024;
if (current->flags & PF_MEMALLOC)
return;
num_dirty = root->fs_info->dirty_metadata_bytes;
if (num_dirty > thresh) { void btrfs_btree_balance_dirty_nodelay(struct btrfs_root *root)
balance_dirty_pages_ratelimited_nr( {
root->fs_info->btree_inode->i_mapping, 1); __btrfs_btree_balance_dirty(root, 0);
}
return;
} }
int btrfs_read_buffer(struct extent_buffer *buf, u64 parent_transid) int btrfs_read_buffer(struct extent_buffer *buf, u64 parent_transid)
......
...@@ -62,8 +62,8 @@ struct btrfs_root *btrfs_read_fs_root_no_radix(struct btrfs_root *tree_root, ...@@ -62,8 +62,8 @@ struct btrfs_root *btrfs_read_fs_root_no_radix(struct btrfs_root *tree_root,
struct btrfs_root *btrfs_read_fs_root_no_name(struct btrfs_fs_info *fs_info, struct btrfs_root *btrfs_read_fs_root_no_name(struct btrfs_fs_info *fs_info,
struct btrfs_key *location); struct btrfs_key *location);
int btrfs_cleanup_fs_roots(struct btrfs_fs_info *fs_info); int btrfs_cleanup_fs_roots(struct btrfs_fs_info *fs_info);
void btrfs_btree_balance_dirty(struct btrfs_root *root, unsigned long nr); void btrfs_btree_balance_dirty(struct btrfs_root *root);
void __btrfs_btree_balance_dirty(struct btrfs_root *root, unsigned long nr); void btrfs_btree_balance_dirty_nodelay(struct btrfs_root *root);
void btrfs_free_fs_root(struct btrfs_fs_info *fs_info, struct btrfs_root *root); void btrfs_free_fs_root(struct btrfs_fs_info *fs_info, struct btrfs_root *root);
void btrfs_mark_buffer_dirty(struct extent_buffer *buf); void btrfs_mark_buffer_dirty(struct extent_buffer *buf);
int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid, int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid,
......
...@@ -1349,7 +1349,7 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file, ...@@ -1349,7 +1349,7 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file,
balance_dirty_pages_ratelimited_nr(inode->i_mapping, balance_dirty_pages_ratelimited_nr(inode->i_mapping,
dirty_pages); dirty_pages);
if (dirty_pages < (root->leafsize >> PAGE_CACHE_SHIFT) + 1) if (dirty_pages < (root->leafsize >> PAGE_CACHE_SHIFT) + 1)
btrfs_btree_balance_dirty(root, 1); btrfs_btree_balance_dirty(root);
pos += copied; pos += copied;
num_written += copied; num_written += copied;
...@@ -1803,7 +1803,6 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len) ...@@ -1803,7 +1803,6 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
u64 cur_offset = lockstart; u64 cur_offset = lockstart;
u64 min_size = btrfs_calc_trunc_metadata_size(root, 1); u64 min_size = btrfs_calc_trunc_metadata_size(root, 1);
u64 drop_end; u64 drop_end;
unsigned long nr;
int ret = 0; int ret = 0;
int err = 0; int err = 0;
bool same_page = (offset >> PAGE_CACHE_SHIFT) == bool same_page = (offset >> PAGE_CACHE_SHIFT) ==
...@@ -1931,9 +1930,8 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len) ...@@ -1931,9 +1930,8 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
break; break;
} }
nr = trans->blocks_used;
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans, root);
btrfs_btree_balance_dirty(root, nr); btrfs_btree_balance_dirty(root);
trans = btrfs_start_transaction(root, 3); trans = btrfs_start_transaction(root, 3);
if (IS_ERR(trans)) { if (IS_ERR(trans)) {
...@@ -1969,9 +1967,8 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len) ...@@ -1969,9 +1967,8 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
trans->block_rsv = &root->fs_info->trans_block_rsv; trans->block_rsv = &root->fs_info->trans_block_rsv;
ret = btrfs_update_inode(trans, root, inode); ret = btrfs_update_inode(trans, root, inode);
nr = trans->blocks_used;
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans, root);
btrfs_btree_balance_dirty(root, nr); btrfs_btree_balance_dirty(root);
out_free: out_free:
btrfs_free_path(path); btrfs_free_path(path);
btrfs_free_block_rsv(root, rsv); btrfs_free_block_rsv(root, rsv);
......
...@@ -3091,7 +3091,6 @@ static int btrfs_unlink(struct inode *dir, struct dentry *dentry) ...@@ -3091,7 +3091,6 @@ static int btrfs_unlink(struct inode *dir, struct dentry *dentry)
struct btrfs_trans_handle *trans; struct btrfs_trans_handle *trans;
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
int ret; int ret;
unsigned long nr = 0;
trans = __unlink_start_trans(dir, dentry); trans = __unlink_start_trans(dir, dentry);
if (IS_ERR(trans)) if (IS_ERR(trans))
...@@ -3111,9 +3110,8 @@ static int btrfs_unlink(struct inode *dir, struct dentry *dentry) ...@@ -3111,9 +3110,8 @@ static int btrfs_unlink(struct inode *dir, struct dentry *dentry)
} }
out: out:
nr = trans->blocks_used;
__unlink_end_trans(trans, root); __unlink_end_trans(trans, root);
btrfs_btree_balance_dirty(root, nr); btrfs_btree_balance_dirty(root);
return ret; return ret;
} }
...@@ -3203,7 +3201,6 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry) ...@@ -3203,7 +3201,6 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry)
int err = 0; int err = 0;
struct btrfs_root *root = BTRFS_I(dir)->root; struct btrfs_root *root = BTRFS_I(dir)->root;
struct btrfs_trans_handle *trans; struct btrfs_trans_handle *trans;
unsigned long nr = 0;
if (inode->i_size > BTRFS_EMPTY_DIR_SIZE) if (inode->i_size > BTRFS_EMPTY_DIR_SIZE)
return -ENOTEMPTY; return -ENOTEMPTY;
...@@ -3232,9 +3229,8 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry) ...@@ -3232,9 +3229,8 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry)
if (!err) if (!err)
btrfs_i_size_write(inode, 0); btrfs_i_size_write(inode, 0);
out: out:
nr = trans->blocks_used;
__unlink_end_trans(trans, root); __unlink_end_trans(trans, root);
btrfs_btree_balance_dirty(root, nr); btrfs_btree_balance_dirty(root);
return err; return err;
} }
...@@ -3800,7 +3796,6 @@ void btrfs_evict_inode(struct inode *inode) ...@@ -3800,7 +3796,6 @@ void btrfs_evict_inode(struct inode *inode)
struct btrfs_root *root = BTRFS_I(inode)->root; struct btrfs_root *root = BTRFS_I(inode)->root;
struct btrfs_block_rsv *rsv, *global_rsv; struct btrfs_block_rsv *rsv, *global_rsv;
u64 min_size = btrfs_calc_trunc_metadata_size(root, 1); u64 min_size = btrfs_calc_trunc_metadata_size(root, 1);
unsigned long nr;
int ret; int ret;
trace_btrfs_inode_evict(inode); trace_btrfs_inode_evict(inode);
...@@ -3882,10 +3877,9 @@ void btrfs_evict_inode(struct inode *inode) ...@@ -3882,10 +3877,9 @@ void btrfs_evict_inode(struct inode *inode)
ret = btrfs_update_inode(trans, root, inode); ret = btrfs_update_inode(trans, root, inode);
BUG_ON(ret); BUG_ON(ret);
nr = trans->blocks_used;
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans, root);
trans = NULL; trans = NULL;
btrfs_btree_balance_dirty(root, nr); btrfs_btree_balance_dirty(root);
} }
btrfs_free_block_rsv(root, rsv); btrfs_free_block_rsv(root, rsv);
...@@ -3901,9 +3895,8 @@ void btrfs_evict_inode(struct inode *inode) ...@@ -3901,9 +3895,8 @@ void btrfs_evict_inode(struct inode *inode)
root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)) root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID))
btrfs_return_ino(root, btrfs_ino(inode)); btrfs_return_ino(root, btrfs_ino(inode));
nr = trans->blocks_used;
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans, root);
btrfs_btree_balance_dirty(root, nr); btrfs_btree_balance_dirty(root);
no_delete: no_delete:
clear_inode(inode); clear_inode(inode);
return; return;
...@@ -4915,7 +4908,6 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry, ...@@ -4915,7 +4908,6 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry,
int err; int err;
int drop_inode = 0; int drop_inode = 0;
u64 objectid; u64 objectid;
unsigned long nr = 0;
u64 index = 0; u64 index = 0;
if (!new_valid_dev(rdev)) if (!new_valid_dev(rdev))
...@@ -4965,9 +4957,8 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry, ...@@ -4965,9 +4957,8 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry,
d_instantiate(dentry, inode); d_instantiate(dentry, inode);
} }
out_unlock: out_unlock:
nr = trans->blocks_used;
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans, root);
btrfs_btree_balance_dirty(root, nr); btrfs_btree_balance_dirty(root);
if (drop_inode) { if (drop_inode) {
inode_dec_link_count(inode); inode_dec_link_count(inode);
iput(inode); iput(inode);
...@@ -4983,7 +4974,6 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry, ...@@ -4983,7 +4974,6 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry,
struct inode *inode = NULL; struct inode *inode = NULL;
int drop_inode = 0; int drop_inode = 0;
int err; int err;
unsigned long nr = 0;
u64 objectid; u64 objectid;
u64 index = 0; u64 index = 0;
...@@ -5033,13 +5023,12 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry, ...@@ -5033,13 +5023,12 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry,
d_instantiate(dentry, inode); d_instantiate(dentry, inode);
} }
out_unlock: out_unlock:
nr = trans->blocks_used;
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans, root);
if (drop_inode) { if (drop_inode) {
inode_dec_link_count(inode); inode_dec_link_count(inode);
iput(inode); iput(inode);
} }
btrfs_btree_balance_dirty(root, nr); btrfs_btree_balance_dirty(root);
return err; return err;
} }
...@@ -5050,7 +5039,6 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir, ...@@ -5050,7 +5039,6 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
struct btrfs_root *root = BTRFS_I(dir)->root; struct btrfs_root *root = BTRFS_I(dir)->root;
struct inode *inode = old_dentry->d_inode; struct inode *inode = old_dentry->d_inode;
u64 index; u64 index;
unsigned long nr = 0;
int err; int err;
int drop_inode = 0; int drop_inode = 0;
...@@ -5094,14 +5082,13 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir, ...@@ -5094,14 +5082,13 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
btrfs_log_new_name(trans, inode, NULL, parent); btrfs_log_new_name(trans, inode, NULL, parent);
} }
nr = trans->blocks_used;
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans, root);
fail: fail:
if (drop_inode) { if (drop_inode) {
inode_dec_link_count(inode); inode_dec_link_count(inode);
iput(inode); iput(inode);
} }
btrfs_btree_balance_dirty(root, nr); btrfs_btree_balance_dirty(root);
return err; return err;
} }
...@@ -5114,7 +5101,6 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) ...@@ -5114,7 +5101,6 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
int drop_on_err = 0; int drop_on_err = 0;
u64 objectid = 0; u64 objectid = 0;
u64 index = 0; u64 index = 0;
unsigned long nr = 1;
/* /*
* 2 items for inode and ref * 2 items for inode and ref
...@@ -5160,11 +5146,10 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) ...@@ -5160,11 +5146,10 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
drop_on_err = 0; drop_on_err = 0;
out_fail: out_fail:
nr = trans->blocks_used;
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans, root);
if (drop_on_err) if (drop_on_err)
iput(inode); iput(inode);
btrfs_btree_balance_dirty(root, nr); btrfs_btree_balance_dirty(root);
return err; return err;
} }
...@@ -6872,7 +6857,6 @@ static int btrfs_truncate(struct inode *inode) ...@@ -6872,7 +6857,6 @@ static int btrfs_truncate(struct inode *inode)
int ret; int ret;
int err = 0; int err = 0;
struct btrfs_trans_handle *trans; struct btrfs_trans_handle *trans;
unsigned long nr;
u64 mask = root->sectorsize - 1; u64 mask = root->sectorsize - 1;
u64 min_size = btrfs_calc_trunc_metadata_size(root, 1); u64 min_size = btrfs_calc_trunc_metadata_size(root, 1);
...@@ -6995,9 +6979,8 @@ static int btrfs_truncate(struct inode *inode) ...@@ -6995,9 +6979,8 @@ static int btrfs_truncate(struct inode *inode)
break; break;
} }
nr = trans->blocks_used;
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans, root);
btrfs_btree_balance_dirty(root, nr); btrfs_btree_balance_dirty(root);
trans = btrfs_start_transaction(root, 2); trans = btrfs_start_transaction(root, 2);
if (IS_ERR(trans)) { if (IS_ERR(trans)) {
...@@ -7031,9 +7014,8 @@ static int btrfs_truncate(struct inode *inode) ...@@ -7031,9 +7014,8 @@ static int btrfs_truncate(struct inode *inode)
if (ret && !err) if (ret && !err)
err = ret; err = ret;
nr = trans->blocks_used;
ret = btrfs_end_transaction(trans, root); ret = btrfs_end_transaction(trans, root);
btrfs_btree_balance_dirty(root, nr); btrfs_btree_balance_dirty(root);
} }
out: out:
...@@ -7594,7 +7576,6 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry, ...@@ -7594,7 +7576,6 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry,
unsigned long ptr; unsigned long ptr;
struct btrfs_file_extent_item *ei; struct btrfs_file_extent_item *ei;
struct extent_buffer *leaf; struct extent_buffer *leaf;
unsigned long nr = 0;
name_len = strlen(symname) + 1; name_len = strlen(symname) + 1;
if (name_len > BTRFS_MAX_INLINE_DATA_SIZE(root)) if (name_len > BTRFS_MAX_INLINE_DATA_SIZE(root))
...@@ -7692,13 +7673,12 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry, ...@@ -7692,13 +7673,12 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry,
out_unlock: out_unlock:
if (!err) if (!err)
d_instantiate(dentry, inode); d_instantiate(dentry, inode);
nr = trans->blocks_used;
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans, root);
if (drop_inode) { if (drop_inode) {
inode_dec_link_count(inode); inode_dec_link_count(inode);
iput(inode); iput(inode);
} }
btrfs_btree_balance_dirty(root, nr); btrfs_btree_balance_dirty(root);
return err; return err;
} }
......
...@@ -2025,7 +2025,6 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc, ...@@ -2025,7 +2025,6 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc,
struct btrfs_root_item *root_item; struct btrfs_root_item *root_item;
struct btrfs_path *path; struct btrfs_path *path;
struct extent_buffer *leaf; struct extent_buffer *leaf;
unsigned long nr;
int level; int level;
int max_level; int max_level;
int replaced = 0; int replaced = 0;
...@@ -2126,10 +2125,9 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc, ...@@ -2126,10 +2125,9 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc,
path->slots[level]); path->slots[level]);
root_item->drop_level = level; root_item->drop_level = level;
nr = trans->blocks_used;
btrfs_end_transaction_throttle(trans, root); btrfs_end_transaction_throttle(trans, root);
btrfs_btree_balance_dirty(root, nr); btrfs_btree_balance_dirty(root);
if (replaced && rc->stage == UPDATE_DATA_PTRS) if (replaced && rc->stage == UPDATE_DATA_PTRS)
invalidate_extent_cache(root, &key, &next_key); invalidate_extent_cache(root, &key, &next_key);
...@@ -2156,10 +2154,9 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc, ...@@ -2156,10 +2154,9 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc,
btrfs_update_reloc_root(trans, root); btrfs_update_reloc_root(trans, root);
} }
nr = trans->blocks_used;
btrfs_end_transaction_throttle(trans, root); btrfs_end_transaction_throttle(trans, root);
btrfs_btree_balance_dirty(root, nr); btrfs_btree_balance_dirty(root);
if (replaced && rc->stage == UPDATE_DATA_PTRS) if (replaced && rc->stage == UPDATE_DATA_PTRS)
invalidate_extent_cache(root, &key, &next_key); invalidate_extent_cache(root, &key, &next_key);
...@@ -3262,7 +3259,6 @@ static int delete_block_group_cache(struct btrfs_fs_info *fs_info, ...@@ -3262,7 +3259,6 @@ static int delete_block_group_cache(struct btrfs_fs_info *fs_info,
struct btrfs_path *path; struct btrfs_path *path;
struct btrfs_root *root = fs_info->tree_root; struct btrfs_root *root = fs_info->tree_root;
struct btrfs_trans_handle *trans; struct btrfs_trans_handle *trans;
unsigned long nr;
int ret = 0; int ret = 0;
if (inode) if (inode)
...@@ -3296,9 +3292,8 @@ static int delete_block_group_cache(struct btrfs_fs_info *fs_info, ...@@ -3296,9 +3292,8 @@ static int delete_block_group_cache(struct btrfs_fs_info *fs_info,
ret = btrfs_truncate_free_space_cache(root, trans, path, inode); ret = btrfs_truncate_free_space_cache(root, trans, path, inode);
btrfs_free_path(path); btrfs_free_path(path);
nr = trans->blocks_used;
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans, root);
btrfs_btree_balance_dirty(root, nr); btrfs_btree_balance_dirty(root);
out: out:
iput(inode); iput(inode);
return ret; return ret;
...@@ -3715,7 +3710,6 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc) ...@@ -3715,7 +3710,6 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
struct btrfs_trans_handle *trans = NULL; struct btrfs_trans_handle *trans = NULL;
struct btrfs_path *path; struct btrfs_path *path;
struct btrfs_extent_item *ei; struct btrfs_extent_item *ei;
unsigned long nr;
u64 flags; u64 flags;
u32 item_size; u32 item_size;
int ret; int ret;
...@@ -3832,9 +3826,8 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc) ...@@ -3832,9 +3826,8 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
ret = btrfs_commit_transaction(trans, rc->extent_root); ret = btrfs_commit_transaction(trans, rc->extent_root);
BUG_ON(ret); BUG_ON(ret);
} else { } else {
nr = trans->blocks_used;
btrfs_end_transaction_throttle(trans, rc->extent_root); btrfs_end_transaction_throttle(trans, rc->extent_root);
btrfs_btree_balance_dirty(rc->extent_root, nr); btrfs_btree_balance_dirty(rc->extent_root);
} }
trans = NULL; trans = NULL;
...@@ -3864,9 +3857,8 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc) ...@@ -3864,9 +3857,8 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
GFP_NOFS); GFP_NOFS);
if (trans) { if (trans) {
nr = trans->blocks_used;
btrfs_end_transaction_throttle(trans, rc->extent_root); btrfs_end_transaction_throttle(trans, rc->extent_root);
btrfs_btree_balance_dirty(rc->extent_root, nr); btrfs_btree_balance_dirty(rc->extent_root);
} }
if (!err) { if (!err) {
...@@ -3945,7 +3937,6 @@ struct inode *create_reloc_inode(struct btrfs_fs_info *fs_info, ...@@ -3945,7 +3937,6 @@ struct inode *create_reloc_inode(struct btrfs_fs_info *fs_info,
struct btrfs_trans_handle *trans; struct btrfs_trans_handle *trans;
struct btrfs_root *root; struct btrfs_root *root;
struct btrfs_key key; struct btrfs_key key;
unsigned long nr;
u64 objectid = BTRFS_FIRST_FREE_OBJECTID; u64 objectid = BTRFS_FIRST_FREE_OBJECTID;
int err = 0; int err = 0;
...@@ -3973,9 +3964,8 @@ struct inode *create_reloc_inode(struct btrfs_fs_info *fs_info, ...@@ -3973,9 +3964,8 @@ struct inode *create_reloc_inode(struct btrfs_fs_info *fs_info,
err = btrfs_orphan_add(trans, inode); err = btrfs_orphan_add(trans, inode);
out: out:
nr = trans->blocks_used;
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans, root);
btrfs_btree_balance_dirty(root, nr); btrfs_btree_balance_dirty(root);
if (err) { if (err) {
if (inode) if (inode)
iput(inode); iput(inode);
......
...@@ -952,7 +952,6 @@ int btrfs_defrag_root(struct btrfs_root *root, int cacheonly) ...@@ -952,7 +952,6 @@ int btrfs_defrag_root(struct btrfs_root *root, int cacheonly)
struct btrfs_fs_info *info = root->fs_info; struct btrfs_fs_info *info = root->fs_info;
struct btrfs_trans_handle *trans; struct btrfs_trans_handle *trans;
int ret; int ret;
unsigned long nr;
if (xchg(&root->defrag_running, 1)) if (xchg(&root->defrag_running, 1))
return 0; return 0;
...@@ -964,9 +963,8 @@ int btrfs_defrag_root(struct btrfs_root *root, int cacheonly) ...@@ -964,9 +963,8 @@ int btrfs_defrag_root(struct btrfs_root *root, int cacheonly)
ret = btrfs_defrag_leaves(trans, root, cacheonly); ret = btrfs_defrag_leaves(trans, root, cacheonly);
nr = trans->blocks_used;
btrfs_end_transaction(trans, root); btrfs_end_transaction(trans, root);
btrfs_btree_balance_dirty(info->tree_root, nr); btrfs_btree_balance_dirty(info->tree_root);
cond_resched(); cond_resched();
if (btrfs_fs_closing(root->fs_info) || ret != -EAGAIN) if (btrfs_fs_closing(root->fs_info) || ret != -EAGAIN)
......
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