summaryrefslogtreecommitdiff
path: root/fs/bcachefs
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-01-04 19:05:08 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:09:21 -0400
commit03ea3962ab99adf0cf7de9949716e6baeda230f3 (patch)
tree1d1a8140f3b43772591ad33ffd49a0b76d7b8b55 /fs/bcachefs
parent57cfdd8b54b945fe80191767e36595b46893e5e0 (diff)
bcachefs: Log & error message improvements
- Add a shim uuid_unparse_lower() in the kernel, since %pU doesn't work in userspace - We don't need to print the bcachefs: or the filesystem name prefix in userspace - Improve a few error messages Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs')
-rw-r--r--fs/bcachefs/bcachefs.h4
-rw-r--r--fs/bcachefs/btree_io.c12
-rw-r--r--fs/bcachefs/btree_key_cache.c3
-rw-r--r--fs/bcachefs/checksum.c25
-rw-r--r--fs/bcachefs/recovery.c9
-rw-r--r--fs/bcachefs/super.c2
-rw-r--r--fs/bcachefs/util.h9
7 files changed, 37 insertions, 27 deletions
diff --git a/fs/bcachefs/bcachefs.h b/fs/bcachefs/bcachefs.h
index 2dd3a0a1943a..8ef874b3afbb 100644
--- a/fs/bcachefs/bcachefs.h
+++ b/fs/bcachefs/bcachefs.h
@@ -223,8 +223,8 @@
#define bch2_fmt(_c, fmt) "bcachefs (%s): " fmt "\n", ((_c)->name)
#define bch2_fmt_inum(_c, _inum, fmt) "bcachefs (%s inum %llu): " fmt "\n", ((_c)->name), (_inum)
#else
-#define bch2_fmt(_c, fmt) "%s: " fmt "\n", ((_c)->name)
-#define bch2_fmt_inum(_c, _inum, fmt) "%s inum %llu: " fmt "\n", ((_c)->name), (_inum)
+#define bch2_fmt(_c, fmt) fmt "\n"
+#define bch2_fmt_inum(_c, _inum, fmt) "inum %llu: " fmt "\n", (_inum)
#endif
#define bch_info(c, fmt, ...) \
diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c
index 287c45253a33..b6551db03968 100644
--- a/fs/bcachefs/btree_io.c
+++ b/fs/bcachefs/btree_io.c
@@ -967,19 +967,23 @@ int bch2_btree_node_read_done(struct bch_fs *c, struct bch_dev *ca,
SET_BSET_BIG_ENDIAN(i, CPU_BIG_ENDIAN);
- b->written += sectors;
-
blacklisted = bch2_journal_seq_is_blacklisted(c,
le64_to_cpu(i->journal_seq),
true);
btree_err_on(blacklisted && first,
BTREE_ERR_FIXABLE, c, ca, b, i,
- "first btree node bset has blacklisted journal seq");
+ "first btree node bset has blacklisted journal seq (%llu)",
+ le64_to_cpu(i->journal_seq));
btree_err_on(blacklisted && ptr_written,
BTREE_ERR_FIXABLE, c, ca, b, i,
- "found blacklisted bset in btree node with sectors_written");
+ "found blacklisted bset (journal seq %llu) in btree node at offset %u-%u/%u",
+ le64_to_cpu(i->journal_seq),
+ b->written, b->written + sectors, ptr_written);
+
+ b->written += sectors;
+
if (blacklisted && !first)
continue;
diff --git a/fs/bcachefs/btree_key_cache.c b/fs/bcachefs/btree_key_cache.c
index 13012f26a677..08df768fbebb 100644
--- a/fs/bcachefs/btree_key_cache.c
+++ b/fs/bcachefs/btree_key_cache.c
@@ -209,7 +209,6 @@ static int btree_key_cache_fill(struct btree_trans *trans,
struct btree_path *ck_path,
struct bkey_cached *ck)
{
- struct bch_fs *c = trans->c;
struct btree_iter iter;
struct bkey_s_c k;
unsigned new_u64s = 0;
@@ -239,7 +238,7 @@ static int btree_key_cache_fill(struct btree_trans *trans,
new_u64s = roundup_pow_of_two(new_u64s);
new_k = kmalloc(new_u64s * sizeof(u64), GFP_NOFS);
if (!new_k) {
- bch_err(c, "error allocating memory for key cache key, btree %s u64s %u",
+ bch_err(trans->c, "error allocating memory for key cache key, btree %s u64s %u",
bch2_btree_ids[ck->key.btree_id], new_u64s);
ret = -ENOMEM;
goto err;
diff --git a/fs/bcachefs/checksum.c b/fs/bcachefs/checksum.c
index fbe8603cfb30..a1d89923d361 100644
--- a/fs/bcachefs/checksum.c
+++ b/fs/bcachefs/checksum.c
@@ -407,16 +407,12 @@ int bch2_rechecksum_bio(struct bch_fs *c, struct bio *bio,
}
#ifdef __KERNEL__
-int bch2_request_key(struct bch_sb *sb, struct bch_key *key)
+static int __bch2_request_key(char *key_description, struct bch_key *key)
{
- char key_description[60];
struct key *keyring_key;
const struct user_key_payload *ukp;
int ret;
- snprintf(key_description, sizeof(key_description),
- "bcachefs:%pUb", &sb->user_uuid);
-
keyring_key = request_key(&key_type_logon, key_description, NULL);
if (IS_ERR(keyring_key))
return PTR_ERR(keyring_key);
@@ -436,16 +432,10 @@ int bch2_request_key(struct bch_sb *sb, struct bch_key *key)
}
#else
#include <keyutils.h>
-#include <uuid/uuid.h>
-int bch2_request_key(struct bch_sb *sb, struct bch_key *key)
+static int __bch2_request_key(char *key_description, struct bch_key *key)
{
key_serial_t key_id;
- char key_description[60];
- char uuid[40];
-
- uuid_unparse_lower(sb->user_uuid.b, uuid);
- sprintf(key_description, "bcachefs:%s", uuid);
key_id = request_key("user", key_description, NULL,
KEY_SPEC_USER_KEYRING);
@@ -459,6 +449,17 @@ int bch2_request_key(struct bch_sb *sb, struct bch_key *key)
}
#endif
+int bch2_request_key(struct bch_sb *sb, struct bch_key *key)
+{
+ char key_description[60];
+ char uuid[40];
+
+ uuid_unparse_lower(sb->user_uuid.b, uuid);
+ sprintf(key_description, "bcachefs:%s", uuid);
+
+ return __bch2_request_key(key_description, key);
+}
+
int bch2_decrypt_sb_key(struct bch_fs *c,
struct bch_sb_field_crypt *crypt,
struct bch_key *key)
diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c
index d11457c229ac..7003cf77fdcd 100644
--- a/fs/bcachefs/recovery.c
+++ b/fs/bcachefs/recovery.c
@@ -530,10 +530,8 @@ static int bch2_journal_replay(struct bch_fs *c)
sizeof(keys_sorted[0]),
journal_sort_seq_cmp, NULL);
- if (keys->nr) {
- bch_verbose(c, "starting journal replay, %zu keys", keys->nr);
+ if (keys->nr)
replay_now_at(j, keys->journal_seq_base);
- }
for (i = 0; i < keys->nr; i++) {
k = keys_sorted[i];
@@ -901,7 +899,6 @@ static int bch2_fs_initialize_subvolumes(struct bch_fs *c)
static int bch2_fs_upgrade_for_subvolumes(struct btree_trans *trans)
{
- struct bch_fs *c = trans->c;
struct btree_iter iter;
struct bkey_s_c k;
struct bch_inode_unpacked inode;
@@ -915,7 +912,7 @@ static int bch2_fs_upgrade_for_subvolumes(struct btree_trans *trans)
goto err;
if (!bkey_is_inode(k.k)) {
- bch_err(c, "root inode not found");
+ bch_err(trans->c, "root inode not found");
ret = -ENOENT;
goto err;
}
@@ -1138,7 +1135,7 @@ use_clean:
if (c->opts.norecovery)
goto out;
- bch_verbose(c, "starting journal replay");
+ bch_verbose(c, "starting journal replay, %zu keys", c->journal_keys.nr);
err = "journal replay failed";
ret = bch2_journal_replay(c);
if (ret)
diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c
index 7b7902fbdcc6..47de774d18b8 100644
--- a/fs/bcachefs/super.c
+++ b/fs/bcachefs/super.c
@@ -745,7 +745,7 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts)
if (ret)
goto err;
- scnprintf(c->name, sizeof(c->name), "%pU", &c->sb.user_uuid);
+ uuid_unparse_lower(c->sb.user_uuid.b, c->name);
/* Compat: */
if (sb->version <= bcachefs_metadata_version_inode_v2 &&
diff --git a/fs/bcachefs/util.h b/fs/bcachefs/util.h
index 969139fef086..fbe5b710e9c5 100644
--- a/fs/bcachefs/util.h
+++ b/fs/bcachefs/util.h
@@ -764,4 +764,13 @@ static inline int u8_cmp(u8 l, u8 r)
return cmp_int(l, r);
}
+#ifdef __KERNEL__
+static inline void uuid_unparse_lower(u8 *uuid, char *out)
+{
+ sprintf(out, "%plU", uuid);
+}
+#else
+#include <uuid/uuid.h>
+#endif
+
#endif /* _BCACHEFS_UTIL_H */