Whamcloud - gitweb
LU-3527 nodemap: add NID range management
[fs/lustre-release.git] / lustre / nodemap / nodemap_internal.h
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
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.
9  *
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).
15  *
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
19  *
20  * GPL HEADER END
21  */
22 /*
23  * Copyright (C) 2013, Trustees of Indiana University
24  * Author: Joshua Walgenbach <jjw@iu.edu>
25  */
26
27 #ifndef _NODEMAP_INTERNAL_H
28 #define _NODEMAP_INTERNAL_H
29
30 #include <lustre_nodemap.h>
31 #include <interval_tree.h>
32
33 #define MODULE_STRING "nodemap"
34
35 /* Default nobody uid and gid values */
36
37 #define NODEMAP_NOBODY_UID 99
38 #define NODEMAP_NOBODY_GID 99
39
40 struct lprocfs_static_vars;
41
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_idmap_active;
46
47 struct lu_nid_range {
48         /* unique id set my mgs */
49         unsigned int             rn_id;
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;
56 };
57
58 int nodemap_procfs_init(void);
59 int lprocfs_nodemap_register(const char *name, bool is_default_nodemap,
60                              struct lu_nodemap *nodemap);
61 struct lu_nid_range *range_create(lnet_nid_t min, lnet_nid_t max,
62                                   struct lu_nodemap *nodemap);
63 void range_destroy(struct lu_nid_range *range);
64 int range_insert(struct lu_nid_range *data);
65 void range_delete(struct lu_nid_range *data);
66 struct lu_nid_range *range_search(lnet_nid_t nid);
67 struct lu_nid_range *range_find(lnet_nid_t start_nid, lnet_nid_t end_nid);
68 int range_parse_nidstring(char *range_string, lnet_nid_t *start_nid,
69                           lnet_nid_t *end_nid);
70 void range_init_tree(void);
71 int nodemap_cleanup_nodemaps(void);
72 #endif  /* _NODEMAP_INTERNAL_H */