aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
authorMiao Xie <miaox@cn.fujitsu.com>2013-05-13 09:55:12 -0400
committerJosef Bacik <jbacik@fusionio.com>2013-05-17 21:40:26 -0400
commitd88033dbf4c23279b012725876f1e164e09644ff (patch)
tree97954bb46f3bbc62e85edd016bc25f6f9e48f89f /fs/btrfs/extent-tree.c
parent5881cfc924c8143dbc3e1f343516fc6527eb8311 (diff)
Btrfs: update the global reserve if it is empty
Before applying this patch, we reserved the space for the global reserve by the minimum unit if we found it is empty, it was unreasonable and inefficient, because if the global reserve space was depleted, it implied that the size of the global reserve was too small. In this case, we shoud update the global reserve and fill it. Cc: Tsutomu Itoh <t-itoh@jp.fujitsu.com> Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r--fs/btrfs/extent-tree.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 54e63b273a64..42f5e6196021 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -6653,12 +6653,13 @@ use_block_rsv(struct btrfs_trans_handle *trans,
6653 struct btrfs_block_rsv *block_rsv; 6653 struct btrfs_block_rsv *block_rsv;
6654 struct btrfs_block_rsv *global_rsv = &root->fs_info->global_block_rsv; 6654 struct btrfs_block_rsv *global_rsv = &root->fs_info->global_block_rsv;
6655 int ret; 6655 int ret;
6656 bool global_updated = false;
6656 6657
6657 block_rsv = get_block_rsv(trans, root); 6658 block_rsv = get_block_rsv(trans, root);
6658 6659
6659 if (unlikely(block_rsv->size == 0)) 6660 if (unlikely(block_rsv->size == 0))
6660 goto try_reserve; 6661 goto try_reserve;
6661 6662again:
6662 ret = block_rsv_use_bytes(block_rsv, blocksize); 6663 ret = block_rsv_use_bytes(block_rsv, blocksize);
6663 if (!ret) 6664 if (!ret)
6664 return block_rsv; 6665 return block_rsv;
@@ -6666,6 +6667,12 @@ use_block_rsv(struct btrfs_trans_handle *trans,
6666 if (block_rsv->failfast) 6667 if (block_rsv->failfast)
6667 return ERR_PTR(ret); 6668 return ERR_PTR(ret);
6668 6669
6670 if (block_rsv->type == BTRFS_BLOCK_RSV_GLOBAL && !global_updated) {
6671 global_updated = true;
6672 update_global_block_rsv(root->fs_info);
6673 goto again;
6674 }
6675
6669 if (btrfs_test_opt(root, ENOSPC_DEBUG)) { 6676 if (btrfs_test_opt(root, ENOSPC_DEBUG)) {
6670 static DEFINE_RATELIMIT_STATE(_rs, 6677 static DEFINE_RATELIMIT_STATE(_rs,
6671 DEFAULT_RATELIMIT_INTERVAL * 10, 6678 DEFAULT_RATELIMIT_INTERVAL * 10,