diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-07-17 23:06:38 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:37 -0400 |
commit | 549d173c1bd9b58c2ad41217522462e012a6545f (patch) | |
tree | 9bf146d761ae1f81ba18ec45a1bda63cb47549eb /fs/bcachefs/alloc_foreground.c | |
parent | 0990efaeeab14de1e3e3bf2791808afebadd1cc4 (diff) |
bcachefs: EINTR -> BCH_ERR_transaction_restart
Now that we have error codes, with subtypes, we can switch to our own
error code for transaction restarts - and even better, a distinct error
code for each transaction restart reason: clearer code and better
debugging.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/alloc_foreground.c')
-rw-r--r-- | fs/bcachefs/alloc_foreground.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/fs/bcachefs/alloc_foreground.c b/fs/bcachefs/alloc_foreground.c index a9f893361c73..99fbf1d2dee5 100644 --- a/fs/bcachefs/alloc_foreground.c +++ b/fs/bcachefs/alloc_foreground.c @@ -470,8 +470,9 @@ again: for (alloc_cursor = max(alloc_cursor, bkey_start_offset(k.k)); alloc_cursor < k.k->p.offset; alloc_cursor++) { - if (btree_trans_too_many_iters(trans)) { - ob = ERR_PTR(-EINTR); + ret = btree_trans_too_many_iters(trans); + if (ret) { + ob = ERR_PTR(ret); break; } @@ -488,7 +489,8 @@ again: break; } } - if (ob) + + if (ob || ret) break; } bch2_trans_iter_exit(trans, &iter); @@ -738,7 +740,7 @@ static int bch2_bucket_alloc_set_trans(struct btree_trans *trans, ret = PTR_ERR_OR_ZERO(ob); if (ret) { - if (ret == -EINTR || cl) + if (bch2_err_matches(ret, BCH_ERR_transaction_restart) || cl) break; continue; } @@ -925,7 +927,7 @@ static int open_bucket_add_buckets(struct btree_trans *trans, target, erasure_code, nr_replicas, nr_effective, have_cache, flags, _cl); - if (ret == -EINTR || + if (bch2_err_matches(ret, BCH_ERR_transaction_restart) || bch2_err_matches(ret, BCH_ERR_freelist_empty) || bch2_err_matches(ret, BCH_ERR_open_buckets_empty)) return ret; @@ -949,7 +951,7 @@ retry_blocking: nr_replicas, nr_effective, have_cache, reserve, flags, cl); if (ret && - ret != -EINTR && + !bch2_err_matches(ret, BCH_ERR_transaction_restart) && !bch2_err_matches(ret, BCH_ERR_insufficient_devices) && !cl && _cl) { cl = _cl; @@ -1191,7 +1193,8 @@ retry: nr_replicas, &nr_effective, &have_cache, reserve, ob_flags, NULL); - if (!ret || ret == -EINTR) + if (!ret || + bch2_err_matches(ret, BCH_ERR_transaction_restart)) goto alloc_done; ret = open_bucket_add_buckets(trans, &ptrs, wp, devs_have, |