|
64 | 64 |
|
65 | 65 | static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info, |
66 | 66 | int scrub_ret); |
67 | | -static void btrfs_dev_replace_update_device_in_mapping_tree( |
68 | | - struct btrfs_fs_info *fs_info, |
69 | | - struct btrfs_device *srcdev, |
70 | | - struct btrfs_device *tgtdev); |
71 | 67 | static int btrfs_dev_replace_kthread(void *data); |
72 | 68 |
|
73 | 69 | int btrfs_init_dev_replace(struct btrfs_fs_info *fs_info) |
@@ -628,6 +624,32 @@ static int btrfs_set_target_alloc_state(struct btrfs_device *srcdev, |
628 | 624 | return ret; |
629 | 625 | } |
630 | 626 |
|
| 627 | +static void btrfs_dev_replace_update_device_in_mapping_tree( |
| 628 | + struct btrfs_fs_info *fs_info, |
| 629 | + struct btrfs_device *srcdev, |
| 630 | + struct btrfs_device *tgtdev) |
| 631 | +{ |
| 632 | + struct extent_map_tree *em_tree = &fs_info->mapping_tree; |
| 633 | + struct extent_map *em; |
| 634 | + struct map_lookup *map; |
| 635 | + u64 start = 0; |
| 636 | + int i; |
| 637 | + |
| 638 | + write_lock(&em_tree->lock); |
| 639 | + do { |
| 640 | + em = lookup_extent_mapping(em_tree, start, (u64)-1); |
| 641 | + if (!em) |
| 642 | + break; |
| 643 | + map = em->map_lookup; |
| 644 | + for (i = 0; i < map->num_stripes; i++) |
| 645 | + if (srcdev == map->stripes[i].dev) |
| 646 | + map->stripes[i].dev = tgtdev; |
| 647 | + start = em->start + em->len; |
| 648 | + free_extent_map(em); |
| 649 | + } while (start); |
| 650 | + write_unlock(&em_tree->lock); |
| 651 | +} |
| 652 | + |
631 | 653 | static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info, |
632 | 654 | int scrub_ret) |
633 | 655 | { |
@@ -797,32 +819,6 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info, |
797 | 819 | return 0; |
798 | 820 | } |
799 | 821 |
|
800 | | -static void btrfs_dev_replace_update_device_in_mapping_tree( |
801 | | - struct btrfs_fs_info *fs_info, |
802 | | - struct btrfs_device *srcdev, |
803 | | - struct btrfs_device *tgtdev) |
804 | | -{ |
805 | | - struct extent_map_tree *em_tree = &fs_info->mapping_tree; |
806 | | - struct extent_map *em; |
807 | | - struct map_lookup *map; |
808 | | - u64 start = 0; |
809 | | - int i; |
810 | | - |
811 | | - write_lock(&em_tree->lock); |
812 | | - do { |
813 | | - em = lookup_extent_mapping(em_tree, start, (u64)-1); |
814 | | - if (!em) |
815 | | - break; |
816 | | - map = em->map_lookup; |
817 | | - for (i = 0; i < map->num_stripes; i++) |
818 | | - if (srcdev == map->stripes[i].dev) |
819 | | - map->stripes[i].dev = tgtdev; |
820 | | - start = em->start + em->len; |
821 | | - free_extent_map(em); |
822 | | - } while (start); |
823 | | - write_unlock(&em_tree->lock); |
824 | | -} |
825 | | - |
826 | 822 | /* |
827 | 823 | * Read progress of device replace status according to the state and last |
828 | 824 | * stored position. The value format is the same as for |
|
0 commit comments