Whamcloud - gitweb
LU-16639 misc: cleanup concole messages 83/50283/7
authorAndreas Dilger <adilger@whamcloud.com>
Mon, 13 Mar 2023 22:08:30 +0000 (16:08 -0600)
committerOleg Drokin <green@whamcloud.com>
Tue, 28 Mar 2023 22:20:25 +0000 (22:20 +0000)
The lprocfs_job_cleanup() was not properly dropping all jobstats
from the hash table and printing errors from job_stat_exit() at
unmount.  Ensure all stats are "old enough" when @clear is set.

Change early libcfs cfs_cpu_init() messages from CERROR() to
pr_err() to avoid circular dependencies on libcfs setup before
printing an error message to the console during module init.

Test-Parameters: trivial
Fixes: ea2cd3af7b ("LU-11407 obdclass: add start time to stats files")
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: Ide3f502103392a79419cc1836200bf5a1a3ebbe5
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50283
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Feng Lei <flei@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
libcfs/libcfs/libcfs_cpu.c
lustre/obdclass/lprocfs_jobstats.c

index 2616fc9..763a033 100644 (file)
@@ -1226,27 +1226,26 @@ int cfs_cpu_init(void)
        if (*cpu_pattern) {
                cfs_cpt_tab = cfs_cpt_table_create_pattern(cpu_pattern);
                if (IS_ERR(cfs_cpt_tab)) {
-                       CERROR("Failed to create cptab from pattern '%s'\n",
-                              cpu_pattern);
                        ret = PTR_ERR(cfs_cpt_tab);
+                       pr_err("libcfs: failed to create cptab from pattern '%s': rc = %d\n",
+                              cpu_pattern, ret);
                        goto failed_alloc_table;
                }
-
        } else {
                cfs_cpt_tab = cfs_cpt_table_create(cpu_npartitions);
                if (IS_ERR(cfs_cpt_tab)) {
-                       CERROR("Failed to create cptab with npartitions %d\n",
-                              cpu_npartitions);
                        ret = PTR_ERR(cfs_cpt_tab);
+                       pr_err("libcfs: failed to create cptab with npartitions=%d: rc = %d\n",
+                              cpu_npartitions, ret);
                        goto failed_alloc_table;
                }
        }
 
        cpus_read_unlock();
 
-       LCONSOLE(0, "HW NUMA nodes: %d, HW CPU cores: %d, npartitions: %d\n",
-                num_online_nodes(), num_online_cpus(),
-                cfs_cpt_number(cfs_cpt_tab));
+       pr_notice("libcfs: HW NUMA nodes: %d, HW CPU cores: %d, npartitions: %d\n",
+                 num_online_nodes(), num_online_cpus(),
+                 cfs_cpt_number(cfs_cpt_tab));
        return 0;
 
 failed_alloc_table:
index 9c61b95..49bf950 100644 (file)
@@ -128,6 +128,7 @@ static void job_putref(struct job_stat *job)
 static void job_stat_put_locked(struct cfs_hash *hs, struct hlist_node *hnode)
 {
        struct job_stat *job;
+
        job = hlist_entry(hnode, struct job_stat, js_hash);
        job_putref(job);
 }
@@ -234,9 +235,14 @@ static void lprocfs_job_cleanup(struct obd_job_stats *stats, bool clear)
         * since locking of the hash is handled internally, but there isn't
         * any benefit to having multiple threads doing cleanup at one time.
         *
-        * Subtract twice the cleanup_interval, since it is 1/2 the maximum age.
+        * Subtract or add twice the cleanup_interval, since it is 1/2 the
+        * maximum age.  When clearing all stats, push oldest into the future.
         */
-       oldest = ktime_sub(now, ktime_add(cleanup_interval, cleanup_interval));
+       cleanup_interval = ktime_add(cleanup_interval, cleanup_interval);
+       if (likely(!clear))
+               oldest = ktime_sub(now, cleanup_interval);
+       else
+               oldest = ktime_add(now, cleanup_interval);
        cfs_hash_for_each_safe(stats->ojs_hash, job_cleanup_iter_callback,
                               &oldest);