Skip to content

Commit 3ed9406

Browse files
author
Kent Overstreet
committed
bcachefs: Improve bch2_fatal_error()
error messages should always include __func__ Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent ec35b30 commit 3ed9406

15 files changed

+35
-35
lines changed

fs/bcachefs/alloc_background.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ int bch2_trigger_alloc(struct btree_trans *trans,
853853
bucket_journal_seq);
854854
if (ret) {
855855
bch2_fs_fatal_error(c,
856-
"error setting bucket_needs_journal_commit: %i", ret);
856+
"setting bucket_needs_journal_commit: %s", bch2_err_str(ret));
857857
return ret;
858858
}
859859
}

fs/bcachefs/btree_io.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ int bch2_btree_node_read_done(struct bch_fs *c, struct bch_dev *ca,
10661066

10671067
ret = bset_encrypt(c, i, b->written << 9);
10681068
if (bch2_fs_fatal_err_on(ret, c,
1069-
"error decrypting btree node: %i", ret))
1069+
"decrypting btree node: %s", bch2_err_str(ret)))
10701070
goto fsck_err;
10711071

10721072
btree_err_on(btree_node_type_is_extents(btree_node_type(b)) &&
@@ -1107,7 +1107,7 @@ int bch2_btree_node_read_done(struct bch_fs *c, struct bch_dev *ca,
11071107

11081108
ret = bset_encrypt(c, i, b->written << 9);
11091109
if (bch2_fs_fatal_err_on(ret, c,
1110-
"error decrypting btree node: %i\n", ret))
1110+
"decrypting btree node: %s", bch2_err_str(ret)))
11111111
goto fsck_err;
11121112

11131113
sectors = vstruct_sectors(bne, c->block_bits);
@@ -1874,8 +1874,8 @@ static void btree_node_write_work(struct work_struct *work)
18741874
return;
18751875
err:
18761876
set_btree_node_noevict(b);
1877-
if (!bch2_err_matches(ret, EROFS))
1878-
bch2_fs_fatal_error(c, "fatal error writing btree node: %s", bch2_err_str(ret));
1877+
bch2_fs_fatal_err_on(!bch2_err_matches(ret, EROFS), c,
1878+
"writing btree node: %s", bch2_err_str(ret));
18791879
goto out;
18801880
}
18811881

@@ -2131,7 +2131,7 @@ void __bch2_btree_node_write(struct bch_fs *c, struct btree *b, unsigned flags)
21312131

21322132
ret = bset_encrypt(c, i, b->written << 9);
21332133
if (bch2_fs_fatal_err_on(ret, c,
2134-
"error encrypting btree node: %i\n", ret))
2134+
"encrypting btree node: %s", bch2_err_str(ret)))
21352135
goto err;
21362136

21372137
nonce = btree_nonce(i, b->written << 9);

fs/bcachefs/btree_key_cache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ static int btree_key_cache_flush_pos(struct btree_trans *trans,
676676
!bch2_err_matches(ret, BCH_ERR_transaction_restart) &&
677677
!bch2_err_matches(ret, BCH_ERR_journal_reclaim_would_deadlock) &&
678678
!bch2_journal_error(j), c,
679-
"error flushing key cache: %s", bch2_err_str(ret));
679+
"flushing key cache: %s", bch2_err_str(ret));
680680
if (ret)
681681
goto out;
682682

fs/bcachefs/btree_update_interior.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ static void btree_update_nodes_written(struct btree_update *as)
646646
bch2_trans_unlock(trans);
647647

648648
bch2_fs_fatal_err_on(ret && !bch2_journal_error(&c->journal), c,
649-
"%s(): error %s", __func__, bch2_err_str(ret));
649+
"%s", bch2_err_str(ret));
650650
err:
651651
if (as->b) {
652652

@@ -1193,7 +1193,8 @@ bch2_btree_update_start(struct btree_trans *trans, struct btree_path *path,
11931193
err:
11941194
bch2_btree_update_free(as, trans);
11951195
if (!bch2_err_matches(ret, ENOSPC) &&
1196-
!bch2_err_matches(ret, EROFS))
1196+
!bch2_err_matches(ret, EROFS) &&
1197+
ret != -BCH_ERR_journal_reclaim_would_deadlock)
11971198
bch_err_fn_ratelimited(c, ret);
11981199
return ERR_PTR(ret);
11991200
}

fs/bcachefs/btree_write_buffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ static int bch2_btree_write_buffer_flush_locked(struct btree_trans *trans)
378378
}
379379
}
380380
err:
381-
bch2_fs_fatal_err_on(ret, c, "%s: insert error %s", __func__, bch2_err_str(ret));
381+
bch2_fs_fatal_err_on(ret, c, "%s", bch2_err_str(ret));
382382
trace_write_buffer_flush(trans, wb->flushing.keys.nr, skipped, fast, 0);
383383
bch2_journal_pin_drop(j, &wb->flushing.pin);
384384
wb->flushing.keys.nr = 0;

fs/bcachefs/buckets.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -990,8 +990,8 @@ static int __trigger_extent(struct btree_trans *trans,
990990
ret = !gc
991991
? bch2_update_cached_sectors_list(trans, p.ptr.dev, disk_sectors)
992992
: update_cached_sectors(c, k, p.ptr.dev, disk_sectors, 0, true);
993-
bch2_fs_fatal_err_on(ret && gc, c, "%s(): no replicas entry while updating cached sectors",
994-
__func__);
993+
bch2_fs_fatal_err_on(ret && gc, c, "%s: no replicas entry while updating cached sectors",
994+
bch2_err_str(ret));
995995
if (ret)
996996
return ret;
997997
}
@@ -1020,7 +1020,7 @@ static int __trigger_extent(struct btree_trans *trans,
10201020
struct printbuf buf = PRINTBUF;
10211021

10221022
bch2_bkey_val_to_text(&buf, c, k);
1023-
bch2_fs_fatal_error(c, "%s(): no replicas entry for %s", __func__, buf.buf);
1023+
bch2_fs_fatal_error(c, ": no replicas entry for %s", buf.buf);
10241024
printbuf_exit(&buf);
10251025
}
10261026
if (ret)

fs/bcachefs/debug.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ void __bch2_btree_verify(struct bch_fs *c, struct btree *b)
170170
struct printbuf buf = PRINTBUF;
171171

172172
bch2_bkey_val_to_text(&buf, c, bkey_i_to_s_c(&b->key));
173-
bch2_fs_fatal_error(c, "btree node verify failed for : %s\n", buf.buf);
173+
bch2_fs_fatal_error(c, ": btree node verify failed for: %s\n", buf.buf);
174174
printbuf_exit(&buf);
175175
}
176176
out:

fs/bcachefs/ec.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ int bch2_trigger_stripe(struct btree_trans *trans,
448448
struct printbuf buf = PRINTBUF;
449449

450450
bch2_bkey_val_to_text(&buf, c, new);
451-
bch2_fs_fatal_error(c, "no replicas entry for %s", buf.buf);
451+
bch2_fs_fatal_error(c, ": no replicas entry for %s", buf.buf);
452452
printbuf_exit(&buf);
453453
return ret;
454454
}
@@ -1868,10 +1868,10 @@ static int __bch2_ec_stripe_head_reuse(struct btree_trans *trans, struct ec_stri
18681868
return -BCH_ERR_stripe_alloc_blocked;
18691869

18701870
ret = get_stripe_key_trans(trans, idx, &h->s->existing_stripe);
1871+
bch2_fs_fatal_err_on(ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart), c,
1872+
"reading stripe key: %s", bch2_err_str(ret));
18711873
if (ret) {
18721874
bch2_stripe_close(c, h->s);
1873-
if (!bch2_err_matches(ret, BCH_ERR_transaction_restart))
1874-
bch2_fs_fatal_error(c, "error reading stripe key: %s", bch2_err_str(ret));
18751875
return ret;
18761876
}
18771877

fs/bcachefs/error.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ do { \
191191

192192
void bch2_fatal_error(struct bch_fs *);
193193

194-
#define bch2_fs_fatal_error(c, ...) \
194+
#define bch2_fs_fatal_error(c, _msg, ...) \
195195
do { \
196-
bch_err(c, __VA_ARGS__); \
196+
bch_err(c, "%s(): fatal error " _msg, __func__, ##__VA_ARGS__); \
197197
bch2_fatal_error(c); \
198198
} while (0)
199199

fs/bcachefs/fs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ int __must_check bch2_write_inode(struct bch_fs *c,
108108
goto retry;
109109

110110
bch2_fs_fatal_err_on(bch2_err_matches(ret, ENOENT), c,
111-
"inode %u:%llu not found when updating",
111+
"%s: inode %u:%llu not found when updating",
112+
bch2_err_str(ret),
112113
inode_inum(inode).subvol,
113114
inode_inum(inode).inum);
114115

0 commit comments

Comments
 (0)