提交 d88033db 编写于 作者: M Miao Xie 提交者: Josef Bacik

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: NMiao Xie <miaox@cn.fujitsu.com>
Signed-off-by: NJosef Bacik <jbacik@fusionio.com>
上级 5881cfc9
...@@ -6653,12 +6653,13 @@ use_block_rsv(struct btrfs_trans_handle *trans, ...@@ -6653,12 +6653,13 @@ use_block_rsv(struct btrfs_trans_handle *trans,
struct btrfs_block_rsv *block_rsv; struct btrfs_block_rsv *block_rsv;
struct btrfs_block_rsv *global_rsv = &root->fs_info->global_block_rsv; struct btrfs_block_rsv *global_rsv = &root->fs_info->global_block_rsv;
int ret; int ret;
bool global_updated = false;
block_rsv = get_block_rsv(trans, root); block_rsv = get_block_rsv(trans, root);
if (unlikely(block_rsv->size == 0)) if (unlikely(block_rsv->size == 0))
goto try_reserve; goto try_reserve;
again:
ret = block_rsv_use_bytes(block_rsv, blocksize); ret = block_rsv_use_bytes(block_rsv, blocksize);
if (!ret) if (!ret)
return block_rsv; return block_rsv;
...@@ -6666,6 +6667,12 @@ use_block_rsv(struct btrfs_trans_handle *trans, ...@@ -6666,6 +6667,12 @@ use_block_rsv(struct btrfs_trans_handle *trans,
if (block_rsv->failfast) if (block_rsv->failfast)
return ERR_PTR(ret); return ERR_PTR(ret);
if (block_rsv->type == BTRFS_BLOCK_RSV_GLOBAL && !global_updated) {
global_updated = true;
update_global_block_rsv(root->fs_info);
goto again;
}
if (btrfs_test_opt(root, ENOSPC_DEBUG)) { if (btrfs_test_opt(root, ENOSPC_DEBUG)) {
static DEFINE_RATELIMIT_STATE(_rs, static DEFINE_RATELIMIT_STATE(_rs,
DEFAULT_RATELIMIT_INTERVAL * 10, DEFAULT_RATELIMIT_INTERVAL * 10,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册