summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/error.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-03-03 04:18:56 +0100
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 23:09:27 +0200
commit2158fe463b9d78c7cf90f74b8b5e9b81249d4347 (patch)
tree97e92efe370a0ae8531d63dc61efa908140bb43b /fs/bcachefs/error.h
parentbcachefs: Drop !did_work path from do_btree_insert_one() (diff)
downloadlinux-2158fe463b9d78c7cf90f74b8b5e9b81249d4347.tar.xz
linux-2158fe463b9d78c7cf90f74b8b5e9b81249d4347.zip
bcachefs: bch2_trans_inconsistent()
Add a new error macro that also dumps transaction updates in addition to doing an emergency shutdown - when a transaction update discovers or is causing a fs inconsistency, it's helpful to see what updates it was doing. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/error.h')
-rw-r--r--fs/bcachefs/error.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/fs/bcachefs/error.h b/fs/bcachefs/error.h
index 4ab3cfe1292c..6e63c38186f3 100644
--- a/fs/bcachefs/error.h
+++ b/fs/bcachefs/error.h
@@ -67,6 +67,26 @@ do { \
})
/*
+ * When a transaction update discovers or is causing a fs inconsistency, it's
+ * helpful to also dump the pending updates:
+ */
+#define bch2_trans_inconsistent(trans, ...) \
+({ \
+ bch_err(trans->c, __VA_ARGS__); \
+ bch2_inconsistent_error(trans->c); \
+ bch2_dump_trans_updates(trans); \
+})
+
+#define bch2_trans_inconsistent_on(cond, trans, ...) \
+({ \
+ bool _ret = unlikely(!!(cond)); \
+ \
+ if (_ret) \
+ bch2_trans_inconsistent(trans, __VA_ARGS__); \
+ _ret; \
+})
+
+/*
* Fsck errors: inconsistency errors we detect at mount time, and should ideally
* be able to repair:
*/