aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/radix-tree.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/radix-tree.h')
-rw-r--r--include/linux/radix-tree.h22
1 files changed, 19 insertions, 3 deletions
diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h
index 7c88ad156a29..f54be7082207 100644
--- a/include/linux/radix-tree.h
+++ b/include/linux/radix-tree.h
@@ -379,12 +379,28 @@ void **radix_tree_next_chunk(struct radix_tree_root *root,
379 struct radix_tree_iter *iter, unsigned flags); 379 struct radix_tree_iter *iter, unsigned flags);
380 380
381/** 381/**
382 * radix_tree_iter_retry - retry this chunk of the iteration
383 * @iter: iterator state
384 *
385 * If we iterate over a tree protected only by the RCU lock, a race
386 * against deletion or creation may result in seeing a slot for which
387 * radix_tree_deref_retry() returns true. If so, call this function
388 * and continue the iteration.
389 */
390static inline __must_check
391void **radix_tree_iter_retry(struct radix_tree_iter *iter)
392{
393 iter->next_index = iter->index;
394 return NULL;
395}
396
397/**
382 * radix_tree_chunk_size - get current chunk size 398 * radix_tree_chunk_size - get current chunk size
383 * 399 *
384 * @iter: pointer to radix tree iterator 400 * @iter: pointer to radix tree iterator
385 * Returns: current chunk size 401 * Returns: current chunk size
386 */ 402 */
387static __always_inline unsigned 403static __always_inline long
388radix_tree_chunk_size(struct radix_tree_iter *iter) 404radix_tree_chunk_size(struct radix_tree_iter *iter)
389{ 405{
390 return iter->next_index - iter->index; 406 return iter->next_index - iter->index;
@@ -418,9 +434,9 @@ radix_tree_next_slot(void **slot, struct radix_tree_iter *iter, unsigned flags)
418 return slot + offset + 1; 434 return slot + offset + 1;
419 } 435 }
420 } else { 436 } else {
421 unsigned size = radix_tree_chunk_size(iter) - 1; 437 long size = radix_tree_chunk_size(iter);
422 438
423 while (size--) { 439 while (--size > 0) {
424 slot++; 440 slot++;
425 iter->index++; 441 iter->index++;
426 if (likely(*slot)) 442 if (likely(*slot))