Commit cee0a8ea authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Improve the nopromote tracepoint

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 1ad36a01
...@@ -235,6 +235,7 @@ ...@@ -235,6 +235,7 @@
x(BCH_ERR_nopromote, nopromote_unwritten) \ x(BCH_ERR_nopromote, nopromote_unwritten) \
x(BCH_ERR_nopromote, nopromote_congested) \ x(BCH_ERR_nopromote, nopromote_congested) \
x(BCH_ERR_nopromote, nopromote_in_flight) \ x(BCH_ERR_nopromote, nopromote_in_flight) \
x(BCH_ERR_nopromote, nopromote_no_writes) \
x(BCH_ERR_nopromote, nopromote_enomem) x(BCH_ERR_nopromote, nopromote_enomem)
enum bch_errcode { enum bch_errcode {
......
...@@ -172,11 +172,13 @@ static struct promote_op *__promote_alloc(struct btree_trans *trans, ...@@ -172,11 +172,13 @@ static struct promote_op *__promote_alloc(struct btree_trans *trans,
int ret; int ret;
if (!bch2_write_ref_tryget(c, BCH_WRITE_REF_promote)) if (!bch2_write_ref_tryget(c, BCH_WRITE_REF_promote))
return NULL; return ERR_PTR(-BCH_ERR_nopromote_no_writes);
op = kzalloc(sizeof(*op) + sizeof(struct bio_vec) * pages, GFP_KERNEL); op = kzalloc(sizeof(*op) + sizeof(struct bio_vec) * pages, GFP_KERNEL);
if (!op) if (!op) {
ret = -BCH_ERR_nopromote_enomem;
goto err; goto err;
}
op->start_time = local_clock(); op->start_time = local_clock();
op->pos = pos; op->pos = pos;
...@@ -188,23 +190,28 @@ static struct promote_op *__promote_alloc(struct btree_trans *trans, ...@@ -188,23 +190,28 @@ static struct promote_op *__promote_alloc(struct btree_trans *trans,
*rbio = kzalloc(sizeof(struct bch_read_bio) + *rbio = kzalloc(sizeof(struct bch_read_bio) +
sizeof(struct bio_vec) * pages, sizeof(struct bio_vec) * pages,
GFP_KERNEL); GFP_KERNEL);
if (!*rbio) if (!*rbio) {
ret = -BCH_ERR_nopromote_enomem;
goto err; goto err;
}
rbio_init(&(*rbio)->bio, opts); rbio_init(&(*rbio)->bio, opts);
bio_init(&(*rbio)->bio, NULL, (*rbio)->bio.bi_inline_vecs, pages, 0); bio_init(&(*rbio)->bio, NULL, (*rbio)->bio.bi_inline_vecs, pages, 0);
if (bch2_bio_alloc_pages(&(*rbio)->bio, sectors << 9, if (bch2_bio_alloc_pages(&(*rbio)->bio, sectors << 9, GFP_KERNEL)) {
GFP_KERNEL)) ret = -BCH_ERR_nopromote_enomem;
goto err; goto err;
}
(*rbio)->bounce = true; (*rbio)->bounce = true;
(*rbio)->split = true; (*rbio)->split = true;
(*rbio)->kmalloc = true; (*rbio)->kmalloc = true;
if (rhashtable_lookup_insert_fast(&c->promote_table, &op->hash, if (rhashtable_lookup_insert_fast(&c->promote_table, &op->hash,
bch_promote_params)) bch_promote_params)) {
ret = -BCH_ERR_nopromote_in_flight;
goto err; goto err;
}
bio = &op->write.op.wbio.bio; bio = &op->write.op.wbio.bio;
bio_init(bio, NULL, bio->bi_inline_vecs, pages, 0); bio_init(bio, NULL, bio->bi_inline_vecs, pages, 0);
...@@ -223,9 +230,8 @@ static struct promote_op *__promote_alloc(struct btree_trans *trans, ...@@ -223,9 +230,8 @@ static struct promote_op *__promote_alloc(struct btree_trans *trans,
* -BCH_ERR_ENOSPC_disk_reservation: * -BCH_ERR_ENOSPC_disk_reservation:
*/ */
if (ret) { if (ret) {
ret = rhashtable_remove_fast(&c->promote_table, &op->hash, BUG_ON(rhashtable_remove_fast(&c->promote_table, &op->hash,
bch_promote_params); bch_promote_params));
BUG_ON(ret);
goto err; goto err;
} }
...@@ -239,7 +245,7 @@ static struct promote_op *__promote_alloc(struct btree_trans *trans, ...@@ -239,7 +245,7 @@ static struct promote_op *__promote_alloc(struct btree_trans *trans,
*rbio = NULL; *rbio = NULL;
kfree(op); kfree(op);
bch2_write_ref_put(c, BCH_WRITE_REF_promote); bch2_write_ref_put(c, BCH_WRITE_REF_promote);
return NULL; return ERR_PTR(ret);
} }
noinline noinline
...@@ -274,10 +280,9 @@ static struct promote_op *promote_alloc(struct btree_trans *trans, ...@@ -274,10 +280,9 @@ static struct promote_op *promote_alloc(struct btree_trans *trans,
? BTREE_ID_reflink ? BTREE_ID_reflink
: BTREE_ID_extents, : BTREE_ID_extents,
k, pos, pick, opts, sectors, rbio); k, pos, pick, opts, sectors, rbio);
if (!promote) { ret = PTR_ERR_OR_ZERO(promote);
ret = -BCH_ERR_nopromote_enomem; if (ret)
goto nopromote; goto nopromote;
}
*bounce = true; *bounce = true;
*read_full = promote_full; *read_full = promote_full;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment