From df6a24f81aa29a0e844afb53f7d5bc8989cdbac3 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Sat, 22 Oct 2022 15:10:28 -0400 Subject: bcachefs: Make error messages more uniform Use __func__ in error messages that refer to function name, and do so more uniformly - suggested by checkpatch.pl Signed-off-by: Kent Overstreet --- fs/bcachefs/tests.c | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) (limited to 'fs/bcachefs/tests.c') diff --git a/fs/bcachefs/tests.c b/fs/bcachefs/tests.c index bed830e678bb..72364313126b 100644 --- a/fs/bcachefs/tests.c +++ b/fs/bcachefs/tests.c @@ -46,7 +46,7 @@ static int test_delete(struct bch_fs *c, u64 nr) bch2_btree_iter_traverse(&iter) ?: bch2_trans_update(&trans, &iter, &k.k_i, 0)); if (ret) { - bch_err(c, "update error in test_delete: %s", bch2_err_str(ret)); + bch_err(c, "%s(): update error in: %s", __func__, bch2_err_str(ret)); goto err; } @@ -55,7 +55,7 @@ static int test_delete(struct bch_fs *c, u64 nr) bch2_btree_iter_traverse(&iter) ?: bch2_btree_delete_at(&trans, &iter, 0)); if (ret) { - bch_err(c, "delete error (first) in test_delete: %s", bch2_err_str(ret)); + bch_err(c, "%s(): delete error (first): %s", __func__, bch2_err_str(ret)); goto err; } @@ -64,7 +64,7 @@ static int test_delete(struct bch_fs *c, u64 nr) bch2_btree_iter_traverse(&iter) ?: bch2_btree_delete_at(&trans, &iter, 0)); if (ret) { - bch_err(c, "delete error (second) in test_delete: %s", bch2_err_str(ret)); + bch_err(c, "%s(): delete error (second): %s", __func__, bch2_err_str(ret)); goto err; } err: @@ -92,7 +92,7 @@ static int test_delete_written(struct bch_fs *c, u64 nr) bch2_btree_iter_traverse(&iter) ?: bch2_trans_update(&trans, &iter, &k.k_i, 0)); if (ret) { - bch_err(c, "update error in test_delete_written: %s", bch2_err_str(ret)); + bch_err(c, "%s(): update error: %s", __func__, bch2_err_str(ret)); goto err; } @@ -103,7 +103,7 @@ static int test_delete_written(struct bch_fs *c, u64 nr) bch2_btree_iter_traverse(&iter) ?: bch2_btree_delete_at(&trans, &iter, 0)); if (ret) { - bch_err(c, "delete error in test_delete_written: %s", bch2_err_str(ret)); + bch_err(c, "%s(): delete error: %s", __func__, bch2_err_str(ret)); goto err; } err: @@ -136,7 +136,7 @@ static int test_iterate(struct bch_fs *c, u64 nr) ret = bch2_btree_insert(c, BTREE_ID_xattrs, &k.k_i, NULL, NULL, 0); if (ret) { - bch_err(c, "insert error in test_iterate: %s", bch2_err_str(ret)); + bch_err(c, "%s(): insert error: %s", __func__, bch2_err_str(ret)); goto err; } } @@ -202,7 +202,7 @@ static int test_iterate_extents(struct bch_fs *c, u64 nr) ret = bch2_btree_insert(c, BTREE_ID_extents, &k.k_i, NULL, NULL, 0); if (ret) { - bch_err(c, "insert error in test_iterate_extents: %s", bch2_err_str(ret)); + bch_err(c, "%s(): insert error: %s", __func__, bch2_err_str(ret)); goto err; } } @@ -269,7 +269,7 @@ static int test_iterate_slots(struct bch_fs *c, u64 nr) ret = bch2_btree_insert(c, BTREE_ID_xattrs, &k.k_i, NULL, NULL, 0); if (ret) { - bch_err(c, "insert error in test_iterate_slots: %s", bch2_err_str(ret)); + bch_err(c, "%s(): insert error: %s", __func__, bch2_err_str(ret)); goto err; } } @@ -342,7 +342,7 @@ static int test_iterate_slots_extents(struct bch_fs *c, u64 nr) ret = bch2_btree_insert(c, BTREE_ID_extents, &k.k_i, NULL, NULL, 0); if (ret) { - bch_err(c, "insert error in test_iterate_slots_extents: %s", bch2_err_str(ret)); + bch_err(c, "%s(): insert error: %s", __func__, bch2_err_str(ret)); goto err; } } @@ -456,7 +456,7 @@ static int insert_test_extent(struct bch_fs *c, ret = bch2_btree_insert(c, BTREE_ID_extents, &k.k_i, NULL, NULL, 0); if (ret) - bch_err(c, "insert error in insert_test_extent: %s", bch2_err_str(ret)); + bch_err(c, "%s(): insert error: %s", __func__, bch2_err_str(ret)); return ret; } @@ -555,7 +555,7 @@ static int test_snapshots(struct bch_fs *c, u64 nr) ret = test_snapshot_filter(c, snapids[0], snapids[1]); if (ret) { - bch_err(c, "err from test_snapshot_filter: %s", bch2_err_str(ret)); + bch_err(c, "%s(): err from test_snapshot_filter: %s", __func__, bch2_err_str(ret)); return ret; } @@ -567,11 +567,8 @@ static int test_snapshots(struct bch_fs *c, u64 nr) static u64 test_rand(void) { u64 v; -#if 0 - v = prandom_u32_max(U32_MAX); -#else + get_random_bytes(&v, sizeof(v)); -#endif return v; } @@ -592,7 +589,7 @@ static int rand_insert(struct bch_fs *c, u64 nr) ret = commit_do(&trans, NULL, NULL, 0, __bch2_btree_insert(&trans, BTREE_ID_xattrs, &k.k_i)); if (ret) { - bch_err(c, "error in rand_insert: %s", bch2_err_str(ret)); + bch_err(c, "%s(): error %s", __func__, bch2_err_str(ret)); break; } } @@ -628,7 +625,7 @@ static int rand_insert_multi(struct bch_fs *c, u64 nr) __bch2_btree_insert(&trans, BTREE_ID_xattrs, &k[6].k_i) ?: __bch2_btree_insert(&trans, BTREE_ID_xattrs, &k[7].k_i)); if (ret) { - bch_err(c, "error in rand_insert_multi: %s", bch2_err_str(ret)); + bch_err(c, "%s(): error %s", __func__, bch2_err_str(ret)); break; } } @@ -655,7 +652,7 @@ static int rand_lookup(struct bch_fs *c, u64 nr) lockrestart_do(&trans, bkey_err(k = bch2_btree_iter_peek(&iter))); ret = bkey_err(k); if (ret) { - bch_err(c, "error in rand_lookup: %s", bch2_err_str(ret)); + bch_err(c, "%s(): error %s", __func__, bch2_err_str(ret)); break; } } @@ -678,7 +675,7 @@ static int rand_mixed_trans(struct btree_trans *trans, k = bch2_btree_iter_peek(iter); ret = bkey_err(k); if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart)) - bch_err(trans->c, "lookup error in rand_mixed: %s", bch2_err_str(ret)); + bch_err(trans->c, "%s(): lookup error: %s", __func__, bch2_err_str(ret)); if (ret) return ret; @@ -708,7 +705,7 @@ static int rand_mixed(struct bch_fs *c, u64 nr) ret = commit_do(&trans, NULL, NULL, 0, rand_mixed_trans(&trans, &iter, &cookie, i, rand)); if (ret) { - bch_err(c, "update error in rand_mixed: %s", bch2_err_str(ret)); + bch_err(c, "%s(): update error: %s", __func__, bch2_err_str(ret)); break; } } @@ -754,7 +751,7 @@ static int rand_delete(struct bch_fs *c, u64 nr) ret = commit_do(&trans, NULL, NULL, 0, __do_delete(&trans, pos)); if (ret) { - bch_err(c, "error in rand_delete: %s", bch2_err_str(ret)); + bch_err(c, "%s(): error %s", __func__, bch2_err_str(ret)); break; } } @@ -786,7 +783,7 @@ static int seq_insert(struct bch_fs *c, u64 nr) bch2_trans_update(&trans, &iter, &insert.k_i, 0); })); if (ret) - bch_err(c, "error in %s(): %s", __func__, bch2_err_str(ret)); + bch_err(c, "%s(): error %s", __func__, bch2_err_str(ret)); bch2_trans_exit(&trans); return ret; @@ -805,7 +802,7 @@ static int seq_lookup(struct bch_fs *c, u64 nr) SPOS(0, 0, U32_MAX), 0, k, 0); if (ret) - bch_err(c, "error in %s(): %s", __func__, bch2_err_str(ret)); + bch_err(c, "%s(): error %s", __func__, bch2_err_str(ret)); bch2_trans_exit(&trans); return ret; @@ -831,7 +828,7 @@ static int seq_overwrite(struct bch_fs *c, u64 nr) bch2_trans_update(&trans, &iter, &u.k_i, 0); })); if (ret) - bch_err(c, "error in %s(): %s", __func__, bch2_err_str(ret)); + bch_err(c, "%s(): error %s", __func__, bch2_err_str(ret)); bch2_trans_exit(&trans); return ret; @@ -845,7 +842,7 @@ static int seq_delete(struct bch_fs *c, u64 nr) SPOS(0, 0, U32_MAX), SPOS_MAX, 0, NULL); if (ret) - bch_err(c, "error in seq_delete: %s", bch2_err_str(ret)); + bch_err(c, "%s(): error %s", __func__, bch2_err_str(ret)); return ret; } -- cgit v1.2.3