Whamcloud - gitweb
LU-13359 quota: call rhashtable_lookup near params decl 76/39676/3
authorMr NeilBrown <neilb@suse.de>
Fri, 14 Aug 2020 04:02:20 +0000 (14:02 +1000)
committerOleg Drokin <green@whamcloud.com>
Sat, 12 Sep 2020 15:43:56 +0000 (15:43 +0000)
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 <neilb@suse.de>
Change-Id: Ieeb3b080491f5b2c9c825885fe7a42f4a8599a2a
Reviewed-on: https://review.whamcloud.com/39676
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Sergey Cheremencev <sergey.cheremencev@hpe.com>
Reviewed-by: Petros Koutoupis <petros.koutoupis@hpe.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/lov/lov_internal.h
lustre/lov/lov_obd.c
lustre/lov/lov_pool.c

index 1a89d3f..62e4d0f 100644 (file)
@@ -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
index 317bd2b..c8efb94 100644 (file)
@@ -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
index ef941ab..f272cfe 100644 (file)
@@ -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;