diff options
author | Eric Sandeen <sandeen@redhat.com> | 2013-04-22 00:01:26 -0500 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2013-04-23 18:56:28 +0200 |
commit | 3456bf086603d11ae77b15e381d6523105f75f15 (patch) | |
tree | 0565eb3e4e80d5ea5b9277af46da1cd5f6f3d027 /root-tree.c | |
parent | 4782e8ebdb583dfa3615f7b38dee729d34f62ec1 (diff) |
btrfs-progs: set generation_v2 any time we write a new root
With this integration branch commit in place:
2bd1169 btrfs-progs: root_item generation_v2 is out of sync after btrfsck
I started seeing generation mismatch messages from the kernel
at mount time, after a fresh mkfs(!):
btrfs: mismatching generation and generation_v2 found in root item...
This is because the code which emits the warning does not do so if
there is a mismatch but generation_v2 is 0; the above commit began
setting generation_v2 to something non-zero, so the warning was emitted.
The reason there is a mismatch at all is because mkfs.btrfs calls
create_data_reloc_tree(), which copies a root, and then calls
btrfs_set_root_generation(), bumping the original copied generation.
But nothing updated generation_v2 to match on the way to disk.
Fix this by updating generation_v2 in btrfs_insert_root(),
as is done in the kernel.
This is safe because it's a new root created by userspace, so
the btrfs_root_item is guaranteed to be big enough to contain
generation_v2.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Diffstat (limited to 'root-tree.c')
-rw-r--r-- | root-tree.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/root-tree.c b/root-tree.c index c10d0684..ef2190fc 100644 --- a/root-tree.c +++ b/root-tree.c @@ -92,6 +92,11 @@ int btrfs_insert_root(struct btrfs_trans_handle *trans, struct btrfs_root *item) { int ret; + + /* + * Make sure generation v1 and v2 match. See update_root for details. + */ + btrfs_set_root_generation_v2(item, btrfs_root_generation(item)); ret = btrfs_insert_item(trans, root, key, item, sizeof(*item)); return ret; } |