Lines Matching defs:xas

1358  * We encode errnos in the xas->xa_node.  If an error has happened, we need to
1380 * @name: Name of this operation state (usually xas).
1391 * @name: Name of this operation state (usually xas).
1406 #define xas_marked(xas, mark) xa_marked((xas)->xa, (mark))
1407 #define xas_trylock(xas) xa_trylock((xas)->xa)
1408 #define xas_lock(xas) xa_lock((xas)->xa)
1409 #define xas_unlock(xas) xa_unlock((xas)->xa)
1410 #define xas_lock_bh(xas) xa_lock_bh((xas)->xa)
1411 #define xas_unlock_bh(xas) xa_unlock_bh((xas)->xa)
1412 #define xas_lock_irq(xas) xa_lock_irq((xas)->xa)
1413 #define xas_unlock_irq(xas) xa_unlock_irq((xas)->xa)
1414 #define xas_lock_irqsave(xas, flags) \
1415 xa_lock_irqsave((xas)->xa, flags)
1416 #define xas_unlock_irqrestore(xas, flags) \
1417 xa_unlock_irqrestore((xas)->xa, flags)
1421 * @xas: XArray operation state.
1425 static inline int xas_error(const struct xa_state *xas)
1427 return xa_err(xas->xa_node);
1432 * @xas: XArray operation state.
1439 static inline void xas_set_err(struct xa_state *xas, long err)
1441 xas->xa_node = XA_ERROR(err);
1445 * xas_invalid() - Is the xas in a retry or error state?
1446 * @xas: XArray operation state.
1448 * Return: %true if the xas cannot be used for operations.
1450 static inline bool xas_invalid(const struct xa_state *xas)
1452 return (unsigned long)xas->xa_node & 3;
1456 * xas_valid() - Is the xas a valid cursor into the array?
1457 * @xas: XArray operation state.
1459 * Return: %true if the xas can be used for operations.
1461 static inline bool xas_valid(const struct xa_state *xas)
1463 return !xas_invalid(xas);
1467 * xas_is_node() - Does the xas point to a node?
1468 * @xas: XArray operation state.
1470 * Return: %true if the xas currently references a node.
1472 static inline bool xas_is_node(const struct xa_state *xas)
1474 return xas_valid(xas) && xas->xa_node;
1497 * @xas: XArray operation state.
1499 * Resets the error or walk state of the @xas so future walks of the
1505 static inline void xas_reset(struct xa_state *xas)
1507 xas->xa_node = XAS_RESTART;
1512 * @xas: XArray operation state.
1516 * a retry entry or a zero entry. This function sets up the @xas to restart
1522 static inline bool xas_retry(struct xa_state *xas, const void *entry)
1528 xas_reset(xas);
1559 static inline void xas_split(struct xa_state *xas, void *entry,
1562 xas_store(xas, entry);
1565 static inline void xas_split_alloc(struct xa_state *xas, void *entry,
1573 * @xas: XArray operation state.
1580 * The caller guarantees that @xas is still valid. If it may be in an
1585 static inline void *xas_reload(struct xa_state *xas)
1587 struct xa_node *node = xas->xa_node;
1592 return xa_head(xas->xa);
1594 offset = (xas->xa_index >> node->shift) & XA_CHUNK_MASK;
1595 entry = xa_entry(xas->xa, node, offset);
1600 offset = xas->xa_offset;
1602 return xa_entry(xas->xa, node, offset);
1607 * @xas: XArray operation state.
1614 static inline void xas_set(struct xa_state *xas, unsigned long index)
1616 xas->xa_index = index;
1617 xas->xa_node = XAS_RESTART;
1622 * @xas: XArray operation state.
1630 static inline void xas_advance(struct xa_state *xas, unsigned long index)
1632 unsigned char shift = xas_is_node(xas) ? xas->xa_node->shift : 0;
1634 xas->xa_index = index;
1635 xas->xa_offset = (index >> shift) & XA_CHUNK_MASK;
1640 * @xas: XArray operation state.
1644 static inline void xas_set_order(struct xa_state *xas, unsigned long index,
1648 xas->xa_index = order < BITS_PER_LONG ? (index >> order) << order : 0;
1649 xas->xa_shift = order - (order % XA_CHUNK_SHIFT);
1650 xas->xa_sibs = (1 << (order % XA_CHUNK_SHIFT)) - 1;
1651 xas->xa_node = XAS_RESTART;
1654 xas_set(xas, index);
1660 * @xas: XArray operation state.
1667 static inline void xas_set_update(struct xa_state *xas, xa_update_node_t update)
1669 xas->xa_update = update;
1672 static inline void xas_set_lru(struct xa_state *xas, struct list_lru *lru)
1674 xas->xa_lru = lru;
1679 * @xas: XArray operation state.
1686 * Return: The next present entry after the one currently referred to by @xas.
1688 static inline void *xas_next_entry(struct xa_state *xas, unsigned long max)
1690 struct xa_node *node = xas->xa_node;
1694 xas->xa_offset != (xas->xa_index & XA_CHUNK_MASK)))
1695 return xas_find(xas, max);
1698 if (unlikely(xas->xa_index >= max))
1699 return xas_find(xas, max);
1700 if (unlikely(xas->xa_offset == XA_CHUNK_MASK))
1701 return xas_find(xas, max);
1702 entry = xa_entry(xas->xa, node, xas->xa_offset + 1);
1704 return xas_find(xas, max);
1705 xas->xa_offset++;
1706 xas->xa_index++;
1713 static inline unsigned int xas_find_chunk(struct xa_state *xas, bool advance,
1716 unsigned long *addr = xas->xa_node->marks[(__force unsigned)mark];
1717 unsigned int offset = xas->xa_offset;
1735 * @xas: XArray operation state.
1743 * Return: The next marked entry after the one currently referred to by @xas.
1745 static inline void *xas_next_marked(struct xa_state *xas, unsigned long max,
1748 struct xa_node *node = xas->xa_node;
1753 return xas_find_marked(xas, max, mark);
1754 offset = xas_find_chunk(xas, true, mark);
1755 xas->xa_offset = offset;
1756 xas->xa_index = (xas->xa_index & ~XA_CHUNK_MASK) + offset;
1757 if (xas->xa_index > max)
1760 return xas_find_marked(xas, max, mark);
1761 entry = xa_entry(xas->xa, node, offset);
1763 return xas_find_marked(xas, max, mark);
1777 * @xas: XArray operation state.
1782 * between the current xas position and @max. @entry will be set to
1788 #define xas_for_each(xas, entry, max) \
1789 for (entry = xas_find(xas, max); entry; \
1790 entry = xas_next_entry(xas, max))
1794 * @xas: XArray operation state.
1800 * between the current xas position and @max. @entry will be set to
1806 #define xas_for_each_marked(xas, entry, max, mark) \
1807 for (entry = xas_find_marked(xas, max, mark); entry; \
1808 entry = xas_next_marked(xas, max, mark))
1812 * @xas: XArray operation state.
1816 * lies within the range specified by @xas. If the loop terminates
1822 #define xas_for_each_conflict(xas, entry) \
1823 while ((entry = xas_find_conflict(xas)))
1830 * @xas: XArray operation state.
1832 * If the @xas was in an error state, it will remain in an error state
1833 * and this function will return %NULL. If the @xas has never been walked,
1844 static inline void *xas_prev(struct xa_state *xas)
1846 struct xa_node *node = xas->xa_node;
1849 xas->xa_offset == 0))
1850 return __xas_prev(xas);
1852 xas->xa_index--;
1853 xas->xa_offset--;
1854 return xa_entry(xas->xa, node, xas->xa_offset);
1859 * @xas: XArray operation state.
1861 * If the @xas was in an error state, it will remain in an error state
1862 * and this function will return %NULL. If the @xas has never been walked,
1873 static inline void *xas_next(struct xa_state *xas)
1875 struct xa_node *node = xas->xa_node;
1878 xas->xa_offset == XA_CHUNK_MASK))
1879 return __xas_next(xas);
1881 xas->xa_index++;
1882 xas->xa_offset++;
1883 return xa_entry(xas->xa, node, xas->xa_offset);