Whamcloud - gitweb
LU-17623 libcfs: save msg_fn pointer to avoid race 20/54320/2
authorAndreas Dilger <adilger@whamcloud.com>
Thu, 7 Mar 2024 22:00:31 +0000 (15:00 -0700)
committerOleg Drokin <green@whamcloud.com>
Sat, 23 Mar 2024 06:11:49 +0000 (06:11 +0000)
commit02fc9e89775fe7f16d0aa78e369fec6313fec411
tree1640d9152b40e45db03760d59686f0f06846722c
parent21aa8404a42b79f7e0434cfe75411f85d7ee063a
LU-17623 libcfs: save msg_fn pointer to avoid race

Save msgdata->msg_fn pointer at the start of libcfs_debug_msg() to
avoid a race condition if another thread calls CDEBUG_WITH_LOC()
at the same time and has a different calling function name.  The
msg_file pointer was already being saved.  Otherwise it is possible
to fail the __LASSERT(debug_buf == string_buf) check if formatted
string length changes between prep and write passes.

Use existing header.ph_mask and .ph_line instead of duplicating them.

Test-Parameters: testlist=sanity-scrub env=ONLY=4d,ONLY_REPEAT=25
Fixes: 1a9bd41846 ("LU-14518 libcfs: print CFS_FAIL_CHECK() location")
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I3fd30cc9eed2ec8dabd795e9622fe1908a3ebbe5
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54320
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Aurelien Degremont <adegremont@nvidia.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
libcfs/libcfs/tracefile.c