Whamcloud - gitweb
LU-6068 misc: update Intel copyright messages 2014
[fs/lustre-release.git] / lustre / ptlrpc / 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  *
25  * Copyright (c) 2013, 2014, Intel Corporation.
26  *
27  * Author: Joshua Walgenbach <jjw@iu.edu>
28  */
29
30 #ifndef _NODEMAP_INTERNAL_H
31 #define _NODEMAP_INTERNAL_H
32
33 #include <lustre_nodemap.h>
34 #include <interval_tree.h>
35
36 #define MODULE_STRING "nodemap"
37
38 /* Default nobody uid and gid values */
39
40 #define NODEMAP_NOBODY_UID 99
41 #define NODEMAP_NOBODY_GID 99
42
43 struct lprocfs_static_vars;
44
45 /* nodemap root proc directory under fs/lustre */
46 extern struct proc_dir_entry *proc_lustre_nodemap_root;
47 /* flag if nodemap is active */
48 extern bool nodemap_active;
49 /* lock for range interval tree, used in nodemap_lproc.c */
50 extern rwlock_t nm_range_tree_lock;
51
52 struct lu_nid_range {
53         /* unique id set my mgs */
54         unsigned int             rn_id;
55         /* lu_nodemap containing this range */
56         struct lu_nodemap       *rn_nodemap;
57         /* list for nodemap */
58         struct list_head         rn_list;
59         /* nid interval tree */
60         struct interval_node     rn_node;
61 };
62
63 struct lu_idmap {
64         /* uid/gid of client */
65         __u32           id_client;
66         /* uid/gid on filesystem */
67         __u32           id_fs;
68         /* tree mapping client ids to filesystem ids */
69         struct rb_node  id_client_to_fs;
70         /* tree mappung filesystem to client */
71         struct rb_node  id_fs_to_client;
72 };
73
74 int nodemap_procfs_init(void);
75 int lprocfs_nodemap_register(const char *name, bool is_default_nodemap,
76                              struct lu_nodemap *nodemap);
77 struct lu_nid_range *range_create(lnet_nid_t min, lnet_nid_t max,
78                                   struct lu_nodemap *nodemap);
79 void range_destroy(struct lu_nid_range *range);
80 int range_insert(struct lu_nid_range *data);
81 void range_delete(struct lu_nid_range *data);
82 struct lu_nid_range *range_search(lnet_nid_t nid);
83 struct lu_nid_range *range_find(lnet_nid_t start_nid, lnet_nid_t end_nid);
84 int range_parse_nidstring(char *range_string, lnet_nid_t *start_nid,
85                           lnet_nid_t *end_nid);
86 void range_init_tree(void);
87 struct lu_idmap *idmap_create(__u32 client_id, __u32 fs_id);
88 void idmap_insert(enum nodemap_id_type id_type, struct lu_idmap *idmap,
89                  struct lu_nodemap *nodemap);
90 void idmap_delete(enum nodemap_id_type id_type,  struct lu_idmap *idmap,
91                   struct lu_nodemap *nodemap);
92 void idmap_delete_tree(struct lu_nodemap *nodemap);
93 struct lu_idmap *idmap_search(struct lu_nodemap *nodemap,
94                               enum nodemap_tree_type,
95                               enum nodemap_id_type id_type,
96                               __u32 id);
97 int nodemap_cleanup_nodemaps(void);
98 int nm_member_init_hash(struct lu_nodemap *nodemap);
99 int nm_member_add(struct lu_nodemap *nodemap, struct obd_export *exp);
100 void nm_member_del(struct lu_nodemap *nodemap, struct obd_export *exp);
101 void nm_member_delete_hash(struct lu_nodemap *nodemap);
102 void nm_member_reclassify_nodemap(struct lu_nodemap *nodemap);
103 void nm_member_revoke_locks(struct lu_nodemap *nodemap);
104 void nm_member_revoke_all(void);
105
106 struct rb_node *nm_rb_next_postorder(const struct rb_node *node);
107 struct rb_node *nm_rb_first_postorder(const struct rb_root *root);
108
109 #define nm_rbtree_postorder_for_each_entry_safe(pos, n,                 \
110                                                 root, field)            \
111         for (pos = nm_rb_first_postorder(root) ?                        \
112                 rb_entry(nm_rb_first_postorder(root), typeof(*pos),     \
113                 field) : NULL,                                          \
114                 n = (pos && nm_rb_next_postorder(&pos->field)) ?        \
115                 rb_entry(nm_rb_next_postorder(&pos->field),             \
116                 typeof(*pos), field) : NULL;                            \
117                 pos != NULL;                                            \
118                 pos = n,                                                \
119                 n = (pos && nm_rb_next_postorder(&pos->field)) ?        \
120                 rb_entry(nm_rb_next_postorder(&pos->field),             \
121                 typeof(*pos), field) : NULL)
122 #endif  /* _NODEMAP_INTERNAL_H */