From 5624256e6811a5c36f1d6a1724705ee170aa5364 Mon Sep 17 00:00:00 2001 From: Timothy Day Date: Wed, 2 Apr 2025 14:30:27 -0400 Subject: [PATCH] LU-18876 misc: make dbgcksum_file_name static 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 Change-Id: I37ac4c60754082561a65e61ab2d956d68555394f Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58629 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Arshad Hussain Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- lustre/osc/osc_request.c | 11 ++++++++--- lustre/target/tgt_handler.c | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index 1f728c06..c2c16ee 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -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 diff --git a/lustre/target/tgt_handler.c b/lustre/target/tgt_handler.c index c1bd5d4..39e36b3 100644 --- a/lustre/target/tgt_handler.c +++ b/lustre/target/tgt_handler.c @@ -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, -- 1.8.3.1