summaryrefslogtreecommitdiff
path: root/fs/bcachefs/alloc_foreground.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2022-10-02 06:54:46 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:09:42 +0300
commit943f9946a6cc58e2c15ae39970547cddbe845190 (patch)
treea9c6dc0560ec56db891dc9fde1d2776c5b262aac /fs/bcachefs/alloc_foreground.c
parent685e0f0c477dfc2b2147a20137a349f25b0a1f62 (diff)
downloadlinux-943f9946a6cc58e2c15ae39970547cddbe845190.tar.xz
bcachefs: Don't quash error in bch2_bucket_alloc_set_trans()
We were incorrectly returning -BCH_ERR_insufficient_devices when we'd received a different error from bch2_bucket_alloc_trans(), which (erronously) turns into -EROFS further up the call chain. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/alloc_foreground.c')
-rw-r--r--fs/bcachefs/alloc_foreground.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/fs/bcachefs/alloc_foreground.c b/fs/bcachefs/alloc_foreground.c
index 2318d08ab70f..0a7657541b8c 100644
--- a/fs/bcachefs/alloc_foreground.c
+++ b/fs/bcachefs/alloc_foreground.c
@@ -671,7 +671,7 @@ static int bch2_bucket_alloc_set_trans(struct btree_trans *trans,
bch2_dev_alloc_list(c, stripe, devs_may_alloc);
unsigned dev;
struct bch_dev *ca;
- int ret = 0;
+ int ret = -BCH_ERR_insufficient_devices;
unsigned i;
BUG_ON(*nr_effective >= nr_replicas);
@@ -701,8 +701,8 @@ static int bch2_bucket_alloc_set_trans(struct btree_trans *trans,
bch2_dev_stripe_increment(ca, stripe);
percpu_ref_put(&ca->ref);
- ret = PTR_ERR_OR_ZERO(ob);
- if (ret) {
+ if (IS_ERR(ob)) {
+ ret = PTR_ERR(ob);
if (bch2_err_matches(ret, BCH_ERR_transaction_restart) || cl)
break;
continue;
@@ -711,15 +711,12 @@ static int bch2_bucket_alloc_set_trans(struct btree_trans *trans,
add_new_bucket(c, ptrs, devs_may_alloc,
nr_effective, have_cache, flags, ob);
- if (*nr_effective >= nr_replicas)
+ if (*nr_effective >= nr_replicas) {
+ ret = 0;
break;
+ }
}
- if (*nr_effective >= nr_replicas)
- ret = 0;
- else if (!ret)
- ret = -BCH_ERR_insufficient_devices;
-
return ret;
}