From: Ronnie Sahlberg Date: Thu, 3 Oct 2024 03:31:45 +0000 (-0400) Subject: LU-4922 cfs_str2mask: Handle passing in a blank string better X-Git-Tag: 2.16.51~100 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=93ba9bfa262bfcbfb500e9e54ef9b59e8f1e9cba;p=fs%2Flustre-release.git LU-4922 cfs_str2mask: Handle passing in a blank string better 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 Change-Id: Ibe43509cbdec250e395e35648d399167026a1a14 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56619 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin Reviewed-by: Alex Zhuravlev Reviewed-by: James Simmons --- diff --git a/libcfs/libcfs/libcfs_string.c b/libcfs/libcfs/libcfs_string.c index cfa3c89..d0c1233 100644 --- a/libcfs/libcfs/libcfs_string.c +++ b/libcfs/libcfs/libcfs_string.c @@ -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; /* 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]) && diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index d6e905f..4f24c6a 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -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)