diff options
author | Liu Bo <bo.li.liu@oracle.com> | 2012-11-14 09:34:34 -0500 |
---|---|---|
committer | Josef Bacik <jbacik@fusionio.com> | 2012-12-12 17:15:28 -0500 |
commit | b53d3f5db2b79637acadc06a330db6c2c60863f5 (patch) | |
tree | f5ad7a1612f413e1ae459eb88d20642972d6b02c /fs/btrfs/inode.c | |
parent | 3ef5969cd8a42a78ccdbc53f7abb2e6136b2ec65 (diff) |
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: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 42 |
1 files changed, 11 insertions, 31 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index e8733fab2739..aabf747d056e 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -3091,7 +3091,6 @@ static int btrfs_unlink(struct inode *dir, struct dentry *dentry) | |||
3091 | struct btrfs_trans_handle *trans; | 3091 | struct btrfs_trans_handle *trans; |
3092 | struct inode *inode = dentry->d_inode; | 3092 | struct inode *inode = dentry->d_inode; |
3093 | int ret; | 3093 | int ret; |
3094 | unsigned long nr = 0; | ||
3095 | 3094 | ||
3096 | trans = __unlink_start_trans(dir, dentry); | 3095 | trans = __unlink_start_trans(dir, dentry); |
3097 | if (IS_ERR(trans)) | 3096 | if (IS_ERR(trans)) |
@@ -3111,9 +3110,8 @@ static int btrfs_unlink(struct inode *dir, struct dentry *dentry) | |||
3111 | } | 3110 | } |
3112 | 3111 | ||
3113 | out: | 3112 | out: |
3114 | nr = trans->blocks_used; | ||
3115 | __unlink_end_trans(trans, root); | 3113 | __unlink_end_trans(trans, root); |
3116 | btrfs_btree_balance_dirty(root, nr); | 3114 | btrfs_btree_balance_dirty(root); |
3117 | return ret; | 3115 | return ret; |
3118 | } | 3116 | } |
3119 | 3117 | ||
@@ -3203,7 +3201,6 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
3203 | int err = 0; | 3201 | int err = 0; |
3204 | struct btrfs_root *root = BTRFS_I(dir)->root; | 3202 | struct btrfs_root *root = BTRFS_I(dir)->root; |
3205 | struct btrfs_trans_handle *trans; | 3203 | struct btrfs_trans_handle *trans; |
3206 | unsigned long nr = 0; | ||
3207 | 3204 | ||
3208 | if (inode->i_size > BTRFS_EMPTY_DIR_SIZE) | 3205 | if (inode->i_size > BTRFS_EMPTY_DIR_SIZE) |
3209 | return -ENOTEMPTY; | 3206 | return -ENOTEMPTY; |
@@ -3232,9 +3229,8 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
3232 | if (!err) | 3229 | if (!err) |
3233 | btrfs_i_size_write(inode, 0); | 3230 | btrfs_i_size_write(inode, 0); |
3234 | out: | 3231 | out: |
3235 | nr = trans->blocks_used; | ||
3236 | __unlink_end_trans(trans, root); | 3232 | __unlink_end_trans(trans, root); |
3237 | btrfs_btree_balance_dirty(root, nr); | 3233 | btrfs_btree_balance_dirty(root); |
3238 | 3234 | ||
3239 | return err; | 3235 | return err; |
3240 | } | 3236 | } |
@@ -3800,7 +3796,6 @@ void btrfs_evict_inode(struct inode *inode) | |||
3800 | struct btrfs_root *root = BTRFS_I(inode)->root; | 3796 | struct btrfs_root *root = BTRFS_I(inode)->root; |
3801 | struct btrfs_block_rsv *rsv, *global_rsv; | 3797 | struct btrfs_block_rsv *rsv, *global_rsv; |
3802 | u64 min_size = btrfs_calc_trunc_metadata_size(root, 1); | 3798 | u64 min_size = btrfs_calc_trunc_metadata_size(root, 1); |
3803 | unsigned long nr; | ||
3804 | int ret; | 3799 | int ret; |
3805 | 3800 | ||
3806 | trace_btrfs_inode_evict(inode); | 3801 | trace_btrfs_inode_evict(inode); |
@@ -3882,10 +3877,9 @@ void btrfs_evict_inode(struct inode *inode) | |||
3882 | ret = btrfs_update_inode(trans, root, inode); | 3877 | ret = btrfs_update_inode(trans, root, inode); |
3883 | BUG_ON(ret); | 3878 | BUG_ON(ret); |
3884 | 3879 | ||
3885 | nr = trans->blocks_used; | ||
3886 | btrfs_end_transaction(trans, root); | 3880 | btrfs_end_transaction(trans, root); |
3887 | trans = NULL; | 3881 | trans = NULL; |
3888 | btrfs_btree_balance_dirty(root, nr); | 3882 | btrfs_btree_balance_dirty(root); |
3889 | } | 3883 | } |
3890 | 3884 | ||
3891 | btrfs_free_block_rsv(root, rsv); | 3885 | btrfs_free_block_rsv(root, rsv); |
@@ -3901,9 +3895,8 @@ void btrfs_evict_inode(struct inode *inode) | |||
3901 | root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)) | 3895 | root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)) |
3902 | btrfs_return_ino(root, btrfs_ino(inode)); | 3896 | btrfs_return_ino(root, btrfs_ino(inode)); |
3903 | 3897 | ||
3904 | nr = trans->blocks_used; | ||
3905 | btrfs_end_transaction(trans, root); | 3898 | btrfs_end_transaction(trans, root); |
3906 | btrfs_btree_balance_dirty(root, nr); | 3899 | btrfs_btree_balance_dirty(root); |
3907 | no_delete: | 3900 | no_delete: |
3908 | clear_inode(inode); | 3901 | clear_inode(inode); |
3909 | return; | 3902 | return; |
@@ -4915,7 +4908,6 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry, | |||
4915 | int err; | 4908 | int err; |
4916 | int drop_inode = 0; | 4909 | int drop_inode = 0; |
4917 | u64 objectid; | 4910 | u64 objectid; |
4918 | unsigned long nr = 0; | ||
4919 | u64 index = 0; | 4911 | u64 index = 0; |
4920 | 4912 | ||
4921 | if (!new_valid_dev(rdev)) | 4913 | if (!new_valid_dev(rdev)) |
@@ -4965,9 +4957,8 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry, | |||
4965 | d_instantiate(dentry, inode); | 4957 | d_instantiate(dentry, inode); |
4966 | } | 4958 | } |
4967 | out_unlock: | 4959 | out_unlock: |
4968 | nr = trans->blocks_used; | ||
4969 | btrfs_end_transaction(trans, root); | 4960 | btrfs_end_transaction(trans, root); |
4970 | btrfs_btree_balance_dirty(root, nr); | 4961 | btrfs_btree_balance_dirty(root); |
4971 | if (drop_inode) { | 4962 | if (drop_inode) { |
4972 | inode_dec_link_count(inode); | 4963 | inode_dec_link_count(inode); |
4973 | iput(inode); | 4964 | iput(inode); |
@@ -4983,7 +4974,6 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry, | |||
4983 | struct inode *inode = NULL; | 4974 | struct inode *inode = NULL; |
4984 | int drop_inode = 0; | 4975 | int drop_inode = 0; |
4985 | int err; | 4976 | int err; |
4986 | unsigned long nr = 0; | ||
4987 | u64 objectid; | 4977 | u64 objectid; |
4988 | u64 index = 0; | 4978 | u64 index = 0; |
4989 | 4979 | ||
@@ -5033,13 +5023,12 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry, | |||
5033 | d_instantiate(dentry, inode); | 5023 | d_instantiate(dentry, inode); |
5034 | } | 5024 | } |
5035 | out_unlock: | 5025 | out_unlock: |
5036 | nr = trans->blocks_used; | ||
5037 | btrfs_end_transaction(trans, root); | 5026 | btrfs_end_transaction(trans, root); |
5038 | if (drop_inode) { | 5027 | if (drop_inode) { |
5039 | inode_dec_link_count(inode); | 5028 | inode_dec_link_count(inode); |
5040 | iput(inode); | 5029 | iput(inode); |
5041 | } | 5030 | } |
5042 | btrfs_btree_balance_dirty(root, nr); | 5031 | btrfs_btree_balance_dirty(root); |
5043 | return err; | 5032 | return err; |
5044 | } | 5033 | } |
5045 | 5034 | ||
@@ -5050,7 +5039,6 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir, | |||
5050 | struct btrfs_root *root = BTRFS_I(dir)->root; | 5039 | struct btrfs_root *root = BTRFS_I(dir)->root; |
5051 | struct inode *inode = old_dentry->d_inode; | 5040 | struct inode *inode = old_dentry->d_inode; |
5052 | u64 index; | 5041 | u64 index; |
5053 | unsigned long nr = 0; | ||
5054 | int err; | 5042 | int err; |
5055 | int drop_inode = 0; | 5043 | int drop_inode = 0; |
5056 | 5044 | ||
@@ -5094,14 +5082,13 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir, | |||
5094 | btrfs_log_new_name(trans, inode, NULL, parent); | 5082 | btrfs_log_new_name(trans, inode, NULL, parent); |
5095 | } | 5083 | } |
5096 | 5084 | ||
5097 | nr = trans->blocks_used; | ||
5098 | btrfs_end_transaction(trans, root); | 5085 | btrfs_end_transaction(trans, root); |
5099 | fail: | 5086 | fail: |
5100 | if (drop_inode) { | 5087 | if (drop_inode) { |
5101 | inode_dec_link_count(inode); | 5088 | inode_dec_link_count(inode); |
5102 | iput(inode); | 5089 | iput(inode); |
5103 | } | 5090 | } |
5104 | btrfs_btree_balance_dirty(root, nr); | 5091 | btrfs_btree_balance_dirty(root); |
5105 | return err; | 5092 | return err; |
5106 | } | 5093 | } |
5107 | 5094 | ||
@@ -5114,7 +5101,6 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) | |||
5114 | int drop_on_err = 0; | 5101 | int drop_on_err = 0; |
5115 | u64 objectid = 0; | 5102 | u64 objectid = 0; |
5116 | u64 index = 0; | 5103 | u64 index = 0; |
5117 | unsigned long nr = 1; | ||
5118 | 5104 | ||
5119 | /* | 5105 | /* |
5120 | * 2 items for inode and ref | 5106 | * 2 items for inode and ref |
@@ -5160,11 +5146,10 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) | |||
5160 | drop_on_err = 0; | 5146 | drop_on_err = 0; |
5161 | 5147 | ||
5162 | out_fail: | 5148 | out_fail: |
5163 | nr = trans->blocks_used; | ||
5164 | btrfs_end_transaction(trans, root); | 5149 | btrfs_end_transaction(trans, root); |
5165 | if (drop_on_err) | 5150 | if (drop_on_err) |
5166 | iput(inode); | 5151 | iput(inode); |
5167 | btrfs_btree_balance_dirty(root, nr); | 5152 | btrfs_btree_balance_dirty(root); |
5168 | return err; | 5153 | return err; |
5169 | } | 5154 | } |
5170 | 5155 | ||
@@ -6872,7 +6857,6 @@ static int btrfs_truncate(struct inode *inode) | |||
6872 | int ret; | 6857 | int ret; |
6873 | int err = 0; | 6858 | int err = 0; |
6874 | struct btrfs_trans_handle *trans; | 6859 | struct btrfs_trans_handle *trans; |
6875 | unsigned long nr; | ||
6876 | u64 mask = root->sectorsize - 1; | 6860 | u64 mask = root->sectorsize - 1; |
6877 | u64 min_size = btrfs_calc_trunc_metadata_size(root, 1); | 6861 | u64 min_size = btrfs_calc_trunc_metadata_size(root, 1); |
6878 | 6862 | ||
@@ -6995,9 +6979,8 @@ static int btrfs_truncate(struct inode *inode) | |||
6995 | break; | 6979 | break; |
6996 | } | 6980 | } |
6997 | 6981 | ||
6998 | nr = trans->blocks_used; | ||
6999 | btrfs_end_transaction(trans, root); | 6982 | btrfs_end_transaction(trans, root); |
7000 | btrfs_btree_balance_dirty(root, nr); | 6983 | btrfs_btree_balance_dirty(root); |
7001 | 6984 | ||
7002 | trans = btrfs_start_transaction(root, 2); | 6985 | trans = btrfs_start_transaction(root, 2); |
7003 | if (IS_ERR(trans)) { | 6986 | if (IS_ERR(trans)) { |
@@ -7031,9 +7014,8 @@ static int btrfs_truncate(struct inode *inode) | |||
7031 | if (ret && !err) | 7014 | if (ret && !err) |
7032 | err = ret; | 7015 | err = ret; |
7033 | 7016 | ||
7034 | nr = trans->blocks_used; | ||
7035 | ret = btrfs_end_transaction(trans, root); | 7017 | ret = btrfs_end_transaction(trans, root); |
7036 | btrfs_btree_balance_dirty(root, nr); | 7018 | btrfs_btree_balance_dirty(root); |
7037 | } | 7019 | } |
7038 | 7020 | ||
7039 | out: | 7021 | out: |
@@ -7594,7 +7576,6 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry, | |||
7594 | unsigned long ptr; | 7576 | unsigned long ptr; |
7595 | struct btrfs_file_extent_item *ei; | 7577 | struct btrfs_file_extent_item *ei; |
7596 | struct extent_buffer *leaf; | 7578 | struct extent_buffer *leaf; |
7597 | unsigned long nr = 0; | ||
7598 | 7579 | ||
7599 | name_len = strlen(symname) + 1; | 7580 | name_len = strlen(symname) + 1; |
7600 | if (name_len > BTRFS_MAX_INLINE_DATA_SIZE(root)) | 7581 | if (name_len > BTRFS_MAX_INLINE_DATA_SIZE(root)) |
@@ -7692,13 +7673,12 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry, | |||
7692 | out_unlock: | 7673 | out_unlock: |
7693 | if (!err) | 7674 | if (!err) |
7694 | d_instantiate(dentry, inode); | 7675 | d_instantiate(dentry, inode); |
7695 | nr = trans->blocks_used; | ||
7696 | btrfs_end_transaction(trans, root); | 7676 | btrfs_end_transaction(trans, root); |
7697 | if (drop_inode) { | 7677 | if (drop_inode) { |
7698 | inode_dec_link_count(inode); | 7678 | inode_dec_link_count(inode); |
7699 | iput(inode); | 7679 | iput(inode); |
7700 | } | 7680 | } |
7701 | btrfs_btree_balance_dirty(root, nr); | 7681 | btrfs_btree_balance_dirty(root); |
7702 | return err; | 7682 | return err; |
7703 | } | 7683 | } |
7704 | 7684 | ||