From 556773616347c9e1b8885db4955e85051c097ec2 Mon Sep 17 00:00:00 2001 From: Chris Mason Date: Wed, 16 Feb 2011 13:57:04 -0500 Subject: [PATCH] --- yaml --- r: 233679 b: refs/heads/master c: c87f08ca44e83b2c8d28f63f9c33f3a270a04bbe h: refs/heads/master i: 233677: 56b569cfe9aeb5af53ad434ea58e681c469df324 233675: 2d44065924d500822a557b72512b127510dfd5aa 233671: cecee2c2acf69eb462d48a6fa015589b7aa9b4fe 233663: 36a6cc87cf0d0556707d8dc97b3f454889887eb2 v: v3 --- [refs] | 2 +- trunk/fs/btrfs/ctree.h | 2 ++ trunk/fs/btrfs/extent-tree.c | 7 +++++++ trunk/fs/btrfs/relocation.c | 13 ++++++++++++- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/[refs] b/[refs] index 5ba2c99f2f0a..541f22a4aa7e 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 91435650c233b93e0da389db74f4b2c11c5ad2d4 +refs/heads/master: c87f08ca44e83b2c8d28f63f9c33f3a270a04bbe diff --git a/trunk/fs/btrfs/ctree.h b/trunk/fs/btrfs/ctree.h index 6297701bc19c..28188a786da0 100644 --- a/trunk/fs/btrfs/ctree.h +++ b/trunk/fs/btrfs/ctree.h @@ -2219,6 +2219,8 @@ int btrfs_error_unpin_extent_range(struct btrfs_root *root, u64 start, u64 end); int btrfs_error_discard_extent(struct btrfs_root *root, u64 bytenr, u64 num_bytes); +int btrfs_force_chunk_alloc(struct btrfs_trans_handle *trans, + struct btrfs_root *root, u64 type); /* ctree.c */ int btrfs_bin_search(struct extent_buffer *eb, struct btrfs_key *key, diff --git a/trunk/fs/btrfs/extent-tree.c b/trunk/fs/btrfs/extent-tree.c index d375fc04a065..100e409e9053 100644 --- a/trunk/fs/btrfs/extent-tree.c +++ b/trunk/fs/btrfs/extent-tree.c @@ -8066,6 +8066,13 @@ int btrfs_set_block_group_ro(struct btrfs_root *root, return ret; } +int btrfs_force_chunk_alloc(struct btrfs_trans_handle *trans, + struct btrfs_root *root, u64 type) +{ + u64 alloc_flags = get_alloc_profile(root, type); + return do_chunk_alloc(trans, root, 2 * 1024 * 1024, alloc_flags, 1); +} + /* * helper to account the unused space of all the readonly block group in the * list. takes mirrors into account. diff --git a/trunk/fs/btrfs/relocation.c b/trunk/fs/btrfs/relocation.c index 0825e4ed9447..31ade5802ae8 100644 --- a/trunk/fs/btrfs/relocation.c +++ b/trunk/fs/btrfs/relocation.c @@ -3654,6 +3654,7 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc) u32 item_size; int ret; int err = 0; + int progress = 0; path = btrfs_alloc_path(); if (!path) @@ -3666,9 +3667,10 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc) } while (1) { + progress++; trans = btrfs_start_transaction(rc->extent_root, 0); BUG_ON(IS_ERR(trans)); - +restart: if (update_backref_cache(trans, &rc->backref_cache)) { btrfs_end_transaction(trans, rc->extent_root); continue; @@ -3781,6 +3783,15 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc) } } } + if (trans && progress && err == -ENOSPC) { + ret = btrfs_force_chunk_alloc(trans, rc->extent_root, + rc->block_group->flags); + if (ret == 0) { + err = 0; + progress = 0; + goto restart; + } + } btrfs_release_path(rc->extent_root, path); clear_extent_bits(&rc->processed_blocks, 0, (u64)-1, EXTENT_DIRTY,