Whamcloud - gitweb
LU-11648 mgs: Create white list for CONFIGS directory files 71/57271/3
authorArtem Blagodarenko <ablagodarenko@ddn.com>
Tue, 3 Dec 2024 10:52:04 +0000 (05:52 -0500)
committerOleg Drokin <green@whamcloud.com>
Thu, 2 Jan 2025 20:51:10 +0000 (20:51 +0000)
Not all files that are stored in CONFIGS directory should
be processed. For example there are ".bak" files which
created during change_nids operation and used to store
non-modified copy. Currently blacklist is used to process
CONFIGS directory (".bak"s are excluded), but using
whitelist looks more robust.

These files(patterns) should be in the white list:

*-client
*-MDT????
*-OST????
mountdata
nodemap
params
sptlrpc

Test-Parameters: testlist=conf-sanity
Change-Id: I34871fa11d50941450233053446c6c41a1f83048
Signed-off-by: Artem Blagodarenko <ablagodarenko@ddn.com>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57271
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Sergey Cheremencev <scherementsev@ddn.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/lu_object.h
lustre/mgs/mgs_llog.c

index 8e3040d..1035a33 100644 (file)
@@ -1315,6 +1315,33 @@ static inline bool lu_name_is_backup_file(const char *name, int namelen,
        return false;
 }
 
+static inline bool lu_name_in_white_list(const char *name, int nlen)
+{
+       /* Check for specific filenames */
+       if (strncmp(name, "mountdata", nlen) == 0 ||
+           strncmp(name, "nodemap", nlen) == 0 ||
+           strncmp(name, "params", nlen) == 0 ||
+           strncmp(name, "sptlrpc", nlen) == 0)
+               return 1;
+
+       /* names like lustre-client */
+       if (nlen > 7 && strncmp(name + nlen - 7, "-client", 7) == 0)
+               return 1;
+
+       /* Check if the string is long enough to match the pattern */
+       if (nlen < 9)
+               return 0;
+
+       /* Check if the string ends with "-OSTxxxx" or "-MDTxxxx" */
+       if ((strncmp(name + nlen - 8, "-OST", 4) == 0 ||
+            strncmp(name + nlen - 8, "-MDT", 4) == 0) &&
+            isxdigit(name[nlen - 4]) && isxdigit(name[nlen - 3]) &&
+            isxdigit(name[nlen - 2]) && isxdigit(name[nlen - 1])) {
+               return 1;
+       }
+       return 0;
+}
+
 static inline bool lu_name_is_valid_len(const char *name, size_t name_len)
 {
        return name != NULL &&
index fe1ba28..0909d56 100644 (file)
@@ -85,9 +85,9 @@ int class_dentry_readdir(const struct lu_env *env, struct mgs_device *mgs,
                                goto next;
                }
 
-               /* filter out backup files */
-               if (lu_name_is_backup_file(key, key_sz, NULL)) {
-                       CDEBUG(D_MGS, "Skipping backup file %.*s\n",
+               /* filter out files */
+               if (!lu_name_in_white_list(key, key_sz)) {
+                       CDEBUG(D_MGS, "Not in white list, skipping %.*s\n",
                               key_sz, key);
                        goto next;
                }