Commit c1f59ef6 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: More info on check_bucket_ref() error

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 930c0c4c
......@@ -663,13 +663,14 @@ int bch2_mark_metadata_bucket(struct bch_fs *c, struct bch_dev *ca,
return ret;
}
static int check_bucket_ref(struct bch_fs *c,
static int check_bucket_ref(struct btree_trans *trans,
struct bkey_s_c k,
const struct bch_extent_ptr *ptr,
s64 sectors, enum bch_data_type ptr_data_type,
u8 b_gen, u8 bucket_data_type,
u32 dirty_sectors, u32 cached_sectors)
{
struct bch_fs *c = trans->c;
struct bch_dev *ca = bch_dev_bkey_exists(c, ptr->dev);
size_t bucket_nr = PTR_BUCKET_NR(ca, ptr);
u16 bucket_sectors = !ptr->cached
......@@ -726,7 +727,7 @@ static int check_bucket_ref(struct bch_fs *c,
if (b_gen != ptr->gen) {
ret = 1;
goto err;
goto out;
}
if (!data_type_is_empty(bucket_data_type) &&
......@@ -756,9 +757,12 @@ static int check_bucket_ref(struct bch_fs *c,
ret = -EIO;
goto err;
}
err:
out:
printbuf_exit(&buf);
return ret;
err:
bch2_dump_trans_updates(trans);
goto out;
}
static int mark_stripe_bucket(struct btree_trans *trans,
......@@ -800,7 +804,7 @@ static int mark_stripe_bucket(struct btree_trans *trans,
bucket_lock(g);
old = *g;
ret = check_bucket_ref(c, k, ptr, sectors, data_type,
ret = check_bucket_ref(trans, k, ptr, sectors, data_type,
g->gen, g->data_type,
g->dirty_sectors, g->cached_sectors);
if (ret)
......@@ -832,7 +836,7 @@ static int __mark_pointer(struct btree_trans *trans,
u32 *dst_sectors = !ptr->cached
? dirty_sectors
: cached_sectors;
int ret = check_bucket_ref(trans->c, k, ptr, sectors, ptr_data_type,
int ret = check_bucket_ref(trans, k, ptr, sectors, ptr_data_type,
bucket_gen, *bucket_data_type,
*dirty_sectors, *cached_sectors);
......@@ -1557,7 +1561,7 @@ static int bch2_trans_mark_stripe_bucket(struct btree_trans *trans,
if (IS_ERR(a))
return PTR_ERR(a);
ret = check_bucket_ref(c, s.s_c, ptr, sectors, data_type,
ret = check_bucket_ref(trans, s.s_c, ptr, sectors, data_type,
a->v.gen, a->v.data_type,
a->v.dirty_sectors, a->v.cached_sectors);
if (ret)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment