From f7392c7c4a16bc1127ee448f937ba81c50dcdfd5 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Thu, 25 Mar 2021 00:39:07 -0600 Subject: [PATCH] LU-14550 libcfs: fix setting of debug_path While it was possible to set "lctl set_param debug_path=path" or "echo path > /sys/module/libcfs/parameters/libcfs_debug_file_path" this change does not affect the path used to dump debug logs. Connect these parameters to the pathname used for the debug log. Test-Parameters: testlist=sanity env=ONLY=60f,ONLY_REPEAT=30 Fixes: 7092309f325 ("LU-8066 libcfs: migrate to debugfs") Signed-off-by: Andreas Dilger Change-Id: Ic18b5b24d1ac939c09637e66a342f5e3622367c3 Reviewed-on: https://review.whamcloud.com/43109 Reviewed-by: Jian Yu Tested-by: jenkins Reviewed-by: James Simmons Tested-by: Maloo Reviewed-by: Oleg Drokin --- libcfs/include/libcfs/libcfs_debug.h | 2 +- libcfs/libcfs/debug.c | 16 ++++------------ lustre/osc/osc_request.c | 5 ++--- lustre/target/tgt_handler.c | 5 ++--- lustre/tests/sanity.sh | 19 +++++++++++++++++++ 5 files changed, 28 insertions(+), 19 deletions(-) diff --git a/libcfs/include/libcfs/libcfs_debug.h b/libcfs/include/libcfs/libcfs_debug.h index 119e450..d331e05 100644 --- a/libcfs/include/libcfs/libcfs_debug.h +++ b/libcfs/include/libcfs/libcfs_debug.h @@ -54,7 +54,7 @@ extern unsigned int libcfs_console_max_delay; extern unsigned int libcfs_console_min_delay; extern unsigned int libcfs_console_backoff; extern unsigned int libcfs_debug_binary; -extern char libcfs_debug_file_path_arr[PATH_MAX]; +extern char *libcfs_debug_file_path; struct task_struct; diff --git a/libcfs/libcfs/debug.c b/libcfs/libcfs/debug.c index d82b2c1..412a10c 100644 --- a/libcfs/libcfs/debug.c +++ b/libcfs/libcfs/debug.c @@ -250,11 +250,9 @@ EXPORT_SYMBOL(libcfs_kmem); static DECLARE_COMPLETION(debug_complete); -char libcfs_debug_file_path_arr[PATH_MAX] = LIBCFS_DEBUG_FILE_PATH_DEFAULT; -EXPORT_SYMBOL(libcfs_debug_file_path_arr); - /* We need to pass a pointer here, but elsewhere this must be a const */ -static char *libcfs_debug_file_path = LIBCFS_DEBUG_FILE_PATH_DEFAULT; +char *libcfs_debug_file_path = LIBCFS_DEBUG_FILE_PATH_DEFAULT; +EXPORT_SYMBOL(libcfs_debug_file_path); module_param(libcfs_debug_file_path, charp, 0644); MODULE_PARM_DESC(libcfs_debug_file_path, "Path for dumping debug logs, set 'NONE' to prevent log dumping"); @@ -403,11 +401,11 @@ static void libcfs_debug_dumplog_internal(void *arg) current_time = ktime_get_real_seconds(); - if (strncmp(libcfs_debug_file_path_arr, "NONE", 4) != 0 && + if (strncmp(libcfs_debug_file_path, "NONE", 4) != 0 && current_time > last_dump_time) { last_dump_time = current_time; snprintf(debug_file_name, sizeof(debug_file_name) - 1, - "%s.%lld.%ld", libcfs_debug_file_path_arr, + "%s.%lld.%ld", libcfs_debug_file_path, (s64)current_time, (uintptr_t)arg); pr_alert("LustreError: dumping log to %s\n", debug_file_name); cfs_tracefile_dump_all_pages(debug_file_name); @@ -680,12 +678,6 @@ int libcfs_debug_init(unsigned long bufsize) libcfs_console_min_delay = CDEBUG_DEFAULT_MIN_DELAY; } - if (libcfs_debug_file_path) { - strlcpy(libcfs_debug_file_path_arr, - libcfs_debug_file_path, - sizeof(libcfs_debug_file_path_arr)); - } - /* If libcfs_debug_mb is uninitialized then just make the * total buffers smp_num_cpus * TCD_MAX_PAGES */ diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index b548e08..6cd0a2c 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -1782,9 +1782,8 @@ static void dump_all_bulk_pages(struct obdo *oa, __u32 page_count, * file/fid, not during the resends/retries. */ snprintf(dbgcksum_file_name, sizeof(dbgcksum_file_name), "%s-checksum_dump-osc-"DFID":[%llu-%llu]-%x-%x", - (strncmp(libcfs_debug_file_path_arr, "NONE", 4) != 0 ? - libcfs_debug_file_path_arr : - LIBCFS_DEBUG_FILE_PATH_DEFAULT), + (strncmp(libcfs_debug_file_path, "NONE", 4) != 0 ? + libcfs_debug_file_path : LIBCFS_DEBUG_FILE_PATH_DEFAULT), oa->o_valid & OBD_MD_FLFID ? oa->o_parent_seq : 0ULL, oa->o_valid & OBD_MD_FLFID ? oa->o_parent_oid : 0, oa->o_valid & OBD_MD_FLFID ? oa->o_parent_ver : 0, diff --git a/lustre/target/tgt_handler.c b/lustre/target/tgt_handler.c index a37e52e..4fff6a6 100644 --- a/lustre/target/tgt_handler.c +++ b/lustre/target/tgt_handler.c @@ -1882,9 +1882,8 @@ static void dump_all_bulk_pages(struct obdo *oa, int count, * file/fid, not during the resends/retries. */ snprintf(dbgcksum_file_name, sizeof(dbgcksum_file_name), "%s-checksum_dump-ost-"DFID":[%llu-%llu]-%x-%x", - (strncmp(libcfs_debug_file_path_arr, "NONE", 4) != 0 ? - libcfs_debug_file_path_arr : - LIBCFS_DEBUG_FILE_PATH_DEFAULT), + (strncmp(libcfs_debug_file_path, "NONE", 4) != 0 ? + libcfs_debug_file_path : LIBCFS_DEBUG_FILE_PATH_DEFAULT), oa->o_valid & OBD_MD_FLFID ? oa->o_parent_seq : (__u64)0, oa->o_valid & OBD_MD_FLFID ? oa->o_parent_oid : 0, oa->o_valid & OBD_MD_FLFID ? oa->o_parent_ver : 0, diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index e4c4e0c..82d0f76 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -8049,6 +8049,25 @@ test_60e() { } run_test 60e "no space while new llog is being created" +test_60f() { + local old_path=$($LCTL get_param -n debug_path) + + stack_trap "$LCTL set_param debug_path=$old_path" + stack_trap "rm -f $TMP/$tfile*" + #define OBD_FAIL_PTLRPC_DUMP_LOG 0x50e + $LCTL set_param debug_path=$TMP/$tfile fail_loc=0x8000050e + test_mkdir $DIR/$tdir + rm -f $TMP/$tfile* 2> /dev/null + # retry in case the open is cached and not released + for (( i = 0; i < 100 && $(ls $TMP/$tfile* | wc -l) == 0; i++ )); do + echo $i > $DIR/$tdir/$tfile.$i && cat $DIR/$tdir/$tfile.$i + sleep 0.1 + done + ls $TMP/$tfile* + (( $(ls $TMP/$tfile* | wc -l) > 0 )) || error "$TMP/$tfile not dumped" +} +run_test 60f "change debug_path works" + test_60g() { local pid local i -- 1.8.3.1