Whamcloud - gitweb
LU-9859 libcfs: discard TCD_MAX_TYPES 68/39668/4
authorMr. NeilBrown <neilb@suse.de>
Thu, 13 Aug 2020 12:44:25 +0000 (08:44 -0400)
committerOleg Drokin <green@whamcloud.com>
Fri, 26 Feb 2021 21:07:53 +0000 (21:07 +0000)
As well as CFS_TCD_TYPE_CNT we have TCD_MAX_TYPES which has a larger
value but a similar meaning.  Discard it and just use
CFS_TCD_TYPE_CNT.

Two places relied on the fact that TCD_MAX_TYPES was larger and so
there would be NULLs at the end of the array.  Change
them to check the array size properly.

Linux-commit: 22627ffa5e7fae0b0b62f90a8f30fc6dae0fff3c

Change-Id: I73a54a409674d3b569bcbaf72e2296209542b74c
Signed-off-by: Mr. NeilBrown <neilb@suse.de>
Reviewed-on: https://review.whamcloud.com/39668
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Yang Sheng <ys@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
libcfs/libcfs/tracefile.c

index f026ec1..eb89132 100644 (file)
@@ -49,7 +49,6 @@
 #include <libcfs/libcfs.h>
 
 #define CFS_TRACE_CONSOLE_BUFFER_SIZE  1024
-#define TCD_MAX_TYPES                  8
 
 enum cfs_trace_buf_type {
        CFS_TCD_TYPE_PROC = 0,
@@ -58,7 +57,7 @@ enum cfs_trace_buf_type {
        CFS_TCD_TYPE_CNT
 };
 
-union cfs_trace_data_union (*cfs_trace_data[TCD_MAX_TYPES])[NR_CPUS] __cacheline_aligned;
+union cfs_trace_data_union (*cfs_trace_data[CFS_TCD_TYPE_CNT])[NR_CPUS] __cacheline_aligned;
 
 char *cfs_trace_console_buffers[NR_CPUS][CFS_TCD_TYPE_CNT];
 char cfs_tracefile[TRACEFILE_NAME_SIZE];
@@ -109,13 +108,13 @@ void cfs_trace_unlock_tcd(struct cfs_trace_cpu_data *tcd, int walking)
 }
 
 #define cfs_tcd_for_each(tcd, i, j)                                    \
-       for (i = 0; cfs_trace_data[i]; i++)                             \
+       for (i = 0; i < CFS_TCD_TYPE_CNT && cfs_trace_data[i]; i++)     \
                for (j = 0, ((tcd) = &(*cfs_trace_data[i])[j].tcd);     \
                     j < num_possible_cpus();                           \
                     j++, (tcd) = &(*cfs_trace_data[i])[j].tcd)
 
 #define cfs_tcd_for_each_type_lock(tcd, i, cpu)                                \
-       for (i = 0; cfs_trace_data[i] &&                                \
+       for (i = 0; i < CFS_TCD_TYPE_CNT && cfs_trace_data[i] &&        \
             (tcd = &(*cfs_trace_data[i])[cpu].tcd) &&                  \
             cfs_trace_lock_tcd(tcd, 1); cfs_trace_unlock_tcd(tcd, 1), i++)
 
@@ -1326,7 +1325,7 @@ static void cfs_trace_cleanup(void)
                        cfs_trace_console_buffers[i][j] = NULL;
                }
 
-       for (i = 0; cfs_trace_data[i]; i++) {
+       for (i = 0; i < CFS_TCD_TYPE_CNT && cfs_trace_data[i]; i++) {
                kfree(cfs_trace_data[i]);
                cfs_trace_data[i] = NULL;
        }