From 0fe756d0f4abd773e2a2d433103a8ca393af7f5a Mon Sep 17 00:00:00 2001 From: Artem Blagodarenko Date: Tue, 3 Dec 2024 05:52:04 -0500 Subject: [PATCH] LU-11648 mgs: Create white list for CONFIGS directory files 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 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57271 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Sergey Cheremencev Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lustre/include/lu_object.h | 27 +++++++++++++++++++++++++++ lustre/mgs/mgs_llog.c | 6 +++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/lustre/include/lu_object.h b/lustre/include/lu_object.h index 8e3040d..1035a33 100644 --- a/lustre/include/lu_object.h +++ b/lustre/include/lu_object.h @@ -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 && diff --git a/lustre/mgs/mgs_llog.c b/lustre/mgs/mgs_llog.c index fe1ba28..0909d56 100644 --- a/lustre/mgs/mgs_llog.c +++ b/lustre/mgs/mgs_llog.c @@ -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; } -- 1.8.3.1