From c5d08e0af6ce819b818a0d9917a41d99899bab67 Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Wed, 20 Mar 2024 09:33:11 +0100 Subject: [PATCH] LU-17431 nodemap: add function to know if nodemap is on MGS Adding nodemap_mgs() function allows to know if nodemaps are defined on an MGS node (pointer to a nodemap config file) or not. Test-Parameters: trivial Signed-off-by: Sebastien Buisson Change-Id: Id87e34dd8d13cd21c88c87ef9e8e91ff9ff142c8 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54506 Tested-by: jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lustre/ptlrpc/nodemap_internal.h | 1 + lustre/ptlrpc/nodemap_storage.c | 25 +++++++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lustre/ptlrpc/nodemap_internal.h b/lustre/ptlrpc/nodemap_internal.h index 933099a..ea76dc5 100644 --- a/lustre/ptlrpc/nodemap_internal.h +++ b/lustre/ptlrpc/nodemap_internal.h @@ -151,6 +151,7 @@ int nm_hash_list_cb(struct cfs_hash *hs, struct cfs_hash_bd *bd, struct hlist_node *hnode, void *nodemap_list_head); +bool nodemap_mgs(void); int nodemap_idx_nodemap_add(const struct lu_nodemap *nodemap); int nodemap_idx_nodemap_update(const struct lu_nodemap *nodemap); int nodemap_idx_nodemap_del(const struct lu_nodemap *nodemap); diff --git a/lustre/ptlrpc/nodemap_storage.c b/lustre/ptlrpc/nodemap_storage.c index a25d00c..430dca0 100644 --- a/lustre/ptlrpc/nodemap_storage.c +++ b/lustre/ptlrpc/nodemap_storage.c @@ -68,6 +68,11 @@ static DEFINE_MUTEX(ncf_list_lock); /* MGS index is different than others, others are listeners to MGS idx */ static struct nm_config_file *nodemap_mgs_ncf; +bool nodemap_mgs(void) +{ + return (nodemap_mgs_ncf != NULL); +} + static void nodemap_cluster_key_init(struct nodemap_key *nk, unsigned int nm_id, enum nodemap_cluster_rec_subid subid) { @@ -423,7 +428,7 @@ static int nodemap_idx_cluster_add_update(const struct lu_nodemap *nodemap, ENTRY; if (idx == NULL) { - if (nodemap_mgs_ncf == NULL) { + if (!nodemap_mgs()) { CERROR("cannot add nodemap config to non-existing MGS.\n"); return -EINVAL; } @@ -482,7 +487,7 @@ int nodemap_idx_nodemap_del(const struct lu_nodemap *nodemap) int rc2 = 0; ENTRY; - if (nodemap_mgs_ncf == NULL) { + if (!nodemap_mgs()) { CERROR("cannot add nodemap config to non-existing MGS.\n"); return -EINVAL; } @@ -572,7 +577,7 @@ int nodemap_idx_cluster_roles_del(const struct lu_nodemap *nodemap) ENTRY; - if (nodemap_mgs_ncf == NULL) { + if (!nodemap_mgs()) { CERROR("cannot add nodemap config to non-existing MGS.\n"); return -EINVAL; } @@ -596,7 +601,7 @@ int nodemap_idx_range_add(const struct lu_nid_range *range) int rc = 0; ENTRY; - if (nodemap_mgs_ncf == NULL) { + if (!nodemap_mgs()) { CERROR("cannot add nodemap config to non-existing MGS.\n"); return -EINVAL; } @@ -626,8 +631,8 @@ int nodemap_idx_range_del(const struct lu_nid_range *range) int rc = 0; ENTRY; - if (nodemap_mgs_ncf == NULL) { - CERROR("cannot add nodemap config to non-existing MGS.\n"); + if (!nodemap_mgs()) { + CERROR("cannot del nodemap config from non-existing MGS.\n"); return -EINVAL; } @@ -654,7 +659,7 @@ int nodemap_idx_idmap_add(const struct lu_nodemap *nodemap, int rc = 0; ENTRY; - if (nodemap_mgs_ncf == NULL) { + if (!nodemap_mgs()) { CERROR("cannot add nodemap config to non-existing MGS.\n"); return -EINVAL; } @@ -681,7 +686,7 @@ int nodemap_idx_idmap_del(const struct lu_nodemap *nodemap, int rc = 0; ENTRY; - if (nodemap_mgs_ncf == NULL) { + if (!nodemap_mgs()) { CERROR("cannot add nodemap config to non-existing MGS.\n"); return -EINVAL; } @@ -706,7 +711,7 @@ static int nodemap_idx_global_add_update(bool value, enum nm_add_update update) int rc = 0; ENTRY; - if (nodemap_mgs_ncf == NULL) { + if (!nodemap_mgs()) { CERROR("cannot add nodemap config to non-existing MGS.\n"); return -EINVAL; } @@ -1348,7 +1353,7 @@ struct nm_config_file *nm_config_file_register_mgs(const struct lu_env *env, int rc = 0; ENTRY; - if (nodemap_mgs_ncf != NULL) + if (nodemap_mgs()) GOTO(out, ncf = ERR_PTR(-EEXIST)); OBD_ALLOC_PTR(ncf); -- 1.8.3.1