From 1d116c8ff68fc784141b647b790e4b4861460797 Mon Sep 17 00:00:00 2001 From: Mr NeilBrown Date: Fri, 14 Aug 2020 14:02:20 +1000 Subject: [PATCH] LU-13359 quota: call rhashtable_lookup near params decl 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. A 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. Fixes: 6b9f849fd5f4 ("LU-13359 quota: make used for pool correct") Signed-off-by: Mr NeilBrown Change-Id: Ieeb3b080491f5b2c9c825885fe7a42f4a8599a2a Reviewed-on: https://review.whamcloud.com/39676 Reviewed-by: James Simmons Reviewed-by: Sergey Cheremencev Reviewed-by: Petros Koutoupis Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/lov/lov_internal.h | 4 ++-- lustre/lov/lov_obd.c | 8 +------- lustre/lov/lov_pool.c | 18 +++++++++++++++++- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/lustre/lov/lov_internal.h b/lustre/lov/lov_internal.h index 1a89d3f..62e4d0f 100644 --- a/lustre/lov/lov_internal.h +++ b/lustre/lov/lov_internal.h @@ -389,6 +389,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/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index 317bd2b..c8efb94 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -1282,13 +1282,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/lustre/lov/lov_pool.c b/lustre/lov/lov_pool.c index ef941ab..f272cfe 100644 --- a/lustre/lov/lov_pool.c +++ b/lustre/lov/lov_pool.c @@ -65,7 +65,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), @@ -458,6 +458,22 @@ out_err: 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