aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
authorStefan Behrens <sbehrens@giantdisaster.de>2012-11-06 07:15:27 -0500
committerJosef Bacik <jbacik@fusionio.com>2012-12-12 17:15:42 -0500
commit8dabb7420f014ab0f9f04afae8ae046c0f48b270 (patch)
tree6342f353ac71003d749a776dd6dc6a18b1bd959b /fs/btrfs/disk-io.c
parente93c89c1aaaaaec3487c4c18dd02360371790722 (diff)
Btrfs: change core code of btrfs to support the device replace operations
This commit contains all the essential changes to the core code of Btrfs for support of the device replace procedure. Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 0e410478ad27..76b82506bf92 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -45,6 +45,7 @@
45#include "inode-map.h" 45#include "inode-map.h"
46#include "check-integrity.h" 46#include "check-integrity.h"
47#include "rcu-string.h" 47#include "rcu-string.h"
48#include "dev-replace.h"
48 49
49#ifdef CONFIG_X86 50#ifdef CONFIG_X86
50#include <asm/cpufeature.h> 51#include <asm/cpufeature.h>
@@ -2438,7 +2439,11 @@ int open_ctree(struct super_block *sb,
2438 goto fail_tree_roots; 2439 goto fail_tree_roots;
2439 } 2440 }
2440 2441
2441 btrfs_close_extra_devices(fs_devices); 2442 /*
2443 * keep the device that is marked to be the target device for the
2444 * dev_replace procedure
2445 */
2446 btrfs_close_extra_devices(fs_info, fs_devices, 0);
2442 2447
2443 if (!fs_devices->latest_bdev) { 2448 if (!fs_devices->latest_bdev) {
2444 printk(KERN_CRIT "btrfs: failed to read devices on %s\n", 2449 printk(KERN_CRIT "btrfs: failed to read devices on %s\n",
@@ -2510,6 +2515,14 @@ retry_root_backup:
2510 goto fail_block_groups; 2515 goto fail_block_groups;
2511 } 2516 }
2512 2517
2518 ret = btrfs_init_dev_replace(fs_info);
2519 if (ret) {
2520 pr_err("btrfs: failed to init dev_replace: %d\n", ret);
2521 goto fail_block_groups;
2522 }
2523
2524 btrfs_close_extra_devices(fs_info, fs_devices, 1);
2525
2513 ret = btrfs_init_space_info(fs_info); 2526 ret = btrfs_init_space_info(fs_info);
2514 if (ret) { 2527 if (ret) {
2515 printk(KERN_ERR "Failed to initial space info: %d\n", ret); 2528 printk(KERN_ERR "Failed to initial space info: %d\n", ret);
@@ -2658,6 +2671,13 @@ retry_root_backup:
2658 return ret; 2671 return ret;
2659 } 2672 }
2660 2673
2674 ret = btrfs_resume_dev_replace_async(fs_info);
2675 if (ret) {
2676 pr_warn("btrfs: failed to resume dev_replace\n");
2677 close_ctree(tree_root);
2678 return ret;
2679 }
2680
2661 return 0; 2681 return 0;
2662 2682
2663fail_qgroup: 2683fail_qgroup:
@@ -3300,6 +3320,8 @@ int close_ctree(struct btrfs_root *root)
3300 /* pause restriper - we want to resume on mount */ 3320 /* pause restriper - we want to resume on mount */
3301 btrfs_pause_balance(fs_info); 3321 btrfs_pause_balance(fs_info);
3302 3322
3323 btrfs_dev_replace_suspend_for_unmount(fs_info);
3324
3303 btrfs_scrub_cancel(fs_info); 3325 btrfs_scrub_cancel(fs_info);
3304 3326
3305 /* wait for any defraggers to finish */ 3327 /* wait for any defraggers to finish */