* [PATCH 2/3] rhashtable: Add rhashtable_walk_curr [not found] <20171218133122.29179-1-agruenba@redhat.com> @ 2017-12-18 13:31 ` Andreas Gruenbacher 2017-12-18 23:38 ` Herbert Xu 0 siblings, 1 reply; 4+ messages in thread From: Andreas Gruenbacher @ 2017-12-18 13:31 UTC (permalink / raw) To: cluster-devel, Thomas Graf, Herbert Xu, netdev; +Cc: Andreas Gruenbacher When iterating through an rhashtable is stopped with rhashtable_walk_stop and then resumed with rhashtable_walk_start, there currently is no way to get back to the current object and thus revisit the object rhashtable_walk_next has previously returned. This functionality is useful when dumping an rhashtable via the seq file interface: seq_read will convert one object after the other. When an object doesn't fit in the remaining buffer space anymore, user-space will be returned all objects that have been fully converted so far. Upon the next read from user-space, the object that didn't fit previously will be revisited. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> --- include/linux/rhashtable.h | 1 + lib/rhashtable.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/linux/rhashtable.h b/include/linux/rhashtable.h index 361c08e35dbc..1a1608bc5405 100644 --- a/include/linux/rhashtable.h +++ b/include/linux/rhashtable.h @@ -380,6 +380,7 @@ void rhashtable_walk_enter(struct rhashtable *ht, void rhashtable_walk_exit(struct rhashtable_iter *iter); int rhashtable_walk_start(struct rhashtable_iter *iter) __acquires(RCU); void *rhashtable_walk_next(struct rhashtable_iter *iter); +void *rhashtable_walk_curr(struct rhashtable_iter *iter); void rhashtable_walk_stop(struct rhashtable_iter *iter) __releases(RCU); void rhashtable_free_and_destroy(struct rhashtable *ht, diff --git a/lib/rhashtable.c b/lib/rhashtable.c index ddd7dde87c3c..1d45a4274b7a 100644 --- a/lib/rhashtable.c +++ b/lib/rhashtable.c @@ -842,6 +842,23 @@ void *rhashtable_walk_next(struct rhashtable_iter *iter) } EXPORT_SYMBOL_GPL(rhashtable_walk_next); +/** + * rhashtable_walk_next - Return the current object + * @iter: Hash table iterator + * + * Returns the object previously returned by rhashtable_walk_next. + * + * Returns -ENOENT if rhashtable_walk_next hasn't been called previously. + */ +void *rhashtable_walk_curr(struct rhashtable_iter *iter) +{ + if (!iter->skip) + return ERR_PTR(-ENOENT); + iter->skip--; + return rhashtable_walk_next(iter); +} +EXPORT_SYMBOL_GPL(rhashtable_walk_curr); + /** * rhashtable_walk_stop - Finish a hash table walk * @iter: Hash table iterator -- 2.14.3 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/3] rhashtable: Add rhashtable_walk_curr 2017-12-18 13:31 ` [PATCH 2/3] rhashtable: Add rhashtable_walk_curr Andreas Gruenbacher @ 2017-12-18 23:38 ` Herbert Xu 2017-12-19 8:35 ` Andreas Gruenbacher 0 siblings, 1 reply; 4+ messages in thread From: Herbert Xu @ 2017-12-18 23:38 UTC (permalink / raw) To: Andreas Gruenbacher; +Cc: cluster-devel, Thomas Graf, netdev On Mon, Dec 18, 2017 at 02:31:21PM +0100, Andreas Gruenbacher wrote: > When iterating through an rhashtable is stopped with > rhashtable_walk_stop and then resumed with rhashtable_walk_start, there > currently is no way to get back to the current object and thus revisit > the object rhashtable_walk_next has previously returned. > > This functionality is useful when dumping an rhashtable via the seq file > interface: seq_read will convert one object after the other. When an > object doesn't fit in the remaining buffer space anymore, user-space > will be returned all objects that have been fully converted so far. > Upon the next read from user-space, the object that didn't fit > previously will be revisited. > > Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> Doesn't the helper that Tom Herbert just added do exactly this? Thanks, -- Email: Herbert Xu <herbert@gondor.apana.org.au> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/3] rhashtable: Add rhashtable_walk_curr 2017-12-18 23:38 ` Herbert Xu @ 2017-12-19 8:35 ` Andreas Gruenbacher 2017-12-19 14:35 ` David Miller 0 siblings, 1 reply; 4+ messages in thread From: Andreas Gruenbacher @ 2017-12-19 8:35 UTC (permalink / raw) To: Herbert Xu; +Cc: cluster-devel, Thomas Graf, netdev, Tom Herbert On 19 December 2017 at 00:38, Herbert Xu <herbert@gondor.apana.org.au> wrote: > On Mon, Dec 18, 2017 at 02:31:21PM +0100, Andreas Gruenbacher wrote: >> When iterating through an rhashtable is stopped with >> rhashtable_walk_stop and then resumed with rhashtable_walk_start, there >> currently is no way to get back to the current object and thus revisit >> the object rhashtable_walk_next has previously returned. >> >> This functionality is useful when dumping an rhashtable via the seq file >> interface: seq_read will convert one object after the other. When an >> object doesn't fit in the remaining buffer space anymore, user-space >> will be returned all objects that have been fully converted so far. >> Upon the next read from user-space, the object that didn't fit >> previously will be revisited. >> >> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> > > Doesn't the helper that Tom Herbert just added do exactly this? Ah, I've missed that; rhastable_walk_peek apparently does what we need here. By the way, git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git master doesn't merge cleanly with current mainline. Thanks, Andreas ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/3] rhashtable: Add rhashtable_walk_curr 2017-12-19 8:35 ` Andreas Gruenbacher @ 2017-12-19 14:35 ` David Miller 0 siblings, 0 replies; 4+ messages in thread From: David Miller @ 2017-12-19 14:35 UTC (permalink / raw) To: agruenba; +Cc: herbert, cluster-devel, tgraf, netdev, tom From: Andreas Gruenbacher <agruenba@redhat.com> Date: Tue, 19 Dec 2017 09:35:47 +0100 > By the way, git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git > master doesn't merge cleanly with current mainline. Yes, this is the case more often than not :-) ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-12-19 14:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20171218133122.29179-1-agruenba@redhat.com>
2017-12-18 13:31 ` [PATCH 2/3] rhashtable: Add rhashtable_walk_curr Andreas Gruenbacher
2017-12-18 23:38 ` Herbert Xu
2017-12-19 8:35 ` Andreas Gruenbacher
2017-12-19 14:35 ` David Miller
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox