[lustre-devel] [PATCH 33/49] lustre: quota: call rhashtable_lookup near params decl

James Simmons jsimmons at infradead.org
Wed Apr 14 21:02:25 PDT 2021


From: Mr NeilBrown <neilb at suse.de>

rhashtable_lookup() is an inline function which depends - for
performancs - on the 'rhashtable_params' being visible and
consnt.  So it should only be called in the same file that
declared the params.

recent patch make pools_hash_params an external variable and calls
rhashtable_lookup from a separate file, which will break the
optimisation.

So add lov_pool_find() and use it to maintainer optimization.

WC-bug-id: https://jira.whamcloud.com/browse/LU-13359
Fixes: 226a0a32c6b3 ("lustre: quota: make used for pool correct")
Lustre-commit: 1d116c8ff68fc784 ("LU-13359 quota: call rhashtable_lookup near params decl")
Signed-off-by: Mr NeilBrown <neilb at suse.de>
Reviewed-on: https://review.whamcloud.com/39676
Reviewed-by: James Simmons <jsimmons at infradead.org>
Reviewed-by: Sergey Cheremencev <sergey.cheremencev at hpe.com>
Reviewed-by: Petros Koutoupis <petros.koutoupis at hpe.com>
Reviewed-by: Oleg Drokin <green at whamcloud.com>
Signed-off-by: James Simmons <jsimmons at infradead.org>
---
 fs/lustre/lov/lov_internal.h |  4 ++--
 fs/lustre/lov/lov_obd.c      |  8 +-------
 fs/lustre/lov/lov_pool.c     | 18 +++++++++++++++++-
 3 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/fs/lustre/lov/lov_internal.h b/fs/lustre/lov/lov_internal.h
index d26e68b..e58235a 100644
--- a/fs/lustre/lov/lov_internal.h
+++ b/fs/lustre/lov/lov_internal.h
@@ -380,6 +380,6 @@ static inline void lov_lsm2layout(struct lov_stripe_md *lsm,
 	}
 }
 
-extern const struct rhashtable_params pools_hash_params;
-extern void lov_pool_putref(struct pool_desc *pool);
+struct pool_desc *lov_pool_find(struct obd_device *obd, char *poolname);
+void lov_pool_putref(struct pool_desc *pool);
 #endif
diff --git a/fs/lustre/lov/lov_obd.c b/fs/lustre/lov/lov_obd.c
index 95fcd57..29b0645 100644
--- a/fs/lustre/lov/lov_obd.c
+++ b/fs/lustre/lov/lov_obd.c
@@ -1235,13 +1235,7 @@ static int lov_quotactl(struct obd_device *obd, struct obd_export *exp,
 	}
 
 	if (oqctl->qc_cmd == LUSTRE_Q_GETQUOTAPOOL) {
-		rcu_read_lock();
-		pool = rhashtable_lookup(&lov->lov_pools_hash_body,
-					 oqctl->qc_poolname,
-					 pools_hash_params);
-		if (pool && !atomic_inc_not_zero(&pool->pool_refcount))
-			pool = NULL;
-		rcu_read_unlock();
+		pool = lov_pool_find(obd, oqctl->qc_poolname);
 		if (!pool)
 			return -ENOENT;
 		/* Set Q_GETOQUOTA back as targets report it's own
diff --git a/fs/lustre/lov/lov_pool.c b/fs/lustre/lov/lov_pool.c
index de8aed9..8fbc6ee 100644
--- a/fs/lustre/lov/lov_pool.c
+++ b/fs/lustre/lov/lov_pool.c
@@ -63,7 +63,7 @@ static int pool_cmpfn(struct rhashtable_compare_arg *arg, const void *obj)
 	return strcmp(pool_name, pool->pool_name);
 }
 
-const struct rhashtable_params pools_hash_params = {
+static const struct rhashtable_params pools_hash_params = {
 	.key_len	= 1, /* actually variable */
 	.key_offset	= offsetof(struct pool_desc, pool_name),
 	.head_offset	= offsetof(struct pool_desc, pool_hash),
@@ -317,6 +317,22 @@ int lov_pool_new(struct obd_device *obd, char *poolname)
 	return rc;
 }
 
+struct pool_desc *lov_pool_find(struct obd_device *obd, char *poolname)
+{
+	struct pool_desc *pool;
+	struct lov_obd *lov = &obd->u.lov;
+
+	rcu_read_lock();
+	pool = rhashtable_lookup(&lov->lov_pools_hash_body,
+				 poolname,
+				 pools_hash_params);
+	if (pool && !atomic_inc_not_zero(&pool->pool_refcount))
+		pool = NULL;
+	rcu_read_unlock();
+
+	return pool;
+}
+
 int lov_pool_del(struct obd_device *obd, char *poolname)
 {
 	struct lov_obd *lov;
-- 
1.8.3.1



More information about the lustre-devel mailing list