reproducing steps:
mkfs.btrfs /dev/dm-2 -f
mount /dev/dm-2 /btrfs
umount /btrfs
btrfs check /dev/dm-2 --repair
mount /dev/dm-2 /btrfs

----
btrfs: mismatching generation and generation_v2 found in root item. This root 
was probably mounted with an older kernel. Resetting all new fields.
----

btrfs-debug-tree shows change in uuid

<               root data bytenr 29425664 level 0 dirid 0 refs 1 gen 43
<               uuid 293596e8-7888-eb4c-9134-6df9db996fe5

Signed-off-by: Anand Jain <anand.j...@oracle.com>
---
 root-tree.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/root-tree.c b/root-tree.c
index c10d068..4454147 100644
--- a/root-tree.c
+++ b/root-tree.c
@@ -69,6 +69,7 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, 
struct btrfs_root
        int ret;
        int slot;
        unsigned long ptr;
+       u32 old_size;
 
        path = btrfs_alloc_path();
        BUG_ON(!path);
@@ -79,6 +80,18 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, 
struct btrfs_root
        l = path->nodes[0];
        slot = path->slots[0];
        ptr = btrfs_item_ptr_offset(l, slot);
+       /*
+       * If the btrfs-progs is newer and kernel is at
+       * generation_v1 then we don't touch v2 items
+       * otherwise when kernel is at same or greater
+       * version compared with btrfs-progs then update
+       * the needed
+       */
+       old_size = btrfs_item_size_nr(l, slot);
+       if (old_size >= sizeof(*item)) {
+               btrfs_set_root_generation_v2(item,
+                       btrfs_root_generation(item));
+       }
        write_extent_buffer(l, item, ptr, sizeof(*item));
        btrfs_mark_buffer_dirty(path->nodes[0]);
 out:
-- 
1.8.1.227.g44fe835

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to