Skip to content

Commit

Permalink
bcachefs: btree node scan now fills in sectors_written
Browse files Browse the repository at this point in the history
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
  • Loading branch information
Kent Overstreet committed Apr 29, 2024
1 parent ae92765 commit f7c3dc2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions fs/bcachefs/btree_node_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,25 @@ static void found_btree_node_to_key(struct bkey_i *k, const struct found_btree_n
bp->v.seq = cpu_to_le64(f->cookie);
bp->v.sectors_written = 0;
bp->v.flags = 0;
bp->v.sectors_written = cpu_to_le16(f->sectors_written);
bp->v.min_key = f->min_key;
SET_BTREE_PTR_RANGE_UPDATED(&bp->v, f->range_updated);
memcpy(bp->v.start, f->ptrs, sizeof(struct bch_extent_ptr) * f->nr_ptrs);
}

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

found_btree_node_to_key(&k.k, f);

struct btree *b = bch2_btree_node_get_noiter(trans, &k.k, f->btree_id, f->level, false);
bool ret = !IS_ERR_OR_NULL(b);
if (ret)
if (ret) {
f->sectors_written = b->written;
six_unlock_read(&b->c.lock);
}

/*
* We might update this node's range; if that happens, we need the node
Expand Down
1 change: 1 addition & 0 deletions fs/bcachefs/btree_node_scan_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ struct found_btree_node {
bool overwritten:1;
u8 btree_id;
u8 level;
unsigned sectors_written;
u32 seq;
u64 cookie;

Expand Down

0 comments on commit f7c3dc2

Please sign in to comment.