Whamcloud - gitweb
LU-18155 lnet: use LASSERT/F instead of if () LBUG() 16/56116/3
authorTimothy Day <timday@amazon.com>
Thu, 22 Aug 2024 01:28:30 +0000 (21:28 -0400)
committerOleg Drokin <green@whamcloud.com>
Mon, 2 Dec 2024 05:47:40 +0000 (05:47 +0000)
We should use a proper LASSERT statement rather than
more verbose if/LBUG blocks.

The patch has been generated with the coccinelle script below.
I manually inverted the conditional logic.

@@
expression L;
expression list F;
@@

- if (L) {
(
- CDEBUG(F);
|
- CWARN(F);
|
- CERROR(F);
|
- CEMERG(F);
|
- CNETERR(F);
|
- LCONSOLE(F);
|
- LCONSOLE_INFO(F);
|
- LCONSOLE_WARN(F);
|
- LCONSOLE_ERROR(F);
|
- LCONSOLE_EMERG(F);
)
- LBUG();
- }
+ LASSERTF(L, F);

@@
expression L;
@@

-if (L) LBUG();
+LASSERT(L);

Test-Parameters: trivial
Signed-off-by: Timothy Day <timday@amazon.com>
Change-Id: I73eff22d6fd4199b02d3ae2cc7740aa754d6945d
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56116
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/klnds/gnilnd/gnilnd_conn.c
lnet/lnet/api-ni.c

index f8c4c26..12f8ca0 100644 (file)
@@ -45,15 +45,12 @@ kgnilnd_map_fmablk(kgn_device_t *device, kgn_fma_memblock_t *fma_blk)
                                   flags, &fma_blk->gnm_hndl);
        if (rrc != GNI_RC_SUCCESS) {
                if (rfto != GNILND_REGFAILTO_DISABLE) {
-                       if (reg_to == 0) {
+                       if (reg_to == 0)
                                reg_to = jiffies + cfs_time_seconds(rfto);
-                       } else if (time_after(jiffies, reg_to)) {
-                               CERROR("FATAL:fmablk registration has failed "
-                                      "for %ld seconds.\n",
-                                      cfs_duration_sec(jiffies - reg_to) +
-                                               rfto);
-                               LBUG();
-                       }
+                       else
+                               LASSERTF(!time_after(jiffies, reg_to),
+                                        "FATAL:fmablk registration has failed for %ld seconds.\n",
+                                        cfs_duration_sec(jiffies - reg_to) + rfto);
                }
 
                CNETERR("register fmablk failed 0x%p mbox_size %d flags %u\n",
index 91f993f..442cd3b 100644 (file)
@@ -2070,10 +2070,7 @@ lnet_ping_target_install_locked(struct lnet_ping_buffer *pbuf)
         * must be the loopback interface.
         */
        rc = lnet_ping_info_validate(&pbuf->pb_info);
-       if (rc) {
-               LCONSOLE_EMERG("Invalid ping target: %d\n", rc);
-               LBUG();
-       }
+       LASSERTF(!rc, "Invalid ping target: %d\n", rc);
        LNET_PING_BUFFER_SEQNO(pbuf) =
                atomic_inc_return(&the_lnet.ln_ping_target_seqno);
 }