Whamcloud - gitweb
LU-4922 cfs_str2mask: Handle passing in a blank string better 19/56619/3
authorRonnie Sahlberg <rsahlberg@whamcloud.com>
Thu, 3 Oct 2024 03:31:45 +0000 (23:31 -0400)
committerOleg Drokin <green@whamcloud.com>
Mon, 9 Dec 2024 06:12:20 +0000 (06:12 +0000)
Do not revert the flags to min_mask if passed an empty string
to the function.
Remove exclusion of the changelog_mask parameter from test_133g
as it no longer needs to be skipped.

The change initializes the new mask to the existing mask and only
re-sets it to use min_mask iff the first token in the string is a
'-' or '+'. This fixes a bug where if you were to pass an empty
string to this function it would reset the flags to min_mask.
With this change the flags will be left unchanged.

The only way curently for a user to invoke this function is via
the set_param param command.
That command does check for and will abort if the user tries to
specify "" before calling into cfs_str2mask() thus preventing the
issue in LU-4922 from triggering.

Signed-off-by: Ronnie Sahlberg <rsahlberg@whamcloud.com>
Change-Id: Ibe43509cbdec250e395e35648d399167026a1a14
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56619
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
libcfs/libcfs/libcfs_string.c
lustre/tests/sanity.sh

index cfa3c89..d0c1233 100644 (file)
@@ -93,7 +93,7 @@ int cfs_str2mask(const char *str, const char *(*bit2str)(int bit),
                 u64 *oldmask, u64 minmask, u64 allmask, u64 defmask)
 {
        const char *debugstr;
-       u64 newmask = minmask, found = 0;
+       u64 newmask = *oldmask, found = 0;
 
        ENTRY;
        /* <str> must be a list of tokens separated by whitespace or comma,
@@ -112,14 +112,13 @@ int cfs_str2mask(const char *str, const char *(*bit2str)(int bit),
                        break;
                if (*str == '+' || *str == '-') {
                        op = *str++;
-                       if (!found)
-                               /* only if first token is relative */
-                               newmask = *oldmask;
                        while (isspace(*str))
                                str++;
                        if (*str == 0)          /* trailing op */
                                return -EINVAL;
-               }
+               } else if (!found)
+                       newmask = minmask;
+
 
                /* find token length */
                for (len = 0; str[len] != 0 && !isspace(str[len]) &&
index d6e905f..4f24c6a 100755 (executable)
@@ -17377,7 +17377,7 @@ test_133g() {
 
        local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
        local proc_dirs_str=$(eval echo $proc_dirs)
-       local skipped_params="'force_lbug|changelog_mask|daemon_file'"
+       local skipped_params="'force_lbug|daemon_file'"
        local facet
        for facet in mds1 ost1; do
                local facet_ver=$(lustre_version_code $facet)