diff options
| author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-12-20 04:46:00 -0500 |
|---|---|---|
| committer | Kent Overstreet <kent.overstreet@linux.dev> | 2025-01-09 23:38:41 -0500 |
| commit | 4bd06f07bcb5c472b7d7a90e6ee890bd0900b3e1 (patch) | |
| tree | 895769dd137a8c6ff93ef92b3881ad6870ac97f3 /fs/bcachefs/snapshot.c | |
| parent | bcachefs: Don't rely on snapshot_tree.master_subvol for reattaching (diff) | |
| download | linux-4bd06f07bcb5c472b7d7a90e6ee890bd0900b3e1.tar.gz linux-4bd06f07bcb5c472b7d7a90e6ee890bd0900b3e1.zip | |
bcachefs: Fixes for snapshot_tree.master_subvol
Ensure that snapshot_tree.master_subvol is cleared when we delete the
master subvolume in a tree of snapshots, and allow for snapshot trees
that don't have a master subvolume in fsck.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/snapshot.c')
| -rw-r--r-- | fs/bcachefs/snapshot.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/fs/bcachefs/snapshot.c b/fs/bcachefs/snapshot.c index 1506445eaaf4..cf6b3256d188 100644 --- a/fs/bcachefs/snapshot.c +++ b/fs/bcachefs/snapshot.c @@ -495,6 +495,9 @@ static int check_snapshot_tree(struct btree_trans *trans, goto err; } + if (!st.v->master_subvol) + goto out; + ret = bch2_subvolume_get(trans, le32_to_cpu(st.v->master_subvol), false, &subvol); if (ret && !bch2_err_matches(ret, ENOENT)) goto err; @@ -538,6 +541,7 @@ static int check_snapshot_tree(struct btree_trans *trans, u->v.master_subvol = cpu_to_le32(subvol_id); st = snapshot_tree_i_to_s_c(u); } +out: err: fsck_err: bch2_trans_iter_exit(trans, &snapshot_iter); @@ -1037,13 +1041,11 @@ fsck_err: int bch2_snapshot_node_set_deleted(struct btree_trans *trans, u32 id) { struct btree_iter iter; - struct bkey_i_snapshot *s; - int ret = 0; - - s = bch2_bkey_get_mut_typed(trans, &iter, + struct bkey_i_snapshot *s = + bch2_bkey_get_mut_typed(trans, &iter, BTREE_ID_snapshots, POS(0, id), 0, snapshot); - ret = PTR_ERR_OR_ZERO(s); + int ret = PTR_ERR_OR_ZERO(s); if (unlikely(ret)) { bch2_fs_inconsistent_on(bch2_err_matches(ret, ENOENT), trans->c, "missing snapshot %u", id); |
