aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorMiao Xie <miaox@cn.fujitsu.com>2011-11-10 20:45:05 -0500
committerChris Mason <chris.mason@oracle.com>2011-11-10 20:45:05 -0500
commit61b520a9d0083b9b361638e456af45fd75150c87 (patch)
tree9545d5f0a2e606bef5702437a7c4c3eca9f12db4 /fs
parent3254c87618354e58fa2a7b375c6664f567480c33 (diff)
Btrfs: Abstract similar code for btrfs_block_rsv_add{, _noflush}
btrfs_block_rsv_add{, _noflush}() have similar code, so abstract that code. Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/extent-tree.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 0b044e509e9f..0f47b3e2010e 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3796,16 +3796,16 @@ void btrfs_free_block_rsv(struct btrfs_root *root,
3796 kfree(rsv); 3796 kfree(rsv);
3797} 3797}
3798 3798
3799int btrfs_block_rsv_add(struct btrfs_root *root, 3799static inline int __block_rsv_add(struct btrfs_root *root,
3800 struct btrfs_block_rsv *block_rsv, 3800 struct btrfs_block_rsv *block_rsv,
3801 u64 num_bytes) 3801 u64 num_bytes, int flush)
3802{ 3802{
3803 int ret; 3803 int ret;
3804 3804
3805 if (num_bytes == 0) 3805 if (num_bytes == 0)
3806 return 0; 3806 return 0;
3807 3807
3808 ret = reserve_metadata_bytes(root, block_rsv, num_bytes, 1); 3808 ret = reserve_metadata_bytes(root, block_rsv, num_bytes, flush);
3809 if (!ret) { 3809 if (!ret) {
3810 block_rsv_add_bytes(block_rsv, num_bytes, 1); 3810 block_rsv_add_bytes(block_rsv, num_bytes, 1);
3811 return 0; 3811 return 0;
@@ -3814,22 +3814,18 @@ int btrfs_block_rsv_add(struct btrfs_root *root,
3814 return ret; 3814 return ret;
3815} 3815}
3816 3816
3817int btrfs_block_rsv_add(struct btrfs_root *root,
3818 struct btrfs_block_rsv *block_rsv,
3819 u64 num_bytes)
3820{
3821 return __block_rsv_add(root, block_rsv, num_bytes, 1);
3822}
3823
3817int btrfs_block_rsv_add_noflush(struct btrfs_root *root, 3824int btrfs_block_rsv_add_noflush(struct btrfs_root *root,
3818 struct btrfs_block_rsv *block_rsv, 3825 struct btrfs_block_rsv *block_rsv,
3819 u64 num_bytes) 3826 u64 num_bytes)
3820{ 3827{
3821 int ret; 3828 return __block_rsv_add(root, block_rsv, num_bytes, 0);
3822
3823 if (num_bytes == 0)
3824 return 0;
3825
3826 ret = reserve_metadata_bytes(root, block_rsv, num_bytes, 0);
3827 if (!ret) {
3828 block_rsv_add_bytes(block_rsv, num_bytes, 1);
3829 return 0;
3830 }
3831
3832 return ret;
3833} 3829}
3834 3830
3835int btrfs_block_rsv_check(struct btrfs_root *root, 3831int btrfs_block_rsv_check(struct btrfs_root *root,