summaryrefslogtreecommitdiff
path: root/libbcachefs/btree_locking.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-02-16 06:31:28 -0500
committerKent Overstreet <kent.overstreet@gmail.com>2022-02-16 06:32:49 -0500
commitde4e778a6add88e6ccf5a7730a8d343d3fb5f064 (patch)
tree90d61ca635315abeb69a13f468ab27f2e6d7804a /libbcachefs/btree_locking.h
parenta1d66a2a4e7c536b2b722f6b1758d36f00ae3c55 (diff)
Update bcachefs sources to a0d7001b0f bcachefs: Change bch2_dev_lookup() to not use lookup_bdev()
Diffstat (limited to 'libbcachefs/btree_locking.h')
-rw-r--r--libbcachefs/btree_locking.h46
1 files changed, 29 insertions, 17 deletions
diff --git a/libbcachefs/btree_locking.h b/libbcachefs/btree_locking.h
index d599008c..b4434eca 100644
--- a/libbcachefs/btree_locking.h
+++ b/libbcachefs/btree_locking.h
@@ -128,23 +128,35 @@ static inline enum bch_time_stats lock_to_time_stat(enum six_lock_type type)
}
}
-/*
- * wrapper around six locks that just traces lock contended time
- */
-static inline void __btree_node_lock_type(struct bch_fs *c, struct btree *b,
- enum six_lock_type type)
-{
- u64 start_time = local_clock();
-
- six_lock_type(&b->c.lock, type, NULL, NULL);
- bch2_time_stats_update(&c->times[lock_to_time_stat(type)], start_time);
-}
-
-static inline void btree_node_lock_type(struct bch_fs *c, struct btree *b,
- enum six_lock_type type)
-{
- if (!six_trylock_type(&b->c.lock, type))
- __btree_node_lock_type(c, b, type);
+static inline bool btree_node_lock_type(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)
+{
+ struct bch_fs *c = trans->c;
+ u64 start_time;
+ bool ret;
+
+ if (six_trylock_type(&b->c.lock, type))
+ return true;
+
+ start_time = local_clock();
+
+ trans->locking_path_idx = path->idx;
+ trans->locking_pos = pos;
+ trans->locking_btree_id = path->btree_id;
+ 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;
+ trans->locking = NULL;
+
+ if (ret)
+ bch2_time_stats_update(&c->times[lock_to_time_stat(type)], start_time);
+
+ return ret;
}
/*