@@ -1337,15 +1337,18 @@ static inline void radix_tree_shrink(struct radix_tree_root *root)
1337
1337
}
1338
1338
1339
1339
/**
1340
- * radix_tree_delete - delete an item from a radix tree
1340
+ * radix_tree_delete_item - delete an item from a radix tree
1341
1341
* @root: radix tree root
1342
1342
* @index: index key
1343
+ * @item: expected item
1343
1344
*
1344
- * Remove the item at @index from the radix tree rooted at @root.
1345
+ * Remove @ item at @index from the radix tree rooted at @root.
1345
1346
*
1346
- * Returns the address of the deleted item, or NULL if it was not present.
1347
+ * Returns the address of the deleted item, or NULL if it was not present
1348
+ * or the entry at the given @index was not @item.
1347
1349
*/
1348
- void * radix_tree_delete (struct radix_tree_root * root , unsigned long index )
1350
+ void * radix_tree_delete_item (struct radix_tree_root * root ,
1351
+ unsigned long index , void * item )
1349
1352
{
1350
1353
struct radix_tree_node * node = NULL ;
1351
1354
struct radix_tree_node * slot = NULL ;
@@ -1380,6 +1383,11 @@ void *radix_tree_delete(struct radix_tree_root *root, unsigned long index)
1380
1383
if (slot == NULL )
1381
1384
goto out ;
1382
1385
1386
+ if (item && slot != item ) {
1387
+ slot = NULL ;
1388
+ goto out ;
1389
+ }
1390
+
1383
1391
/*
1384
1392
* Clear all tags associated with the item to be deleted.
1385
1393
* This way of doing it would be inefficient, but seldom is any set.
@@ -1424,6 +1432,21 @@ void *radix_tree_delete(struct radix_tree_root *root, unsigned long index)
1424
1432
out :
1425
1433
return slot ;
1426
1434
}
1435
+ EXPORT_SYMBOL (radix_tree_delete_item );
1436
+
1437
+ /**
1438
+ * radix_tree_delete - delete an item from a radix tree
1439
+ * @root: radix tree root
1440
+ * @index: index key
1441
+ *
1442
+ * Remove the item at @index from the radix tree rooted at @root.
1443
+ *
1444
+ * Returns the address of the deleted item, or NULL if it was not present.
1445
+ */
1446
+ void * radix_tree_delete (struct radix_tree_root * root , unsigned long index )
1447
+ {
1448
+ return radix_tree_delete_item (root , index , NULL );
1449
+ }
1427
1450
EXPORT_SYMBOL (radix_tree_delete );
1428
1451
1429
1452
/**
0 commit comments