aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorStefan Behrens <sbehrens@giantdisaster.de>2012-11-05 11:26:40 -0500
committerJosef Bacik <jbacik@fusionio.com>2012-12-12 17:15:37 -0500
commite922e087a35c437acef3bc88ce31e59c699c38bd (patch)
tree7fe78c7b4b3927132d5f06617c47f26a3dbcc686 /fs
parent1acd6831d98779c88cd57f0a5826d6df0b09f3fa (diff)
Btrfs: enhance btrfs structures for device replace support
Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/ctree.h39
-rw-r--r--fs/btrfs/disk-io.c5
2 files changed, 44 insertions, 0 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index f8bb62c82b0c..0781fd4a5c1a 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -885,6 +885,42 @@ struct btrfs_dev_stats_item {
885 __le64 values[BTRFS_DEV_STAT_VALUES_MAX]; 885 __le64 values[BTRFS_DEV_STAT_VALUES_MAX];
886} __attribute__ ((__packed__)); 886} __attribute__ ((__packed__));
887 887
888#define BTRFS_DEV_REPLACE_ITEM_CONT_READING_FROM_SRCDEV_MODE_ALWAYS 0
889#define BTRFS_DEV_REPLACE_ITEM_CONT_READING_FROM_SRCDEV_MODE_AVOID 1
890#define BTRFS_DEV_REPLACE_ITEM_STATE_NEVER_STARTED 0
891#define BTRFS_DEV_REPLACE_ITEM_STATE_STARTED 1
892#define BTRFS_DEV_REPLACE_ITEM_STATE_SUSPENDED 2
893#define BTRFS_DEV_REPLACE_ITEM_STATE_FINISHED 3
894#define BTRFS_DEV_REPLACE_ITEM_STATE_CANCELED 4
895
896struct btrfs_dev_replace {
897 u64 replace_state; /* see #define above */
898 u64 time_started; /* seconds since 1-Jan-1970 */
899 u64 time_stopped; /* seconds since 1-Jan-1970 */
900 atomic64_t num_write_errors;
901 atomic64_t num_uncorrectable_read_errors;
902
903 u64 cursor_left;
904 u64 committed_cursor_left;
905 u64 cursor_left_last_write_of_item;
906 u64 cursor_right;
907
908 u64 cont_reading_from_srcdev_mode; /* see #define above */
909
910 int is_valid;
911 int item_needs_writeback;
912 struct btrfs_device *srcdev;
913 struct btrfs_device *tgtdev;
914
915 pid_t lock_owner;
916 atomic_t nesting_level;
917 struct mutex lock_finishing_cancel_unmount;
918 struct mutex lock_management_lock;
919 struct mutex lock;
920
921 struct btrfs_scrub_progress scrub_progress;
922};
923
888/* different types of block groups (and chunks) */ 924/* different types of block groups (and chunks) */
889#define BTRFS_BLOCK_GROUP_DATA (1ULL << 0) 925#define BTRFS_BLOCK_GROUP_DATA (1ULL << 0)
890#define BTRFS_BLOCK_GROUP_SYSTEM (1ULL << 1) 926#define BTRFS_BLOCK_GROUP_SYSTEM (1ULL << 1)
@@ -1471,6 +1507,9 @@ struct btrfs_fs_info {
1471 int backup_root_index; 1507 int backup_root_index;
1472 1508
1473 int num_tolerated_disk_barrier_failures; 1509 int num_tolerated_disk_barrier_failures;
1510
1511 /* device replace state */
1512 struct btrfs_dev_replace dev_replace;
1474}; 1513};
1475 1514
1476/* 1515/*
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 42a8024e935f..9d1b71060813 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2131,6 +2131,11 @@ int open_ctree(struct super_block *sb,
2131 init_rwsem(&fs_info->extent_commit_sem); 2131 init_rwsem(&fs_info->extent_commit_sem);
2132 init_rwsem(&fs_info->cleanup_work_sem); 2132 init_rwsem(&fs_info->cleanup_work_sem);
2133 init_rwsem(&fs_info->subvol_sem); 2133 init_rwsem(&fs_info->subvol_sem);
2134 fs_info->dev_replace.lock_owner = 0;
2135 atomic_set(&fs_info->dev_replace.nesting_level, 0);
2136 mutex_init(&fs_info->dev_replace.lock_finishing_cancel_unmount);
2137 mutex_init(&fs_info->dev_replace.lock_management_lock);
2138 mutex_init(&fs_info->dev_replace.lock);
2134 2139
2135 spin_lock_init(&fs_info->qgroup_lock); 2140 spin_lock_init(&fs_info->qgroup_lock);
2136 fs_info->qgroup_tree = RB_ROOT; 2141 fs_info->qgroup_tree = RB_ROOT;