Commit ac9fa4bd authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Kill btree_insert_ret enum

Replace with standard bcachefs-private error codes.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 5c792e1b
...@@ -692,15 +692,6 @@ struct btree_root { ...@@ -692,15 +692,6 @@ struct btree_root {
s8 error; s8 error;
}; };
enum btree_insert_ret {
BTREE_INSERT_OK,
/* leaf node needs to be split */
BTREE_INSERT_BTREE_NODE_FULL,
BTREE_INSERT_NEED_MARK_REPLICAS,
BTREE_INSERT_NEED_JOURNAL_RES,
BTREE_INSERT_NEED_JOURNAL_RECLAIM,
};
enum btree_gc_coalesce_fail_reason { enum btree_gc_coalesce_fail_reason {
BTREE_GC_COALESCE_FAIL_RESERVE_GET, BTREE_GC_COALESCE_FAIL_RESERVE_GET,
BTREE_GC_COALESCE_FAIL_KEYLIST_REALLOC, BTREE_GC_COALESCE_FAIL_KEYLIST_REALLOC,
......
...@@ -318,7 +318,7 @@ static __always_inline int bch2_trans_journal_res_get(struct btree_trans *trans, ...@@ -318,7 +318,7 @@ static __always_inline int bch2_trans_journal_res_get(struct btree_trans *trans,
flags| flags|
(trans->flags & JOURNAL_WATERMARK_MASK)); (trans->flags & JOURNAL_WATERMARK_MASK));
return ret == -EAGAIN ? BTREE_INSERT_NEED_JOURNAL_RES : ret; return ret == -EAGAIN ? -BCH_ERR_btree_insert_need_journal_res : ret;
} }
#define JSET_ENTRY_LOG_U64s 4 #define JSET_ENTRY_LOG_U64s 4
...@@ -337,23 +337,20 @@ static noinline void journal_transaction_name(struct btree_trans *trans) ...@@ -337,23 +337,20 @@ static noinline void journal_transaction_name(struct btree_trans *trans)
strncpy(l->d, trans->fn, JSET_ENTRY_LOG_U64s * sizeof(u64)); strncpy(l->d, trans->fn, JSET_ENTRY_LOG_U64s * sizeof(u64));
} }
static inline enum btree_insert_ret static inline int btree_key_can_insert(struct btree_trans *trans,
btree_key_can_insert(struct btree_trans *trans, struct btree *b, unsigned u64s)
struct btree *b,
unsigned u64s)
{ {
struct bch_fs *c = trans->c; struct bch_fs *c = trans->c;
if (!bch2_btree_node_insert_fits(c, b, u64s)) if (!bch2_btree_node_insert_fits(c, b, u64s))
return BTREE_INSERT_BTREE_NODE_FULL; return -BCH_ERR_btree_insert_btree_node_full;
return BTREE_INSERT_OK; return 0;
} }
static enum btree_insert_ret static int btree_key_can_insert_cached(struct btree_trans *trans,
btree_key_can_insert_cached(struct btree_trans *trans, struct btree_path *path,
struct btree_path *path, unsigned u64s)
unsigned u64s)
{ {
struct bch_fs *c = trans->c; struct bch_fs *c = trans->c;
struct bkey_cached *ck = (void *) path->l[0].b; struct bkey_cached *ck = (void *) path->l[0].b;
...@@ -365,7 +362,7 @@ btree_key_can_insert_cached(struct btree_trans *trans, ...@@ -365,7 +362,7 @@ btree_key_can_insert_cached(struct btree_trans *trans,
if (!test_bit(BKEY_CACHED_DIRTY, &ck->flags) && if (!test_bit(BKEY_CACHED_DIRTY, &ck->flags) &&
bch2_btree_key_cache_must_wait(c) && bch2_btree_key_cache_must_wait(c) &&
!(trans->flags & BTREE_INSERT_JOURNAL_RECLAIM)) !(trans->flags & BTREE_INSERT_JOURNAL_RECLAIM))
return BTREE_INSERT_NEED_JOURNAL_RECLAIM; return -BCH_ERR_btree_insert_need_journal_reclaim;
/* /*
* bch2_varint_decode can read past the end of the buffer by at most 7 * bch2_varint_decode can read past the end of the buffer by at most 7
...@@ -374,7 +371,7 @@ btree_key_can_insert_cached(struct btree_trans *trans, ...@@ -374,7 +371,7 @@ btree_key_can_insert_cached(struct btree_trans *trans,
u64s += 1; u64s += 1;
if (u64s <= ck->u64s) if (u64s <= ck->u64s)
return BTREE_INSERT_OK; return 0;
new_u64s = roundup_pow_of_two(u64s); new_u64s = roundup_pow_of_two(u64s);
new_k = krealloc(ck->k, new_u64s * sizeof(u64), GFP_NOFS); new_k = krealloc(ck->k, new_u64s * sizeof(u64), GFP_NOFS);
...@@ -684,7 +681,7 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, ...@@ -684,7 +681,7 @@ bch2_trans_commit_write_locked(struct btree_trans *trans,
if (trans->fs_usage_deltas && if (trans->fs_usage_deltas &&
bch2_trans_fs_usage_apply(trans, trans->fs_usage_deltas)) bch2_trans_fs_usage_apply(trans, trans->fs_usage_deltas))
return BTREE_INSERT_NEED_MARK_REPLICAS; return -BCH_ERR_btree_insert_need_mark_replicas;
trans_for_each_update(trans, i) trans_for_each_update(trans, i)
if (BTREE_NODE_TYPE_HAS_MEM_TRIGGERS & (1U << i->bkey_type)) { if (BTREE_NODE_TYPE_HAS_MEM_TRIGGERS & (1U << i->bkey_type)) {
...@@ -916,12 +913,12 @@ int bch2_trans_commit_error(struct btree_trans *trans, ...@@ -916,12 +913,12 @@ int bch2_trans_commit_error(struct btree_trans *trans,
struct bch_fs *c = trans->c; struct bch_fs *c = trans->c;
switch (ret) { switch (ret) {
case BTREE_INSERT_BTREE_NODE_FULL: case -BCH_ERR_btree_insert_btree_node_full:
ret = bch2_btree_split_leaf(trans, i->path, trans->flags); ret = bch2_btree_split_leaf(trans, i->path, trans->flags);
if (bch2_err_matches(ret, BCH_ERR_transaction_restart)) if (bch2_err_matches(ret, BCH_ERR_transaction_restart))
trace_and_count(c, trans_restart_btree_node_split, trans, trace_ip, i->path); trace_and_count(c, trans_restart_btree_node_split, trans, trace_ip, i->path);
break; break;
case BTREE_INSERT_NEED_MARK_REPLICAS: case -BCH_ERR_btree_insert_need_mark_replicas:
bch2_trans_unlock(trans); bch2_trans_unlock(trans);
ret = bch2_replicas_delta_list_mark(c, trans->fs_usage_deltas); ret = bch2_replicas_delta_list_mark(c, trans->fs_usage_deltas);
...@@ -932,7 +929,7 @@ int bch2_trans_commit_error(struct btree_trans *trans, ...@@ -932,7 +929,7 @@ int bch2_trans_commit_error(struct btree_trans *trans,
if (ret) if (ret)
trace_and_count(c, trans_restart_mark_replicas, trans, trace_ip); trace_and_count(c, trans_restart_mark_replicas, trans, trace_ip);
break; break;
case BTREE_INSERT_NEED_JOURNAL_RES: case -BCH_ERR_btree_insert_need_journal_res:
bch2_trans_unlock(trans); bch2_trans_unlock(trans);
if ((trans->flags & BTREE_INSERT_JOURNAL_RECLAIM) && if ((trans->flags & BTREE_INSERT_JOURNAL_RECLAIM) &&
...@@ -949,7 +946,7 @@ int bch2_trans_commit_error(struct btree_trans *trans, ...@@ -949,7 +946,7 @@ int bch2_trans_commit_error(struct btree_trans *trans,
if (ret) if (ret)
trace_and_count(c, trans_restart_journal_res_get, trans, trace_ip); trace_and_count(c, trans_restart_journal_res_get, trans, trace_ip);
break; break;
case BTREE_INSERT_NEED_JOURNAL_RECLAIM: case -BCH_ERR_btree_insert_need_journal_reclaim:
bch2_trans_unlock(trans); bch2_trans_unlock(trans);
trace_and_count(c, trans_blocked_journal_reclaim, trans, trace_ip); trace_and_count(c, trans_blocked_journal_reclaim, trans, trace_ip);
......
...@@ -53,6 +53,11 @@ ...@@ -53,6 +53,11 @@
x(BCH_ERR_no_btree_node, no_btree_node_down) \ x(BCH_ERR_no_btree_node, no_btree_node_down) \
x(BCH_ERR_no_btree_node, no_btree_node_init) \ x(BCH_ERR_no_btree_node, no_btree_node_init) \
x(BCH_ERR_no_btree_node, no_btree_node_cached) \ x(BCH_ERR_no_btree_node, no_btree_node_cached) \
x(0, btree_insert_fail) \
x(BCH_ERR_btree_insert_fail, btree_insert_btree_node_full) \
x(BCH_ERR_btree_insert_fail, btree_insert_need_mark_replicas) \
x(BCH_ERR_btree_insert_fail, btree_insert_need_journal_res) \
x(BCH_ERR_btree_insert_fail, btree_insert_need_journal_reclaim) \
x(0, lock_fail_root_changed) \ x(0, lock_fail_root_changed) \
x(0, journal_reclaim_would_deadlock) \ x(0, journal_reclaim_would_deadlock) \
x(0, fsck) \ x(0, fsck) \
......
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