diff options
author | Stefan Behrens <sbehrens@giantdisaster.de> | 2013-08-15 11:11:19 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@fusionio.com> | 2013-09-01 08:15:54 -0400 |
commit | f7a81ea4cc6bdb51d8267d2f3ff485f0b4070074 (patch) | |
tree | 61fd4fd144fae34736eb2cda2ed6b351c82d9b54 /fs/btrfs/volumes.c | |
parent | 8f8ae8e213300378d2506b68d581c80d9dfd2faf (diff) |
Btrfs: create UUID tree if required
This tree is not created by mkfs.btrfs. Therefore when a filesystem
is mounted writable and the UUID tree does not exist, this tree is
created if required. The tree is also added to the fs_info structure
and initialized, but this commit does not yet read or write UUID tree
elements.
Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r-- | fs/btrfs/volumes.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 306547b51a13..e084218c09d2 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -3429,6 +3429,32 @@ int btrfs_cancel_balance(struct btrfs_fs_info *fs_info) | |||
3429 | return 0; | 3429 | return 0; |
3430 | } | 3430 | } |
3431 | 3431 | ||
3432 | int btrfs_create_uuid_tree(struct btrfs_fs_info *fs_info) | ||
3433 | { | ||
3434 | struct btrfs_trans_handle *trans; | ||
3435 | struct btrfs_root *tree_root = fs_info->tree_root; | ||
3436 | struct btrfs_root *uuid_root; | ||
3437 | |||
3438 | /* | ||
3439 | * 1 - root node | ||
3440 | * 1 - root item | ||
3441 | */ | ||
3442 | trans = btrfs_start_transaction(tree_root, 2); | ||
3443 | if (IS_ERR(trans)) | ||
3444 | return PTR_ERR(trans); | ||
3445 | |||
3446 | uuid_root = btrfs_create_tree(trans, fs_info, | ||
3447 | BTRFS_UUID_TREE_OBJECTID); | ||
3448 | if (IS_ERR(uuid_root)) { | ||
3449 | btrfs_abort_transaction(trans, tree_root, | ||
3450 | PTR_ERR(uuid_root)); | ||
3451 | return PTR_ERR(uuid_root); | ||
3452 | } | ||
3453 | |||
3454 | fs_info->uuid_root = uuid_root; | ||
3455 | |||
3456 | return btrfs_commit_transaction(trans, tree_root); | ||
3457 | } | ||
3432 | /* | 3458 | /* |
3433 | * shrinking a device means finding all of the device extents past | 3459 | * shrinking a device means finding all of the device extents past |
3434 | * the new size, and then following the back refs to the chunks. | 3460 | * the new size, and then following the back refs to the chunks. |