summaryrefslogtreecommitdiff
path: root/drivers/md/bcache/btree_locking.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md/bcache/btree_locking.h')
-rw-r--r--drivers/md/bcache/btree_locking.h58
1 files changed, 31 insertions, 27 deletions
diff --git a/drivers/md/bcache/btree_locking.h b/drivers/md/bcache/btree_locking.h
index f6789bb4a20b..34c12597377d 100644
--- a/drivers/md/bcache/btree_locking.h
+++ b/drivers/md/bcache/btree_locking.h
@@ -19,7 +19,7 @@ enum btree_node_locked_type {
BTREE_NODE_INTENT_LOCKED = SIX_LOCK_intent,
};
-static inline int btree_node_locked_type(struct btree_iter *iter,
+static inline int btree_node_locked_type(struct btree_iter_state *_iter,
unsigned level)
{
/*
@@ -28,35 +28,35 @@ static inline int btree_node_locked_type(struct btree_iter *iter,
* branches:
*/
return BTREE_NODE_UNLOCKED +
- ((iter->nodes_locked >> level) & 1) +
- ((iter->nodes_intent_locked >> level) & 1);
+ ((_iter->nodes_locked >> level) & 1) +
+ ((_iter->nodes_intent_locked >> level) & 1);
}
-static inline bool btree_node_intent_locked(struct btree_iter *iter,
+static inline bool btree_node_intent_locked(struct btree_iter_state *_iter,
unsigned level)
{
- return btree_node_locked_type(iter, level) == BTREE_NODE_INTENT_LOCKED;
+ return btree_node_locked_type(_iter, level) == BTREE_NODE_INTENT_LOCKED;
}
-static inline bool btree_node_read_locked(struct btree_iter *iter,
+static inline bool btree_node_read_locked(struct btree_iter_state *_iter,
unsigned level)
{
- return btree_node_locked_type(iter, level) == BTREE_NODE_READ_LOCKED;
+ return btree_node_locked_type(_iter, level) == BTREE_NODE_READ_LOCKED;
}
-static inline bool btree_node_locked(struct btree_iter *iter, unsigned level)
+static inline bool btree_node_locked(struct btree_iter_state *_iter, unsigned level)
{
- return iter->nodes_locked & (1 << level);
+ return _iter->nodes_locked & (1 << level);
}
-static inline void mark_btree_node_unlocked(struct btree_iter *iter,
+static inline void mark_btree_node_unlocked(struct btree_iter_state *_iter,
unsigned level)
{
- iter->nodes_locked &= ~(1 << level);
- iter->nodes_intent_locked &= ~(1 << level);
+ _iter->nodes_locked &= ~(1 << level);
+ _iter->nodes_intent_locked &= ~(1 << level);
}
-static inline void mark_btree_node_locked(struct btree_iter *iter,
+static inline void mark_btree_node_locked(struct btree_iter_state *_iter,
unsigned level,
enum six_lock_type type)
{
@@ -64,14 +64,14 @@ static inline void mark_btree_node_locked(struct btree_iter *iter,
BUILD_BUG_ON(SIX_LOCK_read != 0);
BUILD_BUG_ON(SIX_LOCK_intent != 1);
- iter->nodes_locked |= 1 << level;
- iter->nodes_intent_locked |= type << level;
+ _iter->nodes_locked |= 1 << level;
+ _iter->nodes_intent_locked |= type << level;
}
-static inline void mark_btree_node_intent_locked(struct btree_iter *iter,
+static inline void mark_btree_node_intent_locked(struct btree_iter_state *_iter,
unsigned level)
{
- mark_btree_node_locked(iter, level, SIX_LOCK_intent);
+ mark_btree_node_locked(_iter, level, SIX_LOCK_intent);
}
static inline enum six_lock_type
@@ -87,10 +87,10 @@ static inline bool btree_want_intent(struct btree_iter *iter, int level)
return btree_lock_want(iter, level) == SIX_LOCK_intent;
}
-static inline void __btree_node_unlock(struct btree_iter *iter, unsigned level,
+static inline void __btree_node_unlock(struct btree_iter_state *_iter, unsigned level,
struct btree *b)
{
- switch (btree_node_locked_type(iter, level)) {
+ switch (btree_node_locked_type(_iter, level)) {
case BTREE_NODE_READ_LOCKED:
six_unlock_read(&b->lock);
break;
@@ -99,12 +99,12 @@ static inline void __btree_node_unlock(struct btree_iter *iter, unsigned level,
break;
}
- mark_btree_node_unlocked(iter, level);
+ mark_btree_node_unlocked(_iter, level);
}
-static inline void btree_node_unlock(struct btree_iter *iter, unsigned level)
+static inline void btree_node_unlock(struct btree_iter_state *_iter, unsigned level)
{
- __btree_node_unlock(iter, level, iter->l[level].node);
+ __btree_node_unlock(_iter, level, _iter->l[level].node);
}
static inline void btree_node_lock_type(struct btree *b, struct btree_iter *iter,
@@ -115,12 +115,15 @@ static inline void btree_node_lock_type(struct btree *b, struct btree_iter *iter
if (six_trylock_type(&b->lock, type))
return;
- for_each_linked_btree_iter(iter, linked)
- if (linked->l[b->level].node == b &&
- btree_node_locked_type(linked, b->level) == type) {
+ for_each_linked_btree_iter(iter, linked) {
+ struct btree_iter_state *_linked = iter_s(linked);
+
+ if (_linked->l[b->level].node == b &&
+ btree_node_locked_type(_linked, b->level) == type) {
six_lock_increment(&b->lock, type);
return;
}
+ }
six_lock_type(&b->lock, type);
}
@@ -134,7 +137,7 @@ static inline void btree_node_lock_type(struct btree *b, struct btree_iter *iter
if ((_raced = ((check_if_raced) || ((b)->level != _level)))) \
six_unlock_type(&(b)->lock, _type); \
else \
- mark_btree_node_locked(_iter, _level, _type); \
+ mark_btree_node_locked(iter_s(_iter), _level, _type); \
\
!_raced; \
})
@@ -143,7 +146,8 @@ static inline void btree_node_lock_type(struct btree *b, struct btree_iter *iter
(!race_fault() && \
__btree_node_lock(b, iter, level, check_if_raced))
-bool btree_node_relock(struct btree_iter *, unsigned);
+bool bch_btree_node_relock(struct btree_iter *, struct btree_iter_state *,
+ unsigned);
void btree_node_unlock_write(struct btree *, struct btree_iter *);
void btree_node_lock_write(struct btree *, struct btree_iter *);