File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -1580,6 +1580,24 @@ static inline void xas_set(struct xa_state *xas, unsigned long index)
15801580 xas -> xa_node = XAS_RESTART ;
15811581}
15821582
1583+ /**
1584+ * xas_advance() - Skip over sibling entries.
1585+ * @xas: XArray operation state.
1586+ * @index: Index of last sibling entry.
1587+ *
1588+ * Move the operation state to refer to the last sibling entry.
1589+ * This is useful for loops that normally want to see sibling
1590+ * entries but sometimes want to skip them. Use xas_set() if you
1591+ * want to move to an index which is not part of this entry.
1592+ */
1593+ static inline void xas_advance (struct xa_state * xas , unsigned long index )
1594+ {
1595+ unsigned char shift = xas_is_node (xas ) ? xas -> xa_node -> shift : 0 ;
1596+
1597+ xas -> xa_index = index ;
1598+ xas -> xa_offset = (index >> shift ) & XA_CHUNK_MASK ;
1599+ }
1600+
15831601/**
15841602 * xas_set_order() - Set up XArray operation state for a multislot entry.
15851603 * @xas: XArray operation state.
Original file line number Diff line number Diff line change @@ -157,7 +157,7 @@ static void xas_move_index(struct xa_state *xas, unsigned long offset)
157157 xas -> xa_index += offset << shift ;
158158}
159159
160- static void xas_advance (struct xa_state * xas )
160+ static void xas_next_offset (struct xa_state * xas )
161161{
162162 xas -> xa_offset ++ ;
163163 xas_move_index (xas , xas -> xa_offset );
@@ -1250,7 +1250,7 @@ void *xas_find(struct xa_state *xas, unsigned long max)
12501250 xas -> xa_offset = ((xas -> xa_index - 1 ) & XA_CHUNK_MASK ) + 1 ;
12511251 }
12521252
1253- xas_advance (xas );
1253+ xas_next_offset (xas );
12541254
12551255 while (xas -> xa_node && (xas -> xa_index <= max )) {
12561256 if (unlikely (xas -> xa_offset == XA_CHUNK_SIZE )) {
@@ -1268,7 +1268,7 @@ void *xas_find(struct xa_state *xas, unsigned long max)
12681268 if (entry && !xa_is_sibling (entry ))
12691269 return entry ;
12701270
1271- xas_advance (xas );
1271+ xas_next_offset (xas );
12721272 }
12731273
12741274 if (!xas -> xa_node )
You can’t perform that action at this time.
0 commit comments