4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.gnu.org/licenses/gpl-2.0.html
23 * Copyright (C) 2013, Trustees of Indiana University
24 * Author: Joshua Walgenbach <jjw@iu.edu>
27 #ifndef _NODEMAP_INTERNAL_H
28 #define _NODEMAP_INTERNAL_H
30 #include <lustre_nodemap.h>
31 #include <interval_tree.h>
33 #define MODULE_STRING "nodemap"
35 /* Default nobody uid and gid values */
37 #define NODEMAP_NOBODY_UID 99
38 #define NODEMAP_NOBODY_GID 99
40 struct lprocfs_static_vars;
42 /* nodemap root proc directory under fs/lustre */
43 extern struct proc_dir_entry *proc_lustre_nodemap_root;
44 /* flag if nodemap is active */
45 extern bool nodemap_active;
48 /* unique id set my mgs */
50 /* lu_nodemap containing this range */
51 struct lu_nodemap *rn_nodemap;
52 /* list for nodemap */
53 struct list_head rn_list;
54 /* nid interval tree */
55 struct interval_node rn_node;
59 /* uid/gid of client */
61 /* uid/gid on filesystem */
63 /* tree mapping client ids to filesystem ids */
64 struct rb_node id_client_to_fs;
65 /* tree mappung filesystem to client */
66 struct rb_node id_fs_to_client;
69 int nodemap_procfs_init(void);
70 int lprocfs_nodemap_register(const char *name, bool is_default_nodemap,
71 struct lu_nodemap *nodemap);
72 struct lu_nid_range *range_create(lnet_nid_t min, lnet_nid_t max,
73 struct lu_nodemap *nodemap);
74 void range_destroy(struct lu_nid_range *range);
75 int range_insert(struct lu_nid_range *data);
76 void range_delete(struct lu_nid_range *data);
77 struct lu_nid_range *range_search(lnet_nid_t nid);
78 struct lu_nid_range *range_find(lnet_nid_t start_nid, lnet_nid_t end_nid);
79 int range_parse_nidstring(char *range_string, lnet_nid_t *start_nid,
81 void range_init_tree(void);
82 struct lu_idmap *idmap_create(__u32 client_id, __u32 fs_id);
83 void idmap_insert(enum nodemap_id_type id_type, struct lu_idmap *idmap,
84 struct lu_nodemap *nodemap);
85 void idmap_delete(enum nodemap_id_type id_type, struct lu_idmap *idmap,
86 struct lu_nodemap *nodemap);
87 void idmap_delete_tree(struct lu_nodemap *nodemap);
88 struct lu_idmap *idmap_search(struct lu_nodemap *nodemap,
89 enum nodemap_tree_type,
90 enum nodemap_id_type id_type,
92 int nodemap_cleanup_nodemaps(void);
94 struct rb_node *nm_rb_next_postorder(const struct rb_node *node);
95 struct rb_node *nm_rb_first_postorder(const struct rb_root *root);
97 #define nm_rbtree_postorder_for_each_entry_safe(pos, n, \
99 for (pos = nm_rb_first_postorder(root) ? \
100 rb_entry(nm_rb_first_postorder(root), typeof(*pos), \
102 n = (pos && nm_rb_next_postorder(&pos->field)) ? \
103 rb_entry(nm_rb_next_postorder(&pos->field), \
104 typeof(*pos), field) : NULL; \
107 n = (pos && nm_rb_next_postorder(&pos->field)) ? \
108 rb_entry(nm_rb_next_postorder(&pos->field), \
109 typeof(*pos), field) : NULL)
110 #endif /* _NODEMAP_INTERNAL_H */