Message ID | 20200313212330.149024-12-josef@toxicpanda.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Throttle delayed refs based on time | expand |
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 45268e50cb17..e3d6ba27663e 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -2797,6 +2797,16 @@ static int reserve_metadata_space(struct btrfs_trans_handle *trans, int ret; u64 tmp; + /* + * If we're generating too many delayed refs we should bail and allow + * the delayed ref throttling stuff to catch up. + */ + if (btrfs_check_space_for_delayed_refs(fs_info) || + btrfs_should_throttle_delayed_refs(fs_info, + &trans->transaction->delayed_refs, + true)) + return -EAGAIN; + num_bytes = calcu_metadata_size(rc, node, 1) * 2; trans->block_rsv = rc->block_rsv;
Relocation can generate a serious amount of delayed refs, so we need to throttle the relocation sometimes in order to keep up with the async flusher. We already have a mechanism to start over because of ENOSPC, simply add delayed ref counts to the check as well. Signed-off-by: Josef Bacik <josef@toxicpanda.com> --- fs/btrfs/relocation.c | 10 ++++++++++ 1 file changed, 10 insertions(+)