summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fs/bcachefs/alloc_foreground.c2
-rw-r--r--fs/bcachefs/btree_cache.c4
-rw-r--r--fs/bcachefs/btree_update_interior.c2
-rw-r--r--fs/bcachefs/btree_update_leaf.c17
-rw-r--r--fs/bcachefs/data_update.c2
-rw-r--r--fs/bcachefs/errcode.h5
-rw-r--r--fs/bcachefs/io.c4
-rw-r--r--fs/bcachefs/journal.c22
-rw-r--r--fs/bcachefs/journal.h2
9 files changed, 26 insertions, 34 deletions
diff --git a/fs/bcachefs/alloc_foreground.c b/fs/bcachefs/alloc_foreground.c
index 634ae1bba41a..86acc7d3b4c6 100644
--- a/fs/bcachefs/alloc_foreground.c
+++ b/fs/bcachefs/alloc_foreground.c
@@ -1224,7 +1224,7 @@ err:
if (bch2_err_matches(ret, BCH_ERR_open_buckets_empty) ||
bch2_err_matches(ret, BCH_ERR_freelist_empty))
return cl
- ? -EAGAIN
+ ? -BCH_ERR_bucket_alloc_blocked
: -BCH_ERR_ENOSPC_bucket_alloc;
return ret;
diff --git a/fs/bcachefs/btree_cache.c b/fs/bcachefs/btree_cache.c
index d24827fb0164..b5e78042c1ff 100644
--- a/fs/bcachefs/btree_cache.c
+++ b/fs/bcachefs/btree_cache.c
@@ -577,7 +577,7 @@ int bch2_btree_cache_cannibalize_lock(struct bch_fs *c, struct closure *cl)
}
trace_and_count(c, btree_cache_cannibalize_lock_fail, c);
- return -EAGAIN;
+ return -BCH_ERR_btree_cache_cannibalize_lock_blocked;
success:
trace_and_count(c, btree_cache_cannibalize_lock, c);
@@ -952,8 +952,6 @@ retry:
* bch_btree_node_get - find a btree node in the cache and lock it, reading it
* in from disk if necessary.
*
- * If IO is necessary and running under generic_make_request, returns -EAGAIN.
- *
* The btree node will have either a read or a write lock held, depending on
* the @write parameter.
*/
diff --git a/fs/bcachefs/btree_update_interior.c b/fs/bcachefs/btree_update_interior.c
index a4476f1662ea..a49e7b6b416d 100644
--- a/fs/bcachefs/btree_update_interior.c
+++ b/fs/bcachefs/btree_update_interior.c
@@ -1162,7 +1162,7 @@ bch2_btree_update_start(struct btree_trans *trans, struct btree_path *path,
bch2_trans_unlock(trans);
closure_sync(&cl);
- } while (ret == -EAGAIN);
+ } while (bch2_err_matches(ret, BCH_ERR_operation_blocked));
}
if (ret) {
diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c
index 3143e2f5bbb2..75d8a5535212 100644
--- a/fs/bcachefs/btree_update_leaf.c
+++ b/fs/bcachefs/btree_update_leaf.c
@@ -316,15 +316,10 @@ bch2_trans_journal_preres_get_cold(struct btree_trans *trans, unsigned u64s,
static __always_inline int bch2_trans_journal_res_get(struct btree_trans *trans,
unsigned flags)
{
- struct bch_fs *c = trans->c;
- int ret;
-
- ret = bch2_journal_res_get(&c->journal, &trans->journal_res,
- trans->journal_u64s,
- flags|
- (trans->flags & JOURNAL_WATERMARK_MASK));
-
- return ret == -EAGAIN ? -BCH_ERR_btree_insert_need_journal_res : ret;
+ return bch2_journal_res_get(&trans->c->journal, &trans->journal_res,
+ trans->journal_u64s,
+ flags|
+ (trans->flags & JOURNAL_WATERMARK_MASK));
}
#define JSET_ENTRY_LOG_U64s 4
@@ -842,7 +837,7 @@ static inline int do_bch2_trans_commit(struct btree_trans *trans,
&trans->journal_preres, trans->journal_preres_u64s,
JOURNAL_RES_GET_NONBLOCK|
(trans->flags & JOURNAL_WATERMARK_MASK));
- if (unlikely(ret == -EAGAIN))
+ if (unlikely(ret == -BCH_ERR_journal_preres_get_blocked))
ret = bch2_trans_journal_preres_get_cold(trans,
trans->journal_preres_u64s, trace_ip);
if (unlikely(ret))
@@ -914,7 +909,7 @@ int bch2_trans_commit_error(struct btree_trans *trans,
if (ret)
trace_and_count(c, trans_restart_mark_replicas, trans, trace_ip);
break;
- case -BCH_ERR_btree_insert_need_journal_res:
+ case -BCH_ERR_journal_res_get_blocked:
bch2_trans_unlock(trans);
if ((trans->flags & BTREE_INSERT_JOURNAL_RECLAIM) &&
diff --git a/fs/bcachefs/data_update.c b/fs/bcachefs/data_update.c
index 62006d1c1126..d4cdfb48ab8f 100644
--- a/fs/bcachefs/data_update.c
+++ b/fs/bcachefs/data_update.c
@@ -349,7 +349,7 @@ void bch2_update_unwritten_extent(struct btree_trans *trans,
update->op.nr_replicas,
update->op.alloc_reserve,
0, &cl, &wp);
- if (ret == -EAGAIN) {
+ if (bch2_err_matches(ret, BCH_ERR_operation_blocked)) {
bch2_trans_unlock(trans);
closure_sync(&cl);
continue;
diff --git a/fs/bcachefs/errcode.h b/fs/bcachefs/errcode.h
index a1e39987fec1..543cdb553188 100644
--- a/fs/bcachefs/errcode.h
+++ b/fs/bcachefs/errcode.h
@@ -85,6 +85,11 @@
x(EROFS, erofs_journal_err) \
x(EROFS, erofs_sb_err) \
x(EROFS, insufficient_devices) \
+ x(0, operation_blocked) \
+ x(BCH_ERR_operation_blocked, btree_cache_cannibalize_lock_blocked) \
+ x(BCH_ERR_operation_blocked, journal_res_get_blocked) \
+ x(BCH_ERR_operation_blocked, journal_preres_get_blocked) \
+ x(BCH_ERR_operation_blocked, bucket_alloc_blocked) \
x(BCH_ERR_invalid, invalid_sb) \
x(BCH_ERR_invalid_sb, invalid_sb_magic) \
x(BCH_ERR_invalid_sb, invalid_sb_version) \
diff --git a/fs/bcachefs/io.c b/fs/bcachefs/io.c
index afef49cd9dd0..706f18bc4238 100644
--- a/fs/bcachefs/io.c
+++ b/fs/bcachefs/io.c
@@ -427,7 +427,7 @@ retry:
opts.data_replicas,
opts.data_replicas,
RESERVE_none, 0, &cl, &wp);
- if (ret == -EAGAIN) {
+ if (bch2_err_matches(ret, BCH_ERR_operation_blocked)) {
bch2_trans_unlock(trans);
closure_sync(&cl);
goto retry;
@@ -1627,7 +1627,7 @@ again:
BCH_WRITE_ONLY_SPECIFIED_DEVS))
? NULL : &op->cl, &wp));
if (unlikely(ret)) {
- if (ret == -EAGAIN)
+ if (bch2_err_matches(ret, BCH_ERR_operation_blocked))
break;
goto err;
diff --git a/fs/bcachefs/journal.c b/fs/bcachefs/journal.c
index 010052742c06..e35b685a6770 100644
--- a/fs/bcachefs/journal.c
+++ b/fs/bcachefs/journal.c
@@ -199,12 +199,6 @@ static bool journal_entry_close(struct journal *j)
/*
* should _only_ called from journal_res_get() - when we actually want a
* journal reservation - journal entry is open means journal is dirty:
- *
- * returns:
- * 0: success
- * -ENOSPC: journal currently full, must invoke reclaim
- * -EAGAIN: journal blocked, must wait
- * -EROFS: insufficient rw devices or journal error
*/
static int journal_entry_open(struct journal *j)
{
@@ -445,7 +439,9 @@ unlock:
}
}
- return ret == JOURNAL_ERR_insufficient_devices ? -EROFS : -EAGAIN;
+ return ret == JOURNAL_ERR_insufficient_devices
+ ? -EROFS
+ : -BCH_ERR_journal_res_get_blocked;
}
/*
@@ -464,7 +460,8 @@ int bch2_journal_res_get_slowpath(struct journal *j, struct journal_res *res,
int ret;
closure_wait_event(&j->async_wait,
- (ret = __journal_res_get(j, res, flags)) != -EAGAIN ||
+ (ret = __journal_res_get(j, res, flags)) !=
+ -BCH_ERR_journal_res_get_blocked||
(flags & JOURNAL_RES_GET_NONBLOCK));
return ret;
}
@@ -815,12 +812,9 @@ static int __bch2_set_nr_journal_buckets(struct bch_dev *ca, unsigned nr,
} else {
ob[nr_got] = bch2_bucket_alloc(c, ca, RESERVE_none,
false, cl);
- if (IS_ERR(ob[nr_got])) {
- ret = cl
- ? -EAGAIN
- : -BCH_ERR_ENOSPC_bucket_alloc;
+ ret = PTR_ERR_OR_ZERO(ob[nr_got]);
+ if (ret)
break;
- }
bu[nr_got] = ob[nr_got]->bucket;
}
@@ -930,7 +924,7 @@ int bch2_set_nr_journal_buckets(struct bch_fs *c, struct bch_dev *ca,
closure_init_stack(&cl);
- while (ja->nr != nr && (ret == 0 || ret == -EAGAIN)) {
+ while (ja->nr != nr && (ret == 0 || ret == -BCH_ERR_bucket_alloc_blocked)) {
struct disk_reservation disk_res = { 0, 0 };
closure_sync(&cl);
diff --git a/fs/bcachefs/journal.h b/fs/bcachefs/journal.h
index 51d29a01b7b2..896a2d7dca36 100644
--- a/fs/bcachefs/journal.h
+++ b/fs/bcachefs/journal.h
@@ -479,7 +479,7 @@ static inline int bch2_journal_preres_get(struct journal *j,
return 0;
if (flags & JOURNAL_RES_GET_NONBLOCK)
- return -EAGAIN;
+ return -BCH_ERR_journal_preres_get_blocked;
return __bch2_journal_preres_get(j, res, new_u64s, flags);
}