On Wed, Mar 28, 2018 at 08:54:41AM +1100, NeilBrown wrote: > > Possibly. > I particularly want the interface to require that you pass the > previously returned object to _continue. That makes it easy to see that > the object is still being used. If someone changes to code to delete > the object before the _continue, there should be a strong hint that it > won't work. > > Maybe it would be better to make it a WARN_ON() > > if (!obj || WARN_ON(iter->p != obj)) > iter->p = NULL;
This doesn't really protect against the case where obj is removed. All it proves is that the user saved a copy of obj which we already did anyway. To detect an actual removal you'd need to traverse the list. I have another idea: we could save insert the walkers into the hash table chain at the end, essentially as a hidden list. We can mark it with a flag like rht_marker so that normal traversal doesn't see it. That way the removal code can simply traverse that list and inform them that the iterator is invalid. Cheers, -- Email: Herbert Xu <herb...@gondor.apana.org.au> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt