Skip to content

Commit

Permalink
Update bcachefs sources to 4d1d53862afb bcachefs: show none if label …
Browse files Browse the repository at this point in the history
…is not set
  • Loading branch information
Kent Overstreet committed Jul 14, 2024
1 parent a1764e0 commit 061a9ff
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .bcachefs_revision
Original file line number Diff line number Diff line change
@@ -1 +1 @@
47d1e7a86242b814ec9ff4f426d521832515f115
4d1d53862afb768e4edcf7256f8fe0634c96b40e
49 changes: 34 additions & 15 deletions libbcachefs/btree_node_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ struct find_btree_nodes_worker {

static void found_btree_node_to_text(struct printbuf *out, struct bch_fs *c, const struct found_btree_node *n)
{
prt_printf(out, "%s l=%u seq=%u cookie=%llx ", bch2_btree_id_str(n->btree_id), n->level, n->seq, n->cookie);
prt_printf(out, "%s l=%u seq=%u journal_seq=%llu cookie=%llx ",
bch2_btree_id_str(n->btree_id), n->level, n->seq,
n->journal_seq, n->cookie);
bch2_bpos_to_text(out, n->min_key);
prt_str(out, "-");
bch2_bpos_to_text(out, n->max_key);
Expand Down Expand Up @@ -63,20 +65,37 @@ static void found_btree_node_to_key(struct bkey_i *k, const struct found_btree_n
memcpy(bp->v.start, f->ptrs, sizeof(struct bch_extent_ptr) * f->nr_ptrs);
}

static inline u64 bkey_journal_seq(struct bkey_s_c k)
{
switch (k.k->type) {
case KEY_TYPE_inode_v3:
return le64_to_cpu(bkey_s_c_to_inode_v3(k).v->bi_journal_seq);
default:
return 0;
}
}

static bool found_btree_node_is_readable(struct btree_trans *trans,
struct found_btree_node *f)
{
struct { __BKEY_PADDED(k, BKEY_BTREE_PTR_VAL_U64s_MAX); } k;
struct { __BKEY_PADDED(k, BKEY_BTREE_PTR_VAL_U64s_MAX); } tmp;

found_btree_node_to_key(&k.k, f);
found_btree_node_to_key(&tmp.k, f);

struct btree *b = bch2_btree_node_get_noiter(trans, &k.k, f->btree_id, f->level, false);
struct btree *b = bch2_btree_node_get_noiter(trans, &tmp.k, f->btree_id, f->level, false);
bool ret = !IS_ERR_OR_NULL(b);
if (!ret)
return ret;

f->sectors_written = b->written;
f->journal_seq = le64_to_cpu(b->data->keys.journal_seq);

struct bkey_s_c k;
struct bkey unpacked;
struct btree_node_iter iter;
for_each_btree_node_key_unpack(b, k, &iter, &unpacked)
f->journal_seq = max(f->journal_seq, bkey_journal_seq(k));

six_unlock_read(&b->c.lock);

/*
Expand All @@ -85,7 +104,7 @@ static bool found_btree_node_is_readable(struct btree_trans *trans,
* this node
*/
if (b != btree_node_root(trans->c, b))
bch2_btree_node_evict(trans, &k.k);
bch2_btree_node_evict(trans, &tmp.k);
return ret;
}

Expand All @@ -107,7 +126,7 @@ static int found_btree_node_cmp_time(const struct found_btree_node *l,
const struct found_btree_node *r)
{
return cmp_int(l->seq, r->seq) ?:
cmp_int(l->journal_seq, r->seq);
cmp_int(l->journal_seq, r->journal_seq);
}

static int found_btree_node_cmp_pos(const void *_l, const void *_r)
Expand Down Expand Up @@ -311,15 +330,15 @@ static int handle_overwrites(struct bch_fs *c,
} else if (n->level) {
n->overwritten = true;
} else {
struct printbuf buf = PRINTBUF;

prt_str(&buf, "overlapping btree nodes with same seq! halting\n ");
found_btree_node_to_text(&buf, c, start);
prt_str(&buf, "\n ");
found_btree_node_to_text(&buf, c, n);
bch_err(c, "%s", buf.buf);
printbuf_exit(&buf);
return -BCH_ERR_fsck_repair_unimplemented;
if (bpos_cmp(start->max_key, n->max_key) >= 0)
n->overwritten = true;
else {
n->range_updated = true;
n->min_key = bpos_successor(start->max_key);
n->range_updated = true;
bubble_up(n, end);
goto again;
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion libbcachefs/super-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,10 @@ void bch2_sb_to_text(struct printbuf *out, struct bch_sb *sb,
prt_printf(out, "Device index:\t%u\n", sb->dev_idx);

prt_printf(out, "Label:\t");
prt_printf(out, "%.*s", (int) sizeof(sb->label), sb->label);
if (!strlen(sb->label))
prt_printf(out, "(none)");
else
prt_printf(out, "%.*s", (int) sizeof(sb->label), sb->label);
prt_newline(out);

prt_printf(out, "Version:\t");
Expand Down

0 comments on commit 061a9ff

Please sign in to comment.