Skip to content

Commit d8e8793

Browse files
author
Kent Overstreet
committed
bcachefs: Add hash seed, type to inode_to_text()
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 <[email protected]>
1 parent 78cf0ae commit d8e8793

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

fs/bcachefs/inode.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,10 @@ static void __bch2_inode_unpacked_to_text(struct printbuf *out,
533533
prt_printf(out, "(%x)\n", inode->bi_flags);
534534

535535
prt_printf(out, "journal_seq=%llu\n", inode->bi_journal_seq);
536+
prt_printf(out, "hash_seed=%llx\n", inode->bi_hash_seed);
537+
prt_printf(out, "hash_type=");
538+
bch2_prt_str_hash_type(out, INODE_STR_HASH(inode));
539+
prt_newline(out);
536540
prt_printf(out, "bi_size=%llu\n", inode->bi_size);
537541
prt_printf(out, "bi_sectors=%llu\n", inode->bi_sectors);
538542
prt_printf(out, "bi_version=%llu\n", inode->bi_version);

fs/bcachefs/opts.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const char * const bch2_compression_opts[] = {
6363
NULL
6464
};
6565

66-
const char * const bch2_str_hash_types[] = {
66+
const char * const __bch2_str_hash_types[] = {
6767
BCH_STR_HASH_TYPES()
6868
NULL
6969
};
@@ -115,6 +115,7 @@ PRT_STR_OPT_BOUNDSCHECKED(fs_usage_type, enum bch_fs_usage_type);
115115
PRT_STR_OPT_BOUNDSCHECKED(data_type, enum bch_data_type);
116116
PRT_STR_OPT_BOUNDSCHECKED(csum_type, enum bch_csum_type);
117117
PRT_STR_OPT_BOUNDSCHECKED(compression_type, enum bch_compression_type);
118+
PRT_STR_OPT_BOUNDSCHECKED(str_hash_type, enum bch_str_hash_type);
118119

119120
static int bch2_opt_fix_errors_parse(struct bch_fs *c, const char *val, u64 *res,
120121
struct printbuf *err)

fs/bcachefs/opts.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ extern const char * const bch2_sb_compat[];
1818
extern const char * const __bch2_btree_ids[];
1919
extern const char * const bch2_csum_opts[];
2020
extern const char * const bch2_compression_opts[];
21-
extern const char * const bch2_str_hash_types[];
21+
extern const char * const __bch2_str_hash_types[];
2222
extern const char * const bch2_str_hash_opts[];
2323
extern const char * const __bch2_data_types[];
2424
extern const char * const bch2_member_states[];
@@ -29,6 +29,7 @@ void bch2_prt_fs_usage_type(struct printbuf *, enum bch_fs_usage_type);
2929
void bch2_prt_data_type(struct printbuf *, enum bch_data_type);
3030
void bch2_prt_csum_type(struct printbuf *, enum bch_csum_type);
3131
void bch2_prt_compression_type(struct printbuf *, enum bch_compression_type);
32+
void bch2_prt_str_hash_type(struct printbuf *, enum bch_str_hash_type);
3233

3334
static inline const char *bch2_d_type_str(unsigned d_type)
3435
{

0 commit comments

Comments
 (0)