aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-01-04 16:47:16 -0500
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:03:59 -0400
commit725c8463ea9bcfc2b56cff09b93a90e5bcca59c4 (patch)
treed61b7136fe1af2b7e3fcaacc6d214d8fea793111 /fs/btrfs/extent-tree.c
parent1372f8e609d260c2352bf74e125614eef7aee8ef (diff)
Btrfs: resizer: don't hold the fs_mutex for long periods of time
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r--fs/btrfs/extent-tree.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index c390fd847a27..c906bb19b211 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -2331,6 +2331,7 @@ int btrfs_shrink_extent_tree(struct btrfs_root *root, u64 new_size)
2331 struct extent_buffer *leaf; 2331 struct extent_buffer *leaf;
2332 u32 nritems; 2332 u32 nritems;
2333 int ret; 2333 int ret;
2334 int progress = 0;
2334 2335
2335 btrfs_set_super_total_bytes(&info->super_copy, new_size); 2336 btrfs_set_super_total_bytes(&info->super_copy, new_size);
2336 block_group_cache = &info->block_group_cache; 2337 block_group_cache = &info->block_group_cache;
@@ -2383,6 +2384,19 @@ next:
2383 } 2384 }
2384 2385
2385 btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); 2386 btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]);
2387
2388 if (progress && need_resched()) {
2389 memcpy(&key, &found_key, sizeof(key));
2390 mutex_unlock(&root->fs_info->fs_mutex);
2391 cond_resched();
2392 mutex_lock(&root->fs_info->fs_mutex);
2393 btrfs_release_path(root, path);
2394 btrfs_search_slot(NULL, root, &key, path, 0, 0);
2395 progress = 0;
2396 goto next;
2397 }
2398 progress = 1;
2399
2386 if (btrfs_key_type(&found_key) != BTRFS_EXTENT_ITEM_KEY || 2400 if (btrfs_key_type(&found_key) != BTRFS_EXTENT_ITEM_KEY ||
2387 found_key.objectid + found_key.offset <= cur_byte) { 2401 found_key.objectid + found_key.offset <= cur_byte) {
2388 path->slots[0]++; 2402 path->slots[0]++;
@@ -2442,7 +2456,7 @@ bg_next:
2442 */ 2456 */
2443 memcpy(&key, &found_key, sizeof(key)); 2457 memcpy(&key, &found_key, sizeof(key));
2444 btrfs_release_path(root, path); 2458 btrfs_release_path(root, path);
2445 continue; 2459 goto resched_check;
2446 } 2460 }
2447 2461
2448 btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); 2462 btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]);
@@ -2465,6 +2479,12 @@ bg_next:
2465 key.objectid = found_key.objectid + 1; 2479 key.objectid = found_key.objectid + 1;
2466 btrfs_del_item(trans, root, path); 2480 btrfs_del_item(trans, root, path);
2467 btrfs_release_path(root, path); 2481 btrfs_release_path(root, path);
2482resched_check:
2483 if (need_resched()) {
2484 mutex_unlock(&root->fs_info->fs_mutex);
2485 cond_resched();
2486 mutex_lock(&root->fs_info->fs_mutex);
2487 }
2468 } 2488 }
2469 clear_extent_dirty(&info->free_space_cache, new_size, (u64)-1, 2489 clear_extent_dirty(&info->free_space_cache, new_size, (u64)-1,
2470 GFP_NOFS); 2490 GFP_NOFS);