bcachefs: Add hash seed, type to inode_to_text()
authorKent Overstreet <kent.overstreet@linux.dev>
Sat, 28 Sep 2024 18:44:06 +0000 (14:44 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Fri, 18 Oct 2024 04:49:48 +0000 (00:49 -0400)
This helped with discovering some filesystem corruption fsck has having
trouble with: the str_hash type had gotten flipped on one snapshot's
version of an inode.

All versions of a given inode number have the same hash seed and hash
type, since lookups will be done with a single hash/seed and type and
see dirents/xattrs from multiple snapshots.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/inode.c
fs/bcachefs/opts.c
fs/bcachefs/opts.h

index 3662f648a6c370ed9e24194c1ce8d478c96194c1..b9fde1566df1f47c8ebd3cc866044b4136eb72dc 100644 (file)
@@ -533,6 +533,10 @@ static void __bch2_inode_unpacked_to_text(struct printbuf *out,
        prt_printf(out, "(%x)\n", inode->bi_flags);
 
        prt_printf(out, "journal_seq=%llu\n",   inode->bi_journal_seq);
+       prt_printf(out, "hash_seed=%llx\n",     inode->bi_hash_seed);
+       prt_printf(out, "hash_type=");
+       bch2_prt_str_hash_type(out, INODE_STR_HASH(inode));
+       prt_newline(out);
        prt_printf(out, "bi_size=%llu\n",       inode->bi_size);
        prt_printf(out, "bi_sectors=%llu\n",    inode->bi_sectors);
        prt_printf(out, "bi_version=%llu\n",    inode->bi_version);
index 68d240126522ad3e067ec8f4db9beae947be20f8..6673cbd8bdb944c080e874bf504eaa39f2e4c3ca 100644 (file)
@@ -63,7 +63,7 @@ const char * const bch2_compression_opts[] = {
        NULL
 };
 
-const char * const bch2_str_hash_types[] = {
+const char * const __bch2_str_hash_types[] = {
        BCH_STR_HASH_TYPES()
        NULL
 };
@@ -115,6 +115,7 @@ PRT_STR_OPT_BOUNDSCHECKED(fs_usage_type,    enum bch_fs_usage_type);
 PRT_STR_OPT_BOUNDSCHECKED(data_type,           enum bch_data_type);
 PRT_STR_OPT_BOUNDSCHECKED(csum_type,           enum bch_csum_type);
 PRT_STR_OPT_BOUNDSCHECKED(compression_type,    enum bch_compression_type);
+PRT_STR_OPT_BOUNDSCHECKED(str_hash_type,       enum bch_str_hash_type);
 
 static int bch2_opt_fix_errors_parse(struct bch_fs *c, const char *val, u64 *res,
                                     struct printbuf *err)
index cb2e244a24298393b0be3ee8fd4b4991d6bf93f4..23dda014e331b132d21511684cd6ba2e0e55ea82 100644 (file)
@@ -18,7 +18,7 @@ extern const char * const bch2_sb_compat[];
 extern const char * const __bch2_btree_ids[];
 extern const char * const bch2_csum_opts[];
 extern const char * const bch2_compression_opts[];
-extern const char * const bch2_str_hash_types[];
+extern const char * const __bch2_str_hash_types[];
 extern const char * const bch2_str_hash_opts[];
 extern const char * const __bch2_data_types[];
 extern const char * const bch2_member_states[];
@@ -29,6 +29,7 @@ void bch2_prt_fs_usage_type(struct printbuf *,                enum bch_fs_usage_type);
 void bch2_prt_data_type(struct printbuf *,             enum bch_data_type);
 void bch2_prt_csum_type(struct printbuf *,             enum bch_csum_type);
 void bch2_prt_compression_type(struct printbuf *,      enum bch_compression_type);
+void bch2_prt_str_hash_type(struct printbuf *,         enum bch_str_hash_type);
 
 static inline const char *bch2_d_type_str(unsigned d_type)
 {