summaryrefslogtreecommitdiff
path: root/fs/bcachefs/btree_locking.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-07-18 06:06:38 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:09:37 +0300
commit549d173c1bd9b58c2ad41217522462e012a6545f (patch)
tree9bf146d761ae1f81ba18ec45a1bda63cb47549eb /fs/bcachefs/btree_locking.h
parent0990efaeeab14de1e3e3bf2791808afebadd1cc4 (diff)
downloadlinux-549d173c1bd9b58c2ad41217522462e012a6545f.tar.xz
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/btree_locking.h')
-rw-r--r--fs/bcachefs/btree_locking.h38
1 files changed, 20 insertions, 18 deletions
diff --git a/fs/bcachefs/btree_locking.h b/fs/bcachefs/btree_locking.h
index b8708466c4e3..33a69e27c39e 100644
--- a/fs/bcachefs/btree_locking.h
+++ b/fs/bcachefs/btree_locking.h
@@ -152,7 +152,7 @@ static inline enum bch_time_stats lock_to_time_stat(enum six_lock_type type)
}
}
-static inline bool btree_node_lock_type(struct btree_trans *trans,
+static inline int btree_node_lock_type(struct btree_trans *trans,
struct btree_path *path,
struct btree *b,
struct bpos pos, unsigned level,
@@ -161,10 +161,10 @@ static inline bool btree_node_lock_type(struct btree_trans *trans,
{
struct bch_fs *c = trans->c;
u64 start_time;
- bool ret;
+ int ret;
if (six_trylock_type(&b->c.lock, type))
- return true;
+ return 0;
start_time = local_clock();
@@ -174,13 +174,14 @@ static inline bool btree_node_lock_type(struct btree_trans *trans,
trans->locking_level = level;
trans->locking_lock_type = type;
trans->locking = b;
- ret = six_lock_type(&b->c.lock, type, should_sleep_fn, p) == 0;
+ ret = six_lock_type(&b->c.lock, type, should_sleep_fn, p);
trans->locking = NULL;
if (ret)
- bch2_time_stats_update(&c->times[lock_to_time_stat(type)], start_time);
+ return ret;
- return ret;
+ bch2_time_stats_update(&c->times[lock_to_time_stat(type)], start_time);
+ return 0;
}
/*
@@ -203,33 +204,34 @@ static inline bool btree_node_lock_increment(struct btree_trans *trans,
return false;
}
-bool __bch2_btree_node_lock(struct btree_trans *, struct btree_path *,
- struct btree *, struct bpos, unsigned,
- enum six_lock_type,
- six_lock_should_sleep_fn, void *,
- unsigned long);
+int __bch2_btree_node_lock(struct btree_trans *, struct btree_path *,
+ struct btree *, struct bpos, unsigned,
+ enum six_lock_type,
+ six_lock_should_sleep_fn, void *,
+ unsigned long);
-static inline bool btree_node_lock(struct btree_trans *trans,
+static inline int btree_node_lock(struct btree_trans *trans,
struct btree_path *path,
struct btree *b, struct bpos pos, unsigned level,
enum six_lock_type type,
six_lock_should_sleep_fn should_sleep_fn, void *p,
unsigned long ip)
{
+ int ret = 0;
+
EBUG_ON(level >= BTREE_MAX_DEPTH);
EBUG_ON(!(trans->paths_allocated & (1ULL << path->idx)));
if (likely(six_trylock_type(&b->c.lock, type)) ||
- btree_node_lock_increment(trans, b, level, type) ||
- __bch2_btree_node_lock(trans, path, b, pos, level, type,
- should_sleep_fn, p, ip)) {
+ btree_node_lock_increment(trans, b, level, type) ||
+ !(ret = __bch2_btree_node_lock(trans, path, b, pos, level, type,
+ should_sleep_fn, p, ip))) {
#ifdef CONFIG_BCACHEFS_LOCK_TIME_STATS
path->l[b->c.level].lock_taken_time = ktime_get_ns();
#endif
- return true;
- } else {
- return false;
}
+
+ return ret;
}
bool __bch2_btree_node_relock(struct btree_trans *, struct btree_path *, unsigned);