diff options
author | Chris Mason <chris.mason@oracle.com> | 2008-03-24 15:01:56 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:04:00 -0400 |
commit | 0b86a832a1f38abec695864ec2eaedc9d2383f1b (patch) | |
tree | 8ec0db0b55f77eb6a23fe7db3c1064d298db55c1 /fs/btrfs/transaction.c | |
parent | 7f93bf8d27653726e3721c01fefc523487ecf2af (diff) |
Btrfs: Add support for multiple devices per filesystem
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/transaction.c')
-rw-r--r-- | fs/btrfs/transaction.c | 50 |
1 files changed, 34 insertions, 16 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index e9a0983897f3..5e9f69244f9f 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c | |||
@@ -198,29 +198,42 @@ int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans, | |||
198 | return werr; | 198 | return werr; |
199 | } | 199 | } |
200 | 200 | ||
201 | int btrfs_commit_tree_roots(struct btrfs_trans_handle *trans, | 201 | static int update_cowonly_root(struct btrfs_trans_handle *trans, |
202 | struct btrfs_root *root) | 202 | struct btrfs_root *root) |
203 | { | 203 | { |
204 | int ret; | 204 | int ret; |
205 | u64 old_extent_block; | 205 | u64 old_root_bytenr; |
206 | struct btrfs_fs_info *fs_info = root->fs_info; | 206 | struct btrfs_root *tree_root = root->fs_info->tree_root; |
207 | struct btrfs_root *tree_root = fs_info->tree_root; | ||
208 | struct btrfs_root *extent_root = fs_info->extent_root; | ||
209 | 207 | ||
210 | btrfs_write_dirty_block_groups(trans, extent_root); | 208 | btrfs_write_dirty_block_groups(trans, root); |
211 | while(1) { | 209 | while(1) { |
212 | old_extent_block = btrfs_root_bytenr(&extent_root->root_item); | 210 | old_root_bytenr = btrfs_root_bytenr(&root->root_item); |
213 | if (old_extent_block == extent_root->node->start) | 211 | if (old_root_bytenr == root->node->start) |
214 | break; | 212 | break; |
215 | btrfs_set_root_bytenr(&extent_root->root_item, | 213 | btrfs_set_root_bytenr(&root->root_item, |
216 | extent_root->node->start); | 214 | root->node->start); |
217 | btrfs_set_root_level(&extent_root->root_item, | 215 | btrfs_set_root_level(&root->root_item, |
218 | btrfs_header_level(extent_root->node)); | 216 | btrfs_header_level(root->node)); |
219 | ret = btrfs_update_root(trans, tree_root, | 217 | ret = btrfs_update_root(trans, tree_root, |
220 | &extent_root->root_key, | 218 | &root->root_key, |
221 | &extent_root->root_item); | 219 | &root->root_item); |
222 | BUG_ON(ret); | 220 | BUG_ON(ret); |
223 | btrfs_write_dirty_block_groups(trans, extent_root); | 221 | btrfs_write_dirty_block_groups(trans, root); |
222 | } | ||
223 | return 0; | ||
224 | } | ||
225 | |||
226 | int btrfs_commit_tree_roots(struct btrfs_trans_handle *trans, | ||
227 | struct btrfs_root *root) | ||
228 | { | ||
229 | struct btrfs_fs_info *fs_info = root->fs_info; | ||
230 | struct list_head *next; | ||
231 | |||
232 | while(!list_empty(&fs_info->dirty_cowonly_roots)) { | ||
233 | next = fs_info->dirty_cowonly_roots.next; | ||
234 | list_del_init(next); | ||
235 | root = list_entry(next, struct btrfs_root, dirty_list); | ||
236 | update_cowonly_root(trans, root); | ||
224 | } | 237 | } |
225 | return 0; | 238 | return 0; |
226 | } | 239 | } |
@@ -616,6 +629,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, | |||
616 | unsigned long timeout = 1; | 629 | unsigned long timeout = 1; |
617 | struct btrfs_transaction *cur_trans; | 630 | struct btrfs_transaction *cur_trans; |
618 | struct btrfs_transaction *prev_trans = NULL; | 631 | struct btrfs_transaction *prev_trans = NULL; |
632 | struct btrfs_root *chunk_root = root->fs_info->chunk_root; | ||
619 | struct list_head dirty_fs_roots; | 633 | struct list_head dirty_fs_roots; |
620 | struct extent_io_tree *pinned_copy; | 634 | struct extent_io_tree *pinned_copy; |
621 | DEFINE_WAIT(wait); | 635 | DEFINE_WAIT(wait); |
@@ -714,6 +728,10 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, | |||
714 | btrfs_set_super_root_level(&root->fs_info->super_copy, | 728 | btrfs_set_super_root_level(&root->fs_info->super_copy, |
715 | btrfs_header_level(root->fs_info->tree_root->node)); | 729 | btrfs_header_level(root->fs_info->tree_root->node)); |
716 | 730 | ||
731 | btrfs_set_super_chunk_root(&root->fs_info->super_copy, | ||
732 | chunk_root->node->start); | ||
733 | btrfs_set_super_chunk_root_level(&root->fs_info->super_copy, | ||
734 | btrfs_header_level(chunk_root->node)); | ||
717 | write_extent_buffer(root->fs_info->sb_buffer, | 735 | write_extent_buffer(root->fs_info->sb_buffer, |
718 | &root->fs_info->super_copy, 0, | 736 | &root->fs_info->super_copy, 0, |
719 | sizeof(root->fs_info->super_copy)); | 737 | sizeof(root->fs_info->super_copy)); |