Whamcloud - gitweb
LU-18876 misc: make dbgcksum_file_name static 29/58629/5
authorTimothy Day <timday@amazon.com>
Wed, 2 Apr 2025 18:30:27 +0000 (14:30 -0400)
committerOleg Drokin <green@whamcloud.com>
Wed, 16 Apr 2025 20:44:52 +0000 (20:44 +0000)
The global variable dbgcksum_file_name is defined
twice: once in OSC and another time in target. This
causes a linker error when the Lustre modules are
compiled into the static kernel image.

Resolve this by making both instances local to
the functions that require them using
OBD_ALLOC()/FREE().

Test-Parameters: trivial
Signed-off-by: Timothy Day <timday@amazon.com>
Change-Id: I37ac4c60754082561a65e61ab2d956d68555394f
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58629
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/osc/osc_request.c
lustre/target/tgt_handler.c

index 1f728c0..c2c16ee 100644 (file)
@@ -2019,21 +2019,24 @@ out:
        RETURN(rc);
 }
 
-char dbgcksum_file_name[PATH_MAX];
-
 static void dump_all_bulk_pages(struct obdo *oa, __u32 page_count,
                                struct brw_page **pga, __u32 server_cksum,
                                __u32 client_cksum)
 {
+       char *dbgcksum_file_name;
        struct file *filp;
        unsigned int len;
        int rc, i;
        char *buf;
 
+       OBD_ALLOC(dbgcksum_file_name, PATH_MAX);
+       if (!dbgcksum_file_name)
+               return;
+
        /* will only keep dump of pages on first error for the same range in
         * file/fid, not during the resends/retries.
         */
-       snprintf(dbgcksum_file_name, sizeof(dbgcksum_file_name),
+       snprintf(dbgcksum_file_name, PATH_MAX,
                 "%s-checksum_dump-osc-"DFID":[%llu-%llu]-%x-%x",
                 (strncmp(libcfs_debug_file_path, "NONE", 4) != 0 ?
                  libcfs_debug_file_path : LIBCFS_DEBUG_FILE_PATH_DEFAULT),
@@ -2055,6 +2058,7 @@ static void dump_all_bulk_pages(struct obdo *oa, __u32 page_count,
                else
                        CERROR("%s: can't open to dump pages with checksum error: rc = %d\n",
                               dbgcksum_file_name, rc);
+               OBD_FREE(dbgcksum_file_name, PATH_MAX);
                return;
        }
 
@@ -2080,6 +2084,7 @@ static void dump_all_bulk_pages(struct obdo *oa, __u32 page_count,
        filp_close(filp, NULL);
 
        libcfs_debug_dumplog();
+       OBD_FREE(dbgcksum_file_name, PATH_MAX);
 }
 
 static int
index c1bd5d4..39e36b3 100644 (file)
@@ -1906,20 +1906,23 @@ static int tgt_checksum_niobuf(struct lu_target *tgt,
        return 0;
 }
 
-char dbgcksum_file_name[PATH_MAX];
-
 static void dump_all_bulk_pages(struct obdo *oa, int count,
                                struct niobuf_local *local_nb,
                                __u32 server_cksum, __u32 client_cksum)
 {
+       char *dbgcksum_file_name;
        struct file *filp;
        int rc, i;
        unsigned int len;
        char *buf;
 
+       OBD_ALLOC(dbgcksum_file_name, PATH_MAX);
+       if (!dbgcksum_file_name)
+               return;
+
        /* will only keep dump of pages on first error for the same range in
         * file/fid, not during the resends/retries. */
-       snprintf(dbgcksum_file_name, sizeof(dbgcksum_file_name),
+       snprintf(dbgcksum_file_name, PATH_MAX,
                 "%s-checksum_dump-ost-"DFID":[%llu-%llu]-%x-%x",
                 (strncmp(libcfs_debug_file_path, "NONE", 4) != 0 ?
                  libcfs_debug_file_path : LIBCFS_DEBUG_FILE_PATH_DEFAULT),
@@ -1941,6 +1944,7 @@ static void dump_all_bulk_pages(struct obdo *oa, int count,
                else
                        CERROR("%s: can't open to dump pages with checksum "
                               "error: rc = %d\n", dbgcksum_file_name, rc);
+               OBD_FREE(dbgcksum_file_name, PATH_MAX);
                return;
        }
 
@@ -1966,6 +1970,7 @@ static void dump_all_bulk_pages(struct obdo *oa, int count,
        filp_close(filp, NULL);
 
        libcfs_debug_dumplog();
+       OBD_FREE(dbgcksum_file_name, PATH_MAX);
 }
 
 static int check_read_checksum(struct niobuf_local *local_nb, int npages,