From: Herbert Xu <herbert@gondor.apana.org.au>
To: "David S. Miller" <davem@davemloft.net>,
Thomas Graf <tgraf@suug.ch>,
netdev@vger.kernel.org
Subject: [PATCH 1/3] gfs2: Use rhashtable walk interface in glock_hash_walk
Date: Tue, 07 Feb 2017 20:39:43 +0800 [thread overview]
Message-ID: <E1cb53f-0003pl-HF@gondobar> (raw)
In-Reply-To: 20170207123827.GA14678@gondor.apana.org.au
The function glock_hash_walk walks the rhashtable by hand. This
is broken because if it catches the hash table in the middle of
a rehash, then it will miss entries.
This patch replaces the manual walk by using the rhashtable walk
interface.
Fixes: 88ffbf3e037e ("GFS2: Use resizable hash table for glocks")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---
fs/gfs2/glock.c | 28 +++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index 94f50ca..70e9417 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -1420,26 +1420,32 @@ static unsigned long gfs2_glock_shrink_count(struct shrinker *shrink,
* @sdp: the filesystem
* @bucket: the bucket
*
+ * Note that the function can be called multiple times on the same
+ * object. So the user must ensure that the function can cope with
+ * that.
*/
static void glock_hash_walk(glock_examiner examiner, const struct gfs2_sbd *sdp)
{
struct gfs2_glock *gl;
- struct rhash_head *pos;
- const struct bucket_table *tbl;
- int i;
+ struct rhashtable_iter iter;
- rcu_read_lock();
- tbl = rht_dereference_rcu(gl_hash_table.tbl, &gl_hash_table);
- for (i = 0; i < tbl->size; i++) {
- rht_for_each_entry_rcu(gl, pos, tbl, i, gl_node) {
+ rhashtable_walk_enter(&gl_hash_table, &iter);
+
+ do {
+ gl = ERR_PTR(rhashtable_walk_start(&iter));
+ if (gl)
+ continue;
+
+ while ((gl = rhashtable_walk_next(&iter)) && !IS_ERR(gl))
if ((gl->gl_name.ln_sbd == sdp) &&
lockref_get_not_dead(&gl->gl_lockref))
examiner(gl);
- }
- }
- rcu_read_unlock();
- cond_resched();
+
+ rhashtable_walk_stop(&iter);
+ } while (cond_resched(), gl == ERR_PTR(-EAGAIN));
+
+ rhashtable_walk_exit(&iter);
}
/**
next prev parent reply other threads:[~2017-02-07 12:39 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-07 12:38 [PATCH 0/3] rhashtable: Handle table allocation failure during insertion Herbert Xu
2017-02-07 12:39 ` Herbert Xu [this message]
2017-02-07 12:39 ` [PATCH 2/3] tipc: Fix tipc_sk_reinit race conditions Herbert Xu
2017-02-10 10:53 ` Ying Xue
2017-02-07 12:39 ` [PATCH 3/3] rhashtable: Add nested tables Herbert Xu
2017-02-07 13:17 ` Florian Westphal
2017-02-07 13:29 ` Herbert Xu
2017-02-07 18:02 ` Florian Westphal
2017-02-08 1:09 ` Herbert Xu
2017-02-09 2:12 ` [lkp-robot] [rhashtable] 60be2ebf32: INFO:suspicious_RCU_usage kernel test robot
2017-02-08 18:26 ` [PATCH 0/3] rhashtable: Handle table allocation failure during insertion David Miller
2017-02-11 11:22 ` Herbert Xu
2017-02-11 11:24 ` [v2 PATCH " Herbert Xu
2017-02-11 11:26 ` [v2 PATCH 1/3] gfs2: Use rhashtable walk interface in glock_hash_walk Herbert Xu
2017-02-11 11:26 ` [v2 PATCH 2/3] tipc: Fix tipc_sk_reinit race conditions Herbert Xu
2017-02-11 11:26 ` [v2 PATCH 3/3] rhashtable: Add nested tables Herbert Xu
2017-02-14 3:18 ` [v2 PATCH 0/3] rhashtable: Handle table allocation failure during insertion David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1cb53f-0003pl-HF@gondobar \
--to=herbert@gondor.apana.org.au \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=tgraf@suug.ch \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).