From baccb77f67fb248cec90edef3c6d280093f0dbc2 Mon Sep 17 00:00:00 2001 From: Timothy Day Date: Thu, 22 Feb 2024 06:07:05 +0000 Subject: [PATCH] LU-17576 nodemap: remove nodemap_rbtree.c Remove nodemap_rbtree.c. This was a port of an in-progress rbtree patch to the kernel. Every kernel that Lustre supports should have the needed macro. The rest of the stuff in the file is unused. Signed-off-by: Timothy Day Change-Id: I25d6eea90a1e9b983fb0be690384e50c6808cb7b Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54136 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin Reviewed-by: Andreas Dilger Reviewed-by: Sebastien Buisson Reviewed-by: James Simmons --- lustre/ptlrpc/Makefile.in | 3 +- lustre/ptlrpc/nodemap_idmap.c | 12 +++---- lustre/ptlrpc/nodemap_internal.h | 16 --------- lustre/ptlrpc/nodemap_rbtree.c | 74 ---------------------------------------- lustre/ptlrpc/nodemap_storage.c | 24 ++++++------- 5 files changed, 19 insertions(+), 110 deletions(-) delete mode 100644 lustre/ptlrpc/nodemap_rbtree.c diff --git a/lustre/ptlrpc/Makefile.in b/lustre/ptlrpc/Makefile.in index 041a64f..5471a34 100644 --- a/lustre/ptlrpc/Makefile.in +++ b/lustre/ptlrpc/Makefile.in @@ -14,8 +14,7 @@ ptlrpc_objs += errno.o batch.o nrs_server_objs := nrs_crr.o nrs_orr.o nrs_tbf.o nodemap_objs := nodemap_handler.o nodemap_lproc.o nodemap_range.o -nodemap_objs += nodemap_idmap.o nodemap_rbtree.o nodemap_member.o -nodemap_objs += nodemap_storage.o +nodemap_objs += nodemap_idmap.o nodemap_member.o nodemap_storage.o -include $(ptlrpc_dir)/../ldlm/Makefile @SERVER_TRUE@-include $(ptlrpc_dir)/../target/Makefile diff --git a/lustre/ptlrpc/nodemap_idmap.c b/lustre/ptlrpc/nodemap_idmap.c index 50aac55..1b42001 100644 --- a/lustre/ptlrpc/nodemap_idmap.c +++ b/lustre/ptlrpc/nodemap_idmap.c @@ -280,20 +280,20 @@ void idmap_delete_tree(struct lu_nodemap *nodemap) struct rb_root root; root = nodemap->nm_fs_to_client_uidmap; - nm_rbtree_postorder_for_each_entry_safe(idmap, temp, &root, - id_fs_to_client) { + rbtree_postorder_for_each_entry_safe(idmap, temp, &root, + id_fs_to_client) { idmap_destroy(idmap); } root = nodemap->nm_client_to_fs_gidmap; - nm_rbtree_postorder_for_each_entry_safe(idmap, temp, &root, - id_client_to_fs) { + rbtree_postorder_for_each_entry_safe(idmap, temp, &root, + id_client_to_fs) { idmap_destroy(idmap); } root = nodemap->nm_client_to_fs_projidmap; - nm_rbtree_postorder_for_each_entry_safe(idmap, temp, &root, - id_client_to_fs) { + rbtree_postorder_for_each_entry_safe(idmap, temp, &root, + id_client_to_fs) { idmap_destroy(idmap); } } diff --git a/lustre/ptlrpc/nodemap_internal.h b/lustre/ptlrpc/nodemap_internal.h index b3765e4..18edead 100644 --- a/lustre/ptlrpc/nodemap_internal.h +++ b/lustre/ptlrpc/nodemap_internal.h @@ -145,28 +145,12 @@ int nodemap_add_range_helper(struct nodemap_config *config, const struct lnet_nid nid[2], u8 netmask, unsigned int range_id); -struct rb_node *nm_rb_next_postorder(const struct rb_node *node); -struct rb_node *nm_rb_first_postorder(const struct rb_root *root); void nodemap_getref(struct lu_nodemap *nodemap); void nodemap_putref(struct lu_nodemap *nodemap); int nm_hash_list_cb(struct cfs_hash *hs, struct cfs_hash_bd *bd, struct hlist_node *hnode, void *nodemap_list_head); -#define nm_rbtree_postorder_for_each_entry_safe(pos, n, \ - root, field) \ - for (pos = nm_rb_first_postorder(root) ? \ - rb_entry(nm_rb_first_postorder(root), typeof(*pos), \ - field) : NULL, \ - n = (pos && nm_rb_next_postorder(&pos->field)) ? \ - rb_entry(nm_rb_next_postorder(&pos->field), \ - typeof(*pos), field) : NULL; \ - pos != NULL; \ - pos = n, \ - n = (pos && nm_rb_next_postorder(&pos->field)) ? \ - rb_entry(nm_rb_next_postorder(&pos->field), \ - typeof(*pos), field) : NULL) - 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_rbtree.c b/lustre/ptlrpc/nodemap_rbtree.c deleted file mode 100644 index 68993fb5..0000000 --- a/lustre/ptlrpc/nodemap_rbtree.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.gnu.org/licenses/gpl-2.0.html - * - * GPL HEADER END - */ -/* - * Copyright (C) 2013, Trustees of Indiana University - * Author: Joshua Walgenbach - */ - -#include -#include -#include "nodemap_internal.h" - -/* This code is from a patch submitted by - * Cody P Schafer linux kernel - * rbtree. When the supported kernel catches up to - * the kernel where it is landed. To remove the - * entire tree, it has to be done in postorder. - * - * I didn't write this other than to change the - * function names to prevent collisions later. - */ - -static struct rb_node *nm_rb_left_deepest_node(const struct rb_node *node); - -static struct rb_node *nm_rb_left_deepest_node(const struct rb_node *node) -{ - while (true) { - if (node->rb_left) - node = node->rb_left; - else if (node->rb_right) - node = node->rb_right; - else - return (struct rb_node *) node; - } -} - -struct rb_node *nm_rb_next_postorder(const struct rb_node *node) -{ - const struct rb_node *parent; - if (!node) - return NULL; - parent = rb_parent(node); - - if (parent && node == parent->rb_left && parent->rb_right) - return nm_rb_left_deepest_node(parent->rb_right); - else - return (struct rb_node *) parent; -} - -struct rb_node *nm_rb_first_postorder(const struct rb_root *root) -{ - if (!root->rb_node) - return NULL; - - return nm_rb_left_deepest_node(root->rb_node); -} diff --git a/lustre/ptlrpc/nodemap_storage.c b/lustre/ptlrpc/nodemap_storage.c index 048c4a2..18ec01f 100644 --- a/lustre/ptlrpc/nodemap_storage.c +++ b/lustre/ptlrpc/nodemap_storage.c @@ -497,8 +497,8 @@ int nodemap_idx_nodemap_del(const struct lu_nodemap *nodemap) rc = rc2; root = nodemap->nm_fs_to_client_uidmap; - nm_rbtree_postorder_for_each_entry_safe(idmap, temp, &root, - id_fs_to_client) { + rbtree_postorder_for_each_entry_safe(idmap, temp, &root, + id_fs_to_client) { nodemap_idmap_key_init(&nk, nodemap->nm_id, NODEMAP_UID, idmap->id_client); rc2 = nodemap_idx_delete(&env, nodemap_mgs_ncf->ncf_obj, @@ -508,8 +508,8 @@ int nodemap_idx_nodemap_del(const struct lu_nodemap *nodemap) } root = nodemap->nm_client_to_fs_gidmap; - nm_rbtree_postorder_for_each_entry_safe(idmap, temp, &root, - id_client_to_fs) { + rbtree_postorder_for_each_entry_safe(idmap, temp, &root, + id_client_to_fs) { nodemap_idmap_key_init(&nk, nodemap->nm_id, NODEMAP_GID, idmap->id_client); rc2 = nodemap_idx_delete(&env, nodemap_mgs_ncf->ncf_obj, @@ -519,8 +519,8 @@ int nodemap_idx_nodemap_del(const struct lu_nodemap *nodemap) } root = nodemap->nm_client_to_fs_projidmap; - nm_rbtree_postorder_for_each_entry_safe(idmap, temp, &root, - id_client_to_fs) { + rbtree_postorder_for_each_entry_safe(idmap, temp, &root, + id_client_to_fs) { nodemap_idmap_key_init(&nk, nodemap->nm_id, NODEMAP_PROJID, idmap->id_client); rc2 = nodemap_idx_delete(&env, nodemap_mgs_ncf->ncf_obj, @@ -1222,8 +1222,8 @@ nodemap_save_config_cache(const struct lu_env *env, * lock prevents changes from happening to nodemaps */ root = nodemap->nm_client_to_fs_uidmap; - nm_rbtree_postorder_for_each_entry_safe(idmap, id_tmp, &root, - id_client_to_fs) { + rbtree_postorder_for_each_entry_safe(idmap, id_tmp, &root, + id_client_to_fs) { nodemap_idmap_key_init(&nk, nodemap->nm_id, NODEMAP_UID, idmap->id_client); nodemap_idmap_rec_init(&nr, idmap->id_fs); @@ -1233,8 +1233,8 @@ nodemap_save_config_cache(const struct lu_env *env, } root = nodemap->nm_client_to_fs_gidmap; - nm_rbtree_postorder_for_each_entry_safe(idmap, id_tmp, &root, - id_client_to_fs) { + rbtree_postorder_for_each_entry_safe(idmap, id_tmp, &root, + id_client_to_fs) { nodemap_idmap_key_init(&nk, nodemap->nm_id, NODEMAP_GID, idmap->id_client); nodemap_idmap_rec_init(&nr, idmap->id_fs); @@ -1244,8 +1244,8 @@ nodemap_save_config_cache(const struct lu_env *env, } root = nodemap->nm_client_to_fs_projidmap; - nm_rbtree_postorder_for_each_entry_safe(idmap, id_tmp, &root, - id_client_to_fs) { + rbtree_postorder_for_each_entry_safe(idmap, id_tmp, &root, + id_client_to_fs) { nodemap_idmap_key_init(&nk, nodemap->nm_id, NODEMAP_PROJID, idmap->id_client); -- 1.8.3.1