]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Introduce maple_lock & maple_unlock
authorMatthew Wilcox <willy@infradead.org>
Wed, 5 Dec 2018 20:42:35 +0000 (15:42 -0500)
committerMatthew Wilcox <willy@infradead.org>
Sat, 8 Dec 2018 10:39:47 +0000 (05:39 -0500)
These are wrappers for spin_lock, just like the XArray.

Signed-off-by: Matthew Wilcox <willy@infradead.org>
include/linux/maple_tree.h
lib/maple_tree.c

index 00892c978e37926e0a2d7863cd437f7917e1bbcd..d42cb5da74be9f095aa7caca9e372864722adee4 100644 (file)
@@ -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);
index e64bdaf61baa1bd45ef22d3ccdb7807944d37e88..6fd0ee8d3ef66af7d10992d6aac27f0f38083112 100644 (file)
@@ -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;
 }