summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/btree_node_scan_types.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2024-03-11 23:11:46 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2024-04-03 14:44:18 -0400
commit4409b8081d1624af814a9cda781ad9cdda3973cb (patch)
tree22adb020d08b6c1d257465ab7c78bbeaa19df4cf /fs/bcachefs/btree_node_scan_types.h
parentb268aa4e7fb8be3c50e25a09008fb2feed2cd345 (diff)
downloadlinux-4409b8081d1624af814a9cda781ad9cdda3973cb.tar.gz
linux-4409b8081d1624af814a9cda781ad9cdda3973cb.tar.bz2
linux-4409b8081d1624af814a9cda781ad9cdda3973cb.zip
bcachefs: Repair pass for scanning for btree nodes
If a btree root or interior btree node goes bad, we're going to lose a lot of data, unless we can recover the nodes that it pointed to by scanning. Fortunately btree node headers are fully self describing, and additionally the magic number is xored with the filesytem UUID, so we can do so safely. This implements the scanning - next patch will rework topology repair to make use of the found nodes. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/btree_node_scan_types.h')
-rw-r--r--fs/bcachefs/btree_node_scan_types.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/fs/bcachefs/btree_node_scan_types.h b/fs/bcachefs/btree_node_scan_types.h
new file mode 100644
index 000000000000..abb7b27d556a
--- /dev/null
+++ b/fs/bcachefs/btree_node_scan_types.h
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _BCACHEFS_BTREE_NODE_SCAN_TYPES_H
+#define _BCACHEFS_BTREE_NODE_SCAN_TYPES_H
+
+#include "darray.h"
+
+struct found_btree_node {
+ bool range_updated:1;
+ bool overwritten:1;
+ u8 btree_id;
+ u8 level;
+ u32 seq;
+ u64 cookie;
+
+ struct bpos min_key;
+ struct bpos max_key;
+
+ unsigned nr_ptrs;
+ struct bch_extent_ptr ptrs[BCH_REPLICAS_MAX];
+};
+
+typedef DARRAY(struct found_btree_node) found_btree_nodes;
+
+struct find_btree_nodes {
+ int ret;
+ struct mutex lock;
+ found_btree_nodes nodes;
+};
+
+#endif /* _BCACHEFS_BTREE_NODE_SCAN_TYPES_H */