From 88c2cc8118d38f70cc32c932e38a645636b7cfe2 Mon Sep 17 00:00:00 2001 From: Rajeev Mishra Date: Sat, 3 Aug 2024 18:28:58 +0000 Subject: [PATCH] LU-17812 coverity: Fixes Boolean operation on a constant This commit fixes the coverity issue introduced by the previous commit of LU-17812. Below given is the coverity report. CID 440624 Integer handling issue constant_expression_result The expression "ldlm_lock_to_ns(__ext->oe_dlmlock)-> ns_dump_stack_on_error && 1 /* D_ERROR & D_ERROR */" performs a Boolean operation on a constant Fixes: 70b9dc57a99d ("LU-17812 ldlm: stack trace log for LDLM error") Signed-off-by: Rajeev Mishra Change-Id: I300831598c54f3f96719938253c7eaacb83f299f Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55926 Tested-by: Maloo Tested-by: jenkins Reviewed-by: Petros Koutoupis Reviewed-by: Shaun Tancheff Reviewed-by: Oleg Drokin Reviewed-by: Andreas Dilger --- lustre/include/lustre_dlm.h | 7 ++++--- lustre/ldlm/ldlm_resource.c | 5 +---- lustre/tests/sanity.sh | 3 +-- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/lustre/include/lustre_dlm.h b/lustre/include/lustre_dlm.h index 98c80d6..3214c6f 100644 --- a/lustre/include/lustre_dlm.h +++ b/lustre/include/lustre_dlm.h @@ -1323,12 +1323,13 @@ extern const char *ldlm_it2str(enum ldlm_intent_flags it); */ #ifdef LIBCFS_DEBUG #define ldlm_lock_debug(msgdata, mask, cdls, lock, fmt, a...) do { \ - if (((mask) & D_CANTMASK) != 0 || \ + if (((mask) & D_CANTMASK) != 0 || \ ((libcfs_debug & (mask)) != 0 && \ (libcfs_subsystem_debug & DEBUG_SUBSYSTEM) != 0)) { \ _ldlm_lock_debug(lock, msgdata, fmt, ##a); \ - if (ldlm_lock_to_ns(lock)->ns_dump_stack_on_error && \ - (mask) & D_ERROR) \ + if (unlikely(ldlm_lock_to_ns(lock)-> \ + ns_dump_stack_on_error) && \ + (mask) & D_ERROR) \ dump_stack(); \ } \ } while (0) diff --git a/lustre/ldlm/ldlm_resource.c b/lustre/ldlm/ldlm_resource.c index 489a53c..abe3a3f 100644 --- a/lustre/ldlm/ldlm_resource.c +++ b/lustre/ldlm/ldlm_resource.c @@ -535,10 +535,7 @@ static ssize_t dump_stack_on_error_store(struct kobject *kobj, if (err != 0) return -EINVAL; - if (tmp != 0) - ns->ns_dump_stack_on_error = 1; - else - ns->ns_dump_stack_on_error = 0; + ns->ns_dump_stack_on_error = tmp; return count; } diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 018e33e6..10a1d3f 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -13689,8 +13689,7 @@ test_105f() { run_test 105f "Enqueue same range flocks" test_105g() { - - (( $CLIENT_VERSION >= $(version_code 2.15.63.127) )) || + (( $CLIENT_VERSION >= $(version_code 2.15.64.117) )) || skip "Need Client >= 2.15.63.127 for ldlm dump stack" flock_is_enabled || skip_env "mount w/o flock enabled" -- 1.8.3.1