Commit a6f4794f authored by Kent Overstreet's avatar Kent Overstreet
Browse files

bcachefs: struct bkey_validate_context



Add a new parameter to bkey validate functions, and use it to improve
invalid bkey error messages: we can now print the btree and depth it
came from, or if it came from the journal, or is a btree root.

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent c7e78f7b
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -198,7 +198,7 @@ static unsigned bch_alloc_v1_val_u64s(const struct bch_alloc *a)
}

int bch2_alloc_v1_validate(struct bch_fs *c, struct bkey_s_c k,
			   enum bch_validate_flags flags)
			   struct bkey_validate_context from)
{
	struct bkey_s_c_alloc a = bkey_s_c_to_alloc(k);
	int ret = 0;
@@ -213,7 +213,7 @@ int bch2_alloc_v1_validate(struct bch_fs *c, struct bkey_s_c k,
}

int bch2_alloc_v2_validate(struct bch_fs *c, struct bkey_s_c k,
			   enum bch_validate_flags flags)
			   struct bkey_validate_context from)
{
	struct bkey_alloc_unpacked u;
	int ret = 0;
@@ -226,7 +226,7 @@ int bch2_alloc_v2_validate(struct bch_fs *c, struct bkey_s_c k,
}

int bch2_alloc_v3_validate(struct bch_fs *c, struct bkey_s_c k,
			   enum bch_validate_flags flags)
			   struct bkey_validate_context from)
{
	struct bkey_alloc_unpacked u;
	int ret = 0;
@@ -239,7 +239,7 @@ int bch2_alloc_v3_validate(struct bch_fs *c, struct bkey_s_c k,
}

int bch2_alloc_v4_validate(struct bch_fs *c, struct bkey_s_c k,
			   enum bch_validate_flags flags)
			   struct bkey_validate_context from)
{
	struct bch_alloc_v4 a;
	int ret = 0;
@@ -509,7 +509,7 @@ static unsigned alloc_gen(struct bkey_s_c k, unsigned offset)
}

int bch2_bucket_gens_validate(struct bch_fs *c, struct bkey_s_c k,
			     enum bch_validate_flags flags)
			      struct bkey_validate_context from)
{
	int ret = 0;

+9 −7
Original line number Diff line number Diff line
@@ -8,8 +8,6 @@
#include "debug.h"
#include "super.h"

enum bch_validate_flags;

/* How out of date a pointer gen is allowed to be: */
#define BUCKET_GC_GEN_MAX	96U

@@ -245,10 +243,14 @@ struct bkey_i_alloc_v4 *bch2_alloc_to_v4_mut(struct btree_trans *, struct bkey_s

int bch2_bucket_io_time_reset(struct btree_trans *, unsigned, size_t, int);

int bch2_alloc_v1_validate(struct bch_fs *, struct bkey_s_c, enum bch_validate_flags);
int bch2_alloc_v2_validate(struct bch_fs *, struct bkey_s_c, enum bch_validate_flags);
int bch2_alloc_v3_validate(struct bch_fs *, struct bkey_s_c, enum bch_validate_flags);
int bch2_alloc_v4_validate(struct bch_fs *, struct bkey_s_c, enum bch_validate_flags);
int bch2_alloc_v1_validate(struct bch_fs *, struct bkey_s_c,
			   struct bkey_validate_context);
int bch2_alloc_v2_validate(struct bch_fs *, struct bkey_s_c,
			   struct bkey_validate_context);
int bch2_alloc_v3_validate(struct bch_fs *, struct bkey_s_c,
			   struct bkey_validate_context);
int bch2_alloc_v4_validate(struct bch_fs *, struct bkey_s_c,
			   struct bkey_validate_context);
void bch2_alloc_v4_swab(struct bkey_s);
void bch2_alloc_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);

@@ -282,7 +284,7 @@ void bch2_alloc_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
})

int bch2_bucket_gens_validate(struct bch_fs *, struct bkey_s_c,
			     enum bch_validate_flags);
			      struct bkey_validate_context);
void bch2_bucket_gens_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);

#define bch2_bkey_ops_bucket_gens ((struct bkey_ops) {	\
+1 −1
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@
#include <linux/mm.h>

int bch2_backpointer_validate(struct bch_fs *c, struct bkey_s_c k,
			      enum bch_validate_flags flags)
			      struct bkey_validate_context from)
{
	struct bkey_s_c_backpointer bp = bkey_s_c_to_backpointer(k);
	int ret = 0;
+2 −1
Original line number Diff line number Diff line
@@ -18,7 +18,8 @@ static inline u64 swab40(u64 x)
		((x & 0xff00000000ULL) >> 32));
}

int bch2_backpointer_validate(struct bch_fs *, struct bkey_s_c k, enum bch_validate_flags);
int bch2_backpointer_validate(struct bch_fs *, struct bkey_s_c k,
			      struct bkey_validate_context);
void bch2_backpointer_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
void bch2_backpointer_swab(struct bkey_s);

+0 −7
Original line number Diff line number Diff line
@@ -9,13 +9,6 @@
#include "util.h"
#include "vstructs.h"

enum bch_validate_flags {
	BCH_VALIDATE_write		= BIT(0),
	BCH_VALIDATE_commit		= BIT(1),
	BCH_VALIDATE_journal		= BIT(2),
	BCH_VALIDATE_silent		= BIT(3),
};

#if 0

/*
Loading