From: Matthew Wilcox Date: Wed, 5 Dec 2018 20:42:35 +0000 (-0500) Subject: maple_tree: Introduce maple_lock & maple_unlock X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=081d29cd5e696f9b3059cef4161d81a92f77dfc8;p=users%2Fjedix%2Flinux-maple.git maple_tree: Introduce maple_lock & maple_unlock These are wrappers for spin_lock, just like the XArray. Signed-off-by: Matthew Wilcox --- diff --git a/include/linux/maple_tree.h b/include/linux/maple_tree.h index 00892c978e37..d42cb5da74be 100644 --- a/include/linux/maple_tree.h +++ b/include/linux/maple_tree.h @@ -163,6 +163,8 @@ struct maple_state { .flags = 0, \ } +#define mtree_lock(mt) spin_lock(&mt->lock); +#define mtree_unlock(mt) spin_unlock(&mt->lock); /* Main interface */ void mtree_init(struct maple_tree *mt); diff --git a/lib/maple_tree.c b/lib/maple_tree.c index e64bdaf61baa..6fd0ee8d3ef6 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -162,9 +162,9 @@ static bool __maple_nomem(struct maple_state *ms, gfp_t gfp) return false; if (gfpflags_allow_blocking(gfp)) { - spin_unlock(&ms->tree->lock); + mtree_unlock(ms->tree); maple_new_node(ms, ma_get_alloc_cnt(ms), gfp); - spin_lock(&ms->tree->lock); + mtree_lock(ms->tree); } else { maple_new_node(ms, ma_get_alloc_cnt(ms), gfp); } @@ -727,7 +727,7 @@ int mtree_insert_range(struct maple_tree *mt, unsigned long start, mt->flags |= MAP_STATE_SPLIT_ON_FULL; - spin_lock(&ms.tree->lock); + mtree_lock(ms.tree); retry: walked = _maple_setup_insert(&ms); if (walked != NULL) @@ -738,7 +738,7 @@ retry: goto retry; already_exists: - spin_unlock(&ms.tree->lock); + mtree_unlock(ms.tree); if (mas_is_err(&ms)) return xa_err(ms.node); @@ -788,13 +788,13 @@ int mtree_destroy(struct maple_tree *mt) { MAP_STATE(ms, mt, 0, 0); - spin_lock(&mt->lock); + mtree_lock(mt); if (xa_is_node(mt->root)) { ms.node = ma_to_node(mt->root); _maple_destroy_walk(&ms); } mt->root = NULL; - spin_unlock(&mt->lock); + mtree_unlock(mt); return 0; }