summaryrefslogtreecommitdiff
path: root/fs/bcachefs/snapshot.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-08-18 21:14:33 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:10:11 -0400
commita111901f52140f7f6f7ff0034c5ffa15448c784b (patch)
tree62b0693b76d8b90e0ee7340f2631d5d41cca4466 /fs/bcachefs/snapshot.h
parentf55d6e07bc6c9b90f58586daf9c432adb5f5ce25 (diff)
bcachefs: bch2_propagate_key_to_snapshot_leaves()
If fsck finds a key that needs work done, the primary example being an unlinked inode that needs to be deleted, and the key is in an internal snapshot node, we have a bit of a conundrum. The conundrum is that internal snapshot nodes are shared, and we in general do updates in internal snapshot nodes because there may be overwrites in some snapshots and not others, and this may affect other keys referenced by this key (i.e. extents). For example, we might be seeing an unlinked inode in an internal snapshot node, but then in one child snapshot the inode might have been reattached and might not be unlinked. Deleting the inode in the internal snapshot node would be wrong, because then we'll delete all the extents that the child snapshot references. But if an unlinked inode does not have any overwrites in child snapshots, we're fine: the inode is overwrritten in all child snapshots, so we can do the deletion at the point of comonality in the snapshot tree, i.e. the node where we found it. This patch adds a new helper, bch2_propagate_key_to_snapshot_leaves(), to handle the case where we need a to update a key that does have overwrites in child snapshots: we copy the key to leaf snapshot nodes, and then rewind fsck and process the needed updates there. With this, fsck can now always correctly handle unlinked inodes found in internal snapshot nodes. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/snapshot.h')
-rw-r--r--fs/bcachefs/snapshot.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/bcachefs/snapshot.h b/fs/bcachefs/snapshot.h
index 624a42d1c8b7..dabc9b9d921b 100644
--- a/fs/bcachefs/snapshot.h
+++ b/fs/bcachefs/snapshot.h
@@ -263,6 +263,9 @@ static inline int bch2_key_has_snapshot_overwrites(struct btree_trans *trans,
return __bch2_key_has_snapshot_overwrites(trans, id, pos);
}
+int bch2_propagate_key_to_snapshot_leaves(struct btree_trans *, enum btree_id,
+ struct bkey_s_c, struct bpos *);
+
int bch2_snapshots_read(struct bch_fs *);
void bch2_fs_snapshots_exit(struct bch_fs *);