aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorStefan Behrens <sbehrens@giantdisaster.de>2013-04-19 11:08:05 -0400
committerJosef Bacik <jbacik@fusionio.com>2013-05-06 15:55:14 -0400
commit6463fe58ea60cbcc3e799937dd0877466fc7b8d5 (patch)
treeb5e43aa6c429eed30b2ff020ca425e636ebda524 /fs
parent5fbf83c10c323cbee61483a06ea61883e3c83e6b (diff)
Btrfs: set UUID in root_item for created trees
It is a rare exception that a new tree is created, like the qgroups tree. So far these new trees have an all-zero UUID in their root items. All trees that mkfs.btrfs has created get an UUID during the first mount when btrfs_read_root_item() rewrites the root_item to the v2 structure style. These UUID are never used so far, but anyway, since it is better to have it uniform for all trees, this commit adds some lines that generate and write an UUID for newly created trees. Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de> Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/disk-io.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index a03a96650548..e4488b57a7ae 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -30,6 +30,7 @@
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/migrate.h> 31#include <linux/migrate.h>
32#include <linux/ratelimit.h> 32#include <linux/ratelimit.h>
33#include <linux/uuid.h>
33#include <asm/unaligned.h> 34#include <asm/unaligned.h>
34#include "compat.h" 35#include "compat.h"
35#include "ctree.h" 36#include "ctree.h"
@@ -1280,6 +1281,7 @@ struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans,
1280 struct btrfs_key key; 1281 struct btrfs_key key;
1281 int ret = 0; 1282 int ret = 0;
1282 u64 bytenr; 1283 u64 bytenr;
1284 uuid_le uuid;
1283 1285
1284 root = btrfs_alloc_root(fs_info); 1286 root = btrfs_alloc_root(fs_info);
1285 if (!root) 1287 if (!root)
@@ -1329,6 +1331,8 @@ struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans,
1329 btrfs_set_root_used(&root->root_item, leaf->len); 1331 btrfs_set_root_used(&root->root_item, leaf->len);
1330 btrfs_set_root_last_snapshot(&root->root_item, 0); 1332 btrfs_set_root_last_snapshot(&root->root_item, 0);
1331 btrfs_set_root_dirid(&root->root_item, 0); 1333 btrfs_set_root_dirid(&root->root_item, 0);
1334 uuid_le_gen(&uuid);
1335 memcpy(root->root_item.uuid, uuid.b, BTRFS_UUID_SIZE);
1332 root->root_item.drop_level = 0; 1336 root->root_item.drop_level = 0;
1333 1337
1334 key.objectid = objectid; 1338 key.objectid = objectid;