File tree 2 files changed +21
-3
lines changed
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)
1580
1580
xas -> xa_node = XAS_RESTART ;
1581
1581
}
1582
1582
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
+
1583
1601
/**
1584
1602
* xas_set_order() - Set up XArray operation state for a multislot entry.
1585
1603
* @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)
157
157
xas -> xa_index += offset << shift ;
158
158
}
159
159
160
- static void xas_advance (struct xa_state * xas )
160
+ static void xas_next_offset (struct xa_state * xas )
161
161
{
162
162
xas -> xa_offset ++ ;
163
163
xas_move_index (xas , xas -> xa_offset );
@@ -1250,7 +1250,7 @@ void *xas_find(struct xa_state *xas, unsigned long max)
1250
1250
xas -> xa_offset = ((xas -> xa_index - 1 ) & XA_CHUNK_MASK ) + 1 ;
1251
1251
}
1252
1252
1253
- xas_advance (xas );
1253
+ xas_next_offset (xas );
1254
1254
1255
1255
while (xas -> xa_node && (xas -> xa_index <= max )) {
1256
1256
if (unlikely (xas -> xa_offset == XA_CHUNK_SIZE )) {
@@ -1268,7 +1268,7 @@ void *xas_find(struct xa_state *xas, unsigned long max)
1268
1268
if (entry && !xa_is_sibling (entry ))
1269
1269
return entry ;
1270
1270
1271
- xas_advance (xas );
1271
+ xas_next_offset (xas );
1272
1272
}
1273
1273
1274
1274
if (!xas -> xa_node )
You can’t perform that action at this time.
0 commit comments