Lines Matching defs:xas
1362 * We encode errnos in the xas->xa_node. If an error has happened, we need to
1384 * @name: Name of this operation state (usually xas).
1395 * @name: Name of this operation state (usually xas).
1410 #define xas_marked(xas, mark) xa_marked((xas)->xa, (mark))
1411 #define xas_trylock(xas) xa_trylock((xas)->xa)
1412 #define xas_lock(xas) xa_lock((xas)->xa)
1413 #define xas_unlock(xas) xa_unlock((xas)->xa)
1414 #define xas_lock_bh(xas) xa_lock_bh((xas)->xa)
1415 #define xas_unlock_bh(xas) xa_unlock_bh((xas)->xa)
1416 #define xas_lock_irq(xas) xa_lock_irq((xas)->xa)
1417 #define xas_unlock_irq(xas) xa_unlock_irq((xas)->xa)
1418 #define xas_lock_irqsave(xas, flags) \
1419 xa_lock_irqsave((xas)->xa, flags)
1420 #define xas_unlock_irqrestore(xas, flags) \
1421 xa_unlock_irqrestore((xas)->xa, flags)
1425 * @xas: XArray operation state.
1429 static inline int xas_error(const struct xa_state *xas)
1431 return xa_err(xas->xa_node);
1436 * @xas: XArray operation state.
1443 static inline void xas_set_err(struct xa_state *xas, long err)
1445 xas->xa_node = XA_ERROR(err);
1449 * xas_invalid() - Is the xas in a retry or error state?
1450 * @xas: XArray operation state.
1452 * Return: %true if the xas cannot be used for operations.
1454 static inline bool xas_invalid(const struct xa_state *xas)
1456 return (unsigned long)xas->xa_node & 3;
1460 * xas_valid() - Is the xas a valid cursor into the array?
1461 * @xas: XArray operation state.
1463 * Return: %true if the xas can be used for operations.
1465 static inline bool xas_valid(const struct xa_state *xas)
1467 return !xas_invalid(xas);
1471 * xas_is_node() - Does the xas point to a node?
1472 * @xas: XArray operation state.
1474 * Return: %true if the xas currently references a node.
1476 static inline bool xas_is_node(const struct xa_state *xas)
1478 return xas_valid(xas) && xas->xa_node;
1501 * @xas: XArray operation state.
1503 * Resets the error or walk state of the @xas so future walks of the
1509 static inline void xas_reset(struct xa_state *xas)
1511 xas->xa_node = XAS_RESTART;
1516 * @xas: XArray operation state.
1520 * a retry entry or a zero entry. This function sets up the @xas to restart
1526 static inline bool xas_retry(struct xa_state *xas, const void *entry)
1532 xas_reset(xas);
1555 int xas_get_order(struct xa_state *xas);
1564 static inline int xas_get_order(struct xa_state *xas)
1569 static inline void xas_split(struct xa_state *xas, void *entry,
1572 xas_store(xas, entry);
1575 static inline void xas_split_alloc(struct xa_state *xas, void *entry,
1583 * @xas: XArray operation state.
1590 * The caller guarantees that @xas is still valid. If it may be in an
1595 static inline void *xas_reload(struct xa_state *xas)
1597 struct xa_node *node = xas->xa_node;
1602 return xa_head(xas->xa);
1604 offset = (xas->xa_index >> node->shift) & XA_CHUNK_MASK;
1605 entry = xa_entry(xas->xa, node, offset);
1610 offset = xas->xa_offset;
1612 return xa_entry(xas->xa, node, offset);
1617 * @xas: XArray operation state.
1624 static inline void xas_set(struct xa_state *xas, unsigned long index)
1626 xas->xa_index = index;
1627 xas->xa_node = XAS_RESTART;
1632 * @xas: XArray operation state.
1640 static inline void xas_advance(struct xa_state *xas, unsigned long index)
1642 unsigned char shift = xas_is_node(xas) ? xas->xa_node->shift : 0;
1644 xas->xa_index = index;
1645 xas->xa_offset = (index >> shift) & XA_CHUNK_MASK;
1650 * @xas: XArray operation state.
1654 static inline void xas_set_order(struct xa_state *xas, unsigned long index,
1658 xas->xa_index = order < BITS_PER_LONG ? (index >> order) << order : 0;
1659 xas->xa_shift = order - (order % XA_CHUNK_SHIFT);
1660 xas->xa_sibs = (1 << (order % XA_CHUNK_SHIFT)) - 1;
1661 xas->xa_node = XAS_RESTART;
1664 xas_set(xas, index);
1670 * @xas: XArray operation state.
1677 static inline void xas_set_update(struct xa_state *xas, xa_update_node_t update)
1679 xas->xa_update = update;
1682 static inline void xas_set_lru(struct xa_state *xas, struct list_lru *lru)
1684 xas->xa_lru = lru;
1689 * @xas: XArray operation state.
1696 * Return: The next present entry after the one currently referred to by @xas.
1698 static inline void *xas_next_entry(struct xa_state *xas, unsigned long max)
1700 struct xa_node *node = xas->xa_node;
1704 xas->xa_offset != (xas->xa_index & XA_CHUNK_MASK)))
1705 return xas_find(xas, max);
1708 if (unlikely(xas->xa_index >= max))
1709 return xas_find(xas, max);
1710 if (unlikely(xas->xa_offset == XA_CHUNK_MASK))
1711 return xas_find(xas, max);
1712 entry = xa_entry(xas->xa, node, xas->xa_offset + 1);
1714 return xas_find(xas, max);
1715 xas->xa_offset++;
1716 xas->xa_index++;
1723 static inline unsigned int xas_find_chunk(struct xa_state *xas, bool advance,
1726 unsigned long *addr = xas->xa_node->marks[(__force unsigned)mark];
1727 unsigned int offset = xas->xa_offset;
1745 * @xas: XArray operation state.
1753 * Return: The next marked entry after the one currently referred to by @xas.
1755 static inline void *xas_next_marked(struct xa_state *xas, unsigned long max,
1758 struct xa_node *node = xas->xa_node;
1763 return xas_find_marked(xas, max, mark);
1764 offset = xas_find_chunk(xas, true, mark);
1765 xas->xa_offset = offset;
1766 xas->xa_index = (xas->xa_index & ~XA_CHUNK_MASK) + offset;
1767 if (xas->xa_index > max)
1770 return xas_find_marked(xas, max, mark);
1771 entry = xa_entry(xas->xa, node, offset);
1773 return xas_find_marked(xas, max, mark);
1787 * @xas: XArray operation state.
1792 * between the current xas position and @max. @entry will be set to
1798 #define xas_for_each(xas, entry, max) \
1799 for (entry = xas_find(xas, max); entry; \
1800 entry = xas_next_entry(xas, max))
1804 * @xas: XArray operation state.
1810 * between the current xas position and @max. @entry will be set to
1816 #define xas_for_each_marked(xas, entry, max, mark) \
1817 for (entry = xas_find_marked(xas, max, mark); entry; \
1818 entry = xas_next_marked(xas, max, mark))
1822 * @xas: XArray operation state.
1826 * lies within the range specified by @xas. If the loop terminates
1832 #define xas_for_each_conflict(xas, entry) \
1833 while ((entry = xas_find_conflict(xas)))
1840 * @xas: XArray operation state.
1842 * If the @xas was in an error state, it will remain in an error state
1843 * and this function will return %NULL. If the @xas has never been walked,
1854 static inline void *xas_prev(struct xa_state *xas)
1856 struct xa_node *node = xas->xa_node;
1859 xas->xa_offset == 0))
1860 return __xas_prev(xas);
1862 xas->xa_index--;
1863 xas->xa_offset--;
1864 return xa_entry(xas->xa, node, xas->xa_offset);
1869 * @xas: XArray operation state.
1871 * If the @xas was in an error state, it will remain in an error state
1872 * and this function will return %NULL. If the @xas has never been walked,
1883 static inline void *xas_next(struct xa_state *xas)
1885 struct xa_node *node = xas->xa_node;
1888 xas->xa_offset == XA_CHUNK_MASK))
1889 return __xas_next(xas);
1891 xas->xa_index++;
1892 xas->xa_offset++;
1893 return xa_entry(xas->xa, node, xas->xa_offset);