Whamcloud - gitweb
LU-17812 coverity: Fixes Boolean operation on a constant 26/55926/4
authorRajeev Mishra <rajeevm@hpe.com>
Sat, 3 Aug 2024 18:28:58 +0000 (18:28 +0000)
committerOleg Drokin <green@whamcloud.com>
Fri, 16 Aug 2024 23:54:51 +0000 (23:54 +0000)
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 <rajeevm@hpe.com>
Change-Id: I300831598c54f3f96719938253c7eaacb83f299f
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55926
Tested-by: Maloo <maloo@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Petros Koutoupis <petros.koutoupis@hpe.com>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/include/lustre_dlm.h
lustre/ldlm/ldlm_resource.c
lustre/tests/sanity.sh

index 98c80d6..3214c6f 100644 (file)
@@ -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)
index 489a53c..abe3a3f 100644 (file)
@@ -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;
 }
index 018e33e..10a1d3f 100755 (executable)
@@ -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"