[LU-15689] libcfs_debug_mb is not set correctly if module has not been initialized Created: 24/Mar/22  Updated: 11/Jun/22  Resolved: 11/Jun/22

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: None
Fix Version/s: Lustre 2.16.0

Type: Bug Priority: Minor
Reporter: Chris Horn Assignee: Chris Horn
Resolution: Fixed Votes: 0
Labels: None

Severity: 3
Rank (Obsolete): 9223372036854775807

 Description   

If libcfs_debug_mb parameter is specified to insmod (i.e. set before module is initialized) then it does not get initialized correctly. This appears to be a regression from:

commit 8b78a3ffb5220330f41b4fa8576a05c4e017cfb1
Author: Mr NeilBrown <neilb@suse.de>
Date:   Sun Mar 8 21:35:57 2020 -0400

   LU-9859 libcfs: always range-check libcfs_debug_mb setting.
diff --git a/libcfs/libcfs/debug.c b/libcfs/libcfs/debug.c
index 99518ab116..e5bff2e18a 100644
--- a/libcfs/libcfs/debug.c
+++ b/libcfs/libcfs/debug.c
@@ -65,21 +65,15 @@ static int libcfs_param_debug_mb_set(const char *val,
        if (rc < 0)
                return rc;

-/*
- * RHEL6 does not support any kind of locking so we have to provide
- * our own
- */
-       if (!*((unsigned int *)kp->arg)) {
-               *((unsigned int *)kp->arg) = num;
-               return 0;
-       }
+       num = cfs_trace_set_debug_mb(num);

-       rc = cfs_trace_set_debug_mb(num);
-
-       if (!rc)
-               *((unsigned int *)kp->arg) = cfs_trace_get_debug_mb();
+       *((unsigned int *)kp->arg) = num;
+       num = cfs_trace_get_debug_mb();
+       if (num)
+               /* This value is more precise */
+               *((unsigned int *)kp->arg) = num;

-       return rc;
+       return 0;
 }

I think the idea is that cfs_trace_get_debug_mb() would only return non-zero if the module had been initialized, so it's return value should be used instead of the return val from cfs_trace_set_debug_mb(). However, cfs_trace_get_debug_mb() never returns 0:

int cfs_trace_get_debug_mb(void)
{
...
        return (total_pages >> (20 - PAGE_SHIFT)) + 1;
}

We can see it will always return at least 1.



 Comments   
Comment by Gerrit Updater [ 24/Mar/22 ]

"Chris Horn <chris.horn@hpe.com>" uploaded a new patch: https://review.whamcloud.com/46925
Subject: LU-15689 libcfs: libcfs_debug_mb set incorrectly on init
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 1502cc4440ef5b138db0ba16ab6368b963272357

Comment by Gerrit Updater [ 11/Jun/22 ]

"Oleg Drokin <green@whamcloud.com>" merged in patch https://review.whamcloud.com/46925/
Subject: LU-15689 libcfs: libcfs_debug_mb set incorrectly on init
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: d38ef181d8250b083553ec95209c28c1dc11fa99

Comment by Peter Jones [ 11/Jun/22 ]

Landed for 2.16

Generated at Sat Feb 10 03:20:28 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.