XArray: Add maple tree special entries
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 27 Feb 2020 19:21:54 +0000 (14:21 -0500)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 27 Feb 2020 20:15:46 +0000 (15:15 -0500)
The SKIP entry indicates this slot is not in use.  It should have been
removed, but memory allocation failure prevented a new node from being
allocated.

The DELETED entry indicates that the entry which used to be in this slot
has been set to NULL.  It has been merged with the NULL in an adjacent
slot, but the slot is available for reuse if a store of exactly the same
size & location happens.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
include/linux/xarray.h

index f73e1775ded0171456c7071f471e3e8c28055355..872527d0244da8db5b6e851f7d8b8520fe84102b 100644 (file)
@@ -169,7 +169,7 @@ static inline bool xa_is_internal(const void *entry)
        return ((unsigned long)entry & 3) == 2;
 }
 
-#define XA_ZERO_ENTRY          xa_mk_internal(257)
+#define XA_ZERO_ENTRY          xa_mk_internal(259)
 
 /**
  * xa_is_zero() - Is the entry a zero entry?
@@ -1261,6 +1261,32 @@ static inline bool xa_is_retry(const void *entry)
        return unlikely(entry == XA_RETRY_ENTRY);
 }
 
+#define XA_SKIP_ENTRY           xa_mk_internal(257)
+
+/**
+ * xa_is_skip() - Is the entry a skip entry?
+ * @entry: Entry retrieved from the XArray
+ *
+ * Return: %true if the entry is a skip entry.
+ */
+static inline bool xa_is_skip(const void *entry)
+{
+       return unlikely(entry == XA_SKIP_ENTRY);
+}
+
+#define XA_DELETED_ENTRY           xa_mk_internal(258)
+
+/**
+ * xa_is_deleted() - has the entry been deleted?
+ * @entry: Entry retrieved from the XArray
+ *
+ * Return: %true if the entry has been deleted.
+ */
+static inline bool xa_is_deleted(const void *entry)
+{
+       return unlikely(entry == XA_DELETED_ENTRY);
+}
+
 /**
  * xa_is_advanced() - Is the entry only permitted for the advanced API?
  * @entry: Entry to be stored in the XArray.