Skip to content

Commit 247ce5f

Browse files
author
Kent Overstreet
committed
bcachefs: Fix bch2_alloc_sectors_start_trans() error handling
When we fail to allocate because of insufficient open buckets, we don't want to retry from the full set of devices - we just want to retry in blocking mode. But if the retry in blocking mode fails with a different error code, we end up squashing the -BCH_ERR_open_buckets_empty error with an error that makes us thing we won't be able to allocate (insufficient_devices) - which is incorrect when we didn't try to allocate from the full set of devices, and causes the write to fail. Signed-off-by: Kent Overstreet <[email protected]>
1 parent 7ba1f6e commit 247ce5f

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

fs/bcachefs/alloc_foreground.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,8 +1374,17 @@ int bch2_alloc_sectors_start_trans(struct btree_trans *trans,
13741374
goto alloc_done;
13751375

13761376
/* Don't retry from all devices if we're out of open buckets: */
1377-
if (bch2_err_matches(ret, BCH_ERR_open_buckets_empty))
1378-
goto allocate_blocking;
1377+
if (bch2_err_matches(ret, BCH_ERR_open_buckets_empty)) {
1378+
int ret = open_bucket_add_buckets(trans, &ptrs, wp, devs_have,
1379+
target, erasure_code,
1380+
nr_replicas, &nr_effective,
1381+
&have_cache, watermark,
1382+
flags, cl);
1383+
if (!ret ||
1384+
bch2_err_matches(ret, BCH_ERR_transaction_restart) ||
1385+
bch2_err_matches(ret, BCH_ERR_open_buckets_empty))
1386+
goto alloc_done;
1387+
}
13791388

13801389
/*
13811390
* Only try to allocate cache (durability = 0 devices) from the
@@ -1389,7 +1398,6 @@ int bch2_alloc_sectors_start_trans(struct btree_trans *trans,
13891398
&have_cache, watermark,
13901399
flags, cl);
13911400
} else {
1392-
allocate_blocking:
13931401
ret = open_bucket_add_buckets(trans, &ptrs, wp, devs_have,
13941402
target, erasure_code,
13951403
nr_replicas, &nr_effective,

0 commit comments

Comments
 (0)