diff options
author | Yan Zheng <zheng.yan@oracle.com> | 2008-11-17 21:11:30 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-11-17 21:11:30 -0500 |
commit | 2b82032c34ec40515d3c45c36cd1961f37977de8 (patch) | |
tree | fbdfe7b13dd51983dfca4aeb75983b37ee186ff9 /fs/btrfs/volumes.h | |
parent | c146afad2c7fea6a366d4945c1bab9b03880f526 (diff) |
Btrfs: Seed device support
Seed device is a special btrfs with SEEDING super flag
set and can only be mounted in read-only mode. Seed
devices allow people to create new btrfs on top of it.
The new FS contains the same contents as the seed device,
but it can be mounted in read-write mode.
This patch does the following:
1) split code in btrfs_alloc_chunk into two parts. The first part does makes
the newly allocated chunk usable, but does not do any operation that modifies
the chunk tree. The second part does the the chunk tree modifications. This
division is for the bootstrap step of adding storage to the seed device.
2) Update device management code to handle seed device.
The basic idea is: For an FS grown from seed devices, its
seed devices are put into a list. Seed devices are
opened on demand at mounting time. If any seed device is
missing or has been changed, btrfs kernel module will
refuse to mount the FS.
3) make btrfs_find_block_group not return NULL when all
block groups are read-only.
Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
Diffstat (limited to 'fs/btrfs/volumes.h')
-rw-r--r-- | fs/btrfs/volumes.h | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index c50e50580b51..1f6f25a5787f 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h | |||
@@ -26,6 +26,7 @@ struct buffer_head; | |||
26 | struct btrfs_device { | 26 | struct btrfs_device { |
27 | struct list_head dev_list; | 27 | struct list_head dev_list; |
28 | struct list_head dev_alloc_list; | 28 | struct list_head dev_alloc_list; |
29 | struct btrfs_fs_devices *fs_devices; | ||
29 | struct btrfs_root *dev_root; | 30 | struct btrfs_root *dev_root; |
30 | struct buffer_head *pending_io; | 31 | struct buffer_head *pending_io; |
31 | struct bio *pending_bios; | 32 | struct bio *pending_bios; |
@@ -34,6 +35,7 @@ struct btrfs_device { | |||
34 | u64 generation; | 35 | u64 generation; |
35 | 36 | ||
36 | int barriers; | 37 | int barriers; |
38 | int writeable; | ||
37 | int in_fs_metadata; | 39 | int in_fs_metadata; |
38 | 40 | ||
39 | spinlock_t io_lock; | 41 | spinlock_t io_lock; |
@@ -77,6 +79,8 @@ struct btrfs_fs_devices { | |||
77 | u64 latest_trans; | 79 | u64 latest_trans; |
78 | u64 num_devices; | 80 | u64 num_devices; |
79 | u64 open_devices; | 81 | u64 open_devices; |
82 | u64 rw_devices; | ||
83 | u64 total_rw_bytes; | ||
80 | struct block_device *latest_bdev; | 84 | struct block_device *latest_bdev; |
81 | /* all of the devices in the FS */ | 85 | /* all of the devices in the FS */ |
82 | struct list_head devices; | 86 | struct list_head devices; |
@@ -84,7 +88,12 @@ struct btrfs_fs_devices { | |||
84 | /* devices not currently being allocated */ | 88 | /* devices not currently being allocated */ |
85 | struct list_head alloc_list; | 89 | struct list_head alloc_list; |
86 | struct list_head list; | 90 | struct list_head list; |
87 | int mounted; | 91 | |
92 | struct btrfs_fs_devices *seed; | ||
93 | int seeding; | ||
94 | int sprouted; | ||
95 | |||
96 | int opened; | ||
88 | }; | 97 | }; |
89 | 98 | ||
90 | struct btrfs_bio_stripe { | 99 | struct btrfs_bio_stripe { |
@@ -109,16 +118,14 @@ struct btrfs_multi_bio { | |||
109 | int btrfs_alloc_dev_extent(struct btrfs_trans_handle *trans, | 118 | int btrfs_alloc_dev_extent(struct btrfs_trans_handle *trans, |
110 | struct btrfs_device *device, | 119 | struct btrfs_device *device, |
111 | u64 chunk_tree, u64 chunk_objectid, | 120 | u64 chunk_tree, u64 chunk_objectid, |
112 | u64 chunk_offset, | 121 | u64 chunk_offset, u64 start, u64 num_bytes); |
113 | u64 num_bytes, u64 *start); | ||
114 | int btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw, | 122 | int btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw, |
115 | u64 logical, u64 *length, | 123 | u64 logical, u64 *length, |
116 | struct btrfs_multi_bio **multi_ret, int mirror_num); | 124 | struct btrfs_multi_bio **multi_ret, int mirror_num); |
117 | int btrfs_read_sys_array(struct btrfs_root *root); | 125 | int btrfs_read_sys_array(struct btrfs_root *root); |
118 | int btrfs_read_chunk_tree(struct btrfs_root *root); | 126 | int btrfs_read_chunk_tree(struct btrfs_root *root); |
119 | int btrfs_alloc_chunk(struct btrfs_trans_handle *trans, | 127 | int btrfs_alloc_chunk(struct btrfs_trans_handle *trans, |
120 | struct btrfs_root *extent_root, u64 *start, | 128 | struct btrfs_root *extent_root, u64 type); |
121 | u64 *num_bytes, u64 type); | ||
122 | void btrfs_mapping_init(struct btrfs_mapping_tree *tree); | 129 | void btrfs_mapping_init(struct btrfs_mapping_tree *tree); |
123 | void btrfs_mapping_tree_free(struct btrfs_mapping_tree *tree); | 130 | void btrfs_mapping_tree_free(struct btrfs_mapping_tree *tree); |
124 | int btrfs_map_bio(struct btrfs_root *root, int rw, struct bio *bio, | 131 | int btrfs_map_bio(struct btrfs_root *root, int rw, struct bio *bio, |
@@ -141,10 +148,11 @@ int btrfs_unplug_page(struct btrfs_mapping_tree *map_tree, | |||
141 | int btrfs_grow_device(struct btrfs_trans_handle *trans, | 148 | int btrfs_grow_device(struct btrfs_trans_handle *trans, |
142 | struct btrfs_device *device, u64 new_size); | 149 | struct btrfs_device *device, u64 new_size); |
143 | struct btrfs_device *btrfs_find_device(struct btrfs_root *root, u64 devid, | 150 | struct btrfs_device *btrfs_find_device(struct btrfs_root *root, u64 devid, |
144 | u8 *uuid); | 151 | u8 *uuid, u8 *fsid); |
145 | int btrfs_shrink_device(struct btrfs_device *device, u64 new_size); | 152 | int btrfs_shrink_device(struct btrfs_device *device, u64 new_size); |
146 | int btrfs_init_new_device(struct btrfs_root *root, char *path); | 153 | int btrfs_init_new_device(struct btrfs_root *root, char *path); |
147 | int btrfs_balance(struct btrfs_root *dev_root); | 154 | int btrfs_balance(struct btrfs_root *dev_root); |
148 | void btrfs_unlock_volumes(void); | 155 | void btrfs_unlock_volumes(void); |
149 | void btrfs_lock_volumes(void); | 156 | void btrfs_lock_volumes(void); |
157 | int btrfs_chunk_readonly(struct btrfs_root *root, u64 chunk_offset); | ||
150 | #endif | 158 | #endif |