Commit 0476fa94 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Rev the on disk format version for snapshots

This will cause the compat code to be run that creates entries in the
subvolumes and snapshots btrees.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent 71ed0056
...@@ -1262,7 +1262,8 @@ enum bcachefs_metadata_version { ...@@ -1262,7 +1262,8 @@ enum bcachefs_metadata_version {
bcachefs_metadata_version_snapshot = 12, bcachefs_metadata_version_snapshot = 12,
bcachefs_metadata_version_inode_backpointers = 13, bcachefs_metadata_version_inode_backpointers = 13,
bcachefs_metadata_version_btree_ptr_sectors_written = 14, bcachefs_metadata_version_btree_ptr_sectors_written = 14,
bcachefs_metadata_version_max = 15, bcachefs_metadata_version_snapshot_2 = 15,
bcachefs_metadata_version_max = 16,
}; };
#define bcachefs_metadata_version_current (bcachefs_metadata_version_max - 1) #define bcachefs_metadata_version_current (bcachefs_metadata_version_max - 1)
......
...@@ -1004,11 +1004,10 @@ static int bch2_fs_upgrade_for_subvolumes(struct btree_trans *trans) ...@@ -1004,11 +1004,10 @@ static int bch2_fs_upgrade_for_subvolumes(struct btree_trans *trans)
struct btree_iter iter; struct btree_iter iter;
struct bkey_s_c k; struct bkey_s_c k;
struct bch_inode_unpacked inode; struct bch_inode_unpacked inode;
struct bkey_inode_buf *packed;
int ret; int ret;
bch2_trans_iter_init(trans, &iter, BTREE_ID_inodes, bch2_trans_iter_init(trans, &iter, BTREE_ID_inodes,
POS(0, BCACHEFS_ROOT_INO), 0); SPOS(0, BCACHEFS_ROOT_INO, U32_MAX), 0);
k = bch2_btree_iter_peek_slot(&iter); k = bch2_btree_iter_peek_slot(&iter);
ret = bkey_err(k); ret = bkey_err(k);
if (ret) if (ret)
...@@ -1025,13 +1024,7 @@ static int bch2_fs_upgrade_for_subvolumes(struct btree_trans *trans) ...@@ -1025,13 +1024,7 @@ static int bch2_fs_upgrade_for_subvolumes(struct btree_trans *trans)
inode.bi_subvol = BCACHEFS_ROOT_SUBVOL; inode.bi_subvol = BCACHEFS_ROOT_SUBVOL;
packed = bch2_trans_kmalloc(trans, sizeof(*packed)); ret = bch2_inode_write(trans, &iter, &inode);
ret = PTR_ERR_OR_ZERO(packed);
if (ret)
goto err;
bch2_inode_pack(c, packed, &inode);
ret = bch2_trans_update(trans, &iter, &packed->inode.k_i, 0);
err: err:
bch2_trans_iter_exit(trans, &iter); bch2_trans_iter_exit(trans, &iter);
return ret; return ret;
...@@ -1096,8 +1089,8 @@ int bch2_fs_recovery(struct bch_fs *c) ...@@ -1096,8 +1089,8 @@ int bch2_fs_recovery(struct bch_fs *c)
} else if (c->sb.version < bcachefs_metadata_version_btree_ptr_sectors_written) { } else if (c->sb.version < bcachefs_metadata_version_btree_ptr_sectors_written) {
bch_info(c, "version prior to btree_ptr_sectors_written, upgrade required"); bch_info(c, "version prior to btree_ptr_sectors_written, upgrade required");
c->opts.version_upgrade = true; c->opts.version_upgrade = true;
} else if (c->sb.version < bcachefs_metadata_version_snapshot) { } else if (c->sb.version < bcachefs_metadata_version_snapshot_2) {
bch_info(c, "filesystem version is prior to snapshot field - upgrading"); bch_info(c, "filesystem version is prior to snapshots - upgrading");
c->opts.version_upgrade = true; c->opts.version_upgrade = true;
} }
...@@ -1267,7 +1260,9 @@ int bch2_fs_recovery(struct bch_fs *c) ...@@ -1267,7 +1260,9 @@ int bch2_fs_recovery(struct bch_fs *c)
bch_verbose(c, "alloc write done"); bch_verbose(c, "alloc write done");
} }
if (c->sb.version < bcachefs_metadata_version_snapshot) { if (c->sb.version < bcachefs_metadata_version_snapshot_2) {
bch2_fs_lazy_rw(c);
err = "error creating root snapshot node"; err = "error creating root snapshot node";
ret = bch2_fs_initialize_subvolumes(c); ret = bch2_fs_initialize_subvolumes(c);
if (ret) if (ret)
...@@ -1281,7 +1276,7 @@ int bch2_fs_recovery(struct bch_fs *c) ...@@ -1281,7 +1276,7 @@ int bch2_fs_recovery(struct bch_fs *c)
goto err; goto err;
bch_verbose(c, "reading snapshots done"); bch_verbose(c, "reading snapshots done");
if (c->sb.version < bcachefs_metadata_version_snapshot) { if (c->sb.version < bcachefs_metadata_version_snapshot_2) {
/* set bi_subvol on root inode */ /* set bi_subvol on root inode */
err = "error upgrade root inode for subvolumes"; err = "error upgrade root inode for subvolumes";
ret = bch2_trans_do(c, NULL, NULL, BTREE_INSERT_LAZY_RW, ret = bch2_trans_do(c, NULL, NULL, BTREE_INSERT_LAZY_RW,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment