summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-02-10 23:47:46 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:09:52 +0300
commit12795a1937460020af999e3cf54c146598402455 (patch)
treeae1869f0095a335873114b3cbc40347e6326bcbc /fs
parent637de729fc86effe021bd067cccd68efd07f59c0 (diff)
downloadlinux-12795a1937460020af999e3cf54c146598402455.tar.xz
bcachefs: Add some logging for btree node rewrites due to errors
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs')
-rw-r--r--fs/bcachefs/btree_io.c10
-rw-r--r--fs/bcachefs/btree_update_interior.c23
2 files changed, 29 insertions, 4 deletions
diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c
index 87d80a59dd7e..66747fe21323 100644
--- a/fs/bcachefs/btree_io.c
+++ b/fs/bcachefs/btree_io.c
@@ -1240,8 +1240,16 @@ start:
bio_put(&rb->bio);
printbuf_exit(&buf);
- if (saw_error && !btree_node_read_error(b))
+ if (saw_error && !btree_node_read_error(b)) {
+ struct printbuf buf = PRINTBUF;
+
+ bch2_bpos_to_text(&buf, b->key.k.p);
+ bch_info(c, "%s: rewriting btree node at btree=%s level=%u %s due to error",
+ __func__, bch2_btree_ids[b->c.btree_id], b->c.level, buf.buf);
+ printbuf_exit(&buf);
+
bch2_btree_node_rewrite_async(c, b);
+ }
clear_btree_node_read_in_flight(b);
wake_up_bit(&b->flags, BTREE_NODE_read_in_flight);
diff --git a/fs/bcachefs/btree_update_interior.c b/fs/bcachefs/btree_update_interior.c
index 6287e926f605..612d0007fb23 100644
--- a/fs/bcachefs/btree_update_interior.c
+++ b/fs/bcachefs/btree_update_interior.c
@@ -2007,6 +2007,7 @@ struct async_btree_rewrite {
static int async_btree_node_rewrite_trans(struct btree_trans *trans,
struct async_btree_rewrite *a)
{
+ struct bch_fs *c = trans->c;
struct btree_iter iter;
struct btree *b;
int ret;
@@ -2018,8 +2019,18 @@ static int async_btree_node_rewrite_trans(struct btree_trans *trans,
if (ret)
goto out;
- if (!b || b->data->keys.seq != a->seq)
+ if (!b || b->data->keys.seq != a->seq) {
+ struct printbuf buf = PRINTBUF;
+
+ if (b)
+ bch2_bkey_val_to_text(&buf, c, bkey_i_to_s_c(&b->key));
+ else
+ prt_str(&buf, "(null");
+ bch_info(c, "%s: node to rewrite not found:, searching for seq %llu, got\n%s",
+ __func__, a->seq, buf.buf);
+ printbuf_exit(&buf);
goto out;
+ }
ret = bch2_btree_node_rewrite(trans, &iter, b, 0);
out:
@@ -2033,9 +2044,12 @@ void async_btree_node_rewrite_work(struct work_struct *work)
struct async_btree_rewrite *a =
container_of(work, struct async_btree_rewrite, work);
struct bch_fs *c = a->c;
+ int ret;
- bch2_trans_do(c, NULL, NULL, 0,
+ ret = bch2_trans_do(c, NULL, NULL, 0,
async_btree_node_rewrite_trans(&trans, a));
+ if (ret)
+ bch_err(c, "%s: error %s", __func__, bch2_err_str(ret));
bch2_write_ref_put(c, BCH_WRITE_REF_node_rewrite);
kfree(a);
}
@@ -2044,12 +2058,15 @@ void bch2_btree_node_rewrite_async(struct bch_fs *c, struct btree *b)
{
struct async_btree_rewrite *a;
- if (!bch2_write_ref_tryget(c, BCH_WRITE_REF_node_rewrite))
+ if (!bch2_write_ref_tryget(c, BCH_WRITE_REF_node_rewrite)) {
+ bch_err(c, "%s: error getting c->writes ref", __func__);
return;
+ }
a = kmalloc(sizeof(*a), GFP_NOFS);
if (!a) {
bch2_write_ref_put(c, BCH_WRITE_REF_node_rewrite);
+ bch_err(c, "%s: error allocating memory", __func__);
return;
}