Whamcloud - gitweb
LU-13258 obdclass: bind zombie export cleanup workqueue 12/38212/11
authorJames Simmons <jsimmons@infradead.org>
Mon, 11 May 2020 22:38:10 +0000 (18:38 -0400)
committerOleg Drokin <green@whamcloud.com>
Wed, 27 May 2020 05:04:49 +0000 (05:04 +0000)
Lustre uses a workqueue to clear out stale exports. Bind this
workqueue to the cores used by Lustre defined by the CPT setup.

Move the code handling workqueue binding to libcfs so it can be
used by everyone.

Rename CONFIG_LUSTRE_PINGER to CONFIG_LUSTRE_FS_PINGER to match
linux client.

Change-Id: Ifa109f6a93e6ec6bbdef5e91fe8ca1cde0eaea3e
Signed-off-by: James Simmons <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/38212
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: Wang Shilong <wshilong@ddn.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
libcfs/include/libcfs/libcfs_cpu.h
libcfs/libcfs/libcfs_cpu.c
lustre/autoconf/lustre-core.m4
lustre/llite/llite_lib.c
lustre/obdclass/genops.c
lustre/obdclass/obd_sysfs.c
lustre/ptlrpc/import.c
lustre/ptlrpc/pinger.c

index 44675f7..bd5ea2a 100644 (file)
@@ -297,6 +297,30 @@ static inline void cfs_cpu_fini(void)
 
 #endif /* CONFIG_SMP */
 
+static inline
+struct workqueue_struct *cfs_cpt_bind_workqueue(const char *wq_name,
+                                               struct cfs_cpt_table *tbl,
+                                               int flags, int cpt, int nthrs)
+{
+       cpumask_var_t *mask = cfs_cpt_cpumask(tbl, cpt);
+       struct workqueue_attrs attrs = { };
+       struct workqueue_struct *wq;
+
+       wq = alloc_workqueue(wq_name, WQ_UNBOUND | flags, nthrs);
+       if (!wq)
+               return ERR_PTR(-ENOMEM);
+
+       if (mask && alloc_cpumask_var(&attrs.cpumask, GFP_KERNEL)) {
+               cpumask_copy(attrs.cpumask, *mask);
+               cpus_read_lock();
+               cfs_apply_workqueue_attrs(wq, &attrs);
+               cpus_read_unlock();
+               free_cpumask_var(attrs.cpumask);
+       }
+
+       return wq;
+}
+
 /*
  * allocate per-cpu-partition data, returned value is an array of pointers,
  * variable can be indexed by CPU ID.
index 9fac258..f7d1bde 100644 (file)
@@ -32,8 +32,8 @@
 
 #include <linux/cpu.h>
 #include <linux/sched.h>
-#include <libcfs/libcfs_cpu.h>
 #include <libcfs/libcfs.h>
+#include <libcfs/libcfs_cpu.h>
 
 /** virtual processing unit */
 struct cfs_cpu_partition {
index 2977275..b3242f7 100644 (file)
@@ -102,7 +102,7 @@ AC_ARG_ENABLE([pinger],
        [], [enable_pinger="yes"])
 AC_MSG_RESULT([$enable_pinger])
 AS_IF([test "x$enable_pinger" != xno],
-       [AC_DEFINE(CONFIG_LUSTRE_PINGER, 1,[Use the Pinger])])
+       [AC_DEFINE(CONFIG_LUSTRE_FS_PINGER, 1,[Use the Pinger])])
 ]) # LC_CONFIG_PINGER
 
 #
index 88b0837..254a641 100644 (file)
@@ -87,8 +87,6 @@ static inline unsigned int ll_get_ra_async_max_active(void)
 
 static struct ll_sb_info *ll_init_sbi(void)
 {
-       struct workqueue_attrs attrs = { };
-       cpumask_var_t *mask;
        struct ll_sb_info *sbi = NULL;
        unsigned long pages;
        unsigned long lru_page_max;
@@ -119,20 +117,11 @@ static struct ll_sb_info *ll_init_sbi(void)
 
        sbi->ll_ra_info.ra_async_max_active = ll_get_ra_async_max_active();
        sbi->ll_ra_info.ll_readahead_wq =
-               alloc_workqueue("ll-readahead-wq", WQ_UNBOUND,
-                               sbi->ll_ra_info.ra_async_max_active);
-       if (!sbi->ll_ra_info.ll_readahead_wq)
-               GOTO(out_pcc, rc = -ENOMEM);
-
-       mask = cfs_cpt_cpumask(cfs_cpt_tab, CFS_CPT_ANY);
-       if (mask && alloc_cpumask_var(&attrs.cpumask, GFP_KERNEL)) {
-               cpumask_copy(attrs.cpumask, *mask);
-               cpus_read_lock();
-               cfs_apply_workqueue_attrs(sbi->ll_ra_info.ll_readahead_wq,
-                                         &attrs);
-               cpus_read_unlock();
-               free_cpumask_var(attrs.cpumask);
-       }
+               cfs_cpt_bind_workqueue("ll-readahead-wq", cfs_cpt_tab,
+                                      0, CFS_CPT_ANY,
+                                      sbi->ll_ra_info.ra_async_max_active);
+       if (IS_ERR(sbi->ll_ra_info.ll_readahead_wq))
+               GOTO(out_pcc, rc = PTR_ERR(sbi->ll_ra_info.ll_readahead_wq));
 
        /* initialize ll_cache data */
        sbi->ll_cache = cl_cache_init(lru_page_max);
index bd59d56..0b2612c 100644 (file)
@@ -1893,11 +1893,11 @@ EXPORT_SYMBOL(obd_stale_export_adjust);
  */
 int obd_zombie_impexp_init(void)
 {
-       zombie_wq = alloc_workqueue("obd_zombid", 0, 0);
-       if (!zombie_wq)
-               return -ENOMEM;
+       zombie_wq = cfs_cpt_bind_workqueue("obd_zombid", cfs_cpt_tab,
+                                          0, CFS_CPT_ANY,
+                                          cfs_cpt_number(cfs_cpt_tab));
 
-       return 0;
+       return IS_ERR(zombie_wq) ? PTR_ERR(zombie_wq) : 0;
 }
 
 /**
index 84bc676..8e4cae2 100644 (file)
@@ -214,7 +214,7 @@ static ssize_t version_show(struct kobject *kobj, struct attribute *attr,
 static ssize_t pinger_show(struct kobject *kobj, struct attribute *attr,
                           char *buf)
 {
-#ifdef CONFIG_LUSTRE_PINGER
+#ifdef CONFIG_LUSTRE_FS_PINGER
        const char *state = "on";
 #else
        const char *state = "off";
index 8ea5f78..b14bc61 100644 (file)
@@ -466,7 +466,7 @@ void ptlrpc_fail_import(struct obd_import *imp, __u32 conn_cnt)
 
 int ptlrpc_reconnect_import(struct obd_import *imp)
 {
-#ifdef CONFIG_LUSTRE_PINGER
+#ifdef CONFIG_LUSTRE_FS_PINGER
        long timeout_jiffies = cfs_time_seconds(obd_timeout);
        int rc;
 
index 0650c2e..6b6cbe0 100644 (file)
@@ -141,7 +141,7 @@ static int ptlrpc_ping(struct obd_import *imp)
 
 static void ptlrpc_update_next_ping(struct obd_import *imp, int soon)
 {
-#ifdef CONFIG_LUSTRE_PINGER
+#ifdef CONFIG_LUSTRE_FS_PINGER
        time64_t time = soon ? PING_INTERVAL_SHORT : PING_INTERVAL;
 
        if (imp->imp_state == LUSTRE_IMP_DISCON) {
@@ -151,7 +151,7 @@ static void ptlrpc_update_next_ping(struct obd_import *imp, int soon)
                time = min(time, dtime);
        }
        imp->imp_next_ping = ktime_get_seconds() + time;
-#endif /* CONFIG_LUSTRE_PINGER */
+#endif /* CONFIG_LUSTRE_FS_PINGER */
 }
 
 void ptlrpc_ping_import_soon(struct obd_import *imp)
@@ -316,26 +316,15 @@ static void ptlrpc_pinger_main(struct work_struct *ws)
 
 int ptlrpc_start_pinger(void)
 {
-#ifdef CONFIG_LUSTRE_PINGER
-       struct workqueue_attrs attrs = { };
-       cpumask_var_t *mask;
-
+#ifdef CONFIG_LUSTRE_FS_PINGER
        if (pinger_wq)
                return -EALREADY;
 
-       pinger_wq = alloc_workqueue("ptlrpc_pinger", WQ_UNBOUND, 1);
-       if (!pinger_wq) {
+       pinger_wq = cfs_cpt_bind_workqueue("ptlrpc_pinger", cfs_cpt_tab,
+                                          0, CFS_CPT_ANY, 1);
+       if (IS_ERR(pinger_wq)) {
                CERROR("cannot start pinger workqueue\n");
-               return -ENOMEM;
-       }
-
-       mask = cfs_cpt_cpumask(cfs_cpt_tab, CFS_CPT_ANY);
-       if (mask && alloc_cpumask_var(&attrs.cpumask, GFP_KERNEL)) {
-               cpumask_copy(attrs.cpumask, *mask);
-               cpus_read_lock();
-               cfs_apply_workqueue_attrs(pinger_wq, &attrs);
-               cpus_read_unlock();
-               free_cpumask_var(attrs.cpumask);
+               return PTR_ERR(pinger_wq);
        }
 
        queue_delayed_work(pinger_wq, &ping_work, 0);
@@ -350,7 +339,7 @@ int ptlrpc_pinger_remove_timeouts(void);
 
 int ptlrpc_stop_pinger(void)
 {
-#ifdef CONFIG_LUSTRE_PINGER
+#ifdef CONFIG_LUSTRE_FS_PINGER
        if (!pinger_wq)
                return -EALREADY;
 
@@ -545,7 +534,7 @@ int ptlrpc_pinger_remove_timeouts(void)
 
 void ptlrpc_pinger_wake_up(void)
 {
-#ifdef CONFIG_LUSTRE_PINGER
+#ifdef CONFIG_LUSTRE_FS_PINGER
        mod_delayed_work(pinger_wq, &ping_work, 0);
 #endif
 }