[lkml]   [2018]   [Mar]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH 4/6] rhashtable: allow a walk of the hash table without missing objects.
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.

Email: Herbert Xu <>
Home Page:
PGP Key:

 \ /
  Last update: 2018-03-28 08:08    [W:0.065 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site