@@ -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: