aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/xarray.h
diff options
context:
space:
mode:
authorMatthew Wilcox <willy@infradead.org>2017-11-09 09:23:56 -0500
committerMatthew Wilcox <willy@infradead.org>2018-10-21 10:45:56 -0400
commit01959dfe771c6893365482ec78dc1d9cbbbe6de8 (patch)
tree6d6a47f561798ae0ec49c44c55e2334068c97c14 /include/linux/xarray.h
parentf8d5d0cc145cc21bfc56ef807dc28102aebbf228 (diff)
xarray: Define struct xa_node
This is a direct replacement for struct radix_tree_node. A couple of struct members have changed name, so convert those. Use a #define so that radix tree users continue to work without change. Signed-off-by: Matthew Wilcox <willy@infradead.org> Reviewed-by: Josef Bacik <jbacik@fb.com>
Diffstat (limited to 'include/linux/xarray.h')
-rw-r--r--include/linux/xarray.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/include/linux/xarray.h b/include/linux/xarray.h
index 9122cf8bf52a..52141dfc5a90 100644
--- a/include/linux/xarray.h
+++ b/include/linux/xarray.h
@@ -252,6 +252,33 @@ static inline void xa_init(struct xarray *xa)
252#endif 252#endif
253#define XA_CHUNK_SIZE (1UL << XA_CHUNK_SHIFT) 253#define XA_CHUNK_SIZE (1UL << XA_CHUNK_SHIFT)
254#define XA_CHUNK_MASK (XA_CHUNK_SIZE - 1) 254#define XA_CHUNK_MASK (XA_CHUNK_SIZE - 1)
255#define XA_MAX_MARKS 3
256#define XA_MARK_LONGS DIV_ROUND_UP(XA_CHUNK_SIZE, BITS_PER_LONG)
257
258/*
259 * @count is the count of every non-NULL element in the ->slots array
260 * whether that is a value entry, a retry entry, a user pointer,
261 * a sibling entry or a pointer to the next level of the tree.
262 * @nr_values is the count of every element in ->slots which is
263 * either a value entry or a sibling of a value entry.
264 */
265struct xa_node {
266 unsigned char shift; /* Bits remaining in each slot */
267 unsigned char offset; /* Slot offset in parent */
268 unsigned char count; /* Total entry count */
269 unsigned char nr_values; /* Value entry count */
270 struct xa_node __rcu *parent; /* NULL at top of tree */
271 struct xarray *array; /* The array we belong to */
272 union {
273 struct list_head private_list; /* For tree user */
274 struct rcu_head rcu_head; /* Used when freeing node */
275 };
276 void __rcu *slots[XA_CHUNK_SIZE];
277 union {
278 unsigned long tags[XA_MAX_MARKS][XA_MARK_LONGS];
279 unsigned long marks[XA_MAX_MARKS][XA_MARK_LONGS];
280 };
281};
255 282
256/* Private */ 283/* Private */
257static inline bool xa_is_node(const void *entry) 284static inline bool xa_is_node(const void *entry)